#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:LonlyCoder&_Codes")
using namespace std;
int main() {
  int n, m, k, step;
  scanf("%d%d%d%d", &n, &m, &k, &step);
  int a[n][m];
  long long s[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      s[i][j] = a[i][j];
      if (i) s[i][j] += s[i - 1][j];
      if (j) s[i][j] += s[i][j - 1];
      if (i && j) s[i][j] -= s[i - 1][j - 1];
    }
  priority_queue<int> q;
  long long dp1[k + 1], dp2[k + 1];
  dp1[0] = dp2[0] = 0;
  for (int i = 0; i < n; i++) {
    long long tmp = s[i][m - 1];
    if (i) tmp -= s[i - 1][m - 1];
    q.push(tmp);
  }
  for (int i = 1; i <= k; i++) {
    long long x = q.top();
    q.pop();
    dp1[i] = dp1[i - 1] + x;
    q.push(x - m * step);
  }
  for (; !q.empty(); q.pop())
    ;
  for (int j = 0; j < m; j++) {
    long long tmp = s[n - 1][j];
    if (j) tmp -= s[n - 1][j - 1];
    q.push(tmp);
  }
  for (int i = 1; i <= k; i++) {
    long long x = q.top();
    q.pop();
    dp2[i] = dp2[i - 1] + x;
    q.push(x - n * step);
  }
  long long ans = max(dp1[k], dp2[k]);
  for (int i = 1; i < k; i++) {
    long long tmp = dp1[i] + dp2[k - i];
    tmp -= (long long)i * step * (k - i);
    ans = max(ans, tmp);
  }
  printf("%I64d", ans);
  exit(0);
}
