#include <bits/stdc++.h>   using namespace std;   struct station {     int pos, price;   } a[200003];   int T[800008], d, n, m;   long long cnt;   bool comp(station A, station B) { return (A.pos < B.pos); }   void Build_MinIT(int, int, int);   int Find_Min(int, int, int, int, int);   int main() {     scanf( %d %d %d , &d, &n, &m);     for (int i = 1; i <= m; i++) scanf( %d %d , &a[i].pos, &a[i].price);     sort(a + 1, a + 1 + m, comp);     a[++m].pos = d;     for (int i = 1; i <= m; i++) {       if (a[i].pos - a[i - 1].pos > n) {         cout << -1;         return 0;       }     }     if (n >= d) {       cout << 0;       return 0;     }     a[200002].price = 1E+9;     Build_MinIT(1, m, 1);     int i = 0, j = 1, t = n;     while (j <= m) {       while (a[i].price < a[j].price && a[j].pos - a[i].pos <= n && j <= m) j++;       if (a[j].pos - a[i].pos <= n) {         cnt += (long long)(a[j].pos - (a[i].pos + t)) * a[i].price;         t = 0;         i = j++;       } else {         int k = Find_Min(i + 1, j - 1, 1, m, 1);         cnt += (long long)(n - t) * a[i].price;         t = a[i].pos + n - a[k].pos;         i = k;       }     }     cout << cnt;     return 0;   }   void Build_MinIT(int L, int R, int v) {     if (L == R) {       T[v] = L;       return;     }     int m = (L + R) / 2;     Build_MinIT(L, m, v * 2);     Build_MinIT(m + 1, R, v * 2 + 1);     T[v] = (a[T[v * 2]].price < a[T[v * 2 + 1]].price ? T[v * 2] : T[v * 2 + 1]);   }   int Find_Min(int l, int r, int L, int R, int v) {     if (l > r) return 200002;     if (l == L && r == R) return T[v];     int m = (L + R) / 2;     int x = Find_Min(l, min(r, m), L, m, v * 2),         y = Find_Min(max(l, m + 1), r, m + 1, R, v * 2 + 1);     return (a[x].price < a[y].price ? x : y);   }   