#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1010;
int a[MAX_N][MAX_N];
int n, m, p, k;
long long sn[MAX_N], sm[MAX_N];
long long kn[MAX_N * MAX_N], km[MAX_N * MAX_N];
priority_queue<long long> q;
void gao(long long s[], int n, int m, long long t[]) {
  while (!q.empty()) q.pop();
  for (int i = 0; i < n; i++) {
    q.push(s[i]);
  }
  t[0] = 0;
  for (int i = 1; i <= k; i++) {
    long long pre = q.top();
    t[i] = t[i - 1] + pre;
    q.pop();
    q.push(pre - m * p);
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    sn[i] = 0;
    for (int j = 0; j < m; j++) {
      sn[i] += a[i][j];
    }
  }
  for (int j = 0; j < m; j++) {
    sm[j] = 0;
    for (int i = 0; i < n; i++) {
      sm[j] += a[i][j];
    }
  }
  gao(sn, n, m, kn), gao(sm, m, n, km);
  long long ans = -1000000000000000000LL;
  for (int i = 0; i <= k; i++) {
    ans = max(ans, kn[i] + km[k - i] - 1LL * i * (k - i) * p);
  }
  printf("%I64d\n", ans);
  return 0;
}
