Problem:
 Score : 300 points    Problem Takahashi, who is a novice in competitive programming, wants to learn M algorithms.
Initially, his understanding level of each of the M algorithms is 0 .  Takahashi is visiting a bookstore, where he finds N books on algorithms.
The i -th book ( 1\leq i\leq N ) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j -th algorithm will increase by A_{i,j} for each j ( 1\leq j\leq M ).
There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.      Constraints  All values in input are integers.  1\leq N, M\leq 12  1\leq X\leq 10^5  1\leq C_i \leq 10^5  0\leq A_{i, j} \leq 10^5         Input Input is given from Standard Input in the following format:  N  M  X  C_1  A_{1,1}  A_{1,2}  \cdots  A_{1,M}  C_2  A_{2,1}  A_{2,2}  \cdots  A_{2,M}  \vdots  C_N  A_{N,1}  A_{N,2}  \cdots  A_{N,M}       Output If the objective is not achievable, print -1 ; otherwise, print the minimum amount of money needed to achieve it.        Sample Input 1 3 3 10
60 2 2 4
70 8 7 9
50 2 3 9      Sample Output 1 120  Buying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.       Sample Input 2 3 3 10
100 3 1 4
100 1 5 9
100 2 6 5      Sample Output 2 -1  Buying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.       Sample Input 3 8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2      Sample Output 3 1067

Solution (Python):
N,M,X=map(int, input().split())


C=[]
A=[]
for i in range(N):
    I=list(map(int, input().split()))
    C.append(I[0])
    A.append(I[1:])


ans="-1"
for b in range(2**N):
    L=[0]*M
    cost=0
    for i in range(N):
        if b>>i&1==0:
            cost+=C[i]
            l=A[i]
            for j,a in enumerate(l):
                L[j]+=a
    if min(L)>=X:
        if ans=="-1":
            ans=cost
        else:
            ans=min(ans, cost)
print(ans)

Solution (Python):
import numpy as np
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m,x=MI()
    caa=LLI(n)
    caa=np.array(caa,dtype="i8")
    ans=10**9
    for bit in range(1<<n):
        cost = 0
        aa = np.zeros(m, dtype="i8")
        for i in range(n):
            if bit>>i&1:
                cost+=caa[i][0]
                aa+=caa[i][1:]
        if np.sum(aa>=x)==m and cost<ans:ans=cost

    if ans==10**9:print(-1)
    else:print(ans)

main()

Solution (Python):
N, M, X = map(int, input().split())
Cost = []
A = []
for _ in range(N):
    temp = list(map(int, input().split()))
    Cost.append(temp[0])
    A.append(temp[1:])
mincos = float('inf')

flag = False
for i in range(1, 2**N):
    cost = 0
    Learn = [0] * M
    for j in range(N):
        if (i >> j) & 1 == 1:
            cost += Cost[j]
            for k in range(M):
                Learn[k] += A[j][k]
    fla = True
    for a in range(M):
        if Learn[a] < X:
            fla = False
            break
    if fla:
        flag = True
        mincos = min(mincos, cost)

if flag:
    print(mincos)
else:
    print(-1)

Solution (Python):
import numpy as np

N, M, X = map(int,input().split())
CA = []
for _ in range(N):
    CA.append(list(map(int,input().split())))

MIN = 10 ** 7
for i in range(2**N):
    cost = 0
    result = np.array([0] * M)
    for j in range(N):
        if ((i>>j)&1):
            cost += CA[j][0]
            result += CA[j][1:]

    if all(result >=X):
        MIN = min(cost,MIN)
if MIN == 10**7:
    print(-1)
else:
    print(MIN)

Solution (Python):
N,M,X = map(int,input().split())
B = []
for i in range(N):
	a = list(map(int,input().split()))
	B.append(a)

def int2bit(n, l):
	ret = [0 for i in range(l)]
	i = 0
	while n > 0:
		ret[i] = n % 2
		i += 1
		n = n // 2
	return ret

