#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 5;
long long n, m, k, p, ans = -1e18;
long long a[N][N], row[N], col[N], rsum[N * N], csum[N * N];
priority_queue<long long, vector<long long> > pq, pq2;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k >> p;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> a[i][j];
      row[i] += a[i][j];
      col[j] += a[i][j];
    }
    pq.push(row[i]);
  }
  for (long long i = 1; i <= m; i++) pq2.push(col[i]);
  for (long long i = 1; i <= k; i++) {
    long long cur = pq.top();
    pq.pop();
    rsum[i] = rsum[i - 1] + cur;
    pq.push(cur - m * p);
  }
  for (long long i = 1; i <= k; i++) {
    long long cur = pq2.top();
    pq2.pop();
    csum[i] = csum[i - 1] + cur;
    pq2.push(cur - n * p);
  }
  for (long long i = 0; i <= k; i++)
    ans = max(ans, rsum[i] + csum[k - i] - i * (k - i) * p);
  cout << ans;
  return 0;
}
