func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void checkMin(T &a, T b) {     if (b < a) a = b;   }   template <typename T>   inline void checkMax(T &a, T b) {     if (a < b) a = b;   }   const int P = 1e7 + 19;   const int Q = 1e9 + 7;   const int MAX_N = 5005 + 30000;   int n, k, w[MAX_N], v[MAX_N];   long long dp[32][1001];   int beg[MAX_N], qc[MAX_N];   set<pair<int, int>, greater<pair<int, int>>> es[MAX_N];   void dfs(int depth, int l, int r) {     copy(dp[depth - 1], dp[depth], dp[depth]);     for (auto iter = es[l].begin(); iter != es[l].end();) {       if (iter->first < r) break;       int i = iter->second;       if (iter->first > r) {         es[r + 1].emplace(iter->first, i);       }       iter = es[l].erase(iter);       for (int j = k; j >= w[i]; --j) {         checkMax(dp[depth][j], dp[depth][j - w[i]] + v[i]);       }     }     if (l == r) {       if (!qc[l]) return;       int ans = 0;       for (int i = k; i >= 1; --i) {         ans = ((long long)ans * P + dp[depth][i]) % Q;       }       for (int i = 0; i < int(qc[l]); ++i) {         printf( %d n , ans);       }     } else {       int m = (l + r) >> 1;       dfs(depth + 1, l, m);       dfs(depth + 1, m + 1, r);     }   }   int main() {     while (~scanf( %d%d , &n, &k)) {       fill(qc, qc + MAX_N, 0);       fill(es, es + MAX_N, set<pair<int, int>, greater<pair<int, int>>>());       int ts = 1;       for (int i = 1; i <= n; ++i) {         scanf( %d%d , &v[i], &w[i]);         beg[i] = ts;       }       int q, type, x;       scanf( %d , &q);       for (int i = 0; i < int(q); ++i) {         scanf( %d , &type);         if (type == 1) {           ++ts;           ++n;           scanf( %d%d , &v[n], &w[n]);           beg[n] = ts;         } else if (type == 2) {           scanf( %d , &x);           es[beg[x]].emplace(ts++, x);           beg[x] = -1;         } else {           ++qc[ts];         }       }       for (int i = 1; i <= n; ++i) {         if (beg[i] == -1) continue;         es[beg[i]].emplace(ts, i);       }       dfs(1, 1, ts);     }     return 0;   }   