#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
long long c[maxn], r[maxn], ll[maxn], rr[maxn];
long long a[1005][1005];
int n, m, k, p;
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%lld", &a[i][j]);
      ll[i] += a[i][j];
      rr[j] += a[i][j];
    }
  }
  priority_queue<long long> Q;
  for (int i = 1; i <= n; i++) Q.push(ll[i]);
  for (int i = 1; i <= k; i++) {
    int now = Q.top();
    Q.pop();
    c[i] = c[i - 1] + now;
    now -= m * p;
    Q.push(now);
  }
  while (!Q.empty()) Q.pop();
  for (int i = 1; i <= m; i++) Q.push(rr[i]);
  for (int i = 1; i <= k; i++) {
    int now = Q.top();
    Q.pop();
    r[i] = r[i - 1] + now;
    now -= n * p;
    Q.push(now);
  }
  long long ans = -1LL << 60;
  for (int i = 0; i <= k; i++)
    ans = max(ans, c[i] + r[k - i] - 1ll * i * (k - i) * p);
  cout << ans << endl;
}
