stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



const int N = 110000;

const long long INF = 1LL << 60;



int L[N], R[N], C[N];

long long val[N];



vector<int> st[N], en[N];



set<pair<long long, int>> S;



int main() {

	

	ios::sync_with_stdio(0);

	cin.tie(0), cout.tie(0);

	

	int n, m; cin >> n >> m;

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

		cin >> L[i] >> R[i] >> C[i];

		st[L[i]].push_back(i);

		en[R[i]].push_back(i);

	}

	

	for (int i = 1; i <= n; i++) val[i] = INF;

	val[1] = 0;

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

		if (S.size()) val[i] = min(val[i], S.begin() -> first);

		for (auto it : st[i]) S.emplace(val[L[it]] + C[it], it);

		for (auto it : en[i]) S.erase(make_pair(val[L[it]] + C[it], it));

	}

	if (val[n] == INF) cout << "-1\n";

	else cout << val[n] << "\n";

	

	return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



const int N = 220000;



int L[N], R[N], id[N];

long long C[N], t[N];



void add(int u, long long w) {

	for (; u; u -= u & -u) t[u] = min(t[u], w);

}



long long get(int u) {

	long long ret = LLONG_MAX;

	for (; u < N; u += u & -u) ret = min(ret, t[u]);

	return ret;

}



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	int n, m; cin >> n >> m;

	for (int i = 0; i < m; i++) cin >> L[i] >> R[i] >> C[i];

	for (int i = 0; i < m; i++) id[i] = i;

	sort(id, id + m, [&](int u, int v) {

		if (L[u] != L[v]) return L[u] < L[v];

		return R[u] < R[v];

	});

	for (int i = 0; i < N; i++) t[i] = LLONG_MAX;

	add(1, 0);

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

		int u = id[i];

		int st = L[u], en = R[u]; long long w = C[u];

		long long now = get(st);

		if (now != LLONG_MAX) add(en, now + w);

	}

	long long ans = get(n);

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

	cout << ans << "\n";

	return 0;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;



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

const ll MOD = pow(10,9)+7;

const ll LLINF = pow(2,61)-1;

const int INF = pow(2,30)-1;





#define P pair<ll, ll>

const int N_MAX = pow(10,5)+10;

struct edge { ll to; ll cost; };

vector<edge> adj[N_MAX], radj[N_MAX];



ll d[N_MAX];

ll N, M, T;



void dijkstra(ll s) {

  priority_queue<P, vector<P>, greater<P>> q;

  fill_n(d, N, LLINF); d[s] = 0; q.push(P(0, s));

  while (!q.empty()) {

    P p = q.top(); q.pop();

    ll v = p.second;

    if (d[v] < p.first) continue;

    for (auto e: adj[v]) {

      if (d[e.to] > d[v]+e.cost) {

        d[e.to] = d[v]+e.cost;

        q.push(P(d[e.to], e.to));

      }

    }

  }

}



int main() {

  cin >> N >> M;

  rep(i,M) {

    int L, R, C; cin >> L >> R >> C; L--; R--;

    edge tmp = {R, C};

    adj[L].push_back(tmp);

  }

  rep(i,N-1) adj[i+1].push_back((edge){i, 0});

  dijkstra(0);

  ll result = (d[N-1]!=LLINF) ? d[N-1] : -1;

  // rep(i,N) cout << d[i] << " "; cout << endl;

  cout << result << endl;

  return 0;

}


// Optimized solution to the same problem (faster):
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

//





#define _USE_MATH_DEFINES

#include<math.h>



//#include<cmath>



#include<deque>

#include<queue>

#include<vector>

#include<algorithm>

#include<iostream>

#include<set>

#include<cmath>

#include<tuple>

#include<string>

#include<chrono>

#include<functional>

#include<iterator>

#include<random>

#include<unordered_set>

#include<array>

#include<map>

#include<iomanip>

#include<assert.h>

#include<bitset>

#include<stack>

#include<memory>







//#include "Ants.h"

using namespace std;

typedef long long ll;

#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

#define EPS (1e-7)

#define INF (1e9)

#define PI (acos(-1))

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

#define show(s) cout<<s<<endl

#define chmin(x,y) x=min(x,y)

#define chmax(x,y) x=max(x,y)



