#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> Q;
int n, m, k, p, d;
long long r[1001], c[1001], S[1000001], P[1000001], a = -99999999999999;
int main() {
  cin >> n >> m >> k >> p;
  for (int i = 1; i <= n; Q.push(r[i]), i++)
    for (int j = 1; j <= m; j++) cin >> d, r[i] += d, c[j] += d;
  for (int i = 1; i <= k; i++) S[i] = Q.top(), Q.pop(), Q.push(S[i] - m * p);
  while (!Q.empty()) Q.pop();
  for (int i = 1; i <= m; i++) Q.push(c[i]);
  for (int i = 1; i <= k; i++) P[i] = Q.top(), Q.pop(), Q.push(P[i] - n * p);
  for (int i = 1; i <= k; i++) S[i] += S[i - 1], P[i] += P[i - 1];
  for (int i = 0; i <= k; i++)
    a = max(a, S[i] + P[k - i] - (long long)(i) * (k - i) * p);
  cout << a;
}
