#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9 + 5;
const long long ll_inf = 1e18 + 5;
template <typename T, typename T2>
ostream &operator<<(ostream &s, const pair<T, T2> &p) {
  return s << p.first << ' ' << p.second << ' ';
}
template <typename T, typename T2>
istream &operator>>(istream &s, pair<T, T2> &p) {
  return s >> p.first >> p.second;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
  for (auto it : v) s << it << ' ';
  return s;
}
template <typename T>
istream &operator>>(istream &s, vector<T> &v) {
  for (auto it = (v).begin(), it_ = (v).end(); it != it_; it++) s >> *it;
  return s;
}
template <typename T>
void read_range(T beg, T end) {
  while (beg != end) cin >> *beg++;
}
template <typename T>
void print_range(T beg, T end) {
  while (beg != end) cout << *beg++ << ' ';
}
struct reader {
  template <typename T>
  reader &operator,(T &v) {
    cin >> v;
    return *this;
  }
} rdr;
struct debugger {
  template <typename T>
  debugger &operator,(const T &v) {
    cerr << v << ", ";
    return *this;
  }
} dbg;
priority_queue<long long> row_max, col_max;
long long row[(int)(1e3 + 5)], col[(int)(1e3 + 5)];
long long row_m[(int)(1e6 + 5)], col_m[(int)(1e6 + 5)];
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m, k, p;
  rdr, n, m, k, p;
  ;
  for (int i = 0, end = (n); i < end; i++)
    for (int j = 0, end = (m); j < end; j++) {
      int val;
      rdr, val;
      ;
      row[i] += val;
      col[j] += val;
    }
  for (int i = 0, end = (n); i < end; i++) row_max.push(row[i]);
  for (int i = 0, end = (m); i < end; i++) col_max.push(col[i]);
  for (int i = 1; i <= k; i++) {
    row_m[i] = row_max.top();
    row_max.pop();
    row_max.push(row_m[i] - p * m);
    row_m[i] += row_m[i - 1];
  }
  for (int i = 1; i <= k; i++) {
    col_m[i] = col_max.top();
    col_max.pop();
    col_max.push(col_m[i] - p * n);
    col_m[i] += col_m[i - 1];
  }
  long long max_res = -ll_inf;
  for (int i = 0, end = (k + 1); i < end; i++)
    max_res = max(max_res, row_m[i] + col_m[k - i] - (i) * (k - i) * p);
  cout << max_res;
  return 0;
}
