#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const int maxn = 1e6 + 48;
using namespace std;
long long n, m, k, p;
priority_queue<long long> q;
long long r[maxn], c[maxn];
int a[1035][1048];
int main() {
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  long long s = 0;
  for (int i = 0; i < n; i++) {
    s = 0;
    for (int j = 0; j < m; j++) {
      s += a[i][j];
    }
    q.push(s);
  }
  long long now = 0;
  for (int i = 0; i <= k; i++) {
    long long x = q.top();
    q.pop();
    r[i] = now;
    now += x;
    x -= p * m;
    q.push(x);
  }
  for (; !q.empty(); q.pop())
    ;
  now = 0;
  for (int i = 0; i < m; i++) {
    s = 0;
    for (int j = 0; j < n; j++) {
      s += a[j][i];
    }
    q.push(s);
  }
  for (int i = 0; i <= k; i++) {
    long long x = q.top();
    q.pop();
    c[i] = now;
    now += x;
    x -= p * n;
    q.push(x);
  }
  long long ans = -1e18 - 3548, a = 0;
  for (long long i = 0; i <= k; i++) {
    a = r[i] + c[k - i] - p * i * (k - i);
    ans = max(ans, a);
  }
  cout << ans;
}
