func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename G>   struct triple {     G first, second, T;   };   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long d, n, m;     cin >> d >> n >> m;     vector<pair<long long, long long> > x(m + 2);     x[m + 1].first = d;     for (int i = 1; i <= m; i++) cin >> x[i].first >> x[i].second;     sort(x.begin(), x.end());     vector<int> mn(m + 2);     stack<int> s;     for (int i = m + 1; i >= 0; i--) {       while (!s.empty() && x[s.top()].second > x[i].second) s.pop();       if (!s.empty())         mn[i] = s.top();       else         mn[i] = m + 2;       s.push(i);     }     long long comb = n, ans = 0;     for (int i = 0; i < m + 1; i++) {       int p = mn[i];       long long t = min(n - comb, max(x[p].first - x[i].first - comb, 0LL));       ans += x[i].second * t;       comb += t;       comb -= x[i + 1].first - x[i].first;       if (comb < 0) {         cout <<  -1 n ;         return 0;       }     }     cout << ans <<   n ;     return 0;   }   