#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-9;
int n, m, k, p;
long long a[1005][1005], str[1005], stlb[1005];
priority_queue<long long> q;
long long dp1[1005 * 1005];
long long dp2[1005 * 1005];
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      str[i] += a[i][j];
      stlb[j] += a[i][j];
    }
  }
  long long ans = -1ll * inf * inf;
  while (!q.empty()) q.pop();
  for (int i = 0; i < n; i++) q.push(str[i]);
  for (int i = 1; i <= k; i++) {
    dp1[i] = dp1[i - 1] + q.top();
    long long t = q.top();
    q.pop();
    t -= 1ll * m * p;
    q.push(t);
  }
  while (!q.empty()) q.pop();
  for (int i = 0; i < m; i++) q.push(stlb[i]);
  for (int i = 1; i <= k; i++) {
    dp2[i] = dp2[i - 1] + q.top();
    long long t = q.top();
    q.pop();
    t -= 1ll * n * p;
    q.push(t);
  }
  ans = dp1[0] + dp2[k];
  for (int i = 0; i <= k; i++) {
    ans = max(ans, dp1[i] + dp2[k - i] - 1ll * (k - i) * i * p);
  }
  cout << ans << endl;
  return 0;
}
