func_code_string: #include <bits/stdc++.h>   using namespace std;   long long g, x, y, z;   int n, m;   int nn, mm;   deque<long long> q;   long long a[3010][3010];   long long b[3010][3010];   long long c[3010][3010];   int main() {     scanf( %d%d%d%d , &nn, &mm, &n, &m);     scanf( %lld%lld%lld%lld , &g, &x, &y, &z);     for (int i = 1; i <= nn; i++) {       for (int j = 1; j <= mm; j++) {         a[i][j] = g;         g = g * x + y;         g %= z;       }     }     for (int i = 1; i <= nn; i++) {       for (int j = mm; j >= 1; j--) {         while (!q.empty() && a[i][q.back()] >= a[i][j]) {           q.pop_back();         }         q.push_back(j);         while (!q.empty() && q.front() - q.back() + 1 > m) {           q.pop_front();         }         if (j <= mm - m + 1) b[i][j] = a[i][q.front()];       }       while (!q.empty()) q.pop_front();     }     for (int i = 1; i <= mm - m + 1; i++) {       for (int j = nn; j >= 1; j--) {         while (!q.empty() && b[q.back()][i] >= b[j][i]) {           q.pop_back();         }         q.push_back(j);         while (!q.empty() && q.front() - q.back() + 1 > n) {           q.pop_front();         }         if (j <= nn - n + 1) c[j][i] = b[q.front()][i];       }       while (!q.empty()) q.pop_front();     }     long long ans = 0;     for (int i = 1; i <= nn - n + 1; i++) {       for (int j = 1; j <= mm - m + 1; j++) {         ans += c[i][j];       }     }     printf( %lld n , ans);     return 0;   }   