func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, t, d;     cin >> n >> m;     map<long long, long long> mp;     set<pair<long long, long long> > st;     vector<long long> a(n), c(n);     for (int i = 0; i < n; i++) {       cin >> a[i];       mp[i] = a[i];     }     for (int i = 0; i < n; i++) {       cin >> c[i];       st.insert({c[i], i});     }     for (int i = 0; i < m; i++) {       cin >> t >> d;       long long cost = 0;       t--;       if (st.size() == 0)         cout << 0 << endl;       else {         if (mp[t] != 0) {           if (mp[t] > d) {             mp[t] -= d;             cout << (long long)d * c[t] << endl;             d = 0;           } else if (mp[t] == d) {             mp[t] -= d;             cout << (long long)d * c[t] << endl;             d = 0;             st.erase({c[t], t});           } else {             cost += (long long)mp[t] * c[t];             d -= mp[t];             mp[t] = 0;             st.erase({c[t], t});           }         }         if (d > 0) {           while (d > 0 && st.size() > 0) {             pair<int, int> now = *st.begin();             if (mp[now.second] > d) {               mp[now.second] -= d;               cout << (long long)cost + d * now.first << endl;               d = 0;             } else if (mp[now.second] == d) {               mp[now.second] -= d;               cout << (long long)cost + d * now.first << endl;               d = 0;               st.erase(st.begin());             } else {               cost += (long long)mp[now.second] * now.first;               d -= mp[now.second];               mp[now.second] = 0;               st.erase(st.begin());             }           }           if (d > 0) {             cout << 0 << endl;           }         }       }     }     return 0;   }   