#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k, p;
  cin >> n >> m >> k >> p;
  vector<vector<int>> in(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> in[i][j];
    }
  }
  vector<long long> a(k + 1);
  {
    priority_queue<long long> que;
    for (int i = 0; i < n; i++) {
      int cur = 0;
      for (int j = 0; j < m; j++) cur += in[i][j];
      que.push(cur);
    }
    for (int i = 1; i <= k; i++) {
      a[i] = que.top();
      long long cur = que.top();
      que.pop();
      que.push(cur - p * m);
      if (i > 0) a[i] += a[i - 1];
    }
  }
  vector<long long> b(k + 1);
  {
    priority_queue<long long> que;
    for (int j = 0; j < m; j++) {
      int cur = 0;
      for (int i = 0; i < n; i++) cur += in[i][j];
      que.push(cur);
    }
    for (int i = 1; i <= k; i++) {
      b[i] = que.top();
      long long cur = que.top();
      que.pop();
      que.push(cur - p * n);
      if (i > 0) b[i] += b[i - 1];
    }
  }
  long long ans = -(1LL << 60);
  for (int i = 0; i <= k; i++) {
    ans = max(ans, 1LL * a[i] + b[k - i] - 1LL * i * (k - i) * p);
  }
  cout << ans << endl;
  return 0;
}
