func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     long long d, n, m;     cin >> d >> n >> m;     vector<pair<long long, long long>> V(m);     for (auto &x : V) cin >> x.first >> x.second;     sort(V.begin(), V.end());     bool poss = true;     for (int i = 0; i < V.size() - 1; i++)       poss = poss && V[i].first + n >= V[i + 1].first;     poss = poss && V[0].first <= n;     poss = poss && d - V.back().first <= n;     if (!poss) {       printf( -1 n );       return 0;     }     sort(V.begin(), V.end(),          [](pair<long long, long long> a, pair<long long, long long> b) {            return a.second < b.second;          });     set<int> pos;     pos.insert(0);     pos.insert(d);     long long ans = 0;     for (auto &x : V) {       auto aft = pos.lower_bound(x.first);       auto bef = prev(aft);       long long reach = max(0ll, n - (x.first - *bef));       long long leave = min(n, *aft - x.first);       ans += x.second * max(0ll, leave - reach);       pos.insert(x.first);     }     cout << ans <<   n ;     return 0;   }   