func_code_string: #include <bits/stdc++.h>   using namespace std;   using pii = pair<int, int>;   const int N = 3 + 1e5;   struct node {     int x, h, id;     bool operator<(const node& b) const { return x < b.x; }   } a[N];   struct {     int l, r, v;     bool flag;   } tr[1000000 * 4];   int n;   int b[N * 10], t;   int ans[N];   void up(int k) { tr[k].v = tr[(k << 1)].v + tr[(k << 1 | 1)].v; }   void down(int k) {     tr[(k << 1)].v = 0;     tr[(k << 1 | 1)].v = 0;     tr[(k << 1)].flag = tr[(k << 1 | 1)].flag = true;     tr[k].flag = false;   }   void build(int k, int l, int r) {     tr[k].l = l;     tr[k].r = r;     if (l == r) {       return;     }     int mid = l + r >> 1;     build((k << 1), l, mid);     build((k << 1 | 1), mid + 1, r);   }   void update1(int k, int l, int r) {     if (l <= tr[k].l && tr[k].r <= r) {       tr[k].v = 0;       tr[k].flag = true;       return;     }     int mid = tr[k].l + tr[k].r >> 1;     if (tr[k].flag) down(k);     if (l <= mid) update1((k << 1), l, r);     if (r > mid) update1((k << 1 | 1), l, r);     up(k);   }   void update2(int k, int p, int v) {     if (tr[k].l == tr[k].r) {       tr[k].v += v;       return;     }     int mid = tr[k].l + tr[k].r >> 1;     if (tr[k].flag) down(k);     if (p <= mid)       update2((k << 1), p, v);     else       update2((k << 1 | 1), p, v);     up(k);   }   int query(int k, int l, int r) {     if (l <= tr[k].l && tr[k].r <= r) return tr[k].v;     if (tr[k].flag) down(k);     int ans = 0, mid = tr[k].l + tr[k].r >> 1;     if (l <= mid) ans = query((k << 1), l, r);     if (r > mid) ans += query((k << 1 | 1), l, r);     return ans;   }   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i].x >> a[i].h;       a[i].id = i;       b[++t] = a[i].x;       b[++t] = a[i].x + 1;       b[++t] = a[i].x + a[i].h - 1;     }     sort(b + 1, b + t + 1);     t = unique(b + 1, b + t + 1) - b - 1;     sort(a + 1, a + n + 1);     build(1, 1, t);     for (int i = n; i; --i) {       int p1 = lower_bound(b + 1, b + t + 1, a[i].x) - b;       int p2 = lower_bound(b + 1, b + t + 1, a[i].x + 1) - b;       int p3 = lower_bound(b + 1, b + t + 1, a[i].x + a[i].h - 1) - b;       int rec = query(1, p2, p3);       ans[a[i].id] = rec + 1;       update1(1, p2, p3);       update2(1, p1, rec + 1);     }     for (int i = 1; i <= n; ++i) cout << ans[i] <<    ;     return 0;   }   