#include <bits/stdc++.h>
using namespace std;
const char IO_MODE = 0;
inline long long ReadInt() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void WriteInt(long long x) {
  char CH[20];
  if (x < 0) putchar('-');
  x = -x;
  int Num = 0;
  if (!x) {
    putchar('0');
    return;
  }
  while (x > 0) CH[++Num] = x % 10, x /= 10;
  while (Num) putchar(CH[Num--] + 48);
}
inline void out(int x) {
  if (IO_MODE & 1)
    WriteInt(x);
  else
    printf("%i", x);
}
template <typename... Args>
inline void out(int x, Args... args) {
  out(x);
  putc(' ', stdout);
  out(args...);
}
inline void in(int &x) {
  if (IO_MODE & 2)
    x = ReadInt();
  else
    scanf("%i", &x);
}
template <typename... Args>
inline void in(int &x, Args &...args) {
  in(x);
  in(args...);
}
inline void outll(long long x) {
  if (IO_MODE & 1)
    WriteInt(x);
  else
    printf("%I64d", x);
}
template <typename... Args>
inline void outll(long long x, Args... args) {
  outll(x);
  putc(' ', stdout);
  outll(args...);
}
inline void inll(long long &x) {
  if (IO_MODE & 2)
    x = ReadInt();
  else
    scanf("%I64d", &x);
}
template <typename... Args>
inline void inll(long long &x, Args &...args) {
  inll(x);
  inll(args...);
}
int aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, mm, nn, oo, pp, qq, rr, ss, tt,
    uu, vv, ww, xx, yy, zz;
int tc;
long long n, m, k, p;
int A[1003][1003];
long long K[2][1000005];
multiset<long long> row, col;
int main() {
  inll(n, m, k, p);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) in(A[i][j]);
  for (int i = 0; i < n; i++) {
    long long sum = 0;
    for (int j = 0; j < m; j++) sum += A[i][j];
    row.insert(sum);
  }
  for (int j = 0; j < m; j++) {
    long long sum = 0;
    for (int i = 0; i < n; i++) sum += A[i][j];
    col.insert(sum);
  }
  for (int i = 1; i <= k; i++) {
    long long inc;
    inc = *row.rbegin();
    K[0][i] = K[0][i - 1] + inc;
    row.erase(next(row.rbegin()).base());
    row.insert(inc - m * p);
    inc = *col.rbegin();
    K[1][i] = K[1][i - 1] + inc;
    col.erase(next(col.rbegin()).base());
    col.insert(inc - n * p);
  }
  long long ans = -1e17;
  for (int i = 0; i <= k; i++)
    ans = max(ans, K[0][i] + K[1][k - i] - i * (k - i) * p);
  cout << ans << endl;
}
