func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 )       x = (x << 3) + (x << 1) + (c ^  0 ), c = getchar();     return x * f;   }   const int N = 2e5 + 5;   int d, n, m;   struct node {     int x, p;   } a[N];   inline int operator<(const node x, const node y) {     if (x.p == y.p) return x.x > y.x;     return x.p > y.p;   }   inline int cmp(node x, node y) { return x.x < y.x; }   priority_queue<node> q;   long long ans;   int main() {     d = read(), n = read(), m = read();     for (int i = 1; i <= m; i++) a[i] = {read(), read()};     sort(a + 1, a + m + 1, cmp);     int t = n, j = 1;     while (t < d) {       while (j <= m && a[j].x <= t) q.push(a[j++]);       while (!q.empty() && q.top().x + n <= t) q.pop();       if (q.empty()) return puts( -1 ), 0;       int x = q.top().x, p = q.top().p;       int nxt = min(d, x + n);       if (j <= m && nxt >= a[j].x) nxt = a[j].x;       ans += 1ll * p * (nxt - t);       t = nxt;     }     printf( %lld n , ans);     return 0;   }   