func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int vv[3003] = {0}, vvv[3003] = {0};     int n, v, m = -1, k;     cin >> n >> v;     while (n--) {       int a, b;       cin >> a >> b;       vv[a] += b;       vvv[a + 1] += b;       m = max(m, a + 1);     }     int ans = 0, mm;     for (int i = 0; i <= m; i++) {       mm = v;       if (vvv[i]) {         if (vvv[i] < mm) {           ans += vvv[i];           mm -= vvv[i];         } else {           ans += mm;           mm = 0;         }       }       if (mm) {         if (vv[i] < mm) {           ans += vv[i];           vvv[i + 1] -= vv[i];         } else {           ans += mm;           vvv[i + 1] -= mm;         }       }     }     cout << ans << endl;     return 0;   }   