func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     long long d, n, m;     cin >> d >> n >> m;     vector<pair<long long, long long> > stations(m + 2);     stations[0] = pair<long long, long long>(0, 0);     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       stations[i] = pair<long long, long long>(x, y);     }     stations[m + 1] = pair<long long, long long>(d, 0);     sort(stations.begin(), stations.end());     long long cost = 0, current = n, i = 0;     while (i < m + 1) {       bool found = false;       int last = i + 1;       while (stations[last].first <= stations[i].first + n) {         if (stations[last].second <= stations[i].second) {           int needed =               max(0LL, stations[last].first - stations[i].first - current);           current += needed - stations[last].first + stations[i].first;           cost += needed * stations[i].second;           i = last;           if (last == m + 1) {             cout << cost << endl;             return 0;           }           found = true;         }         last++;       }       if (!found) {         if (last == i + 1) {           cout << -1 << endl;           return 0;         }         cost += (n - current) * stations[i].second;         current = n - (stations[i + 1].first - stations[i].first);         i++;       }     }     cout << -1 << endl;   }   