func_code_string: #include <bits/stdc++.h>   using namespace std;   long long spf[21];   long long fac[21];   void sieve() {     spf[1] = 1;     for (long long i = 2; i < 21; i++) spf[i] = i;     for (long long i = 4; i < 21; i += 2) spf[i] = 2;     for (long long i = 3; i * i < 21; i++) {       if (spf[i] == i) {         for (long long j = i * i; j < 21; j += i)           if (spf[j] == j) spf[j] = i;       }     }   }   map<long long, long long> getfactor(long long a) {     map<long long, long long> m;     while (a > 1) {       m[spf[a]]++;       a /= spf[a];     }     return m;   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long inverse(long long a, long long p) { return power(a, p - 2, p); }   long long ncr(long long n, long long r, long long p) {     if (r == 0) return 1;     return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;   }   long long seg[500000];   void update(long long v, long long l, long long r, long long pos,               long long val) {     if (l == r) {       seg[v] = val;       return;     }     long long mid = (l + r) / 2;     if (pos <= mid)       update(v * 2, l, mid, pos, val);     else       update(v * 2 + 1, mid + 1, r, pos, val);     seg[v] = max(seg[v * 2], seg[v * 2 + 1]);   }   long long query(long long v, long long l, long long r, long long posl,                   long long posr) {     if (l >= posl && r <= posr)       return seg[v];     else if (l > posr || r < posl)       return 0;     long long mid = (l + r) / 2;     return max(query(v * 2, l, mid, posl, posr),                query(v * 2 + 1, mid + 1, r, posl, posr));   }   void solve() {     long long n, temp = 0;     cin >> n;     vector<pair<pair<long long, long long>, long long> > v(n);     memset(seg, 0, sizeof(seg));     long long dp[n];     memset(dp, 0, sizeof(dp));     for (long long i = 0; i < n; i++) {       cin >> v[i].first.first;       cin >> v[i].first.second;       v[i].second = i;       v[i].first.second *= -1;     }     long long p;     sort(v.begin(), v.end());     vector<long long> v1(n);     for (long long i = 0; i < n; i++) v1[i] = v[i].first.first;     for (long long i = n - 1; i >= 0; i--) {       p = v[i].first.first - v[i].first.second - 1;       long long t = upper_bound(v1.begin(), v1.end(), p) - v1.begin();       long long ss = query(1, 1, n, i + 1, t);       if (ss == 0) ss = i + 1;       dp[v[i].second] = ss - i;       update(1, 1, n, i + 1, ss);     }     for (long long i = 0; i < n; i++) {       cout << dp[i] <<    ;     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     while (t--) {       solve();     }   }   