#include <bits/stdc++.h>
using namespace std;
int INT_MAX_VAL = (int)1e20;
int INT_MIN_VAL = (int)-1e20;
long long LONG_MAX_VAL = (long long)1e20;
long long LONG_MIN_VAL = (long long)-1e20;
long long a[1005][1005];
long long n, m, k, p;
int main() {
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  set<pair<long long, long long> > row, col;
  for (int i = 0; i < n; i++) {
    long long sum = 0;
    for (int j = 0; j < m; j++) {
      sum += a[i][j];
    }
    row.insert(make_pair(-sum, i));
  }
  for (int j = 0; j < m; j++) {
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[i][j];
    }
    col.insert(make_pair(-sum, j));
  }
  long long res = 0;
  long long min_col = 0, min_row = 0;
  vector<long long> cl(k + 1), rw(k + 1);
  for (int z = 0; z < k; z++) {
    pair<long long, long long> r = *(row.begin());
    pair<long long, long long> c = *(col.begin());
    cl[z + 1] = cl[z] - c.first;
    col.erase(col.begin());
    col.insert(make_pair(c.first + p * n, c.second));
    rw[z + 1] = rw[z] - r.first;
    row.erase(row.begin());
    row.insert(make_pair(r.first + p * m, r.second));
  }
  long long mx = LONG_MIN_VAL;
  for (int i = 0; i <= k; i++) {
    mx = max(mx, rw[i] + cl[k - i] - i * (k - i) * p);
  }
  cout << mx << '\n';
  return 0;
}
