#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
long long p, s, r, c, u, v;
long long ans = -1e18;
long long rr[1000001];
long long rc[1000001];
long long a[1001][1001];
priority_queue<long long> qr, qc;
int main(void) {
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &k, &p);
  for (long long i = (1); i <= (n); i++)
    for (long long j = (1); j <= (m); j++) scanf("%I64d", &a[i][j]);
  for (long long i = (1); i <= (n); i++) {
    s = 0;
    for (long long j = (1); j <= (m); j++) s += a[i][j];
    qr.push(s);
  }
  for (long long j = (1); j <= (m); j++) {
    s = 0;
    for (long long i = (1); i <= (n); i++) s += a[i][j];
    qc.push(s);
  }
  for (long long i = (1); i <= (k); i++) {
    u = qr.top();
    r += u;
    qr.pop();
    qr.push(u - p * m);
    rr[i] = r;
  }
  for (long long i = (1); i <= (k); i++) {
    v = qc.top();
    c += v;
    qc.pop();
    qc.push(v - p * n);
    rc[i] = c;
  }
  for (long long i = (0); i <= (k); i++)
    ans = max(ans, rr[i] + rc[k - i] - i * (k - i) * p);
  printf("%I64d\n", ans);
}
