Company: visa_18oct
Difficulty: medium
Dynamic Array Queries You are designing a data structure for a new programming language. It holds two integer arrays, a of length n and b of length m , and it must answer a stream of queries of two kinds. Update — 0 i x : add x to a[i] , that is, a[i] becomes a[i] + x . Only a ever changes; b stays fixed for the whole run. Sum — 1 x : report how many pairs of indices (i, j) with 0 <= i < n and 0 <= j < m satisfy a[i] + b[j] == x . A sum query counts index pairs , not distinct values. If a value appears several times in a , or several times in b , every index carrying it contributes its own pairs. Process the queries in the given order and report the answer of every sum query. Input Format Line 1: an integer n , the length of a . Line 2: n space-separated integers a[0] ... a[n-1] . Line 3: an integer m , the length of b . Line 4: m space-separated integers b[0] ... b[m-1] . Line 5: an integer q , the number of queries. The next q lines each hold one query: either 0 i x (upda