#include <bits/stdc++.h>
using namespace std;
int arr[1002][1002] = {0};
int n, m, k, p;
long long temp;
vector<long long> solve(vector<long long> vl, int minus) {
  priority_queue<int> q(vl.begin(), vl.end());
  vector<long long> ret;
  long long ans = 0;
  ret.push_back(0);
  for (int j = 0; (j) < (k); j++) {
    temp = q.top();
    ans += temp;
    ret.push_back(ans);
    q.pop();
    q.push(temp - minus);
  }
  return ret;
}
int main() {
  cin >> n >> m >> k >> p;
  vector<long long> row_tot, col_tot;
  for (int i = 0; (i) < (n); i++) {
    long long tot = 0;
    for (int j = 0; (j) < (m); j++) {
      scanf("%d", &arr[i][j]);
      tot += arr[i][j];
    }
    row_tot.push_back(tot);
  }
  for (int i = 0; (i) < (m); i++) {
    long long tot = 0;
    for (int j = 0; (j) < (n); j++) {
      tot += arr[j][i];
    }
    col_tot.push_back(tot);
  }
  vector<long long> row_s = solve(row_tot, p * m);
  vector<long long> col_s = solve(col_tot, p * n);
  long long ret = -9223372036854775807;
  for (int i = 0; (i) < (k + 1); i++) {
    ret = max(ret, row_s[i] + col_s[k - i] - ((long long)p) * i * (k - i));
  }
  cout << ret << '\n';
  return 0;
}
