Language: C++

#include <bits/stdc++.h>

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Functional
template<typename U> auto mapf(const auto& a, auto f){Arr<U> r; for(const auto& x:a)r.pushb(f(x)); return r;}
template<typename T> auto reduce(const auto& a, T acc){ return accumulate(all(a),acc); }
template<typename T> auto reduce(const auto& a, T acc, auto f){ return accumulate(all(a),acc,f); }
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

const int N=12, M=12;
int n,m,x;
int c[N], a[N][M];

int z[M];
int f(int idx){
	if(idx==n)
		return reduce<int>({z,z+m},0,lam(acc+(i<x), auto acc, auto i))?inf<int>():0;
	int ret=f(idx+1);

	rep(i,m)
		z[i]+=a[idx][i];
	ret=min(ret,f(idx+1)+c[idx]);
	rep(i,m)
		z[i]-=a[idx][i];
	return ret;
}

signed main(){
	cin>>n>>m>>x;
	rep(i,n){
		cin>>c[i];
		rep(j,m)
			cin>>a[i][j];
	}
	int ans=f(0);
	cout<<(ans>=inf<int>()?-1:ans)<<endl;
	return 0;
}

Compiler output:
a.cc:48:38: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   48 | template<typename U> auto mapf(const auto& a, auto f){Arr<U> r; for(const auto& x:a)r.pushb(f(x)); return r;}
      |                                      ^~~~
a.cc:48:47: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   48 | template<typename U> auto mapf(const auto& a, auto f){Arr<U> r; for(const auto& x:a)r.pushb(f(x)); return r;}
      |                                               ^~~~
a.cc:49:40: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   49 | template<typename T> auto reduce(const auto& a, T acc){ return accumulate(all(a),acc); }
      |                                        ^~~~
a.cc:50:40: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   50 | template<typename T> auto reduce(const auto& a, T acc, auto f){ return accumulate(all(a),acc,f); }
      |                                        ^~~~
a.cc:50:56: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   50 | template<typename T> auto reduce(const auto& a, T acc, auto f){ return accumulate(all(a),acc,f); }
      |                                                        ^~~~
a.cc:53:21: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   53 | struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
      |                     ^~~~
a.cc:56:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   56 | auto split(auto s, auto p){
      |            ^~~~
a.cc:56:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   56 | auto split(auto s, auto p){
      |                    ^~~~
a.cc: In function 'i64 f(i64)':
a.cc:77:35: error: no matching function for call to 'reduce<i64>(<brace-enclosed initializer list>, int, f(i64)::<lambda(auto:36, auto:37)>)'
   77 |                 return reduce<int>({z,z+m},0,lam(acc+(i<x), auto acc, auto i))?inf<int>():0;
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:49:27: note: candidate: 'template<class T, class auto:30> auto reduce(const auto:30&, T)'
   49 | template<typename T> auto reduce(const auto& a, T acc){ return accumulate(all(a),acc); }
      |                           ^~~~~~
a.cc:49:27: note:   candidate expects 2 arguments, 3 provided
a.cc:50:27: note: candidate: 'template<class T, class auto:31, class auto:32> auto reduce(const auto:31&, T, auto:32)'
   50 | template<typename T> auto reduce(const auto& a, T acc, auto f){ return accumulate(all(a),acc,f); }
      |                           ^~~~~~
a.cc:50:27: note:   template argument deduction/substitution failed:
a.cc:77:35: note:   couldn't deduce template parameter 'auto:31'
   77 |                 return reduce<int>({z,z+m},0,lam(acc+(i<x), auto acc, auto i))?inf<int>():0;
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/numeric:287:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::reduce(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  287 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~
/usr/include/c++/14/numeric:287:5: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/numeric:325:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::reduce(_InputIterator, _InputIterator, _Tp)'
  325 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~
/usr/include/c++/14/numeric:325:5: note:   template argument deduction/substitution failed:
a.cc:77:35: note:   cannot convert '{z, (((i64*)(& z)) + ((sizetype)(((long unsigned int)m) * 8)))}' (type '<brace-enclosed initializer list>') to type 'long long int'
   77 |                 return reduce<int>({z,z+m},0,lam(acc+(i<x), auto acc, auto i))?inf<int>():0;
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/numeric:342:5: note: candidate: 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::value_type std::reduce(_InputIterator, _InputIterator)'
  342 |     reduce(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~
/usr/include/c++/14/numeric:342:5: note:   candidate expects 2 arguments, 3 provided
In file included from /usr/include/c++/14/numeric:739:
/usr/include/c++/14/pstl/glue_numeric_defs.h:21:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation)'
   21 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init,
      | ^~~~~~
/usr/include/c++/14/pstl/glue_numeric_defs.h:21:1: note:   candidate expects 5 arguments, 3 provided
/usr/include/c++/14/pstl/glue_numeric_defs.h:26:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp)'
   26 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init);
      | ^~~~~~
/usr/include/c++/14/pstl/glue_numeric_defs.h:26:1: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/pstl/glue_numeric_defs.h:31:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::value_type> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
   31 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~
/usr/include/c++/14/pstl/glue_numeric_defs.h:31:1: note:   template argument deduction/substitution failed:
a.cc:77:35: note:   deduced conflicting types for parameter '_ForwardIterator' ('int' and 'f(i64)::<lambda(auto:36, auto:37)>')
   77 |                 return reduce<int>({z,z+m},0,lam(acc+(i<x), auto acc, auto i))?inf<int>():0;
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~