#include <bits/stdc++.h>
using namespace std;
long long n, m, r[1010], c[1010], k, p, sr[1000100], sc[1000100];
priority_queue<long long> q;
void read() {
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; ++i)
    for (int j = 0, x; j < m; ++j) {
      cin >> x;
      r[i] += x;
      c[j] += x;
    }
}
void get(int n, long long dec, long long* a, long long* ans) {
  while (!q.empty()) q.pop();
  ans[0] = 0;
  for (int i = 0; i < n; ++i) q.push(a[i]);
  for (int i = 1; i <= k; ++i) {
    long long x = q.top();
    q.pop();
    ans[i] = ans[i - 1] + x;
    x -= dec;
    q.push(x);
  }
}
void kill() {
  long long ans = -1000000000100000000ll;
  get(n, p * m, r, sr);
  get(m, p * n, c, sc);
  for (int i = 0; i <= k; ++i)
    ans = max(ans, sr[i] + sc[k - i] - p * i * (k - i));
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  read();
  kill();
  return 0;
}
