func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:167772160 )   using namespace std;   const int inf = 1000000000;   long long k[1001], p[1001], f[1001], c[1001];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> k[i] >> c[i];     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++)         if (c[i] > c[j]) {           swap(c[i], c[j]);           swap(k[i], k[j]);         }     int t;     cin >> t;     for (int i = 1; i <= t; i++) cin >> p[i];     p[0] = 0;     for (int i = 1; i <= t; i++) f[i] = p[i] - p[i - 1];     f[t + 1] = 1000000000000LL;     int j = 1;     long long num = 0;     long long ans = 0;     for (int i = 1; i <= t + 1; i++) {       while (j <= n) {         long long mn = min(k[j] - num, f[i]);         ans += (long long)c[j] * mn * (long long)i;         if (mn == k[j] - num && mn == f[i]) {           ++j;           num = 0;           break;         } else if (mn == k[j] - num) {           ++j;           f[i] -= mn;           num = 0;         } else {           num += mn;           break;         }       }     }     cout << ans << endl;   }   