MAX = 10**7
ans = MAX
for i in range(1, 2**N):
	b = int2bit(i, N)
	rikai = [0 for j in range(M)]
	for p in range(N):
		if b[p] == 1:
			for j in range(M):
				rikai[j] += B[p][j+1]
	if len([r for r in rikai if r < X]) == 0:
		ans = min(ans, sum([B[p][0] for p in range(N) if b[p] == 1]))
if ans == MAX:
	print(-1)
else:
	print(ans)

Solution (Python):
from itertools import product
inpl = lambda: list(map(int,input().split()))
N, M, X = inpl()
A = []
C = []
for _ in range(N):
    H = inpl()
    C.append(H[0])
    A.append(H[1:])

ans = -1
for s in product(range(2), repeat=N):
    U = [ sum( A[n][m] for n in range(N) if s[n]) for m in range(M)]
    for m in range(M):
        if U[m] < X:
            break
    else:
        P = sum(C[n] for n in range(N) if s[n])
        if ans < 0 or P < ans:
            ans = P
print(ans)

Solution (Python):
def main():
    N, M, X = (int(i) for i in input().split())
    A = []
    C = []
    for _ in range(N):
        c, *a = (int(i) for i in input().split())
        A.append(a)
        C.append(c)
    ans = 10**9
    for bit in range(1 << N):
        cur_m = 0
        cur_ri = [0]*M  
        for i in range(N):
            if bit & (1 << i):
                cur_m += C[i]
                for j, a in enumerate(A[i]):
                    cur_ri[j] += a
        if all(ri >= X for ri in cur_ri):
            ans = min(ans, cur_m)
    print(ans if ans != 10**9 else -1)


if __name__ == '__main__':
    main()

Solution (Python):
n,m,x1= map(int, input().split())

c= [list(map(int, input().split())) for i in range(n)]

ans=pow(10,9)
for i in range(2**n):
    cnt=0
    x=[0]*m
    for j in range(n):
        if (i>>j)&1:
            cnt+=c[j][0]
            for k in range(1,m+1):
                x[k-1]+=c[j][k]
    if min(x)>=x1:
        ans=min(cnt,ans)

if ans==pow(10,9):
    print(-1)

else:
    print(ans)

Solution (Python):
n,m,x=map(int,input().split())
a=[]
cost=[]
for i in range(n):
    p=list(map(int,input().split()))
    cost.append(p[0])
    a.append(p[1:])
ans=-1
for i in range(pow(2,n)):
    temp=0
    lev=[0 for i in range(m)]
    for j in range(n):
        if i&(pow(2,j)):
            temp += cost[j]
            for k in range(m):
                lev[k] += a[j][k]
    if min(lev)>=x:
        if ans==-1:
            ans=temp
        else:
            ans=min(ans,temp)
print(ans)

Solution (Python):
N, M, X = map(int, input().split())
Cs = []
Ass = []
for _ in range(N):
    c, *a = list(map(int, input().split()))
    Cs.append(c)
    Ass.append(a)

INF = float('inf')
ans = INF
for i in range(2 ** N):
    score = [0] * M
    d = 1
    cost = 0
    for j in range(N):
        if i & d:
            cost += Cs[j]
            for k, s in enumerate(Ass[j]):
                score[k] += s
        d <<= 1
    for s in score:
        if s < X:
            break
    else:
        ans = ans if ans < cost else cost

print(-1 if ans == INF else ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n, m, x = MAP()
arr = [LIST() for _ in range(n)]
c = [arr[i][0] for i in range(n)]
a = [arr[i][1:] for i in range(n)]

ans = inf
for i in range(1, n + 1):
    cmb = list(combinations(range(n), i))
    for lst in cmb:
        tmp = [0 for _ in range(m)]
        cst = 0
        for idx in lst:
            cst += c[idx]
            for j in range(m):
                tmp[j] += a[idx][j]
        flag = True
        for j in range(m):
            if tmp[j] < x:
                flag = False
        if flag:
            ans = min(ans, cst)
if ans == inf:
    print(-1)
else:
    print(ans)

Solution (Python):
N,M,X = map(int,input().split())
data = [list(map(int,input().split())) for i in range(N)]

A = []
for i in range(2**N):
    B = [0]*M
    price = 0
    for j in range(N):
        if i >> j & 1:
            price += data[j][0]
            for k in range(M):
                B[k] += data[j][k+1]
    for j in range(M):
        if B[j] < X:
            break
    else:
        A.append(price)
if len(A) == 0:
    print(-1)
else:
    print(min(A))

Solution (Python):

import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))


