#include using namespace std; using ll = long long int; using P = pair; using P3 = pair; using PP = pair; constexpr int INF = 1 << 30; constexpr ll MOD = ll(1e9) + 7; constexpr int di[] = {0, 1, 0, -1}; constexpr int dj[] = {1, 0, -1, 0}; int N=1, Q; vector A, B, lazy; void eval(int k){ if(lazy[k]>0){ if(k < N-1){ lazy[k*2+1] += lazy[k]; lazy[k*2+2] += lazy[k]; }else{ B[k-(N-1)] += A[k-(N-1)]*lazy[k]; } lazy[k] = 0; } } void add(int x, int y, int k=0, int l=0, int r=N){ if(y <= l || r <= x) return; if(x <= l && r <= y) lazy[k]++; else{ add(x,y,k*2+1,l,(l+r)/2); add(x,y,k*2+2,(l+r)/2,r); } } void update(int x, ll y, int k=0, int l=0, int r=N){ if(x < l || x >= r) return; eval(k); if(k> n >> Q; while(N> A[i]; } for(int i=0;i> c >> x >> y; x--; if(c=='A') update(x,y); else add(x,y); } for(int i=0;i