#include #include using namespace std; using namespace atcoder; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define all(a) (a).begin(), (a).end() #define contains(a, x) ((a).find(x) != (a).end()) #define rep(i, a, b) for (int i = (a); i < (int)(b); i++) #define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--) #define YN(b) cout << ((b) ? "YES" : "NO") << "\n"; #define Yn(b) cout << ((b) ? "Yes" : "No") << "\n"; #define yn(b) cout << ((b) ? "yes" : "no") << "\n"; template ostream& operator<<(ostream& os, vector& vec) { for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : " "); } return os; } using ll = long long; using vb = vector; using vvb = vector; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using mint = modint998244353; using vm = vector; using vvm = vector; inline ostream& operator<<(ostream& os, const mint P) { return os << P.val(); }; int op(int x, int y) { return x + y; } int e() { return 0; } bool g(int x) { return x == 0; } void solve() { int h, w, n; cin >> h >> w >> n; vvi b(h, vi()); rep(i, 0, n) { int u, v; cin >> u >> v; b[u - 1].push_back(v - 1); } ll ans = 0; rep(r, 0, h) { segtree seg(w); ll sum = (ll)w * (w + 1) / 2; vector f(w, false); rep(x, r, h) { for (auto y : b[x]) { if (f[y]) continue; f[y] = true; int l = seg.min_left(y); int r = seg.max_right(y); ll d = r - l; sum -= d * (d + 1) / 2; ll d1 = y - l, d2 = r - (y + 1); sum += d1 * (d1 + 1) / 2 + d2 * (d2 + 1) / 2; seg.set(y, 1); } ans += sum; } } cout << ans << "\n"; } int main() { int t = 1; // cin >> t; while (t--) solve(); }