#include <bits/stdc++.h>
using namespace std;
const int N = 1010, M = 1001001;
long long n, m, k, p, a, i, j, sumR[N], sumC[N], dpR[M], dpC[M], ans = -1e18;
priority_queue<long long> qR, qC;
int main() {
  cin >> n >> m >> k >> p;
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) scanf("%d", &a), sumR[i] += a, sumC[j] += a;
  for (i = 0; i < n; ++i) qR.push(sumR[i]);
  for (j = 0; j < m; ++j) qC.push(sumC[j]);
  for (i = 1; i <= k; ++i) {
    dpR[i] = qR.top() + dpR[i - 1];
    qR.push(qR.top() - p * m);
    qR.pop();
    dpC[i] = qC.top() + dpC[i - 1];
    qC.push(qC.top() - p * n);
    qC.pop();
  }
  for (i = 0; i <= k; ++i)
    ans = max(ans, dpR[i] + dpC[k - i] - i * (k - i) * p);
  cout << ans << endl;
  return 0;
}
