func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, k;   vector<pair<long long, long long> > nums;   int main() {     cin >> n;     nums.resize(n);     for (int i = 0; i < n; i++) {       long long a, b;       cin >> a >> b;       nums[i] = make_pair(b, a);     }     sort(nums.begin(), nums.end());     long long res = 0;     long long left;     long long fac = 1;     long long last_left = 0;     cin >> k;     vector<long long> ks(k + 1);     for (int i = 0; i < k; i++) cin >> ks[i];     ks[k] = -1;     long long k_cnt = 0;     left = ks[0];     for (int i = 0; i < n; i++) {       if (left == -1) {         res += fac * nums[i].second * nums[i].first;         continue;       }       if (left <= nums[i].second) {         res += fac * left * nums[i].first;         nums[i].second -= left;         i--;         k_cnt++;         if (ks[k_cnt] == -1)           left = -1;         else           left = (ks[k_cnt] - ks[k_cnt - 1]);         fac++;       } else {         res += fac * nums[i].second * nums[i].first;         left -= nums[i].second;         nums[i].second = 0;       }     }     cout << res;     return 0;   }   