typedef pair < ll, ll> P;



const ll LLINF = pow(2, 61) - 1;

ll N, M;

struct edge {

	ll to, cost;

	

};



ll d[10000000];



vector<edge>G[100000];

void dijkstra(ll s) {

	priority_queue<P, vector<P>, greater<P>> q;

	fill_n(d, N, LLINF); d[s] = 0; q.push(P(0, s));

	while (!q.empty()) {

		P p = q.top(); q.pop();

		ll v = p.second;

		if (d[v] < p.first) continue;

		for (auto e : G[v]) {

			if (d[e.to] > d[v] + e.cost) {

				d[e.to] = d[v] + e.cost;

				q.push(P(d[e.to], e.to));

			}

		}

	}

}



int main() {

	cin >> N >> M;

	rep(i, M) {

		int L, R, C; cin >> L >> R >> C; L--; R--;

		edge tmp = { R, C };

		G[L].push_back(tmp);

	}

	rep(i, N - 1) G[i + 1].push_back((edge){i, 0});

	dijkstra(0);

	ll result = (d[N - 1] != LLINF) ? d[N - 1] : -1;

	// rep(i,N) cout << d[i] << " "; cout << endl;

	cout << result << endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <cmath>

#include <complex>

#include <iostream>



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



using namespace std;



typedef complex<double> P;



const double PI = 3.1415926535;

P pos[40];

int n, m;

int fst;



double memo[41][41];



inline double outp(const P &a, const P &b){

  return (conj(a)*b).imag();

}



double solve(int p, int rest){

  if(p == n) return 0.0;

  if(rest == 0) return 0.0;

  if(memo[p][rest] > -1.0)

    return memo[p][rest];

  double ret = 0.0;



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

    double tmp = 0.0;



    if(rest != m - 1){

      P p1 = pos[fst];

      P p2 = pos[p];

      P p3 = pos[i];

      tmp += std::abs(outp(p2 - p1, p3 - p1) / 2.0);

      // printf("tmp: %f\n", tmp);

    }



    ret = max(ret, tmp + solve(i, rest - 1));

  }



  // printf("%d %d %d: %f\n", fst, p, rest, ret);

  return memo[p][rest] = ret;

}



int main(){

  while(scanf("%d%d", &n, &m), n + m){

    REP(i,n){

      double ang;

      scanf("%lf", &ang);

      pos[i] = P(cos(2 * PI * ang), sin(2 * PI * ang));

      // cout << "pos[" << i << "]=" << pos[i] << endl;

    }



    double ans = 0.0;

    REP(i,n){

      REP(j,n) REP(k,m) memo[j][k] = -2.0;

      fst = i;

      ans = max(ans, solve(i, m - 1));

    }



    printf("%.6f\n", ans);

  }

  return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#include <complex>

#include <iostream>



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



using namespace std;



typedef complex<double> P;



const double PI = 3.1415926535;

P pos[40];

int n, m;

int fst;



double memo[41][41];



inline double outp(const P &a, const P &b){

  return (conj(a)*b).imag();

}



double solve(int p, int rest){

  if(p == n) return 0.0;

  if(rest > n - p) return 0.0;

  if(rest == 0) return 0.0;

  if(memo[p][rest] > -1.0)

    return memo[p][rest];

  double ret = 0.0;



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

    double tmp = 0.0;



    if(rest != m - 1){

      P p1 = pos[fst];

      P p2 = pos[p];

      P p3 = pos[i];

      tmp += std::abs(outp(p2 - p1, p3 - p1) / 2.0);

      // printf("tmp: %f\n", tmp);

    }



    ret = max(ret, tmp + solve(i, rest - 1));

  }



  // printf("%d %d %d: %f\n", fst, p, rest, ret);

  return memo[p][rest] = ret;

}