def main():
    min_money = float('inf')

    N,M,X = MAP()
    A = [LI() for _ in range(N)]

    from itertools import product

    for bit in product([0,1],repeat=N):
        ability = [0]*M
        money = 0

        for i in range(N):
            if bit[i] == 1:
                money += A[i][0]
                
                for j in range(M):
                    ability[j] += A[i][j+1]

        for aa in ability:
            if aa >= X:
                continue
            else:
                break
        else:
            min_money = min(min_money,money)
         
    if min_money == float('inf'):
        print(-1)
    else:
        print(min_money)
    
    return 




if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**6) 
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque 


from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush




def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def main():
    mod = 10**9+7
    

    
    N, M, X = map(int, input().split())
    
    
    S = tuple(tuple(map(int, input().split())) for i in range(N)) 
    ans=10**7
    for i in range(2**12):
        count=0
        und=[0]*M
        for n in range(N):
            if i >>n &1:
                s=S[n]
                count+=s[0]
                for j in range(M):
                    und[j]+=s[j+1]
        flag=True
        for j in range(M):
            if und[j]<X: 
                flag=False
                break
        if flag:
            ans=min(ans,count)
            
    if ans ==10**7:
        print(-1)
    else:
        print(ans)




if __name__ == "__main__":
    main()

Solution (Python):
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter

from functools import lru_cache

sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

n, m, x = inpl()
data = [inpl() for _ in range(n)]
ans=INF
for t in itertools.product([0, 1], repeat=n):
    tmp = 0
    a=[0]*m
    for idx, use in enumerate(t):
        if not use:
            continue
        else:
            tmp+=data[idx][0]
        for i in range(m):
            a[i] += data[idx][i + 1]
    FLAG=True
    for i in range(m):
        if a[i] < x:
            FLAG = False
            break
    if FLAG:
        ans=min(ans,tmp)
if ans == INF:
    print(-1)
else:
    print(ans)

Solution (Python):
import sys, os

def f():
    args = list(map(int,input().split()))
    if len(args) > 1:
        return args
    return args[0]

if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,m,x = f()
    data = []
    for i in range(n):
        data.append(f())
    
    ans = 10**8
    for i in range(1<<n):
        cursummoney = 0
        curleve = [0] * m
        for j in range(n):
            if i&(1<<j):
                cursummoney += data[j][0]
                for k in range(m):
                    curleve[k] += data[j][1+k]
        ok = 1
        for j in range(m):
            if curleve[j] < x:
                ok = 0
        
        if ok:
            ans = min(ans, cursummoney)
    
    if  ans != 10**8:
        print(ans)
    else:
        print(-1)
    



solve()

Solution (Python):
N, M, X = map(int, input().split())
books = [input().split() for i in range(N)]
min_costs = float('inf')

for i in range(2 ** N):
    tmp_costs = 0
    skills = [0 for i in range(M)]
    for j in range(N): 
        if ((i >> j) & 1):
            tmp_costs += int(books[j][0])
            for k in range(M):
                skills[k] += int(books[j][k+1])
    
    if len([i for i in skills if i >= X]) == M:
        min_costs = min(min_costs, tmp_costs)

if min_costs == float('inf'):
    print(-1)        
else:
    print(min_costs)

Solution (Python):
N, M, X = map(int, input().split())
RB = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')

for x in range(2**N):
    indexes = [n for n in range(N) if (x >> n) % 2]
    if X <= min([sum([RB[i][j] for i in indexes]) for j in range(1, M+1)]):
        temp = sum([RB[i][0] for i in indexes])
        if ans > temp:
            ans = temp

