洛谷P3374
//单点修改,区间查询
#include<cstdio>
#include<vector>
#define lowbit(x) (x&(-x))
using namespace std;
int main(){
int n,m;
scanf("%d%d",&n,&m);
vector<long long> a(n+1),b(n+1,0);
for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
auto build=[&](int d){
for(int i=1;i<=d;++i){
b[i]+=a[i];
int j=i+lowbit(i);
if(j<=n)b[j]+=b[i];
}
};
auto update=[&](int x,int val){
while(x<=n){
b[x]+=val;
x+=lowbit(x);
}
};
auto getsum=[&](int x){
long long res=0;
while(x>0){
res+=b[x];
x-=lowbit(x);
}
return res;
};
build(n);
for(int i=1;i<=m;++i){
int opt,x,y;
scanf("%d%d%d",&opt,&x,&y);
if(opt==1){
update(x,y);
}else{
printf("%lld\n",getsum(y)-getsum(x-1));
}
}
}