#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
#pragma GCC optimize(3)
const int maxn = 1000010;
const int maxn2 = 1e3 + 5;
int a[maxn2][maxn2];
long long csum[maxn];
long long rsum[maxn];
priority_queue<int> p;
int main(int argc, char const *argv[]) {
  int n, m, k, del;
  cin >> n >> m >> k >> del;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    int now_sum = 0;
    for (int j = 1; j <= m; ++j) {
      now_sum += a[i][j];
    }
    p.push(now_sum);
  }
  for (int i = 1; i <= k; ++i) {
    int x = p.top();
    p.pop();
    rsum[i] = rsum[i - 1] + x;
    p.push(x - m * del);
  }
  while (!p.empty()) {
    p.pop();
  }
  for (int j = 1; j <= m; ++j) {
    int now_sum = 0;
    for (int i = 1; i <= n; ++i) {
      now_sum += a[i][j];
    }
    p.push(now_sum);
  }
  for (int i = 1; i <= k; ++i) {
    int x = p.top();
    p.pop();
    csum[i] = csum[i - 1] + x;
    p.push(x - n * del);
  }
  long long ans = -0x3f3f3f3f3f3f3f3fll;
  for (int i = 0; i <= k; ++i) {
    ans = max(ans, rsum[i] + csum[k - i] - (long long)i * (k - i) * del);
  }
  cout << ans << endl;
  return 0;
}