int main(){

  while(scanf("%d%d", &n, &m), n + m){

    REP(i,n){

      double ang;

      scanf("%lf", &ang);

      pos[i] = P(cos(2 * PI * ang), sin(2 * PI * ang));

      // cout << "pos[" << i << "]=" << pos[i] << endl;

    }



    double ans = 0.0;

    REP(i,n){

      REP(j,n) REP(k,m) memo[j][k] = -2.0;

      fst = i;

      ans = max(ans, solve(i, m - 1));

    }



    printf("%.6f\n", ans);

  }

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

ll A[14][14],C[14];

int main()

{

    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    ll n,m,x;

    memset(A,0,sizeof(A));

    memset(C,0,sizeof(C));

    cin>>n>>m>>x;

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

    {

        cin>>C[i];

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

        {

            cin>>A[i][j];

        }

    }

    ll Ans=10000007;

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

    {

        string s = bitset<12>(i).to_string();

        reverse(s.begin(),s.end());

        ll Cost=0,ul[14];

        memset(ul,0,sizeof(ul));

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

        {

            if(s[j]=='0')

                continue;

            Cost+=C[j];

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

            {

                ul[k]+=A[j][k];

            }

        }

        bool flag=true;

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

        {

            if(ul[j]<x)

                flag=false;

        }

        if(flag==true)

            Ans=min(Ans,Cost);

    }

    if(Ans==10000007)

        cout<<-1<<endl;

    else

        cout<<Ans<<endl;





    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

const int N = 109;

int n, m, x, c[N], a[N][N], p[N], ans = 0x3f3f3f3f;

void dfs(int s, int price) {

    if (s == n + 1) {

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

            if (p[i] < x)

                return;

        ans = min(ans, price);

        return;

    }

    dfs(s + 1, price);

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

        p[i] += a[s][i];

    dfs(s + 1, price + c[s]);

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

        p[i] -= a[s][i];

}

int main() {

    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);

    if (ans > 1e9)

        cout << -1;

    else

        cout << ans;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int n,m,x;

int c[22];

int a[22][22];

int ptr;

string s[4444];

int q[22];

void dfs(string cnt){

	if(cnt.size()==n){

		s[ptr++]=cnt;

		return ;

	}

	dfs(cnt+'1');

	dfs(cnt+'0');

}

int main()

{

	cin>>n>>m>>x;

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

		cin>>c[i];

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

			cin>>a[i][j];

	}

	dfs("0");

	dfs("1");

	int ans=1e9;

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

		int cur=0;

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

			q[j]=0;

		for(int j=0;j<s[i].size();j++)

			if(s[i][j]=='1'){

				cur+=c[j];

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

					q[k]+=a[j][k];

			}

		bool flag=true;

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

			if(q[j]<x)

				flag=false;

		if(flag==true)

			ans=min(ans,cur);

	}

	if(ans==1e9)

		cout<<-1<<endl;

	else

		cout<<ans<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

int x[22];

int a,b,c;

int y[22][22];

int ans=1e9;

int sum;

int check[22];

void dfs(int i)

{

	if(i>a){

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

			if(check[j]<c)

				return ;

		ans=min(ans,sum);

		return ;

	}

	dfs(i+1);

	sum+=x[i];

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

		check[j]+=y[i][j];

	dfs(i+1);

	sum-=x[i];

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

		check[j]-=y[i][j];

}

int main()

{

	cin>>a>>b>>c;

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

		cin>>x[i];

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

			cin>>y[i][j];

	}

	dfs(1);

	if(ans==1e9)

		cout<<-1<<endl;

	else

		cout<<ans<<endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>

#include<queue>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

ll inf = 1000000007;

int dx[4] = { 1,-1,0,0 };

int dy[4] = { 0,0,1,-1 };

vector<ll>to[200005];

ll c[15];

int main() {

	int n, m, x;

	cin >> n >> m >> x;

	vector<vector<ll>>a(n);

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

		cin >> c[i];

		a[i].resize(m);

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

			cin >> a[i][j];

		}

	}

	ll ans = inf;

	ll sum;

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

		vector<ll>t(m, 0);

		sum = 0;

		bool ok = true;

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

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

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

					t[k] += a[i][k];

				}

				sum += c[i];

			}

		}

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

			if (t[j] < x) {

				ok = false;

			}

		}

		if (ok) {

			ans = min(ans, sum);

		}

	}

	if (ans != inf) {

		cout << ans << endl;

	}

	else {

		cout << "-1" << endl;

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cmath>

#include<iostream>

#include<vector>

#include<algorithm>

#include<map>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

ll inf = 1000000007;

ll c[15];

int main() {

	ll n, m, x;

	cin >> n >> m >> x;

	vector<vector<ll>>a(n);

	

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

		cin >> c[i];

		a[i].resize(m);

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

			cin >> a[i][j];

		}

	}

	ll ans = inf;

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

		ll sum = 0;

		vector<ll>check(m, 0);

		bool ok = true;

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

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

				sum += c[i];

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

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

				}

			}

		}

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

			if (check[k] < x) {

				ok = false;

			}

		}

		if (ok) {

			ans = min(ans, sum);

		}



	}

	if (ans == inf) {

		cout << "-1" << endl;

	}

	else {

		cout << ans << endl;

	}

	return 0;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

