#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> colonne, righe;
vector<long long> sol_colonne, sol_righe;
long long C[1000], R[1000], temp, N, M, K, P, happy;
vector<long long> solve(priority_queue<long long> pq, long long A) {
  vector<long long> sol;
  sol.push_back(0);
  for (int i = 1; i <= K; i++) {
    sol.push_back(sol.back() + pq.top());
    pq.push(pq.top() - P * A);
    pq.pop();
  }
  return sol;
}
int main() {
  cin >> N >> M >> K >> P;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      cin >> temp;
      C[j] += temp;
      R[i] += temp;
    }
  for (int i = 0; i < N; i++) righe.push(R[i]);
  for (int j = 0; j < M; j++) colonne.push(C[j]);
  sol_colonne = solve(colonne, N);
  sol_righe = solve(righe, M);
  happy = sol_colonne[K];
  for (int i = 1; i <= K; i++)
    if (sol_colonne[K - i] + sol_righe[i] - P * i * (K - i) > happy)
      happy = sol_colonne[K - i] + sol_righe[i] - P * i * (K - i);
  cout << happy << endl;
  return 0;
}