if ans == float('inf'):
    print(-1)
else:
    print(ans)

Solution (Python):
import itertools
n,m,x=map(int,input().split())
k=[list(map(int,input().split())) for i in [0]*n]
l=12*10**5+1
a=list(range(n))
for i in range(1,n+1):
    for v in itertools.combinations(a,i):
        s=0
        p=[0]*m
        for j in v:
            q=k[j]
            s+=q[0]
            for b in range(m):
                p[b]+=q[b+1]
        t=1
        for j in p:
            if j<x:
                t=0
        if t:
            l=min([s,l])
print(l) if l<12*10**5+1 else print(-1)

Solution (Python):



def main():
    
    N,M,X = map(int,input().split())
    C = []
    A = []
    for i in range(N):
        l = list(map(int,input().split()))
        C.append(l[0])
        A.append(l[1:])
    INF = 10**10
    minCost = INF
    for b in range(1<<N):
        cost = 0
        costs = [0] * M
        for j in range(N):
            if b & 1 > 0:
                for k in range(M):
                    costs[k] += A[j][k]
                cost += C[j]
            b= b>>1
        if min(costs) >= X:
            minCost = min(minCost,cost)
    if minCost == INF:
        print(-1)
    else:
        print(minCost)


    pass

if __name__ == '__main__':
    main()

Solution (Python):
from itertools import combinations

N, M, X = map(int,input().split())

C, A = [], []
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

INF = 10**10
answer = INF
L = list(range(N))
for n in range(1,N+1):
    for comb in combinations(L, n):
        cost = 0
        S = [0]*M
        for i in comb:
            cost += C[i]
            for m in range(M):
                S[m] += A[i][m]
        if all(s >= X for s in S):
            answer = min(answer, cost)

if answer == INF:
    print(-1)
else:
    print(answer)

Solution (Python):
N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    CA = list(map(int, input().split()))
    C.append(CA[0])
    A.append(CA[1:])

INF = 10**10
ans = INF
for x in range(1<<N):
    cost=0
    R=[0]*M
    for i in range(N):
        if (x>>i)&1: continue
        cost+=C[i]
        for m,a in enumerate(A[i]):
            R[m]+=a

    if min(R)>=X:
        ans=min(ans,cost)

print(-1 if ans==INF else ans)

Solution (Python):
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

n,m,x = l_in()

MAX = 10000000
res = MAX


C = []
A = []
for _ in range(n):
    tmp = l_in()
    c = tmp[0]
    a = tmp[1:]
    C.append(c)
    A.append(a)

stack = []

def evaluate():
    R = [0]*m
    c = 0
    for i, t in enumerate(stack):
        if t == 1:
            c += C[i]
            for j, b in enumerate(A[i]):
                R[j] += b

    if all(r >= x for r in R):
        return c
    else:
        return MAX
            

def do(i):
    tmp = MAX
    for t in [0,1]:        
        stack.append(t)
        if i == n-1:
            tmp = min(tmp, evaluate())
        else:
            tmp = min(tmp, do(i+1))
        stack.pop()
    return tmp

res = do(0)
    
if res == MAX:
    print(-1)
else:
    print(res)

Solution (Python):

def main():
    N, M, X = map(int, input().split())
    A = [[] for _ in range(N)]
    C = []
    for i in range(N):
        x = input().split()
        C.append(int(x[0]))
        A[i] = list(map(int, x[1:]))
    mn = 1e12 
    for i in range(1<<N):
        K = [0 for _ in range(M)]
        c = 0
        for j in range(N):
            if i>>j & 1:
                K = [x+y for (x, y) in zip(K, A[j])]
                c += C[j]
        if all([k >= X for k in K]):
            mn = min(mn, c)
    if mn > 1e10:
        print("-1")
    else:
        print(mn)

if __name__ == '__main__':
    main()

Solution (Python):
from itertools import product
import numpy as np

n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
ca = np.array(ca)

