#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 mask = 0; mask < (1LL << n); mask++) {
    if(__builtin_popcount(mask) != k) {
      continue;
    }
    int sum = 0;
    std::vector<int> mx(k);
    for(int j = 0; j < n; j++) {
      if(mask & (1LL << j)) {
        for(int w = 0; w < k; w++) {
          mx[w] = std::max(mx[w], a[j][w]);
        }
      }
    }
    for(int j = 0; j < k; j++) {
      sum += mx[j];
    }
    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... |