func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = 5e18;   const int MK = 10101;   const int MN = 101010;   long long H, M, N, K;   map<long long, long long> mp;   vector<long long> methods;   vector<pair<long long, long long> > ip[MK];   bool pllcmp(pair<long long, long long> p1, pair<long long, long long> p2) {     p1.second = -p1.second;     p2.second = -p2.second;     return p1 < p2;   };   priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,                  std::function<bool(pair<long long, long long>,                                     pair<long long, long long>)> >       pq(pllcmp);   long long dis[MK];   long long op[MN];   void spfa() {     for (int i = 0; i < K; i++) dis[i] = INF;     dis[0] = 0;     queue<int> qe;     qe.push(0);     while (qe.size()) {       long long v = qe.front();       qe.pop();       for (int i = 0; i < (int)methods.size(); i++) {         long long m = methods[i];         long long r = (m + v) % K;         if (dis[r] > dis[v] + m) {           dis[r] = dis[v] + m;           qe.push(r);         }       }     }     pq = priority_queue<         pair<long long, long long>, vector<pair<long long, long long> >,         function<bool(pair<long long, long long>, pair<long long, long long>)> >(         pllcmp);     for (int i = 0; i < N; i++) {       long long a = op[i], c = mp[op[i]];       long long r = a % K;       if (a >= dis[r]) {         pq.push(make_pair(c, i));       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> H >> N >> M >> K;     for (int i = 0; i < N; i++) {       long long a, c;       cin >> a >> c;       a--;       mp[a] = c;       ip[a % K].push_back(make_pair(i, c));       op[i] = a;     }     for (int i = 0; i < (int)ip[0].size(); i++) {       pq.push(make_pair(ip[0][i].second, ip[0][i].first));     }     for (int i = 1; i < K; i++) dis[i] = INF;     for (int i = 0; i < M; i++) {       int t;       cin >> t;       if (t == 1) {         long long x;         cin >> x;         methods.push_back(x);         spfa();       } else if (t == 2) {         long long id, a, c;         cin >> id >> c;         id--;         a = op[id];         mp[a] -= c;         if (dis[a % K] <= a) pq.push(make_pair(mp[a], id));       } else if (t == 3) {         pair<long long, long long> tp;         while (pq.size()) {           tp = pq.top();           if (mp[op[tp.second]] == tp.first) break;           pq.pop();         }         cout << (pq.size() ? tp.first : 0) << endl;         if (pq.size()) mp[op[tp.second]] = 0;       }     }     return 0;   }   