ans = 10**7
for buy in product(range(2),repeat = n):
    
    buy = np.array(buy)
    judge = (np.dot(buy,ca[:,1:]) >= x).all()
    if judge:
        ans = min(ans, np.dot(ca[:,0],buy))
    
if ans == 10**7: ans = -1
print(ans)

Solution (Python):
n, m, x =  map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = float("INF")
for i in range(2**n):
    d = [(i >> j) & 1 for j in range(n)]
    res = [0] * m
    ans_ = 0
    flag = True
    for i in range(n):
        if d[i]:
            ans_ += ca[i][0] 
            for j in range(1, m+1):
                res[j-1] += ca[i][j]
    for k in res:
        if k < x:
            flag = False
            break
    if flag: ans = min(ans, ans_)
if ans == float("INF"): print(-1)
else: print(ans)

Solution (Python):



def main():
    N, M, X = map(int, input().split())
    C = [None] * N
    A = [None] * N

    for i in range(N):
        line = list(map(int, input().split()))
        C[i] = line[0]
        A[i] = line[1:]

    min_moneys = []

    def rec(i, scores, money, X):
        if i == N:
            if all([score >= X for score in scores]):
                min_moneys.append(money)
            else:
                return None

        if all([score >= X for score in scores]):
            min_moneys.append(money)
            return None

        rec(i+1, scores, money, X)
        rec(i+1, [scores[j]+A[i][j] for j in range(M)], money+C[i], X)

    rec(0, [0] * M, 0, X)
    
    if len(min_moneys) == 0:
        return -1

    return min(min_moneys)



print(main())

Solution (Python):
N, M, X = map(int, input().split())
costs = []
incs = []
for _ in range(N):
    C, *inc = map(int, input().split())
    costs.append(C)
    incs.append(inc)
ans = 1e100
for i in range(1 << N):
    tot = 0
    skills = [0] * M
    for j in range(N):
        if (i & (1 << j)) == 0:
            continue
        tot += costs[j]
        for k in range(M):
            skills[k] += incs[j][k]
    if min(skills) >= X:
        ans = min(ans, tot)
if ans == 1e100:
    print(-1)
else:
    print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, m, x = LI()
    C = []
    A = [[] for _ in range(n)]
    money = inf
    for i in range(n):
        inp = LI()
        C.append(inp[0])
        A[i] = inp[1:]
    for i in range(1 << n):
        rikai = [0] * m
        flag = True
        kingaku = 0
        for j in range(n):
            if (i >> j) & 1 == 1:
                for k in range(m):
                    rikai[k] += A[j][k]
                kingaku += C[j]
        for r in rikai:
            if r < x:
                flag = False
        if flag:
            money = min(money, kingaku)
    if money != inf:
        print(money)
    else:
        print("-1")
main()

Solution (Python):

import collections


def solve(n, m, x, bookPrices, bookKnowledge):
    def go(i, achievedKnowledge):
        allHigherThanX = True

        for j in range(m):
            if achievedKnowledge[j] < x:
                allHigherThanX = False
                break

        if allHigherThanX:
            return 0

        if i >= n:
            return float("inf")

        newKnowledge = [achievedKnowledge[j] + bookKnowledge[i][j]
                        for j in range(m)]
        ans1 = bookPrices[i]

        return min(ans1 + go(i+1, newKnowledge), go(i+1, achievedKnowledge))

    ans = go(0, [0 for _ in range(m)])

    return -1 if ans == float("inf") else ans


[n, m, x] = list(map(int, input().strip().split()))

bookPrices = []
bookKnowledge = []

for i in range(n):
    arr = list(map(int, input().strip().split()))
    bookPrices.append(arr[0])
    bookKnowledge.append(arr[1:])


print(solve(n, m, x, bookPrices, bookKnowledge))

Solution (Python):

n,m,X=map(int,input().split())
C=[]
A=[]

for i in range(n):
    x=list(map(int,input().split()))
    C.append(x[0])
    A.append(x[1:])

