#include <bits/stdc++.h>
using namespace std;
long long hg[1000010], sg[1000010], h[1010], s[1010];
priority_queue<long long> qq;
int main() {
  int m, n, k, p;
  cin >> n >> m >> k >> p;
  int i, j;
  memset(h, 0, sizeof(h));
  memset(s, 0, sizeof(s));
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) {
      int x;
      scanf("%d", &x);
      h[i] += x;
      s[j] += x;
    }
  for (i = 0; i < n; ++i) qq.push(h[i]);
  long long sum = 0;
  for (i = 0; i < k; ++i) {
    long long x = qq.top();
    qq.pop();
    sum += x;
    qq.push(x - m * p);
    hg[i + 1] = sum;
  }
  sum = 0;
  while (!qq.empty()) qq.pop();
  for (i = 0; i < m; ++i) qq.push(s[i]);
  hg[0] = sg[0] = 0;
  for (i = 0; i < k; ++i) {
    long long x = qq.top();
    qq.pop();
    sum += x;
    qq.push(x - n * p);
    sg[i + 1] = sum;
  }
  sum = -100000000000000000;
  for (i = 0; i <= k; ++i) {
    if (sum < hg[i] + sg[k - i] - (long long)i * (k - i) * p)
      sum = hg[i] + sg[k - i] - (long long)i * (k - i) * p;
  }
  printf("%I64d\n", sum);
  return 0;
}
