#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const int maxn = 1e3 + 10;
long long r[maxn * maxn], c[maxn * maxn];
long long sr[maxn], sc[maxn];
long long n, m, k, p;
long long a[maxn][maxn];
int main() {
  memset(sr, 0, sizeof(sr));
  memset(sc, 0, sizeof(sc));
  cin >> n >> m >> k >> p;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%I64d", &a[i][j]);
      sr[i] += a[i][j];
      sc[j] += a[i][j];
    }
  }
  priority_queue<long long> q;
  for (int i = 1; i <= n; i++) {
    q.push(sr[i]);
  }
  r[0] = 0;
  for (int i = 1; i <= k; i++) {
    long long tmp = q.top();
    r[i] = r[i - 1] + tmp;
    tmp -= p * m;
    q.pop();
    q.push(tmp);
  }
  while (!q.empty()) q.pop();
  for (int i = 1; i <= m; i++) {
    q.push(sc[i]);
  }
  c[0] = 0;
  for (int i = 1; i <= k; i++) {
    long long tmp = q.top();
    c[i] = c[i - 1] + tmp;
    tmp -= p * n;
    q.pop();
    q.push(tmp);
  }
  long long ans = -1e18;
  for (int i = 0; i <= k; i++) {
    ans = max(ans, c[i] + r[k - i] - (long long)i * (k - i) * p);
  }
  cout << ans << endl;
}