ans = 10**9
for x in range(2**n):
    v=[0 for _ in range(m)]
    p=x
    c=0
    for i in range(n):
        if p%2==1:
            c+=C[i]
            for j in range(m):
                v[j] += A[i][j]
        p//=2
    f=True
    for j in range(m):
        if v[j]<X:
            f = False
            break
    if f:
        ans = min(ans, c)

if ans==10**9:
    print("-1")
else:
    print(ans)

Solution (Python):
N,M,X = list(map(int,input().split()))
books = [list(map(int,input().split())) for i in range(N)]

ans = float('inf')
for i in range(2**N):
    rikai = [0]*M
    onedan = 0
    for j in range(N):
        if (i>>j) & 1:
            onedan += books[j][0]
            for k in range(1,M+1):
                rikai[k-1] += books[j][k]
    for r in rikai:
        if r < X:
            break
    else:
        ans = min(ans,onedan)

if ans == float('inf'):
    print(-1)
else:
    print(ans)

Solution (Python):
n,m,x = map(int, input().split())
ca=[list(map(int,input().split())) for i in range(n)]

ans=10**20
from itertools import *
for tmp in list(product([True,False], repeat=n)):
    cost=0
    algo = [0] * m
    for i in range(n):
        if tmp[i]:
            cost+=ca[i][0]
            for j in range(m):
                algo[j] += ca[i][j+1]

    ok=True
    for i in range(m):
        if algo[i] < x:
            ok=False
    if ok:
        ans=min(ans,cost)

if ans==10**20:
    print(-1)
else:
    print(ans)

Solution (Python):
n, m, x = map(int, input().split())
lis = []
for i in range(n):
    lis.append(list(map(int, input().split())))
r = []    
for i in range(2**n+1):
    num = i
    a = [0 for _ in range(m)]
    p = 0
    for j in range(n):
        if num%2==1:
            p += lis[j][0]
            for s in range(m):
                a[s] += lis[j][s+1]
        num >>= 1
    if all(i>=x for i in a):
        r.append(p)
if len(r)==0:
    print(-1)
else:
    print(min(r))

Solution (Python):
N, M, X = map(int, input().split())
A = []
INF = 1e18
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
ans = INF
for S in range((1<<N)):
    cost = 0
    unst = [0 for i in range(M)]
    for i in range(N):
        if S & (1<<i):
            cost += A[i][0]
            for j in range(M):
                unst[j] += A[i][j+1]
    flag = 1
    for i in range(M):
        if unst[i] < X:
            flag = 0
            break
    if flag:
        if ans > cost:
            ans = cost
if ans == INF:
    print(-1)
else:
    print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")











N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for _ in range(N)]
MIN = 10**7
for i in range(2**N):
    ler = [0]*M
    money = 0
    bitlist = deque()
    for j in range(N):
        if ((i >> j) & 1): 
            bitlist.appendleft(1)
        else:
          	bitlist.appendleft(0)
    bitlist = list(bitlist)
    for k in range(N):
        if bitlist[k] == 1:
            money += CA[k][0]
            for l in range(1,M+1):
                ll = CA[k][l]
                ler[l-1] += ll
    judge = 0
    for ju in range(M):
        if ler[ju] < X:
            judge = 1
            break
    if judge == 0:
        MIN = min(MIN,money)
if MIN == 10**7:
    print(-1)
else:
    print(MIN)

Solution (Python):
n,m,x = list(map(int,input().split()))

l = [list(map(int,input().split())) for i in range(n)]

ans=10**9
for i in range(2**n):
    s = str(bin(i))
    s = s[2:]
    s = "0"*(n-len(s))+s

    flag=True
    tmp=0
    p = [0]*m
    for j in range(n):
        if s[j]=="0":
            continue
        tmp+=l[j][0]
        for k in range(m):
            p[k]+=l[j][k+1]
    for j in p:
        if j<x:
            flag = False
            break
    if flag:
        ans = min(tmp,ans)

if ans==10**9:
    print(-1)
else:
    print(ans)

