func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   struct node {     int x, p;   } a[N];   int d, n, m, top, xx, nexttttt[N], last, q[N];   long long ans;   bool cmp(node a, node b) { return a.x < b.x; }   int main() {     scanf( %d%d%d , &d, &n, &m);     for (int i = 1; i <= m; i++) scanf( %d%d , &a[i].x, &a[i].p);     sort(a + 1, a + m + 1, cmp);     a[m + 1].x = d;     a[m + 1].p = 0;     for (int i = m + 1; i >= 0; i--) {       if (a[i].x - a[i - 1].x > n) {         puts( -1 );         return 0;       }       while (top && a[i].p < a[q[top]].p) top--;       nexttttt[i] = q[top];       q[++top] = i;     }     for (int i = 0; i <= m; i++) {       xx = max(0, min(a[nexttttt[i]].x - a[i].x, n) - last);       ans += 1ll * xx * a[i].p;       last -= a[i + 1].x - a[i].x - xx;     }     printf( %lld n , ans);     return 0;   }   