using vi = vector<int>;

using vvi = vector<vector<int>>;

using vl = vector<ll>;

using vvl = vector<vector<ll>>;

using pi = pair<int, int>;

using pl = pair<ll, ll>;

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

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

#define _GLIBCXX_DEBUG

#define n_p(v) next_permutation(v.begin(),v.end())

#define print(a) cout<<(a)<<endl;

#define to_ll(b) stoll(b)

#define MOD 1000000007



int main(){

	int N,M,X; cin>>N>>M>>X;

	vector<int> mny(N);

	vvi power(N,vi(M));

	rep(i,0,N){

		int c;cin>>c;

		mny[i]=c;

		rep(j,0,M){

			int a; cin>>a;

			power.at(i).at(j)=a;

		}

	}

	ll ans=-1; 

	for (ll tmp=0;tmp<(1<<12);tmp++){

		bitset<12> s(tmp);

		vi v(M);

		ll cnt=0;

		rep(i,0,N){

			if(s.test(i)){

				cnt+=mny[i];

				rep(j,0,M){

					v[j]+=power.at(i).at(j);

				}

			}

		}

		sort(all(v));

		if(v[0]>=X && ans==-1){

			ans=cnt;

		}

		else if(v[0]>=X){

			ans = min(ans,cnt);

		}

	}

	cout<<ans;

	return 0;

					

		

	

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

using vi = vector<int>;

using vvi = vector<vector<int>>;

using vl = vector<ll>;

using vvl = vector<vector<ll>>;

using pi = pair<int, int>;

using pl = pair<ll, ll>;

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

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

#define _GLIBCXX_DEBUG

#define n_p(v) next_permutation(v.begin(),v.end())

#define print(a) cout<<(a)<<endl;

#define to_ll(b) stoll(b)

#define MOD 1000000007



int main(){

	int N,M,X; cin>>N>>M>>X;

	vector<int> mny(N);

	vvi power(N,vi(M));

	rep(i,0,N){

		int c;cin>>c;

		mny[i]=c;

		rep(j,0,M){

			int a; cin>>a;

			power.at(i).at(j)=a;

		}

	}

	ll ans=-1; 

	for (ll tmp=0;tmp<(1<<N);tmp++){

		bitset<12> s(tmp);

		vi v(M);

		ll cnt=0;

		rep(i,0,N){

			if(s.test(i)){

				cnt+=mny[i];

				rep(j,0,M){

					v[j]+=power.at(i).at(j);

				}

			}

		}

		sort(all(v));

		if(v[0]>=X && ans==-1){

			ans=cnt;

		}

		else if(v[0]>=X){

			ans = min(ans,cnt);

		}

	}

	cout<<ans;

	return 0;

					

		

	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1LL << 60;



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++) {

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

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

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

        }

    }



    int ans = 10000000;

    for (int tmp = 0; tmp < (1 << 12); tmp++) {

        bitset<12> s(tmp);

        int sum = 0;

        vector<int> Alg(M);

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

            if (s.test(i)) {

                sum += C[i];

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

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

                }

            }

        }



        bool flag = true;

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

            if (Alg[i] < X) flag = false;

        }

        if (flag) {

            chmin(ans, sum);

        }

    }



    if (ans == 10000000) {

        cout << -1 << endl;

    } else {

        cout << ans << endl;

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1LL << 60;



int N, M, X;

vector<int> C;

vector<vector<int>> A;



bool ok(vector<int> &ALG) {

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

        if (ALG[i] < X) return false;

    }



    return true;

}



