#include <bits/stdc++.h>
using namespace std;
long long int a[1004][1004];
long long int n, m, k, p;
long long int rturn[1000010], cturn[1000010];
void solve1() {
  priority_queue<long long int> pq;
  long long int rsum = 0;
  long long int now = 0;
  for (int i = 1; i <= n; i++) {
    rsum = 0;
    for (int j = 1; j <= m; j++) rsum = rsum + a[i][j];
    pq.push(rsum);
  }
  long long int iter = 1, curr = 0;
  while (iter <= k) {
    curr = pq.top();
    pq.pop();
    now = now + curr;
    curr = curr - (m * p);
    pq.push(curr);
    rturn[iter] = now;
    iter++;
  }
}
void solve2() {
  priority_queue<long long int> pq;
  long long int csum = 0;
  long long int now = 0;
  for (int i = 1; i <= m; i++) {
    csum = 0;
    for (int j = 1; j <= n; j++) csum = csum + a[j][i];
    pq.push(csum);
  }
  long long int iter = 1, curr;
  while (iter <= k) {
    curr = pq.top();
    pq.pop();
    now = now + curr;
    curr = curr - (n * p);
    pq.push(curr);
    cturn[iter] = now;
    iter++;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  scanf("%lld", &n);
  ;
  scanf("%lld", &m);
  ;
  scanf("%lld", &k);
  ;
  scanf("%lld", &p);
  ;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%lld", &a[i][j]);
  ;
  solve1();
  solve2();
  long long int fans = -1LL * ((1LL << 63) - 10), ans;
  for (long long int i = 0; i <= k; i++) {
    ans = rturn[i] + cturn[k - i] - (i * (k - i) * p);
    fans = max<long long int>(fans, ans);
  }
  cout << fans << endl;
  return 0;
}
