func_code_string: #include <bits/stdc++.h>   using namespace std;   int ans[210000], k;   vector<pair<int, int>> item, b;   struct R {     int l, r, cc;     long long value;     R(int L, int R, int CC = 0, long long VALUE = 0) {       l = L, r = R, cc = CC, value = VALUE;     }   };   vector<R> range;   void update() {     long long value;     int l, r, c;     for (int i = 0; i < range.size(); i++) {       l = range[i].l, r = range[i].r;       c = range[i].cc, value = range[i].value;       for (int j = l; j <= r; j++) b[j].first -= value, ans[b[j].second] += c;     }     sort(b.begin(), b.end());     range.clear();     range.push_back(R(0, k - 1));   }   int main() {     int n, c, q, l, r;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d %d , &c, &q);       item.push_back(make_pair(-q, c));     }     sort(item.begin(), item.end());     scanf( %d , &k);     for (int i = 0; i < k; i++) scanf( %d , &c), b.push_back(make_pair(c, i));     sort(b.begin(), b.end());     int value = 0;     update();     for (int i = 0; i < n; i++) {       c = item[i].second;       q = range.size();       for (int j = 0; j < q; j++) {         l = range[j].l, r = range[j].r;         value = range[j].value;         if (b[l].first >= value + c)           range[j].value += c, ++range[j].cc;         else if (b[r].first >= c + value) {           int index = lower_bound(b.begin() + l, b.begin() + r + 1,                                   make_pair(c + value, 0)) -                       b.begin();           range.push_back(R(index, r, range[j].cc + 1, value + c));           range[j].r = index - 1;         }       }       if (range.size() > 500) update();     }     update();     for (int i = 0; i < k; i++) printf( %d  , ans[i]);     return 0;   }   