#include <bits/stdc++.h>
using std::priority_queue;
int n, m, k, p;
int a[1111][1111];
long long col[1000011], row[1000011];
void Init() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", &a[i][j]);
  priority_queue<long long> rque, cque;
  for (int i = 0; i < n; ++i) {
    int rowsum = 0;
    for (int j = 0; j < m; ++j) rowsum += a[i][j];
    rque.push(rowsum);
  }
  for (int j = 0; j < m; ++j) {
    int colsum = 0;
    for (int i = 0; i < n; ++i) colsum += a[i][j];
    cque.push(colsum);
  }
  for (int i = 1; i <= k; ++i) {
    long long rt = rque.top();
    rque.pop();
    row[i] = row[i - 1] + rt;
    rque.push(rt - m * p);
    long long ct = cque.top();
    cque.pop();
    col[i] = col[i - 1] + ct;
    cque.push(ct - n * p);
  }
}
void Work() {
  long long ans = -1000000000000000000ll;
  for (int r = 0; r <= k; ++r) {
    ans = std::max(ans, row[r] + col[k - r] - (long long)p * r * (k - r));
  }
  std::cout << ans << std::endl;
}
int main() {
  Init();
  Work();
  return 0;
}
