#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
const int M = 1e6 + 10;
const double eps = 1e-8;
const int iinf = INT_MAX;
const long long linf = LONG_LONG_MAX;
const int MOD = 1000000007;
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
void print(int x) {
  cout << x << '\n';
  exit(0);
}
void PRINT(string x) {
  cout << x << '\n';
  exit(0);
}
void douout(double x) { printf("%lf\n", x + 0.0000000001); }
long long n, m, p, k, ans = -linf;
long long mp, h[N], l[N], ansh[M], ansl[M];
priority_queue<long long> qh, ql;
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      scanf("%lld", &mp);
      h[i] += mp;
      l[j] += mp;
    }
  for (int i = 1; i <= n; ++i) qh.push(h[i]);
  for (int i = 1; i <= m; ++i) ql.push(l[i]);
  ansh[0] = ansl[0] = 0;
  for (int i = 1; i <= k; ++i) {
    long long x = qh.top(), y = ql.top();
    qh.pop();
    ql.pop();
    ansh[i] = ansh[i - 1] + x;
    ansl[i] = ansl[i - 1] + y;
    qh.push(x - p * m);
    ql.push(y - p * n);
  }
  for (int i = 0; i <= k; ++i)
    ans = max(ansh[i] + ansl[k - i] - (k - i) * i * p, ans);
  printf("%lld\n", ans);
}
