#include <bits/stdc++.h>
using namespace std;
void calcula(long long int n, long long int m, long long int r[10000],
             long long int sumar[10000], long long int k, long long int p) {
  priority_queue<long long int> q;
  for (int i = 0; i < n; i++) q.push(r[i]);
  for (int paso = 1; paso <= k; paso++) {
    long long int x = q.top();
    q.pop();
    sumar[paso] = sumar[paso - 1] + x;
    q.push(x - m * p);
  }
}
long long int n, m, k, p;
long long int c[10000], r[10000];
long long int sumac[2000000], sumar[2000000];
int main() {
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int a;
      cin >> a;
      r[i] += a;
      c[j] += a;
    }
  }
  calcula(n, m, r, sumar, k, p);
  calcula(m, n, c, sumac, k, p);
  long long int maximo = -1000000000000000000LL;
  for (long long int kc = 0; kc <= k; kc++) {
    long long int kr = k - kc;
    maximo = max(maximo, sumar[kr] + sumac[kc] - p * kc * kr);
  }
  cout << maximo << endl;
}
