#include #include #include using namespace std; struct E{ int n; struct E *l; struct E *r; }; E* f(int x,int l,int r,int y,E *tree){ if((l<=x && x<=r)==false){ return tree; } if (tree == NULL) { tree =(E*) malloc(sizeof(E)); tree->n = 0; tree->l = NULL; tree->r = NULL; } (tree->n)+=y; if(l==r){ return tree; }else if(l<=x && x<=r){ int m=(l+r)/2; tree->l=f(x,l,m,y,tree->l); tree->r=f(x,m+1,r,y,tree->r); return tree; } } long long int sum(int l,int r,int l2,int r2,E *tree){ if (tree == NULL){ return 0; }else{ if(rn; } int m=(l+r)/2; long long int res=0; res=sum(l,m,l2,r2,tree->l); res+=sum(m+1,r,l2,r2,tree->r); return res; } } void delete_binary_tree(E *tree) { if( tree == NULL ){ return; } delete_binary_tree( tree->l ); delete_binary_tree( tree->r ); free( tree ); } int main() { // your code goes here int x,n; cin>>n; long long int ans=0; E *tree= (E*)malloc(sizeof(E)); tree->n = 0; tree->l = NULL; tree->r = NULL; for(int i=0;i>x; if(x==0){ int p1,y; cin>>p1>>y; f(p1,0,1073741823,y,tree); }else{ int l,r; cin>>l>>r; ans+=sum(0,1073741823,l,r,tree); } } cout<