#include <bits/stdc++.h>
using namespace std;
const int MXN = 1005;
int n, m, k, p;
int sr[MXN], sc[MXN];
long long vr[MXN * 1000], vc[MXN * 1000];
priority_queue<long long> pqr, pqc;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int val;
      cin >> val;
      sr[i] += val;
      sc[j] += val;
    }
  }
  for (int i = 0; i < n; i++) pqr.push(sr[i]);
  for (int i = 0; i < m; i++) pqc.push(sc[i]);
  for (int i = 1; i <= k; i++) {
    long long f = pqr.top();
    pqr.pop();
    vr[i] = f + vr[i - 1];
    pqr.push(f - m * p);
    f = pqc.top();
    pqc.pop();
    vc[i] = f + vc[i - 1];
    pqc.push(f - n * p);
  }
  long long res = -1e15;
  for (int i = 0; i <= k; i++) {
    res = max(res, vr[i] + vc[k - i] - (long long)i * (k - i) * p);
  }
  cout << res << endl;
  return 0;
}
