#include <bits/stdc++.h>
using namespace std;
int n, m, k, p;
long long ans = (long long)(-1) * (2100000000) * (2100000000);
int bb[1000];
char cccc[1000];
int a[1010][1010];
long long ii[1010], jj[1010];
long long aasdfso[1000010], asfoihivcozxv[1000010];
priority_queue<long long> q;
inline long long max(long long a, long long b) { return a > b ? a : b; }
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]);
      ii[i] += (long long)a[i][j];
      jj[j] += (long long)a[i][j];
    }
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; i++) q.push(ii[i]);
  aasdfso[0] = 0;
  for (int i = 1; i <= k; i++) {
    aasdfso[i] = q.top();
    q.pop();
    q.push(aasdfso[i] - (long long)m * p);
    aasdfso[i] += aasdfso[i - 1];
  }
  while (!q.empty()) q.pop();
  asfoihivcozxv[0] = 0;
  for (int i = 1; i <= m; i++) q.push(jj[i]);
  for (int i = 1; i <= k; i++) {
    asfoihivcozxv[i] = q.top();
    q.pop();
    q.push(asfoihivcozxv[i] - (long long)n * p);
    asfoihivcozxv[i] += asfoihivcozxv[i - 1];
  }
  for (int i = 0; i <= k; i++)
    ans = max(ans,
              aasdfso[i] + asfoihivcozxv[k - i] - (long long)i * (k - i) * p);
  printf("%I64d\n", ans);
  return 0;
}
