func_code_string: #include <bits/stdc++.h>   using namespace std;   void solve();   int main() {     ios::sync_with_stdio(0);     solve();     return 0;   }   list<pair<deque<int>, int> > basket;   int N, bN;   int p[100001];   void update(pair<deque<int>, int>& it) {     it.second = it.first[0];     for (int i = 0; i < (int)((it.first).size()); i++) {       it.second = max(it.second, it.first[i]);     }   }   void solve() {     cin >> N;     bN = 250;     basket.push_back(pair<deque<int>, int>(deque<int>(), 0));     for (int i = 0; i < N; i++) {       int a, c;       cin >> a >> c;       p[a] = i + 1;       int cc = c;       list<pair<deque<int>, int> >::iterator it = basket.begin();       for (; it != basket.end(); it++) {         if (it->second > a || (int)it->first.size() > cc) {           break;         }         cc -= it->first.size();       }       if (it == basket.end()) {         it--;         cc += it->first.size();       }       deque<int>& b = it->first;       b.push_front(a);       for (int j = 0; j < (int)((b).size()) - 1 && cc > 0; j++, cc--) {         if (b[j] < b[j + 1]) break;         swap(b[j], b[j + 1]);       }       if ((int)((b).size()) >= 2 * bN) {         pair<deque<int>, int> item(deque<int>(), 0);         while ((int)((b).size()) > bN) {           item.first.push_back(b.front());           b.pop_front();         }         update(*it);         update(item);         basket.insert(it, item);       } else {         update(*it);       }     }     vector<int> ans;     for (list<pair<deque<int>, int> >::iterator it = basket.begin();          it != basket.end(); it++) {       deque<int>& b = it->first;       for (int i = 0; i < (int)((b).size()); i++) {         ans.push_back(p[b[i]]);       }     }     reverse(ans.begin(), ans.end());     for (int i = 0; i < (int)((ans).size()); i++) cout << ans[i] <<    ;   }   