#include #include #include #include #include #define MAX 100000 using namespace std; int dynArray[MAX]; int cost[MAX]; int res[MAX]; void op(int who, int quantity){ dynArray[who]=dynArray[who]+quantity; } void calcCost(int n){ cost[0]=dynArray[0]; for(int i=1; i< n; i++){ cost[i]=dynArray[i]+cost[i-1]; } } int main(int argc, char** argv){ ifstream fin(argv[1]); assert(fin); ofstream fout("output.txt"); assert(fout); int n=0, m=0, j=0; int tmp; fin >> n >> m; for(int i =0; i< n; i++){ dynArray[i]=0; } for(int i =0; i< n; i++){ cost[i]=0; } do{ int q1,q2,i1,i2; fin >> tmp; if(tmp == 0){ fin >> q1 >> q2; if(q1 == q2){ res[j]=dynArray[q2-1]; }else{ calcCost(n); res[j]=cost[q2-1]; } j++; }else{ i1=tmp; fin >> i2; op(i2-1, i1); } }while(fin.good()); for(int i=0; i< j-1; i++){ fout << res[i] << " "; } fin.close(); fout.close(); }