#include <bits/stdc++.h>
using namespace std;
long long n, mp, m, k, p, np, i, j, x, col[1100], row[1100], mx, r[1000100],
    c[1000100];
priority_queue<int> cl, rw;
int main() {
  cin >> n >> m >> k >> p;
  np = n * p, mp = m * p;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> x, row[i] += x, col[j] += x;
    }
  }
  for (i = 0; i < n; i++) rw.push(row[i]);
  for (j = 0; j < m; j++) cl.push(col[j]);
  for (i = 1; i <= k; i++) {
    c[i] = cl.top();
    cl.pop();
    cl.push(c[i] - np);
    c[i] += c[i - 1];
  }
  for (i = 1; i <= k; i++) {
    r[i] = rw.top();
    rw.pop();
    rw.push(r[i] - mp);
    r[i] += r[i - 1];
  }
  mx = -1e18;
  for (i = 0; i <= k; i++) mx = max(mx, c[i] + r[k - i] - i * (k - i) * p);
  cout << mx;
}
