#include <bits/stdc++.h>
using namespace std;
long long cols[1000001] = {0};
long long rows[1000001] = {0};
int mat[1010][1010] = {{0}};
class cmp {
 public:
  bool operator()(long long &p1, long long &p2) { return p2 > p1; }
};
int main() {
  ios_base::sync_with_stdio(false);
  rows[0] = cols[0] = 0;
  int n, m, k, p;
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> mat[i][j];
  priority_queue<long long, vector<long long>, cmp> pq;
  for (int i = 0; i < n; i++) {
    long long sum = 0;
    for (int j = 0; j < m; j++) sum += mat[i][j];
    pq.push(sum);
  }
  for (int i = 1; i <= k; i++) {
    rows[i] = rows[i - 1];
    long long ele = pq.top();
    pq.pop();
    rows[i] += ele;
    ele -= (m * p);
    pq.push(ele);
  }
  while (!pq.empty()) pq.pop();
  for (int i = 0; i < m; i++) {
    long long sum = 0;
    for (int j = 0; j < n; j++) sum += mat[j][i];
    pq.push(sum);
  }
  for (int i = 1; i <= k; i++) {
    cols[i] = cols[i - 1];
    long long ele = pq.top();
    pq.pop();
    cols[i] += ele;
    ele -= (n * p);
    pq.push(ele);
  }
  long long ans = -1E18;
  for (int i = 0; i <= k; i++) {
    int r = i;
    int c = k - i;
    long long rem = 1LL * r * c;
    rem = rem * p;
    long long temp = rows[r] + cols[c] - rem;
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}
