#include <bits/stdc++.h>
int ret[1005][1005];
long long MaxRow[1000001];
long long MaxColumn[1000001];
inline int Parent(int i) { return (i + 1) / 2 - 1; }
inline int RIGHT(int i) { return (i + 1) * 2; }
inline int LEFT(int i) { return (i + 1) * 2 - 1; }
int cmp(long long, long long);
void heapify(long long *a, int i, int length, int (*cmp)(long long, long long));
void buildHeap(long long *a, int length);
int main(void) {
  int n, m, k, p, i, j;
  long long result = -99999999999999, row[1001], column[1001], max;
  scanf("%d %d %d %d", &n, &m, &k, &p);
  for (i = 0; i < 1001; i++) {
    row[i] = 0;
    column[i] = 0;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &ret[i][j]);
      row[i] += ret[i][j];
      column[j] += ret[i][j];
    }
  }
  for (i = 0; i < k; i++) {
  }
  buildHeap(row, n);
  buildHeap(column, m);
  for (i = 0; i < k; i++) {
  }
  for (i = 0; i < k; i++) {
    MaxRow[i + 1] = MaxRow[i] + row[0];
    row[0] = row[0] - m * p;
    heapify(row, 0, n, cmp);
    MaxColumn[i + 1] = MaxColumn[i] + column[0];
    column[0] = column[0] - n * p;
    heapify(column, 0, m, cmp);
  }
  for (i = 1; i <= k; i++) {
  }
  for (i = 0; i <= k; i++) {
    max = MaxRow[i] + MaxColumn[k - i] - (long long)p * i * (k - i);
    result = result > max ? result : max;
  }
  printf("%I64d\n", result);
  return 0;
}
int cmp(long long a, long long b) { return a - b; }
void buildHeap(long long *a, int length) {
  int i;
  int heapSize = length;
  for (i = length / 2 - 1; i >= 0; i--) {
    heapify(a, i, length, cmp);
  }
  for (i = 0; i < 2; i++) {
  }
}
void heapify(long long *a, int i, int length,
             int (*cmp)(long long, long long)) {
  int l = LEFT(i);
  int r = RIGHT(i);
  int adjust;
  long long temp;
  if (l < length && cmp(a[l], a[i]) > 0) {
    adjust = l;
  } else {
    adjust = i;
  }
  if (r < length && cmp(a[r], a[adjust]) > 0) {
    adjust = r;
  }
  if (i != adjust) {
    temp = a[i];
    a[i] = a[adjust];
    a[adjust] = temp;
    heapify(a, adjust, length, cmp);
  }
}
