#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1004;
const int MAXK = 1000005;
int n, m, k, p, a[MAXN][MAXN];
long long row[MAXK], col[MAXK];
priority_queue<long long> q;
int main() {
  int i, j;
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; i++) {
    long long sum = 0;
    for (int j = 1; j <= m; j++) sum += a[i][j];
    q.push(sum);
  }
  row[0] = 0;
  for (int i = 1; i <= k; i++) {
    long long now = q.top();
    q.pop();
    row[i] = row[i - 1] + now;
    q.push(now - 1ll * m * p);
  }
  while (!q.empty()) q.pop();
  for (int i = 1; i <= m; i++) {
    long long sum = 0;
    for (int j = 1; j <= n; j++) sum += a[j][i];
    q.push(sum);
  }
  col[0] = 0;
  for (int i = 1; i <= k; i++) {
    long long now = q.top();
    q.pop();
    col[i] = col[i - 1] + now;
    q.push(now - 1ll * n * p);
  }
  long long ans = row[0] + col[k];
  for (int i = 1; i <= k; i++)
    ans = max(ans, row[i] + col[k - i] - 1ll * i * (k - i) * p);
  printf("%I64d\n", ans);
  return 0;
}