Solution (Python):
import itertools


n, m, x = map(int, input().split())
book_costs = list()
book_skills = list()
for i in range(n):
    line = list(map(int, input().split()))
    book_cost = line[0]
    book_skill = line[1:]
    book_costs.append(book_cost)
    book_skills.append(book_skill)
    

ans = 12 * 101001
for flags in itertools.product(*[[True, False]] * n):
    cost = 0
    skill = [0 for i in range(m)]
    for i, flag in enumerate(flags):
        if flag:
            cost += book_costs[i]
            for j, skl in enumerate(book_skills[i]):
                skill[j] += skl
    
    if min(skill) >= x:
        ans = min(ans, cost)

if ans == 12 * 101001:
    print(-1)
else:
    print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, m, x = Is()
CA = LIR(n)

ans = INF
for bit in range(1<<n):
    B = [0]*m
    money = 0
    for i in range(n):
       if bit & (1<<i):
           money += CA[i][0]
           for j in range(m):
               B[j] += CA[i][j+1]
    for j in range(m):
        if B[j] < x:
            break
    else:
        ans = min(ans, money)

if ans == INF:
    print(-1)
else:
    print(ans)

Solution (Python):
from itertools import combinations
def main():
    N, M, X = map(int, input().split())
    l = []
    for _ in range(N):
        A = list(map(int, input().split()))
        l.append(A)
    m = pow(10, 7)
    for i in range(1, N+1):
        for j in combinations([k for k in range(N)], i):
            ll = [0] * (M+1)
            for k in j:
                for w in range(M+1):
                    ll[w] += l[k][w]
            if min(ll[1:]) >= X:
                m = min(m, ll[0])
    if m >= pow(10, 7):
        return -1
    return m

print(main())

Solution (Python):
N, M, X = map(int, input().split())

L = []
for _ in range(N):
    L.append(list(map(int, input().split())))

a = 10000000000
for v in range(2 ** N):
    tv, tk = 0, [0 for _ in range(M)]
    for i in range(N):
        if v & (1 << i) != 0:
            tv += L[i][0]
            for p in range(M):
                tk[p] += L[i][p + 1]

    f = True
    for p in range(M):
        if tk[p] < X:
            f = False
            break

    if f:
        a = min(a, tv)

if a == 10000000000:
    print(-1)
else:
    print(a)

Solution (Python):
from itertools import product
import numpy as np

n, m, x = map(int, input().split())
cost = []
aaa = []

for _ in range(n):
    c, *a = map(int, input().split())
    cost.append(c)
    aaa.append(a)

cost = np.array(cost, dtype=np.int64)
aaa = np.array(aaa, dtype=np.int64)

ans = 10 ** 18
for books in product([True, False], repeat=n):
    books = list(books)
    if (aaa[books].sum(axis=0) >= x).all():
        ans = min(ans, cost[books].sum())
if ans == 10 ** 18:
    print(-1)
else:
    print(ans)

Solution (Python):
n,m,x=map(int, input().split())
C = []
A=[]
for i in range(n):
    tmp=list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

cost=10**10
for i in range(2**n):
    rikai=[0]*m
    tmp=0
    for j in range(n):
        if (i>>j)%2==1:
            tmp+=C[j]
            rikai=[rikai[k]+A[j][k] for k in range(m)]
    if all([k>=x for k in rikai]):
        cost=min(cost, tmp)
        
if cost!=10**10:
    print(cost)
else:
    print(-1)

Solution (Python):
N, M, X = [int(i) for i in input().split()]
C = []
B = []
for i in range(N):
    c, *a = [int(i) for i in input().split()]
    C.append(c)
    B.append(a)
minv = 10**18
for bit in range(1<<N):
    c = 0
    u = [0]*M
    for i in range(N):
        if(1 & bit >> i):
            c += C[i]
            for j in range(M):
                u[j] += B[i][j]

    if all([u[i] >= X for i in range(M)]):
        minv = min(minv, c)

if minv == 10**18:
    print(-1)
else:
    print(minv)