#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1003;
const int MAXK = 1000006;
const long long INF = 1e18 + 18;
int n, m, k, p;
int mat[MAXN][MAXN];
priority_queue<int> aq, bq;
long long a[MAXK], b[MAXK];
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &mat[i][j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    int s = 0;
    for (int j = 0; j < m; ++j) s += mat[i][j];
    aq.push(s);
  }
  for (int i = 0; i < m; ++i) {
    int s = 0;
    for (int j = 0; j < n; ++j) s += mat[j][i];
    bq.push(s);
  }
  a[0] = b[0] = 0;
  for (int i = 1; i <= k; ++i) {
    int ta = aq.top(), tb = bq.top();
    aq.pop();
    aq.push(ta - p * m);
    bq.pop();
    bq.push(tb - p * n);
    a[i] = ta + a[i - 1];
    b[i] = tb + b[i - 1];
  }
  long long sol = -INF;
  for (int i = 0; i <= k; ++i) {
    sol = max(sol, a[i] + b[k - i] - (long long)i * (k - i) * p);
  }
  printf("%lld", sol);
}
