#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
const int maxl = 1e6 + 5;
const unsigned long long inf = -1;
long long a[maxn], b[maxn], c[maxl], d[maxl], n, m, k, p;
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      long long x;
      scanf("%I64d", &x);
      a[i] += x;
      b[j] += x;
    }
  }
  priority_queue<long long> qa;
  priority_queue<long long> qb;
  for (int i = 1; i <= n; i++) {
    qa.push(a[i]);
  }
  for (int j = 1; j <= m; j++) {
    qb.push(b[j]);
  }
  for (int j = 0; j <= k; j++) {
    if (j == 0)
      c[j] = 0;
    else if (j == 1) {
      c[j] = qa.top();
      qa.push(qa.top() - m * p);
      qa.pop();
    } else {
      c[j] = c[j - 1] + qa.top();
      qa.push(qa.top() - m * p);
      qa.pop();
    }
  }
  for (int j = 0; j <= k; j++) {
    if (j == 0)
      d[j] = 0;
    else if (j == 1) {
      d[j] = qb.top();
      qb.push(qb.top() - n * p);
      qb.pop();
    } else {
      d[j] = d[j - 1] + qb.top();
      qb.push(qb.top() - n * p);
      qb.pop();
    }
  }
  long long ans = -(inf >> 1);
  for (int i = 0; i <= k; i++) {
    ans = max(ans, c[i] + d[k - i] - (k - i) * i * p);
  }
  printf("%lld\n", ans);
}
