#include <bits/stdc++.h>
using namespace std;
int n, m, k;
long long data[3001][3001];
long long s[3001][3001], p;
long long sumr[1000100], sumc[1000100];
priority_queue<long long> ql, qc;
int main() {
  scanf("%d%d%d%I64d", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%I64d", &data[i][j]);
      s[i][j] = s[i][j - 1] + s[i - 1][j] + data[i][j] - s[i - 1][j - 1];
    }
  }
  for (int i = 1; i <= n; i++) ql.push(s[i][m] - s[i - 1][m]);
  for (int i = 1; i <= m; i++) qc.push(s[n][i] - s[n][i - 1]);
  for (int i = 1; i <= k; i++) {
    long long t = ql.top();
    ql.pop();
    sumr[i] = sumr[i - 1] + t;
    ql.push(t - p * m);
  }
  for (int i = 1; i <= k; i++) {
    long long t = qc.top();
    qc.pop();
    sumc[i] = sumc[i - 1] + t;
    qc.push(t - p * n);
  }
  long long ans = max(sumr[k], sumc[k]);
  for (int i = 1; i < k; i++) {
    ans = max(ans, sumr[i] + sumc[k - i] - p * i * (k - i));
  }
  printf("%I64d", ans);
  return 0;
}
