#include <bits/stdc++.h>
using namespace std;
long long arr[1005][1005], r[2000005], c[2000005];
priority_queue<long long> sh, susu;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long i, j, k, l, m, n, t, x, y, p, cnt, ans, car1, car2;
  cin >> n >> m >> k >> p;
  for (i = 0; i < n; i++) {
    cnt = 0;
    for (j = 0; j < m; j++) {
      cin >> arr[i][j];
      cnt += arr[i][j];
    }
    sh.push(cnt);
  }
  for (j = 0; j < m; j++) {
    cnt = 0;
    for (i = 0; i < n; i++) {
      cnt += arr[i][j];
    }
    susu.push(cnt);
  }
  for (i = 1; i <= k; i++) {
    r[i] = r[i - 1] + sh.top();
    sh.pop();
    sh.push(r[i] - r[i - 1] - m * p);
    c[i] = c[i - 1] + susu.top();
    susu.pop();
    susu.push(c[i] - c[i - 1] - n * p);
  }
  ans = r[0] + c[k];
  for (i = 0; i <= k; i++) {
    ans = max(ans, (c[i] + r[k - i] - i * (k - i) * p));
  }
  cout << ans << endl;
  return 0;
}
