#include <bits/stdc++.h>
using namespace std;
const long long MAXN = (long long)((1e5) + 100);
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
void pr(long long x) { cout << x; }
void prl(long long x) { cout << x << "\n"; }
long long cbrt(long long x) {
  long long lo = 1, hi = min(2000000ll, x);
  while (hi - lo > 1) {
    long long mid = (lo + hi) / 2;
    if (mid * mid * mid < x) {
      lo = mid;
    } else
      hi = mid;
  }
  if (hi * hi * hi <= x)
    return hi;
  else
    return lo;
}
const long long dx[4] = {-1, 1, 0, 0};
const long long dy[4] = {0, 0, -1, 1};
long long XX[] = {-1, -1, -1, 0, 0, 1, 1, 1};
long long YY[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const long long N = (long long)(2 * 1e5 + 5);
bool isPowerOfTwo(long long x) { return x && (!(x & (x - 1))); }
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, m, k, p;
    cin >> n >> m >> k >> p;
    long long a[n][m];
    priority_queue<long long> pq1, pq2;
    for (long long i = 0; i < n; i++) {
      long long sum = 0;
      for (long long j = 0; j < m; j++) {
        cin >> a[i][j];
        sum += a[i][j];
      }
      pq1.push(sum);
    }
    for (long long i = 0; i < m; i++) {
      long long sum = 0;
      for (long long j = 0; j < n; j++) {
        sum += a[j][i];
      }
      pq2.push(sum);
    }
    long long sum = 0;
    long long row[k + 1], col[k + 1];
    memset(row, 0, sizeof(row));
    memset(col, 0, sizeof(col));
    for (long long i = 1; i <= k; i++) {
      long long el = pq1.top();
      pq1.pop();
      row[i] = el;
      if (i > 1) row[i] += row[i - 1];
      pq1.push(el - (m * p));
    }
    for (long long i = 1; i <= k; i++) {
      long long el = pq2.top();
      pq2.pop();
      col[i] = el;
      if (i > 1) col[i] += col[i - 1];
      pq2.push(el - (n * p));
    }
    long long ans = -1e18;
    for (long long i = 0; i < k + 1; i++)
      ans = max(ans, row[i] + col[k - i] - ((i) * (k - i) * p));
    cout << ans;
  }
}
