#include <bits/stdc++.h>
using namespace std;
struct node {
  long long a, b, c, d;
};
bool cmp(const node &first, const node &sec) {
  if (first.a != sec.a) return first.a < sec.a;
  return first.b < sec.b;
}
long long n, m, k, p, i, j;
long long arr[1005][1005], sum, ans, ansr[1000005], ansc[1000005], r[1005],
    c[1005];
priority_queue<long long> q, q1;
int main() {
  cin >> n >> m >> k >> p;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) scanf("%lld", &arr[i][j]);
  }
  for (i = 1; i <= n; i++) {
    sum = 0;
    for (j = 1; j <= m; j++) sum += arr[i][j];
    r[i] = sum;
  }
  for (i = 1; i <= m; i++) {
    sum = 0;
    for (j = 1; j <= n; j++) sum += arr[j][i];
    c[i] = sum;
  }
  for (i = 1; i <= n; i++) q.push(r[i]);
  ansr[0] = 0;
  for (i = 1; i <= k; i++) {
    long long x = q.top();
    ansr[i] = ansr[i - 1] + x;
    q.pop();
    q.push(x - (m * p));
  }
  for (i = 1; i <= m; i++) q1.push(c[i]);
  ansc[0] = 0;
  for (i = 1; i <= k; i++) {
    long long x = q1.top();
    ansc[i] = ansc[i - 1] + x;
    q1.pop();
    q1.push(x - (n * p));
  }
  ans = ansr[0] + ansc[k];
  ;
  for (i = 0; i <= k; i++) {
    long long y = ansr[i] + ansc[k - i] - (p * i * (k - i));
    if (y > ans) ans = y;
  }
  cout << ans;
  return 0;
}
