Shooting on the array

All submissions for this problem are available.
You have an array A of length N consisting of positive integers. Let's consider N vertical segments (parallel to y axis) on the plane, the ith segment connects the points (i, 0) and (i, A_{i}).
You have Q queries of following two types:
 + i X : A_{i} += X
 ? i L R : Let's consider R  L+ 1 rays which are parallel to x axis. The jth ray eminates at point (i  0.5, L+ j  1.5) and extends to the right infinitely long parallel to x axis. You have to print the number of the segments that will be shot by some ray. If a ray shoots a segment then it stops at that point and does't extend further.
Note that all the queries of the second type are independent of each other.
Input
The first line of the input contains an integer T denoting the number of tests
The first line of each test case consists of two space separated integers N, Q .
The second line contains N space separated denoting the array A.
Next Q lines contain the description of the queries in the format above.
Output
After each query of the second type, output in a single line the number of segments that are shot.
Constraints
 1 ≤ T ≤ 100
 1 ≤ N ≤ 10^{6}
 1 ≤ Q ≤ 10^{5}
 0 < X ≤ 10,000
 1 ≤ i ≤ N
 1 ≤ A_{i} ≤ 10^{9}
 1 ≤ L ≤ R ≤ 10^{9}
 The sum of N over all testcases does not exceed 10^{6}
 The sum of Q over all testcases does not exceed 10^{5}
Subtasks
 Subtask #1 (10 points) : There are only queries of the second type
 Subtask #2 (10 points) : In all queries of the second type i = 1
 Subtask #3 (30 points) : The sum of Q over all testcases does not exceed 10^{4}
 Subtask #4 (50 points) : Original constraints
Example
Input: 1 6 4 3 7 2 4 8 7 ? 4 3 9 ? 3 1 7 + 6 2 ? 4 3 9 Output: 2 3 3
Author:  altruist_ 
Editorial  https://discuss.codechef.com/problems/SHTARR 
Tags  altruist_, mediumhard, oct17, segmenttree 
Date Added:  13082017 
Time Limit:  3 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 