#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
long long a[1005][1005];
long long sum1[N], sum2[N], r[N], c[N];
int main() {
  int n, m, k, p;
  long long ans = -1LL << 60;
  cin >> n >> m >> k >> p;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      sum1[i] += a[i][j];
      sum2[j] += a[i][j];
    }
  }
  priority_queue<long long> que;
  for (int i = 1; i <= n; i++) que.push(sum1[i]);
  for (int i = 1; i <= k; i++) {
    int now = que.top();
    que.pop();
    c[i] = c[i - 1] + now;
    now -= p * m;
    que.push(now);
  }
  while (!que.empty()) que.pop();
  for (int i = 1; i <= m; i++) que.push(sum2[i]);
  for (int i = 1; i <= k; i++) {
    int now = que.top();
    que.pop();
    r[i] = r[i - 1] + now;
    now -= p * n;
    que.push(now);
  }
  for (int i = 0; i <= k; i++) {
    ans = max(ans, c[i] + r[k - i] - 1ll * (k - i) * i * p);
  }
  cout << ans << endl;
  return 0;
}