int dfs(vector<int> &B) {

    if (B.size() == N) {

        vector<int> ALG(M);

        int cost = 0;

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

            if (B[i]) {

                cost += C[i];

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

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

                }

            }

        }



        if (ok(ALG)) {

            return cost;

        }



        return 1000000000;

    }



    int ans = 1000000000;

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

        B.push_back(i);

        chmin(ans, dfs(B));

        B.pop_back();

    }



    return ans;

}



int main() {

    cin >> N >> M >> X;

    C.resize(N);

    A.resize(N, vector<int>(M));

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

        cin >> C[i];

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

            cin >> A[i][j];

        }

    }

    vector<int> B;



    int ans = dfs(B);



    if (ans == 1000000000) {

        cout << -1 << endl;

    } else {

        cout << ans << endl;

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string>

#include<vector>

#include<cmath>

#include<algorithm>

#include <sstream>

#include <iomanip>



using namespace std;



int64_t binary(int64_t bina) {

	int64_t ans = 0;

	for (int64_t i = 0; bina > 0; i++)

	{

		ans = ans + (bina % 2)*pow(10, i);

		bina = bina / 2;

	}

	return ans;

}



int main() {

	

	int64_t N, M, X;



	vector<int64_t> C;



	cin >> N >> M >> X;

	int64_t A[12][12];





	





	for (int64_t i = 0; i < N; i++) {

		int64_t c;

		cin >> c;

		C.push_back(c);



		for (int64_t j = 0; j < M; j++) {

			

			cin >> A[i][j];

			

		

		}





	}

	



	



	string str;

	string one="1";

	int64_t min_value = 9223372036854775807;

	

	for (int64_t i = 0; i < pow(2, N); i++) {

	

		ostringstream ss;

		ss << setfill('0') << setw(N) << binary(i);

		str = ss.str();

		

		vector<int64_t> ability(M);

		int64_t value=0;

		

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

		

			if (str[j] == one[0]) {

				

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

					ability[k] += A[j][k];

					

				}

				value += C[j];

				

			}





		}

		int64_t count = 0;

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

			if (ability[k] >= X)count++;

			

		}

		



		if (count == M) {

			if (min_value > value) {

				min_value = value;

			}





		}

	



	}



	if (min_value == 9223372036854775807) {

		cout << -1;

		return 0;

	}

	else {

		cout << min_value;

		return 0;

	}



	





}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<string>

#include<vector>

#include<cmath>

#include<algorithm>

#include <sstream>

#include <iomanip>



using namespace std;



int64_t binary(int64_t bina) {

	int64_t ans = 0;

	for (int64_t i = 0; bina > 0; i++)

	{

		ans = ans + (bina % 2)*pow(10, i);

		bina = bina / 2;

	}

	return ans;

}



int main() {

	

	int64_t N, M, X;



	vector<int64_t> C;



	cin >> N >> M >> X;

	int64_t A[12][12];





	





	for (int64_t i = 0; i < N; i++) {

		int64_t c;

		cin >> c;

		C.push_back(c);



		for (int64_t j = 0; j < M; j++) {

			

			cin >> A[i][j];

			

		

		}





	}

	



	



	string str;

	string one="1";

	int64_t min_value = 9223372036854775807;

	

	for (int64_t i = 0; i < pow(2, N); i++) {

	

	

		

		vector<int64_t> ability(M);

		int64_t value=0;

		

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

		

			if (i&1<<j) {

				

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

					ability[k] += A[j][k];

					

				}

				value += C[j];

				

			}





		}

		int64_t count = 0;

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

			if (ability[k] >= X)count++;

			

		}

		



		if (count == M) {

			if (min_value > value) {

				min_value = value;

			}





		}

	



	}



	if (min_value == 9223372036854775807) {

		cout << -1;

		return 0;

	}

	else {

		cout << min_value;

		return 0;

	}



	





}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL_DEBUG

  #include "LOCAL_DEBUG.hpp"

#endif

#define int long long

const int INF = 1LL << 60;



signed 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[i];

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

      cin >> a[i][j];

    }

  }



  int ans = INF;

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

    vector<int> v(m, 0);

    int cost = 0;

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

      if(i >> j & 1){

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

          v[k] += a[j][k];

        }

        cost += c[j];

      }

    }

    bool judge = true;

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

      if(v[j] < x) judge = false;

    }

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

  }

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

  cout << ans << endl;



  return 0;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: