#include <bits/stdc++.h>
using namespace std;
long long CA[1000006], CB[1000006];
long long sumA[1006], sumB[1006];
long long mat[1006][1006];
int n, m, k, p;
priority_queue<long long> P1;
priority_queue<long long> P2;
void builtC() {
  while (!P1.empty()) P1.pop();
  while (!P2.empty()) P2.pop();
  for (int i = 1; i <= n; i++) {
    P1.push(sumA[i]);
  }
  CA[0] = 0;
  for (int i = 1; i <= k; i++) {
    long long x = P1.top();
    CA[i] = CA[i - 1] + x;
    P1.pop();
    P1.push((long long)(x - p * m));
  }
  for (int i = 1; i <= m; i++) {
    P2.push(sumB[i]);
  }
  CB[0] = 0;
  for (int i = 1; i <= k; i++) {
    long long x = P2.top();
    CB[i] = CB[i - 1] + x;
    P2.pop();
    P2.push((long long)(x - p * n));
  }
}
void solve() {
  long long mx = -9223372036854775808;
  for (int i = 0; i <= k; i++) {
    long long x = CA[i] + CB[k - i] - (long long)i * (k - i) * p;
    mx = max(mx, x);
  }
  printf("%I64d\n", mx);
  return;
}
int main() {
  while (~scanf("%d%d%d%d", &n, &m, &k, &p)) {
    memset(sumA, 0, sizeof(sumA));
    memset(sumB, 0, sizeof(sumB));
    CA[0] = 0;
    CB[0] = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        long long x;
        scanf("%I64d", &x);
        sumA[i] += x;
        sumB[j] += x;
      }
    }
    builtC();
    solve();
  }
  return 0;
}
