#include <bits/stdc++.h>
#define int long long
signed main() {
  int n, k, c;
  std::cin >> n >> k >> c;
  std::vector<std::vector<int>> a(n, std::vector<int>(k));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < k; j++) {
      std::cin >> a[i][j];
    }
  }
  std::vector<int> ans;
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      int sum = 0;
      std::vector<int> mx(k);
      for(int w = 0; w < k; w++) {
        mx[w] = std::max(mx[w], a[i][w]);
        mx[w] = std::max(mx[w], a[j][w]);
      }
      for(int w = 0; w < k; w++) {
        sum += mx[w];
      }
      ans.push_back(sum);
    }
  }
  std::sort(ans.begin(), ans.end());
  std::reverse(ans.begin(), ans.end());
  std::cout << ans[--c];
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |