#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5, M = 1e3 + 5;
const long long INF = 1e18;
priority_queue<long long> row, col;
long long r[N], c[N];
long long a[M][M];
signed main() {
  long long n, m, k, p;
  cin >> n >> m >> k >> p;
  for (long long i = 0; i < n; ++i) {
    long long sum = 0;
    for (long long j = 0; j < m; ++j) {
      scanf("%lld", &a[i][j]);
      sum += a[i][j];
    }
    row.push(sum);
  }
  for (long long j = 0; j < m; ++j) {
    long long sum = 0;
    for (long long i = 0; i < n; ++i) sum += a[i][j];
    col.push(sum);
  }
  for (long long i = 1; i <= k; ++i) {
    long long temp = row.top();
    row.pop();
    r[i] = r[i - 1] + temp;
    row.push(temp - m * p);
  }
  for (long long i = 1; i <= k; ++i) {
    long long temp = col.top();
    col.pop();
    c[i] = c[i - 1] + temp;
    col.push(temp - n * p);
  }
  long long ans = -INF;
  for (long long i = 0; i <= k; ++i)
    ans = max(ans, r[i] + c[k - i] - 1ll * i * (k - i) * p);
  cout << ans << endl;
  return 0;
}
