func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 3006;   struct arr {     int x, y, i;   } a[maxn];   int r, c, n, K;   int pos[maxn], L[maxn], R[maxn];   long long ans;   bool cmpx(arr x, arr y) {     if (x.x == y.x) return x.y < y.y;     return x.x < y.x;   }   bool cmpy(arr x, arr y) {     if (x.y == y.y) return x.x < y.x;     return x.y < y.y;   }   int main() {     scanf( %d%d%d%d , &r, &c, &n, &K);     for (int i = 1; i <= n; i++) scanf( %d%d , &a[i].x, &a[i].y);     sort(a + 1, a + n + 1, cmpy);     for (int i = 1; i <= n; i++) a[i].i = i;     sort(a + 1, a + n + 1, cmpx);     for (int i = 1; i <= n; i++) L[i] = i - 1;     for (int i = 1; i <= n; i++) R[i] = i + 1;     for (int i = 1; i <= n; i++) pos[a[i].i] = i;     R[0] = 1;     L[n + 1] = n;     pos[n + 1] = n + 1;     a[n + 1].x = r + 1;     a[n + 1].y = c + 1;     int nn = n;     for (int i = r; i >= 1; i--) {       int t = 0;       long long tmp = 0;       for (int j = 1; j <= n && a[j].x <= i; t = j++)         R[L[a[j].i]] = R[a[j].i], L[R[a[j].i]] = L[a[j].i];       for (int j = i, k = t; j >= 1; ans += tmp, j--) {         for (; a[k].x == j; k--) {           R[L[a[k].i]] = a[k].i;           L[R[a[k].i]] = a[k].i;           int val = 1, lp = a[k].i, rp = a[k].i;           for (; L[lp] && val < K; lp = L[lp], val++)             ;           for (; lp <= a[k].i; lp = R[lp], val--) {             for (; R[rp] <= n && val < K; rp = R[rp], val++)               ;             if (val < K) break;             long long tmp_1 = a[pos[lp]].y - a[pos[L[lp]]].y;             long long tmp_2 = a[pos[R[rp]]].y - a[pos[rp]].y;             tmp += tmp_1 * tmp_2;           }         }       }       while (a[nn].x == i) {         R[L[a[nn].i]] = R[a[nn].i];         L[R[a[nn].i]] = L[a[nn].i];         nn--;       }     }     printf( %lld n , ans);     return 0;   }   