#include <bits/stdc++.h>
using namespace std;
const int MAX = 1010;
priority_queue<long long> mc;
priority_queue<long long> mr;
int n, m, k, p;
int i, j;
int a[MAX][MAX] = {0};
int sr[MAX] = {0};
int sc[MAX] = {0};
long long A[MAX * MAX] = {0};
long long B[MAX * MAX] = {0};
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
  for (i = 0; i < n; i++) {
    int ts = 0;
    for (j = 0; j < m; j++) ts += a[i][j];
    sr[i] = ts;
    mr.push(ts);
  }
  for (j = 0; j < m; j++) {
    int ts = 0;
    for (i = 0; i < n; i++) ts += a[i][j];
    sc[j] = ts;
    mc.push(ts);
  }
  A[0] = B[0] = 0;
  for (i = 1; i <= k; i++) {
    long long tr = mr.top();
    long long tc = mc.top();
    mr.pop();
    mc.pop();
    A[i] = A[i - 1] + tr;
    B[i] = B[i - 1] + tc;
    tr -= m * p;
    tc -= n * p;
    mr.push(tr);
    mc.push(tc);
  }
  long long r = LLONG_MIN;
  for (i = 0; i <= k; i++) {
    long long tmp = 0;
    tmp = A[i] - (long long)i * (k - i) * p + B[k - i];
    r = r > tmp ? r : tmp;
  }
  printf("%I64d", r);
  return 0;
}
