stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int n, m, x, ans = 1e9;

int a[13][13], c[13], level[13];



void dfs(int cur, int money) {

    if (cur == n + 1) {

        for (int i = 1; i <= m; i++)

            if (level[i] < x) return;

        ans = min(ans, money);

        return;

    }

    for (int i = 1; i <= m; i++)

        level[i] += a[cur][i];

    dfs(cur + 1, money + c[cur]);

    for (int i = 1; i <= m; i++)

        level[i] -= a[cur][i];

    dfs(cur + 1, money);

}



int main() {

    //freopen("test.out", "w", stdout);

    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n >> m >> x;

    for (int i = 1; i <= n; i++) {

        cin >> c[i];

        for (int j = 1; j <= m; j++) 

            cin >> a[i][j];

    }

    dfs(1, 0);

    cout << (ans == 1e9 ? -1 : ans) << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.789587763983687x):
#include <cstdio>

#include <algorithm>

using namespace std;

int n,m,x;

int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;

void init(){//数据读取

	int i,j;

	scanf("%d%d%d",&n,&m,&x);

	for(i=1;i<=n;i++){

		scanf("%d",&c[i]);

		for(j=1;j<=m;j++)

			scanf("%d",&a[i][j]);

	}

}

void dfs(int step){

	int i,j,k;

	if(step==len+1){//深搜结束条件

		for(k=1;k<=m;k++)d[k]=0;//d[k]表示被选择的书店，在k列位置上的和

		for(j=1;j<=len;j++)

			for(k=1;k<=m;k++)

				d[k]+=a[b[j]][k];//计算被选择的书店，在k列位置上的和

		for(k=1;k<=m;k++)

			if(d[k]<x)return;//不满足条件

		cost=0;

		for(j=1;j<=len;j++)cost+=c[b[j]];//计算花费

		sum=min(sum,cost);//找最小值

		return ;

	}

	for(i=b[step-1]+1;i<=n;i++)//找组合情况，就让后查找的位置越来越大，请注意i=b[step-1]+1

		b[step]=i,dfs(step+1);

}

