func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 3079;   int r, c, n, k;   vector<int> nx(maxn, -1), pv(maxn, -1), kth(maxn, -1);   vector<vector<int> > my(maxn);   class point {    public:     int x, y;   };   bool cmp(point& a, point& b) { return (a.y == b.y ? a.x < b.x : a.y < b.y); }   vector<point> v(maxn);   long long sum(int i) { return (v[i].y - v[pv[i]].y) * (c + 1 - v[kth[i]].y); }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> r >> c >> n >> k;     long long ans = 0;     int m = n + k + 1;     for (int i = 1; i <= n; i++) cin >> v[i].x >> v[i].y;     v[0] = {r + 1, 0};     for (int i = n + 1; i < m; i++) v[i] = {r + 1, c + 1};     sort(v.begin(), v.begin() + m, cmp);     for (int i = n + 1; i < m; i++)       kth[i] = m - 1, pv[i] = i - 1, nx[i] = min(m - 1, i + 1);     for (int i = m - 1; i >= 0; i--) my[v[i].x].push_back(i);     for (int x1 = 1; x1 <= r; x1++) {       int p = 0;       for (int i = 1; i <= n; i++) {         if (v[i].x < x1) continue;         nx[p] = i, pv[i] = p;         p = i;       }       nx[p] = n + 1, pv[n + 1] = p;       kth[p] = (k == 1 ? p : pv[m - 1]);       for (int i = p; i >= 0; i = pv[i]) kth[i] = pv[kth[nx[i]]];       long long cur = 0;       for (int i = nx[0]; i <= n; i = nx[i]) cur += sum(i);       for (int x2 = r; x2 >= x1; x2--) {         ans += cur;         for (int i : my[x2]) {           cur -= sum(i);           for (int j = pv[i], cnt = 0; cnt < k - 1 && j; cnt++, j = pv[j]) {             cur -= sum(j);             if (j < i) kth[j] = nx[kth[j]];             cur += sum(j);           }           cur -= sum(nx[i]);           nx[pv[i]] = nx[i], pv[nx[i]] = pv[i];           cur += sum(nx[i]);         }       }     }     cout << ans <<   n ;     return 0;   }   