func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 200100;   mt19937 rnd;   struct Treap {     int id, y, best;     Treap *l, *r;     Treap(int id) : id(id), y(rnd()), best(id), l(NULL), r(NULL) {}   };   int n, m;   int x[MAXN];   long long len[MAXN];   int p[MAXN], b[MAXN];   set<pair<int, int> > alive;   int c[MAXN];   void update(Treap *&t) {     if (t) {       t->best = t->id;       if (t->l && x[t->l->best] < x[t->best]) t->best = t->l->best;       if (t->r && x[t->r->best] < x[t->best]) t->best = t->r->best;     }   }   void merge(Treap *&t, Treap *l, Treap *r) {     if (!l)       t = r;     else if (!r)       t = l;     else if (l->y < r->y) {       merge(l->r, l->r, r);       t = l;     } else {       merge(r->l, l, r->l);       t = r;     }     update(t);   }   void split(Treap *t, Treap *&l, Treap *&r, long long k, int id) {     if (!t) {       l = r = NULL;     } else if (x[t->id] + len[t->id] < k ||                (x[t->id] + len[t->id] == k && t->id < id)) {       split(t->r, t->r, r, k, id);       l = t;     } else {       split(t->l, l, t->l, k, id);       r = t;       update(t);     }   }   Treap *t;   void insert(int id) {     Treap *L, *R;     split(t, L, R, x[id] + len[id], id);     merge(t, L, new Treap(id));     merge(t, t, R);   }   void erase(Treap *&t, int id) {     if (t->id == id) {       merge(t, t->l, t->r);     } else if (x[t->id] + len[t->id] < x[id] + len[id] ||                (x[t->id] + len[t->id] == x[id] + len[id] && t->id < id)) {       erase(t->r, id);     } else {       erase(t->l, id);     }     update(t);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     rnd = mt19937(0xdeadbeef);     cin >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> x[i] >> len[i];       insert(i);     }     for (int i = 0; i < m; ++i) {       cin >> p[i] >> b[i];       Treap *L, *R;       split(t, L, R, p[i], 0);       int best = R ? R->best : -1;       merge(t, L, R);       if (best != -1 && x[best] <= p[i]) {         erase(t, best);         len[best] += b[i];         insert(best);         ++c[best];         while (true) {           auto it = alive.upper_bound(make_pair(x[best] - 1, 1e9));           if (it != alive.end() && it->first <= x[best] + len[best]) {             ++c[best];             erase(t, best);             len[best] += b[it->second];             insert(best);             alive.erase(it);           } else             break;         }       } else {         alive.insert(make_pair(p[i], i));       }     }     for (int i = 0; i < n; ++i) cout << c[i] <<     << len[i] <<   n ;     return 0;   }   