func_code_string: #include <bits/stdc++.h>   using namespace std;   int dq[4040];   int st = 0;   int dr = 0;   int m[3030][3030];   int mn[3030][3030];   int N, M, K, L, X, Y, Z;   long long ret = 0;   void make() {     for (int i = 1; i <= N; ++i) {       int ind = 0;       st = dr = 0;       for (int j = 1; j <= M; ++j) {         while (dr - st > 0 && m[i][dq[dr - 1]] > m[i][j]) {           --dr;         }         dq[dr++] = j;         while (dq[st] <= j - L) {           ++st;         }         if (j - L >= 0) {           mn[i][j - L + 1] = m[i][dq[st]];         }       }     }     for (int j = 1; j <= M - L + 1; ++j) {       st = dr = 0;       for (int i = 1; i <= N; ++i) {         while (dr - st > 0 && mn[dq[dr - 1]][j] > mn[i][j]) --dr;         dq[dr++] = i;         while (dq[st] <= i - K) ++st;         if (i - K >= 0) {           ret += mn[dq[st]][j];         }       }     }   }   int G[3030 * 3030];   int main() {     cin.sync_with_stdio(false);     cin >> N >> M >> K >> L;     cin >> G[0] >> X >> Y >> Z;     for (int i = 1; i <= N * M + 100; ++i) {       G[i] = (1LL * G[i - 1] * X + Y) % Z;     }     for (int i = 1; i <= N; ++i) {       for (int j = 1; j <= M; ++j) {         m[i][j] = G[(i - 1) * M + j - 1];       }     }     make();     cout << ret << endl;   }   