#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p, x;
long long r[1005], c[1005];
multiset<long long> R, C;
long long A[1000006], B[1000006], ans = -1000000000000000;
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++)
    for (int h = 1; h <= m; h++) scanf("%lld", &x), r[i] += x, c[h] += x;
  for (int i = 1; i <= n; i++) R.insert(r[i]);
  for (int i = 1; i <= m; i++) C.insert(c[i]);
  for (int i = 1; i <= k; i++) {
    int j = *(--R.end());
    A[i] = A[i - 1] + j;
    R.erase(R.find(j));
    R.insert(j - m * p);
    j = *(--C.end());
    B[i] = B[i - 1] + j;
    C.erase(C.find(j));
    C.insert(j - n * p);
  }
  for (int i = 0; i <= k; i++)
    ans = max(ans, A[i] + B[k - i] - i * 1LL * (k - i) * 1LL * p);
  printf("%lld\n", ans);
}
