#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) -x&x
typedef long long LL;
const int N = 1e6 + 10;
LL tree[N];
LL n, q;
void add(int i, int z){
for (; i <= n; i += lowbit(i))
tree[i] += z;
}
LL ask(int i){
LL res = 0;
for (; i; i -= lowbit(i))
res += tree[i];
return res;
}
int main(){
cin >> n >> q;
for (int i = 1; i <= n; i ++ ){
int x;
cin >> x;
add(i, x);
}
while (q -- ){
int op;
cin >> op;
if (op == 1){
int i, x;
cin >> i >> x;
add(i, x);
}else{
int l, r;
cin >> l >> r;
cout << ask(r) - ask(l - 1) << endl;
}
}
return 0;
}
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define lowbit(x) -x&x
typedef long long LL;
const int N = 1e5 + 10;
int tree[N];
int n;
void add(int i, int z){
for (; i <= n; i += lowbit(i))
tree[i] += z;
}
int ask(int i){
LL res = 0;
for (; i; i -= lowbit(i))
res += tree[i];
return res;
}
int main(){
while (cin >> n && n){
memset(tree, 0, sizeof tree);
for (int i = 1; i <= n; i ++ ){
int a, b;
cin >> a >> b;
add(a, 1);
add(b + 1, -1);
}
for (int i = 1; i <= n; i ++ ){
if (i == n)
cout << ask(i) << endl;
else
cout << ask(i) << ' ';
}
}
return 0;
}
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define lowbit(x) -x&x
typedef long long LL;
const int N = 1e5 + 10;
int tree[N];
int n;
int s[N];
void add(int i, int z){
for (; i <= n; i += lowbit(i))
tree[i] += z;
}
int ask(int i){
int res = 0;
for (; i; i -= lowbit(i))
res += tree[i];
return res;
}
int main(){
while (cin >> n && n){
memset(s, 0, sizeof s);
for (int i = 1; i <= n; i ++ ){
int a, b;
cin >> a >> b;
s[a] ++, s[b + 1] --;
}
for (int i = 1; i <= n; i ++ ) s[i] += s[i - 1];
for (int i = 1; i <= n; i ++ ){
if (i == n) cout << s[i] << endl;
else cout << s[i] << ' ';
}
}
return 0;
}
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define lowbit(x) -x&x
typedef long long LL;
const int N = 32010;
int tree[N];
int n;
int s[N];
void add(int i, int z){
for (; i < N; i += lowbit(i))
tree[i] += z;
}
int ask(int i){
int res = 0;
for (; i; i -= lowbit(i))
res += tree[i];
return res;
}
int main(){
scanf("%d", &n);
for (int i = 1; i <= n; i ++ ){
int x, y;
scanf("%d%d", &x, &y);
x ++ ;
s[ask(x)] ++ ;
add(x, 1);
}
for (int i = 0; i < n; i ++ )
printf("%d\n", s[i]);
return 0;
}