int main(){

	init();

	for(len=1;len<=n;len++)//len界定选择的书店的数量

		b[0]=0,dfs(1);

	if(sum==100000000)printf("-1\n");//没找到

	else printf("%d\n",sum);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

#define int long long

#define inf 999999999999999999

#define N 666666

int arr[N];

int n,m,x;

int c[N];

int mp[666][666];

int t[N];

signed main(){

	cin>>n>>m>>x;

	for(int i=0;i<n;i++){

		cin>>c[i];

		for(int j=1;j<=m;j++) cin>>mp[i][j];

	}

	int ans=inf;

	for(int i=0;i<(1<<n);i++){

		int s=0;

		for(int j=0;j<=400;j++) t[j]=0;

		for(int j=0;j<n;j++){

			if(i&(1<<j)){

				s+=c[j];

				for(int k=1;k<=m;k++) t[k]+=mp[j][k];

			}

		}

		int f=1;

		for(int j=1;j<=m;j++){

			if(t[j]<x){

				 f=0;

				break;

			}

		}

		if(f) ans=min(ans,s);

	}

	if(ans==inf) cout<<"-1";else cout<<ans;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.021036811288761x):
#include <cstdio>

#include <algorithm>

using namespace std;

int n,m,x;

int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;

void init(){//数据读取

	int i,j;

	scanf("%d%d%d",&n,&m,&x);

	for(i=1;i<=n;i++){

		scanf("%d",&c[i]);

		for(j=1;j<=m;j++)

			scanf("%d",&a[i][j]);

	}

}

void dfs(int step){

	int i,j,k;

	if(step==len+1){//深搜结束条件

		for(k=1;k<=m;k++)d[k]=0;//d[k]表示被选择的书店，在k列位置上的和

		for(j=1;j<=len;j++)

			for(k=1;k<=m;k++)

				d[k]+=a[b[j]][k];//计算被选择的书店，在k列位置上的和

		for(k=1;k<=m;k++)

			if(d[k]<x)return;//不满足条件

		cost=0;

		for(j=1;j<=len;j++)cost+=c[b[j]];//计算花费

		sum=min(sum,cost);//找最小值

		return ;

	}

	for(i=b[step-1]+1;i<=n;i++)//找组合情况，就让后查找的位置越来越大，请注意i=b[step-1]+1

		b[step]=i,dfs(step+1);

}

int main(){

	init();

	for(len=1;len<=n;len++)//len界定选择的书店的数量

		b[0]=0,dfs(1);

	if(sum==100000000)printf("-1\n");//没找到

	else printf("%d\n",sum);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long int

#define ld long double

#define ull unsigned long long int

#define forn(i,n)for(ll i=0;i<(n);i++)

#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)

#define for1n(i,n) for(ll i=1;i<=(n);i++)

#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)

#define MOD 1000000007

#define MAXN 1000005



using namespace std;



vector<ll> ans;



void recur(ll i,vector<ll> cost,vector<vector<ll>> arr,ll N,ll M,ll X){

    if(i<N){

        vector<ll> temp_cost=cost;

        forn(j,M+1){

            cost[j]+=arr[i][j];

        }

        bool exist=false;

        for1n(j,M){

            if(cost[j]<X){

                exist=true;

                break;

            }



        }

        if(exist){

            recur(i+1,cost,arr,N,M,X);

            recur(i+1,temp_cost,arr,N,M,X);

        }

        else{

            ans.push_back(cost[0]);

            recur(i+1,temp_cost,arr,N,M,X);

        }





    }





}





int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(NULL); cout.tie(NULL);

    ll T=1;

    //cin>>T;

    while(T--)

    {



       ll N,M,X;

       cin>>N>>M>>X;

       vector<ll> cost(M+1,0);

       vector<vector<ll>> arr(N,vector<ll>(M+1,0));

       forn(i,N) forn(j,M+1) cin>>arr[i][j];

       recur(0,cost,arr,N,M,X);

       if(ans.size()==0){

        cout<<-1;

        return 0;

       }

       cout<<*min_element(ans.begin(),ans.end());





    }







    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.193213276450951x):
#include <bits/stdc++.h>

#define ll long long int

#define ld long double

#define ull unsigned long long int

#define forn(i,n)for(ll i=0;i<(n);i++)

#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)

#define for1n(i,n) for(ll i=1;i<=(n);i++)

#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)

#define MOD 1000000007

#define MAXN 1000005



using namespace std;



vector<ll> ans;



void recur(ll i,vector<ll> cost,vector<vector<ll>> &arr,ll N,ll M,ll X){

    if(i<N){

        vector<ll> temp_cost=cost;

        forn(j,M+1){

            cost[j]+=arr[i][j];

        }

        bool exist=false;

        for1n(j,M){

            if(cost[j]<X){

                exist=true;

                break;

            }



        }

        if(exist){

            recur(i+1,cost,arr,N,M,X);

            recur(i+1,temp_cost,arr,N,M,X);

        }

        else{

            ans.push_back(cost[0]);

            recur(i+1,temp_cost,arr,N,M,X);

        }





    }





}





int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(NULL); cout.tie(NULL);

    ll T=1;

    //cin>>T;

    while(T--)

    {



       ll N,M,X;

       cin>>N>>M>>X;

       vector<ll> cost(M+1,0);

       vector<vector<ll>> arr(N,vector<ll>(M+1,0));

       forn(i,N) forn(j,M+1) cin>>arr[i][j];

       recur(0,cost,arr,N,M,X);

       if(ans.size()==0){

        cout<<-1;

        return 0;

       }

       cout<<*min_element(ans.begin(),ans.end());





    }







    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

using LL = long long;

using Graph = vector<vector<LL>>;



long long gcd(long long a, long long b){

  if (b==0) return a;

  else return gcd(b,a%b);

}

vector<bool> seen;

void dfs(const Graph &G, int v) {

    seen[v] = true;



    for (auto next_v : G[v]) { 

        if (seen[next_v]) continue;

        dfs(G, next_v);

    }

}







int main() {

  LL n,m,x,k=0,sum=0,a=0,b=0,c=0,d=0,ans=10000000;

  LL MOD = 1000000007;

  LL INF = 1LL << 60;

  LL C[100001],A[13][13],R[100001]={0},O[100001];

  string S="",T="",U="";

  cin >> n >> m >> x;

  for (LL i=0;i<n;i++){

    cin >> C[i];

    for (LL j=0;j<m;j++){

      cin >> A[i][j];

      R[j] += A[i][j];

    }

  }

  for (int i=0;i<m;i++){

    if(R[i]<x) ans=-1;

  }



  if(ans != -1){

    for (int bit = 0; bit < (1 << n); ++bit) {

          b=0;

          a=0;

          for(int i=0;i<m;i++){

            O[i]=0;

          }

          for (int i = 0; i < n; ++i) {

              if (bit & (1 << i)){

                b += C[i];

                for (int j=0;j<m;j++){

                  O[j] += A[i][j];

                }

              }

          }

          for(int j=0;j<m;j++){

            if(O[j]<x){

              a=1;

            }

          }

          if(a==0){

            ans = min(ans,b);

          }

    }

  }

  cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.8217701842434229x):
#include <bits/stdc++.h>

#include <math.h>

#define rep(i,n) for (int i=0;i < (n); ++i)

#define ALL(x) (x).begin(), (x).end()

using namespace std;

using ll = long long;



int main() {

   int n,m,x,ans=1e8,tmp=0;

   cin >> n >> m >> x;

   vector<int> c(n);

   vector<int> cnt(m,0);

   vector<vector<int>> a(n,vector<int>(m));

   rep(i,n){

       cin >> c[i];

       rep(j,m){

           cin >> a[i][j];

       }

    }

    bool flag=true;

    for (int bit = 0; bit < (1<<n); ++bit) {

        for (int i = 0; i < n; ++i) {

            if (bit & (1<<i)) {

                rep(j,m){

                    cnt[j] += a[i][j];

                }

                tmp += c[i];

            }

        }

        rep(i,m){

            if(cnt[i]<x) flag = false;

        }

        if(flag) ans = min(ans,tmp);

        tmp = 0;

        flag = true;

        rep(i,m){

            cnt[i] = 0;

        }

    }

    if(ans!=1e8) cout << ans << endl;

    else cout << -1 << endl;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<string>

#include<map>

#include<utility>

#include<algorithm>

#include<queue>

#include<cmath>

#include<iomanip>

#define REP(i, n) for(ll i = 0; i < n; i++)

#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)

#define FOR(i, m, n) for(ll i = m; i <= n; i++)

#define FORR(i, m, n) for(ll i = m; i >= n; i--)

#define SORT(v, n) sort(v, v+n)

#define MAX 100000

#define inf 1000000007

using namespace std;

using ll = long long;

using vll = vector<ll>;

using vvll = vector<vector<ll>>;

using P = pair<ll, ll>;



ll n, m, x, ans;



void isSkill(vll tmp, vvll a) {//今回の組の計算

    bool flag = true;

    vll now(m+1, 0);

    ll money = 0;

    for(ll num : tmp){//今回の組の理解度を算出

        FOR(i, 1, m){

            now[i] += a[num][i];

        }

        money += a[num][0];

    }

    FOR(i, 1, m){//今回の組がいけているか判断

        if (now[i] < x){

            flag = false;

            break;

        }

    }

    if(flag) ans = min(ans, money);



    while (tmp.back() < n) {

        tmp.back()++;//後ろの値を1大きくした場合

        isSkill(tmp, a);

        tmp.back()--;//後ろに1大きい値を入れた場合

        tmp.push_back(tmp.back()+1);

        isSkill(tmp, a);

    }

    return;

}



int main() {

    //cin高速化

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> n >> m >> x;

    ans = inf;

    vvll a(n+1, vll(m+1, 0));

    FOR(i, 1, n){

        REP(j, m+1){

            cin >> a[i][j];

        }

    }

    vll t = {1};

    isSkill(t, a);

    if(ans == inf){

        ans = -1;

    }



    cout << ans <<"\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.959692189116671x):
#include <bits/stdc++.h>

#define REP(i, n) for(ll i = 0; i < n; i++)

#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)

#define FOR(i, m, n) for(ll i = m; i <= n; i++)

#define FORR(i, m, n) for(ll i = m; i >= n; i--)

#define SORT(v, n) sort(v, v+n)

#define MAX 100000

#define inf 1000000007

using namespace std;

using ll = long long;

using vll = vector<ll>;

using vvll = vector<vector<ll>>;

using P = pair<ll, ll>;



ll n, m, x, ans;



void isSkill(ll bit, vvll a){//この組の理解度を算出

    bool flag = true;

    vll now(m+1, 0);

    ll money = 0;

    REP(i, n){

        if (bit & 1 << i){//  そのbitが1ならば

            FOR(j, 1, m) now[j] += a[i+1][j];

            money += a[i+1][0];

        }

    }

    FOR(i, 1, m){//今回の組がいけているか判断

        if (now[i] < x){

            flag = false;

            break;

        }

    }

    if(flag) ans = min(ans, money);

    return;

}



int main() {

    //cin高速化

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> n >> m >> x;

    ans = inf;

    vvll a(n+1, vll(m+1, 0));

    //input

    FOR(i, 1, n) REP(j, m+1) cin >> a[i][j];

    //bit full search

    REP(bit, 1 << n){

        isSkill(bit, a);

    }



    if(ans == inf) ans = -1;

    cout << ans <<"\n";

	return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<math.h>

#define rep(i,N) for(int i=0;i<(int)N;i++)

const int dz=12,INF=0x7f7f7f7f;

int min(int x,int y){return(x<y)?x:y;}

int main(void)

{

  int N,M,X,check,cost,C[dz],A[dz][dz],skill[dz],total=INF;

  check=scanf("%d %d %d",&N,&M,&X);

  rep(i,N){check=scanf("%d",&C[i]);rep(j,M)check=scanf("%d",&A[i][j]);}

  rep(bit,pow(2,N))

  {

    cost=0;rep(i,M)skill[i]=0;

    rep(i,N)if(bit&(int)pow(2,i)){cost+=C[i];rep(j,M)skill[j]+=A[i][j];}

    check=1;rep(i,M)if(skill[i]<X){check=0;break;}

    if(check)total=min(total,cost);

  }

  return printf("%d\n",total==INF?-1:total),0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3440635175750417x):
#include<stdio.h>

#define rep(i,N) for(int i=0;i<(int)N;i++)

const int INF=0x7f7f7f7f;

int main(void)

{

  int N,M,X,check,C[12]={0},A[12][12]={0},skill[12],pay=INF,sum;

  check=scanf("%d %d %d",&N,&M,&X);

  rep(i,N){check=scanf("%d",&C[i]);rep(j,M)check=scanf("%d",&A[i][j]);}

  rep(bit,(1<<N))

  {

    sum=0;rep(i,M)skill[i]=0;

    rep(i,N)if(bit&(1<<i)){sum+=C[i];rep(j,M)skill[j]+=A[i][j];}

    check=1;rep(i,M)if(skill[i]<X){check=0;break;}

    if(check)pay=(pay<sum)?pay:sum;

  }

  return printf("%d\n",pay==INF?-1:pay),0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int solve_number(

                 vector<bool> comp, vector<int> &c, vector<vector<int>> a, int x){

    

    int ne=0;

    

    int m = (int)a[0].size();

    

    vector<int> ri(m,0);

    

    for(int i=0; i<c.size(); i++){

        if(!comp[i])continue;

        

        ne += c[i];

        

        for(int j=0; j<m; j++){

            ri[j] += a[i][j];

            

        }

    }

    

    bool ok=true;

    

    for(int j=0; j<m; j++){

        if(ri[j]<x)return 2000000;

    }

    

    return ne;

}



void combi(

           vector<bool> comp,

           vector<int> &c, vector<vector<int>> a, int n, int x, int &nmin){

    

    int m = (int)a[0].size();

    

    if(n==0){

        nmin = min( nmin, solve_number(comp, c, a, x));

        return;

    }

    

    combi(comp, c, a, n-1, x, nmin);

    comp.at(n-1) = true;

    combi(comp, c, a, n-1, x, nmin);

    comp.at(n-1) = false;

    

    return;

}



int main(){

    

    int n,m,x;

    cin >> n >> m >> x;

    

    vector<int> c(n);

    vector<vector<int>> a(n, vector<int> (m));

    

    for(int i=0; i<n ; i++){

        cin >> c.at(i);

        for(int j=0; j<m; j++){

            cin >> a.at(i).at(j);

        }

    }

    

    vector<bool> comp(n, false);

    int nmin=2000000;

    

    combi(comp, c, a, n, x, nmin);

    

    if(nmin==2000000)

        cout << "-1" << endl;

    else

        cout << nmin << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3176445837524837x):
#include <bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); ++i)

using namespace std;



const int INF = 1001001001;



int main(){

    

    int n,m,x;

    cin >> n >> m >> x;

    

    vector<int> c(n);

    vector<vector<int>> a(n, vector<int> (m));

    

    for(int i=0; i<n ; i++){

        cin >> c.at(i);

        for(int j=0; j<m; j++){

            cin >> a.at(i).at(j);

        }

    }

    

    int ans = INF;

    

    rep(s, 1<<n){//ビット演算

        

        int cost = 0;

        vector<int> d(m);

        rep(i,n){

            if(s>>i & 1){//ビット演算

                cost += c[i];

                rep(j,m) d[j] += a[i][j];

            }

        }

        

        bool ok = true;

        rep(j,m)if(d[j]<x)ok = false;

        

        if(ok) ans = min(ans, cost);

    }

    

    if(ans==INF)

        cout << "-1" << endl;

    else

        cout << ans << endl;

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

#define ll long long

#define pb push_back

#define mem(arr,x) memset(arr,x,sizeof(arr))

long int ans=INT_MAX,n,m,x;

long int row[20];

void calc(vector<vector<long int>>books,vector<long int>price)

{

    vector<long int>vec(m,0);

    long int p=0;

    for(int i=0;i<n;i++)

    {

        if(row[i]==1)

        {

            p+=price[i];

            for(int j=0;j<m;j++)

            vec[j]+=books[i][j];

        }

    }

    for(int i=0;i<m;i++)

    {

        if(vec[i]<x)

        return;

    }

    ans=min(ans,p);

    return;

}

void bactrack(vector<vector<long int>>books,vector<long int>price,int i)

{

    if(i>=n)

    {

        calc(books,price);

        return;

    }

    row[i]=1;

    bactrack(books,price,i+1);

    row[i]=0;

    bactrack(books,price,i+1);

}

int main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    long int i,j;

    cin>>n>>m>>x;

    vector<vector<long int>>books(n+1,vector<long int>(m+1,0));

    vector<long int>price(n+1);

    for(i=0;i<n;i++)

    {

        cin>>price[i];

        for(j=0;j<m;j++)

        cin>>books[i][j];

    }

    memset(row,0,sizeof(row));

    bactrack(books,price,0);

    if(ans==INT_MAX)

    cout<<-1;

    else

    cout<<ans;

    return 0;

}   

// Faster C++ solution for the same problem (measured speedup: 1.3428304327317253x):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define pb push_back

#define pii pair<int,int>

#define sorted(a) sort(a.begin(),a.end())

#define rsorted(a) sort(a.rbegin(),a.rend())

#define test(val) cout<<val<<endl;

#define test1(val) cout<<val<<" ";



struct node{

    ll cost;

    ll arr[20];

};



ll required_level;

ll min_cost = INT_MAX;

void backtrack(node books[], int start, vector<ll>level,int n, int m, ll current_cost){

    if(start>=n)

    return;



    for(int i=start;i<n;i++){



        current_cost+=books[i].cost;

        for(int j=0;j<m;j++)

         level[j]+=books[i].arr[j];



        int f=0;

        for(int k=0;k<m;k++){

            if(level[k]<required_level){

                f=1;

                break;

            }

        }

        if(f==0)

        min_cost = min(min_cost,current_cost);

        backtrack(books,i+1,level,n,m,current_cost);

        for(int j=0;j<m;j++) 

        level[j]-=books[i].arr[j];

        current_cost-=books[i].cost;

    }

    return;

}



void solve(){

    int n,m,x;

    cin>>n>>m>>x;

    required_level=x;

    node books[n+1];

    vector<ll>level(m+1,0);

    for(int i=0;i<n;i++){

        cin>>books[i].cost;

        for(int j=0;j<m;j++)

            cin>>books[i].arr[j];

    }

    backtrack(books,0,level,n,m,0ll);

    if(min_cost==INT_MAX)

        cout<<-1<<endl;

    else

    cout<<min_cost<<endl;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t=1;

    // cin>>t;

    while(t--){

        solve();

    }



return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <iostream>

#include <algorithm>

#include <cstring>



using namespace std;



struct node

{

	int c;

	int a[15];

}book[15];

int b[15];



int main()

{

//	freopen("input.txt","r",stdin);

	

	int n,m,x;

	cin>>n>>m>>x;

	for(int i=0;i<n;i++)

	{

		cin>>book[i].c;

		for(int j=0;j<m;j++) cin>>book[i].a[j];

	}

//	for(int i=0;i<n;i++)

//	{

//		cout<<book[i].c<<" ";

//		for(int j=0;j<m;j++) cout<<book[i].a[j];

//		puts("");

//	}

	int ans=-1;

	for(int i=0;i<(1<<n);i++)

	{

		int sum=0;

		memset(b,0,sizeof b); 

		for(int j=0;j<n;j++)

			if((i>>j)&1)

			{

				sum+=book[j].c;

				for(int k=0;k<m;k++) b[k]+=book[j].a[k];

			}

		bool flag=1;

		for(int j=0;j<m;j++) if(b[j]<x) flag=0;

		if(flag)

		{

			if(ans==-1) ans=sum;

			else ans=min(ans,sum);

		}

	}

	cout<<ans<<endl;

	

	return 0;

 } 

 

//每行第一个数前不输出 

 



 

 

 

 

 

// Faster C++ solution for the same problem (measured speedup: 4.868380124072959x):
#include <cstdio>

#include <algorithm>

using namespace std;

int n,m,x;

int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;

void dfs(int step){

	int i,j,k;

	if(step==len+1){

		for(k=1;k<=m;k++)d[k]=0;

		for(j=1;j<=len;j++)

			for(k=1;k<=m;k++)

				d[k]+=a[b[j]][k];

		for(k=1;k<=m;k++)

			if(d[k]<x)return;

		cost=0;

		for(j=1;j<=len;j++)cost+=c[b[j]];

		sum=min(sum,cost);

		return ;

	}

	for(i=b[step-1]+1;i<=n;i++)

		b[step]=i,dfs(step+1);

}

int main(){

	int i,j;

	scanf("%d%d%d",&n,&m,&x);

	for(i=1;i<=n;i++)

	{

		scanf("%d",&c[i]);

		for(j=1;j<=m;j++)

			scanf("%d",&a[i][j]);

	}

	for(len=1;len<=n;len++)

		b[0]=0,dfs(1);

	if(sum==100000000)printf("-1\n");

	else printf("%d\n",sum);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

using namespace std;



int pr[16],ex[16][16],mi=0x3f3f3f3f,sum,now[16];

int n,m,x;

void solve(int u)

{

	int flag=1;

	for(int i=1;i<=m;++i)

	{

		if(now[i]<x)flag=0;

	}

	if(flag){if(sum<mi)mi=sum;return;}

	for(int i=u;i<=n;++i)

	{

		for(int j=1;j<=m;++j)now[j]+=ex[i][j];

		sum+=pr[i];

		solve(i+1);

		for(int j=1;j<=m;++j)now[j]-=ex[i][j];

		sum-=pr[i];

	}

	//cout<<1;

}

int main()

{

	ios;

	cin>>n>>m>>x;

	for(int i=1;i<=n;++i)

	{

		cin>>pr[i];

		for(int j=1;j<=m;++j)cin>>ex[i][j];

	}

	//cout<<1;

	solve(1);

	if(mi!=0x3f3f3f3f)cout<<mi<<'\n';

	else cout<<-1<<'\n';

}

// Faster C++ solution for the same problem (measured speedup: 4.797856526900995x):
#include <cstdio>

#include <algorithm>

using namespace std;

int n,m,x;

int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;

void dfs(int step){

	int i,j,k;

	if(step==len+1){

		for(k=1;k<=m;k++)d[k]=0;

		for(j=1;j<=len;j++)

			for(k=1;k<=m;k++)

				d[k]+=a[b[j]][k];

		for(k=1;k<=m;k++)

			if(d[k]<x)return;

		cost=0;

		for(j=1;j<=len;j++)cost+=c[b[j]];

		sum=min(sum,cost);

		return ;

	}

	for(i=b[step-1]+1;i<=n;i++)

		b[step]=i,dfs(step+1);

}

int main(){

	int i,j;

	scanf("%d%d%d",&n,&m,&x);

	for(i=1;i<=n;i++)

	{

		scanf("%d",&c[i]);

		for(j=1;j<=m;j++)

			scanf("%d",&a[i][j]);

	}

	for(len=1;len<=n;len++)

		b[0]=0,dfs(1);

	if(sum==100000000)printf("-1\n");

	else printf("%d\n",sum);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cstring>



using namespace std;



struct node{

	int money;

	int a[15];

}book[15];

int b[15];



int main(){

	int n,m,x;

	cin>>n>>m>>x;

	for(int i=0;i<n;i++){

		cin>>book[i].money;

		for(int j=0;j<m;j++) cin>>book[i].a[j];

	}

	int ans=1e7;

	for(int i=0;i<(1<<n);i++){

		memset(b,0,sizeof b);

		int sum=0;

		for(int j=0;j<n;j++)

			if(i>>j&1){

				sum+=book[j].money;

				for(int k=0;k<m;k++) b[k]+=book[j].a[k];

			}

		bool flag=1;

		for(int j=0;j<m;j++) if(b[j]<x) flag=0;

		if(flag) ans=min(ans,sum);

	}

	if(ans==1e7) cout<<"-1";

	else cout<<ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.858636485629255x):
#include <cstdio>

#include <algorithm>

using namespace std;

int n,m,x;

int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;

void dfs(int step){

	int i,j,k;

	if(step==len+1){

		for(k=1;k<=m;k++)d[k]=0;

		for(j=1;j<=len;j++)

			for(k=1;k<=m;k++)

				d[k]+=a[b[j]][k];

		for(k=1;k<=m;k++)

			if(d[k]<x)return;

		cost=0;

		for(j=1;j<=len;j++)cost+=c[b[j]];

		sum=min(sum,cost);

		return ;

	}

	for(i=b[step-1]+1;i<=n;i++)

		b[step]=i,dfs(step+1);

}

int main(){

	int i,j;

	scanf("%d%d%d",&n,&m,&x);

	for(i=1;i<=n;i++)

	{

		scanf("%d",&c[i]);

		for(j=1;j<=m;j++)

			scanf("%d",&a[i][j]);

	}

	for(len=1;len<=n;len++)

		b[0]=0,dfs(1);

	if(sum==100000000)printf("-1\n");

	else printf("%d\n",sum);

	return 0;

}