#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> #define ll unsigned long long #define maxn 100001 #define lson u<<1,l,mid #define rson u<<1|1,mid+1,r using namespace std; int n,q; int t,a,b; struct node{ ll ans; int l,r; }e[maxn*4]; void build(int k,int l,int r) { e[k].l=l;e[k].r=r; e[k].ans=0; if(l==r)return ; int mid=(l+r)>>1; build(k<<1,l,mid); build(k<<1|1,mid+1,r); } void update(int u,int l,int r,int x,int add) { if(l==r) { e[u].ans+=add; return; } int mid=(l+r)>>1; if(x<=mid) update(lson,x,add); else update(rson,x,add); e[u].ans=max(e[u<<1].ans,e[u<<1|1].ans); } long long query(int k,int left,int right) { if(left <=e[k].l && right >=e[k].r) return e[k].ans; int mid = (e[k].l+e[k].r)>>1; if(right <= mid) return query(k<<1,left,right); else if(left > mid) return query((k<<1)|1,left,right); else return max(query(k<<1,left,mid),query((k<<1)|1,mid+1,right)); } int main() { scanf("%d%d",&n,&q); build(1,1,n); for(int i=1;i<=q;i++) { scanf("%d%d%d",&t,&a,&b); if(t==1) { update(1,1,n,a,b); } else { printf("%lld\n",query(1,a,b)); } } return 0; }