#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> q;
long long sumr[1005], sumc[1005], a[1000005], b[1000005];
int main() {
  long long i, j, k, p, r, c, ans = 0, v;
  int id;
  cin >> r >> c >> k >> p;
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      scanf("%d", &id);
      sumr[i] += id;
      sumc[j] += id;
    }
  }
  for (i = 0; i < r; i++) q.push(sumr[i]);
  for (i = 1; i <= k; i++) {
    v = q.top();
    q.pop();
    a[i] = a[i - 1] + v;
    q.push(v - c * p);
  }
  while (!q.empty()) q.pop();
  for (i = 0; i < c; i++) q.push(sumc[i]);
  for (i = 1; i <= k; i++) {
    v = q.top();
    q.pop();
    b[i] = b[i - 1] + v;
    q.push(v - r * p);
  }
  for (i = 0; i <= k; i++) {
    v = a[i] + b[k - i] - (k - i) * i * p;
    if (i == 0) ans = v;
    ans = max(ans, v);
  }
  cout << ans << endl;
  return 0;
}
