#include <bits/stdc++.h>
using namespace std;
int mat[1005][1005];
int main() {
  vector<int> rows;
  vector<int> cols;
  vector<long long> colsums;
  vector<long long> rowsums;
  long long n, m, k, p, s, ans = (-1) * 9223372036854775807ll, ma;
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  for (int i = 0; i < n; i++) {
    s = 0;
    for (int j = 0; j < m; j++) {
      scanf("%lld", &mat[i][j]);
      s += mat[i][j];
    }
    rows.push_back(s);
  }
  for (int i = 0; i < m; i++) {
    s = 0;
    for (int j = 0; j < n; j++) {
      s += mat[j][i];
    }
    cols.push_back(s);
  }
  make_heap(rows.begin(), rows.end());
  make_heap(cols.begin(), cols.end());
  rowsums.push_back(0);
  colsums.push_back(0);
  for (int i = 0; i < k + 1; i++) {
    ma = rows.front();
    pop_heap(rows.begin(), rows.end());
    rows.pop_back();
    rowsums.push_back(rowsums.back() + ma);
    rows.push_back(ma - m * p);
    push_heap(rows.begin(), rows.end());
  }
  for (int i = 0; i < k + 1; i++) {
    ma = cols.front();
    pop_heap(cols.begin(), cols.end());
    cols.pop_back();
    colsums.push_back(colsums.back() + ma);
    cols.push_back(ma - n * p);
    push_heap(cols.begin(), cols.end());
  }
  for (int i = 0; i < k + 1; i++) {
    ans = max(ans, colsums[i] + rowsums[k - i] - p * i * (k - i));
  }
  printf("%lld", ans);
  return 0;
}
