#include <cstdio>
#include <cctype>
__always_inline static void read(int &x){
char c = getchar_unlocked();
x = 0;
while (!isdigit(c)) c = getchar_unlocked();
while (isdigit(c)) x = x * 10 + c - '0',c = getchar_unlocked();
}
inline static void write(const int &x){
if (x > 9) write(x / 10);
putchar_unlocked(x % 10 + '0');
}
__always_inline static void writeln(const int &x){write(x),putchar_unlocked('\n');}
const int N = 1e7 + 5;
int n,m,tree[N];
__always_inline static int lowbit(int x){return x & (-x);}
void update(int x,int y){
for (;x <= n;x += lowbit(x)) tree[x] += y;
}
int query(int x){
int ans = 0;
for (;x;x -= lowbit(x)) ans += tree[x];
return ans;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("P4939.in","r",stdin);
#endif
for (read(n),read(m);m--;){
int op,a,b;
read(op),read(a);
switch (op){
case 0:read(b);update(a,1);update(b + 1,-1);break;
case 1:writeln(query(a));break;
}
}
return 0;
}
从提交记录中找到的,大佬的代码看不懂(就看懂了树状数组函数的一点点,他在函数前加的那些东东是干嘛的?)