cswork / OAOpen practice workspace

Capital OneOA #6

Pair Sum Queries

Estimated MediumJudge-ready

Topics (AI-labelled)HashingIterators

Given integer arrays a and b, process two types of queries in order: 0 i x increases a[i] by x, where i is a 0-based index; 1 x asks for the number of index pairs (i,j) such that a[i]+b[j]=x. Different positions are counted separately.

Input

The first line contains n m q. The second line contains the n integers of a, the third line contains the m integers of b, and the next q lines are queries. Site-supplemented ranges: 1≤n,m≤200000, 1≤q≤200000; initial values, increments, and targets have absolute value ≤10^9, and every updated a[i] is guaranteed to have absolute value ≤10^12; it is also guaranteed that over all type 1 queries, Σ min(Da,Db)≤10^7, where Da and Db are the numbers of distinct values in a and b at the time of that query. This limit corresponds to the program iterating over the smaller frequency table on each query.

Output

For each 1 x query, output the corresponding number of index pairs in order, separated by spaces; if there are no such queries, output an empty line.

Example 1

Input:

3 2 3
1 1 2
2 3
1 4
0 0 2
1 4

Output:

3 2

Example 2

Input:

1 1 1
0
0
1 0

Output:

1

Example 3

Input:

2 2 3
-1 4
2 -2
1 1
0 1 -3
1 1

Output:

1 1

Editorial

Loading solution…