func_code_string: #include <bits/stdc++.h>   using namespace std;   struct station {     int p, x, dir;     station() {}     station(int pp, int xx, int dirr) {       p = pp;       x = xx;       dir = dirr;     }   };   bool cmp(station a, station b) {     if (a.x != b.x) return a.x < b.x;     return a.dir == 1;   }   int d, n, m;   int main() {     ios_base::sync_with_stdio(0);     cin >> d >> n >> m;     vector<station> v;     for (int i = 0; i < m; i++) {       int x, p;       cin >> x >> p;       v.push_back(station(p, x, 1));       v.push_back(station(p, min(d, x + n), -1));     }     v.push_back(station(0, 0, 1));     v.push_back(station(0, n, -1));     sort(v.begin(), v.end(), cmp);     long long last = 0;     long long res = 0;     multiset<long long> s;     s.insert(0);     long long mx = 0;     for (int i = 1; i < v.size(); i++) {       long long cur = (long long)v[i].x;       long long mn = *s.begin();       res += (cur - last) * mn;       if (cur - last > n || s.size() == 0) return cout << -1, 0;       if (v[i].dir == 1) {         s.insert(v[i].p);       } else {         s.erase(s.find(v[i].p));       }       last = cur;     }     (last == d) ? cout << res : cout << -1;     return 0;   }   