#include <bits/stdc++.h>
using namespace std;
int n, m, k, p;
long long row[1005], col[1005];
long long ar[1000005], ac[1000005];
priority_queue<long long> h;
priority_queue<long long> l;
int a[1005][1005];
long long ans = -199912310;
void go() {
  for (int i = 1; i <= k; i++) {
    int t = l.top();
    ac[i] = ac[i - 1] + t;
    l.pop();
    l.push(t - p * n);
  }
}
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++) {
      scanf("%d", &a[i][j]);
      row[i] += a[i][j];
    }
    h.push(row[i]);
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      col[i] += a[j][i];
    }
    l.push(col[i]);
  }
  for (int i = 1; i <= k; i++) {
    int t = h.top();
    ar[i] = ar[i - 1] + t;
    h.pop();
    h.push(t - p * m);
  }
  go();
  for (int i = 0; i <= k; i++) {
    long long res = ar[i] + ac[k - i] - (long long)p * i * (k - i);
    if (i == 0)
      ans = res;
    else
      ans = max(ans, res);
  }
  printf("%I64d\n", ans);
  return 0;
}
