func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int x[N], p[N], n, d, ind[N];   long long ans = 0;   vector<pair<int, int> > tank;   int head, cur;   bool cmp(int a, int b) { return x[a] < x[b]; }   bool use(int dis) {     while (dis) {       if (head == (int)tank.size()) return 1;       int tmp = min(dis, tank[head].first);       dis -= tmp;       tank[head].first -= tmp;       cur -= tmp;       if (tank[head].first == 0) head++;     }     return 0;   }   void sale(int p) {     while ((int)tank.size() > head && tank.back().second > p) {       ans -= 1LL * tank.back().second * tank.back().first;       cur -= tank.back().first;       tank.pop_back();     }   }   void buy(int p) {     ans += 1LL * p * (n - cur);     tank.push_back(make_pair(n - cur, p));     cur = n;   }   int main() {     int m;     scanf( %d%d%d , &d, &n, &m);     for (int i = 1; i <= m; ++i) scanf( %d%d , &x[i], &p[i]), ind[i] = i;     x[m + 1] = d;     p[m + 1] = 0;     ind[m + 1] = m + 1;     sort(ind + 1, ind + 1 + m, cmp);     tank.push_back(make_pair(n, 0));     cur = n;     for (int i = 1; i <= m + 1; ++i) {       int dis = x[ind[i]] - x[ind[i - 1]];       if (use(dis)) return 0 * puts( -1 );       sale(p[ind[i]]);       buy(p[ind[i]]);     }     cout << ans << endl;   }   