func_code_string: #include <bits/stdc++.h>   using namespace std;   int mat[1005][1005];   long long cols[1000005];   long long rows[1000005];   priority_queue<long long> pq;   int main() {     int n, m;     long long k, p;     scanf( %d %d %lld %lld , &n, &m, &k, &p);     for (int i = 0; i < n; i++) {       long long sum = 0;       for (int j = 0; j < m; j++) {         scanf( %d , &mat[i][j]);         sum += mat[i][j];       }       pq.push(sum);     }     for (int i = 1; i <= k; i++) {       long long val = pq.top();       pq.pop();       pq.push(val - p * m);       rows[i] = rows[i - 1] + val;     }     while (pq.size()) pq.pop();     for (int i = 0; i < m; i++) {       long long sum = 0;       for (int j = 0; j < n; j++) {         sum += mat[j][i];       }       pq.push(sum);     }     for (int i = 1; i <= k; i++) {       long long val = pq.top();       pq.pop();       pq.push(val - p * n);       cols[i] = cols[i - 1] + val;     }     long long ans = -1e18;     for (long long i = 0; i <= k; i++) {       ans = max(ans, rows[i] + cols[k - i] - i * (k - i) * p);     }     printf( %lld n , ans);     return 0;   }   