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):
import itertools
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
sum=[0]*m
for i in range(n):
  for j in range(1,m+1):
    sum[j-1]+=l[i][j]
for ss in sum:
  if ss<x:
    print(-1)
    exit()
list=[]
for p in itertools.product([1,0],repeat=n):
  cnt=[0]*m
  ans=0
  for i in range(n):
    if p[i]==1:
      ans+=l[i][0]
      for j in range(1,m+1):
        cnt[j-1]+=l[i][j]
  if all(cc>=x for cc in cnt):
    list.append(ans)
print(min(list))

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:])

BASE = 1000000000000000
ans = BASE
def dfs(idx, num_list):
    global ans
    global c
    global a
    if idx == n:
        tmp_c_ans = 0
        tmp_a_ans = [0 for i in range(m)]
        for c_idx, c_include in enumerate(num_list):
            if c_include == 1:
                tmp_c_ans += c[c_idx]
                for a_idx, a_score in enumerate(a[c_idx]):
                    tmp_a_ans[a_idx] += a_score
        if all([t >= x for t in tmp_a_ans]):
            ans = min(ans, tmp_c_ans)
    else:
        dfs(idx + 1, num_list + [1])
        dfs(idx + 1, num_list + [0])

dfs(0, [])

if ans == BASE:
    ans = -1
print(ans)

Solution (Python):
import itertools

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

MAX_COST = 1e5*12+1
min_cost = MAX_COST
selector = [i for i in range(N)]
for n in range(1, len(selector)+1):
	for conb in itertools.combinations(selector,n):
		cost = 0
		rikai = [0 for _ in range(M)]
		for sel in conb:
			cost += books[sel][0]
			for i in range(M): rikai[i] += books[sel][i+1]
		if all(a >= X for a in rikai):
			if cost < min_cost: min_cost = cost

if min_cost != MAX_COST:
	print(min_cost)
else:
	print(-1)

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

@lru_cache(None)
def recur(temp, index=0, cost=0):
    if index == n:
        for j in range(m):
            if temp[j] < x:
                return inf
        return cost
    answer = inf
    answer = min(answer, recur(temp, index+1, cost))
    temp = list(temp)
    for j in range(m):
        temp[j] += mat[index][j+1]
    cost += mat[index][0]
    answer = min(answer, recur(tuple(temp), index+1, cost))
    return answer


n, m, x = sp()
mat = []
for i in range(n):
    mat.append(l())
res = recur(tuple([0]*m))
if res == inf:
    out(-1)
    exit()
out(res)

Solution (Python):
n,m,x = map(int,input().split())
import copy
ans1 = 10**10
g = []
def v(a,b):
    for i in range(len(a)):
        a[i] += b[i]
    return a
b = [0 for i in range(n)]
for i in range(n):
    a = list(map(int,input().split()))
    g.append(a)
for i in range(len(g)):
    b[i] = g[i][0]
    g[i].pop(0)
for i in range(2**n):
    ans = 0
    ni = [0 for s in range(m)]
    u = copy.deepcopy(i)
    for j in range(n):
        if u &1 == 1:
            ni = v(ni,g[j])
            ans += b[j]
        u = u >> 1
    if min(ni) >= x:
        ans1 = min(ans1,ans)
if ans1 == 10**10:
    print(-1)
else:
    print(ans1)

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

def rec(r,progress,result):
    if r == N:
        result.append(progress)
        progress = progress + [grid[N]]
        result.append(progress)
        return
    else:
        rec(r+1,progress,result)
        progress = progress + [grid[r]]
        rec(r+1,progress,result)

def rap():
    result = []
    progress = []
    rec(0,progress,result)
    ans = float('inf')
    for item in result:
        stals = [0]*(M+1)
        for item2 in item:
            for i, j in enumerate(item2):
                stals[i] += j
        f = True
        for  m in stals[1:]:
            if m < X:
                f = False
        if f:
            ans = min(ans,stals[0])
    if  ans == float('inf'):
        print(-1)
    else:
        print(ans)
            
    return 

rap()

Solution (Python):
n, m, x = map(int, input().split())
c = []
a = [[] for _ in range(n)]
for i in range(n):
  inp = list(map(int, input().split()))
  c.append(inp[0])
  for j in range(m):
    a[i].append(inp[j+1])
kumi=1
for i in range(n):
  kumi *= 2
  
min_score = 10000000000000
for i in range(1, kumi):
  t = [0 for _ in range(m)]
  p = 0
  ni = format(i, 'b').zfill(n)
  for j in range(n):
    if(ni[j]=="1"):
      for kk in range(m):
        t[kk] += a[j][kk]
      p += c[j]
  flag = True
  for j in range(m):
    if(t[j] < x):
      flag = False
  if(flag):
    if(min_score > p):
      min_score = p
      
if(min_score == 10000000000000):
  print(-1)
else:
  print(min_score)

Solution (Python):
import itertools
 
N,M,X = map(int, input().split())
C_A = []
for _ in range(N):
    C_A.append(list(map(int, input().split())))

 
min_price = 10**5 * 12 
rikaido = [0 for _ in range(M)]
possible = 0
for i in itertools.product([0,1], repeat=N):
    price_rikaido = [sum(C_A[j][k]*i[j] for j in range(N)) for k in range(M+1)]
    
    
    flag = 1
    for l in range(M):
        if price_rikaido[l+1] <X:
            flag = 0
            break
    if flag and (min_price >= price_rikaido[0]):
        min_price = price_rikaido[0]
        possible = 1
        
if possible:
    print(min_price)
else:
    print(-1)

Solution (Python):
import itertools

def check(arr,t):
    for i in arr:
        if i < t:
            return False
    return True

N,M,X = list(map(int,input().split()))
l = []
for _ in range(N):
    l.append(list(map(int,input().split())))
buy_bit = list(itertools.product([0,1], repeat=N))

mi = 990000000
for pattern in buy_bit:
    learned = [0 for _ in range(M)]
    total = 0
    for idx,bit in enumerate(pattern):
        if bit == 1:
            total += l[idx][0]
            for learned_id in range(M):
                learned[learned_id] += l[idx][learned_id+1]
    if total < mi and check(learned,X):
        mi = total
if mi == 990000000:
    print(-1)
else:
    print(mi)

Solution (Python):
import itertools
import numpy as np

n, m, x = map(int, input().split())
c = []
a = []
for i in range(n):
    cu, *au = list(map(int, input().split()))
    c.append(cu)
    a.append(au)
c = np.array(c)
a = np.array(a)
    
pmin = 10000000
for e in itertools.product([0, 1], repeat=n):
    e = np.array(e)
    results = np.dot(e, a)
    if results.min()>=x:
        p = np.dot(e, c)
        if p < pmin:
            pmin = p

pmin = -1 if pmin==10000000 else pmin
print(pmin)

Solution (Python):
from itertools import combinations
n, m, x = map(int, input().split())

books = []

for i in range(n):
  books.append(list(map(int, input().split())))

combBooks = []
for i in range(n, 0, -1):
    combBooks.append(list(combinations(books, i)))
prices = []
flag = True
for combin in combBooks:
    if flag:
        flag = False
        for comb in combin:
            sums = [0]*m
            price = 0
            for book in comb:
                price += book[0]
                for algorithm in range(m):
                    sums[algorithm] += book[algorithm+1]
            flag_break = True
            for sum in sums:
                if sum < x:
                    flag_break = False
                    break
            if flag_break:
                flag = True
                prices.append(price)

if not prices:
    print("-1")
else:
    print(min(prices))

Solution (Python):
import itertools

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


kakaku = 9999999
combinations = []
for n in range(1, N+1):
    combinations += list(itertools.combinations(range(N), n))

for pair in combinations:
    hantei = True
    for m in range(M):
        total = 0
        for i in pair:
            total += CA[i][m+1]
        if X <= total:
            continue
        else:
            hantei = False
            break
    if hantei:
        kingaku = 0
        for i in pair:
            kingaku += CA[i][0]
        kakaku = min(kakaku, kingaku)
    else:
        continue

if kakaku == 9999999:
    print(-1)
else:
    print(kakaku)

Solution (Python):
import numpy as np 


n,m,x = map(int, input().split())


s_list = list()

for i in range(n):
    line = list(map(int, input().split()))
    s_list.append([line[0], np.array(line[1:], dtype=int)])


cands = list()

cands.append([0, np.zeros(m, dtype=int)])


for l in s_list:
    next_cands = list()
    for c in cands:
        next_cands.append([c[0] + l[0], c[1] + l[1]])
    cands += next_cands


min_cost = 10**12
for l in cands:
    if (l[1] >= x).all() and l[0] < min_cost:
        min_cost = l[0]


if min_cost == 10**12:
    print(-1)
else:
    print(min_cost)

Solution (Python):
import numpy as np
n,m,x=map(int,input().split())
c=[None for i in range(n)]
a=[None for i in range(n)]
for i in range(n):
    l=[int(i) for i in input().split()]
    c[i]=l[0]
    a[i]=np.array(l[1:])
mincos=1000000000000
for mask in range(2**n):
    rikai=np.zeros(m,dtype="int32")
    cos=0
    mm=mask
    for i in range(n):
        if mm%2:
            rikai+=a[i]
            cos+=c[i]
        mm//=2
    if np.all(rikai>=x):
        mincos=min(cos,mincos)

if mincos==1000000000000:
    print(-1)
else:
    print(mincos)

Solution (Python):
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())









N, M, X = mapint_inp()
CA = [list(mapint_inp()) for _ in range(N)]

total_value_and_understanding_value = []

def add_each_element_in_list(l1, l2):
    return [a + b for a, b in zip(l1, l2)]


totals = []
for i in range(2**N):
    t = []
    for j in range(N):
        if ((i >> j) & 1):
            if t:
                t = add_each_element_in_list(t, CA[j])
                continue
            t = CA[j]
    if t:
        totals.append(t)

def check_X(l):
    for i in range(M+1):
        if i == 0:
            continue
        if l[i] < X:
            return False
    return True

import math
ans = math.inf
f = False
for total in totals:
    if check_X(total):
        ans = min(total[0], ans)

if ans == math.inf:
    print(-1)
else:
    print(ans)

Solution (Python):
def main():
    IN1 = [int(_) for _ in input().split()]
    N = IN1[0]
    M = IN1[1]
    X = IN1[2]
    AC = [[int(_) for _ in input().split()] for i in range(N)]

    minSum = 1200001
    for i in range(2 ** N):
        tmpSum = 0
        tmpA = [0] * M
        for j in range(N):
            if ((i >> j) & 1):
                tmpSum = tmpSum + AC[j][0]
                for k in range(1, M + 1):
                    tmpA[k-1] = tmpA[k-1] + AC[j][k]

        result = True
        for a in tmpA:
            if a < X:
                result = False
        if result:
            if minSum >= tmpSum:
                minSum = tmpSum

    if minSum != 1200001:
        print(minSum)
        return
    print(-1)

if __name__ == "__main__":
    main()

Solution (Python):
a = input().split()
n = int(a[0])
m = int(a[1])
x = int(a[2])

bo =  []
for i in range(n):
    bo.append([int(j) for j in input().split()])


cost = 999999999999
pat = []
for i in range(2 ** n):
    tp = []
    for j in  range(n):
        if ((i >> j) & 1):
            tp.append(bo[j])
    pat.append(tp)



for i in pat:
    ef = [0] * (m)
    tcost = 0
    for j in i:
        tcost += j[0]
        for k in range(1,m+1):
            ef[k-1] += j[k]
    flg = True
    for l in range(1,m+1):
        if ef[l-1] < x:
            flg = False
    if flg:
        cost = min(cost,tcost)

if cost == 999999999999:
    print(-1)
else :
    print(cost)

Solution (Python):
import itertools
n,m,x=map(int,input().split())
l=list()
for i in range(n):
    l.append(list(map(int,input().split())))
pp=list()
for i in range(1,n+1):
    for j in itertools.combinations(l,i):
        r=[0 for i in range(m)]
        for k in j:
            a=0
            p=0
            for i in range(1,m+1):
                r[i-1]+=k[i]
                a+=r[i-1]>=x
            if a==m:
                for c in j:
                    p+=c[0]
                pp.append(p)
if len(pp)==0:
    print(-1)
else:
    print(min(pp))

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


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


a=[]
ans=[]
for j in range(N):

    A = list(map(int,input().split()))
    a.append(A)

for i in range(1,N+1):
    for l in list(combinations(a,i)):
        s=np.zeros(M+1)
        for k in l:
            k=np.array(k)
            s=s+k
        

        if min(s[1:])>=X:
            ans.append(s[0])
if len(ans)==0:
    print(-1)
else:
    print(int(min(ans)))

Solution (Python):
import itertools
import numpy as np

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

ans = 10**10
for i in range(1, n+1):
  for v in itertools.combinations(num, i):
    tmp = 0
    rikaido = np.array([0 for _ in range(m)])
    
    for each in v:
      tmp += l[each][0]
      rikaido += l[each][1:]
    
    if np.min(rikaido) >= x:
      ans = min(ans, tmp)
      
if ans == 10**10:
  print(-1)
else:
  print(ans)

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

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

best = float("inf")
for i in range(1<<n):
    sk = [0] * m
    pr = 0
    for j in range(n):
        if i&(1<<j):
            for k in range(m):
                sk[k] += arr[j][k+1]
            pr += arr[j][0]

    gud = True
    for e in sk:
        if e < x:
            gud = False
            break

    if gud:
        best = min(best, pr)

if best == float("inf"):
    best = -1
print(best)

Solution (Python):
N,M,X=map(int,input().split())
C=[0]*N
A=[]
for i in range(N):
  x=list(map(int,input().split()))
  C[i]=x[0]
  A.append(x[1:])
ans=sum(C)+1
for i in range(2**N):
  summ=0
  x=[0]*M
  flag=True
  for j in range(N):
    if(i>>j & 1):
      for k in range(M):
        x[k]+=A[j][k]
      summ+=C[j]
  for k in range(M):
    if(x[k]<X):
      flag=False
  if(flag==True):
    ans=min(ans,summ)
if(ans<=sum(C)):
  print(ans)
else:
  print(-1)

Solution (Python):

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


def II():
    return int(input())


N,M,X=acinput()

books=[]
for i in range(N):
    books.append(acinput())
    

res=10**9
for k in range(2**N):
    bk=list(map(int,list(bin(k)[2:].zfill(N))))
    
    sm=0
    usd=np.array([0]*M)
    for l,s in enumerate(bk):
        if s==1:
            sm+=books[l][0]
            usd+=books[l][1:]
    
    
    
    if np.all(usd>=X):
        res=min(res,sm)
        
    
if res==10**9:
    print(-1)
else:
    print(res)

Solution (Python):
import numpy as np
import itertools
import sys
N,M,X=map(int, input().split())

i=0
lst = []
while i < N:
    m = map(int, input().split())
    lst.append(list(m))
    i+=1
arr = np.array(lst)


if np.min(np.sum(arr[:,1:], axis=0)) < X:
    print(-1)
    sys.exit()
data = arr[:,1:]
res = []
for i in range(1,N+1):
    for conbi in itertools.combinations(lst, i):
        arrx = np.array(conbi)
        if np.min(np.sum(arrx[:,1:], axis=0)) >= X:
            res.append(np.sum(arrx[:,0]))

print(min(res))

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

score = -1
for i in range(2**n):
    score_ = 0
    a = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                a[k] += v[j][k+1]
            score_ += v[j][0]
    if min(a) >= x:
        if score == -1:
            score = score_
        else:
            score = min(score_,score)
if score == -1:
    print(-1)
else:
    print(score)

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

ar = [[0]*(m+1)]*n

for i in range(n):
    ar[i] = [int(s) for s in input().split()]




smp = 111

def goukei(bitt):
    bitt = str(bitt)
    cnt = 0
    mn = 0
    skl = [0]*m
    for i in bitt:
        if(i == "1"):
            mn += ar[cnt][0]
            skl = [x + y for (x, y) in zip(skl, ar[cnt][1:])]
            
        cnt += 1
    
    
    flag = 1
    if any(ss < x for ss in skl):
        flag = 0
    
    
    return mn,flag



            

mx = 2**n 


mnmn = []

for i in range(mx+1):
    bit_sentaku = str(bin(i))
    bit_sentaku = bit_sentaku[2:]
    bit_sentaku = bit_sentaku.zfill(n)
    
    if(goukei(bit_sentaku)[1] == 1):
        mnmn.append(goukei(bit_sentaku)[0])

if not(len(mnmn) == 0):
    print(min(mnmn))
else:
    print(-1)

Solution (Python):
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for _ in range(n)]
ans=[-1]*(m+1)
tmp=[0]*(m+1)
for i in range(2**n):
  for j in range(n):
    if (i>>j)&1:
      for k in range(m+1):
        tmp[k]+=ca[j][k]
  for j in range(1,m+1):
    if tmp[j]<x:
      break
  else:
    if ans[0]>tmp[0] or ans[0]<0:
      ans=tmp
  tmp=[0]*(m+1)
print(ans[0])

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

costs = []
a = []
ans = 10 ** 9

for i in range(n):
    c, *j = map(int, input().split())
    costs.append(c)
    a.append(j)

for y in range(2 ** n):
    total = 0
    b = [0] * m
    bi = '{:b}'.format(y).zfill(n)
    for i in range(n):
        if bi[i] == '1':
            total += costs[i]
            r = a[i]
            for j in range(m):
                b[j] += r[j]
    if all([k >= x for k in b]):
        ans = min(ans, total)

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

Solution (Python):
a=input().split()
N=int(a[0])
M=int(a[1])
X=int(a[2])
list1=[]
for i in range(N) :
  k=input().split()
  k=[int(j) for j in k]
  list1.append(k)

flag1=True
def count(item,i) :
  count1=0
  for a in item :
    count1+=a[i]
  return count1

def algo(item,i) :

  for j in range(1,i+1) :
    if count(item,j)<X :
      return False
  return True


import itertools
value_list=[]
for i in range(1,N+1) :
  c=list(itertools.combinations(list1,i))


  for item in c :
    item1=list(item)


    if algo(item1,M) :
      value_list.append(count(item1,0))

if value_list!=[] :
  print(min(value_list))
else :
  print('-1')

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

cost_list = []
for choice in range(n+1):
  for v in itertools.combinations(ca, choice):
    cost = 0
    us = [0] * m
    for t in v:
      cost += t[0]
      for i in range(m):
        us[i] += t[i+1]
    flag = True
    for check in range(m):
      if us[check] < x:
        flag = False
    if flag == True:
      cost_list.append(cost)

if len(cost_list) == 0:
  print(-1)
else:
  print(min(cost_list))

Solution (Python):
def solve():
    N, M, X = map(int, input().split())
    AC = []
    ans = 10**8
    for n in range(N):
        AC.append(list(map(int, input().split())))
    for i in range(2**N):
        level = [0]*M
        cost = 0
        for j in range(N):
            if ((i >> j) & 1):
                for l in range(M):
                    level[l] += AC[j][l+1]
                cost += AC[j][0]
        if (min(level) >= X) and (ans > cost):
            ans = cost
    if ans == 10**8:
        print(-1)
    else:
        print(ans)


solve()

Solution (Python):
import itertools
n,m,x = map(int,input().split())
boollist = list(map(list,itertools.product([True,False],repeat = n)))
itemlist = []
for i in range(n):
    itemlist.append(list(map(int,input().split())))

a = 10**8
for i in range(len(boollist)):
    unders = [0 for i in range(m)]
    money = 0
    for j in range(n):
        if boollist[i][j]:
            money += itemlist[j][0]
            for k in range(m):
                unders[k] += itemlist[j][k+1]
    if min(unders) >= x and money < a:
        a = money
if a == 10**8:
    print(-1)
else:
    print(a)

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

from itertools import combinations

combs = list()
for k in range(1, n+1):
    combs.extend(list(combinations(range(0, n), k)))

mn = -1
for comb in combs:
    money = 0
    us = [0] * m
    for i in list(comb):
        b = bs[i]
        money += b[0]
        for j, u in enumerate(b[1:]):
            us[j] += u

    is_ok = True
    for i in range(m):
        if us[i] < x:
            is_ok = False
            break
    if is_ok:
        if mn < 0 or money < mn:
            mn = money

print(mn)

Solution (Python):
import numpy as np
n, m, x = map(int, input().split())
c = [0] * n
a = np.zeros((n, m))
for i in range(n):
    t = [int(j) for j in input().split()]
    c[i] = t[0]
    a[i] = t[1:]
low = float('inf')
for i in range(2 ** n):
    price = 0
    score = np.zeros(m)
    for j in range(n):
        if i & (1 << j):
            score += a[j]
            price += c[j]
    if len(score[score >= x]) == m:
        low = min(low, price)
print(-1) if low==float('inf') else print(low)

Solution (Python):
def main():
    import sys
    import numpy as np
    import itertools
    N,M,X=list(map(int,sys.stdin.readline().split()))
    C=[]
    for i in range(N):
        C.append(list(map(int,sys.stdin.readline().split())))

    C=np.array(C)
    costs=C[:,0]
    C=C[:,1:]
    cost=10**12
    for a in list(itertools.product([0,1], repeat=N)):
        if all((np.sum(C.T*np.array(a),axis=1)>=X).tolist()):
            cost=min(cost,np.sum(costs*np.array(a)))
    if cost==10**12:
        print(-1)
    else:
        print(cost)
        


main()

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

mincost = 10**9
for i in range(2**n):
	cost = 0
	knowledge = [0]*m
	for j in range(n):
		if i%2 == 1:
			cost += books[j][0]
			for b in range(m):
				knowledge[b] += books[j][b+1]
		i = i >> 1
	if min(knowledge) >= x and cost < mincost:
		mincost = cost

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

Solution (Python):
n,m,x = map(int,input().split())
pattern = []
for i in range(2**(n)):
    tmp = [0 for i in range(n)]
    for j in range(n):
        if i>>j & 1:
            tmp[j] = 1
    pattern.append(tmp)

ans = 10**9
Input= []
for i in range(n):
    tmp = [int(i) for i in input().split()]
    Input.append(tmp)
for i in pattern:
    score = [0 for j in range(m)]
    tmp_ans = 0
    Flag = True
    for j in range(len(i)):
        if i[j]==0:
            continue
        else:
            tmp_ans += Input[j][0]
            for k in range(m):
                score[k] += Input[j][k+1]
    for k in range(m):
        if score[k]<x:
            Flag = False
    if Flag == False:
        continue
    ans = min(ans,tmp_ans)
if ans==10**9:
    print(-1)
else:
    print(ans)

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

bit=[]
for i in range(2**n):
    b=[]
    for j in range(n):
        if (i>>j & 1):
            b.append(1)
        else:
            b.append(0)
    bit.append(b)

ans_list=[]

for i in range(len(bit)):
    a=[0 for l in range(m+1)]
    for j in range(n):
        if bit[i][j]==1:
            for k in range(m+1):
                a[k]=a[k]+book[j][k]
    if min(a[1:])>=x:
        ans_list.append(a[0])
    a=[]
    
if len(ans_list)==0:
    print(-1)
else:
    print(min(ans_list))

Solution (Python):

from itertools import combinations

N,M,X=map(int,input().split())
Z=[[int(x) for x in input().split()] for i in range(N)]
num=[i for i in range(N)]

com=[]
for i in range(1,N+1):
    com=com+list(combinations(num, i))
    
Min=10**8
for A in com:
    cost=0
    B=[0 for j in range(M)]
    for i in A:
        cost+=Z[i][0]
        for j in range(M):
            B[j]+=Z[i][j+1]
        
    if min(B)<X:
        continue
    else:
        Min=min(Min,cost)
        
if Min==10**8:
    print(-1)
else:
    print(Min)

Solution (Python):
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
def printCombination(arr, n, r): 
	data = [0] * r 
	combinationUtil(arr, n, r, 0, data, 0) 
def combinationUtil(arr, n, r, index, data, i): 
	if (index == r): 
		ans=[]
		for j in range(r): 
			ans.append(data[j]) 
		f.append(ans)
		return
	if (i >= n): 
		return
	data[index] = arr[i] 
	combinationUtil(arr, n, r, index + 1, 
					data, i + 1) 
	combinationUtil(arr, n, r, index, 
					data, i + 1) 


n,m,x=map(int,input().split())
cost=[]
l=[]
for i in range(n):
	l.append(list(map(int,input().split())))
z=[i for i in range(n)]
for i in range(1,n+1):
	f=[]
	printCombination(z,n,i)
	for t in f:
		ans=0
		ansd=[0 for i in range(m)]
		for j in t:
			ans+=l[j][0]
			for k in range(m):
				ansd[k]+=l[j][k+1]
		flag=1
		for k in ansd:
			if k<x:
				flag=0
		if flag==1:
			cost.append(ans)
if len(cost)>0:
	print(min(cost))
else:
	print(-1)

Solution (Python):
n,m,x = (int(x) for x in input().split())

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

y = 0
for i in range(2 ** n):
  lb = [0]*(m+1)
  for j in range(n):
    if ((i >> j) & 1):
      lb = [x + y for (x, y) in zip(lb, la[j][:])] 
  frg=1
  for h in range(m):
    if lb[h+1]<x:
      frg=0
  if frg==1:
    if lb[0] <= y or y==0:
      y=lb[0]
  del lb[:]
print(y if y>0 else -1)

Solution (Python):
import itertools
N,M,X=map(int,input().split())
ans=13*10**5
List=[]
for _ in range(N):
  List.append([int(i) for i in input().split()])
for i in range(0,N):
  for j in itertools.combinations(range(N),i+1):
    tmp=[0]*(M+1)
    for k in j:      
      for l in range(M+1):
        tmp[l]+=List[k][l]
    if len([m for m in tmp[1:] if m>=X])==M:
      ans=min(ans,tmp[0])
if ans==13*10**5:
  print(-1)
else:
  print(ans)

Solution (Python):
n, m, x = [int(elem) for elem in input().split()]

cs = []
a_lsts = []
for i in range(n):
    elems = [int(elem) for elem in input().split()]
    c, a_lst = elems[0], elems[1:]
    cs.append(c)
    a_lsts.append(a_lst)


min_ = -1
for i in range(2 ** n):
    s = '0' * n + bin(i)[2:]
    s = s[-n:]
    res = 0
    costs = [0] * m
    for j in range(n):
        if s[j] == '0':
            pass
        else:
            res += cs[j]
            costs = [costs[k] + a_lsts[j][k] for k in range(m)]
    if all(elem >= x for elem in costs):
        if min_ == -1:
            min_ = res
        elif min_ > res:
            min_ = res
print(min_)

Solution (Python):
from itertools import combinations
import numpy as np
ans = -1

N, M, X = map(int, input().split())
A = np.ndarray(shape=(N, M), dtype=int)
C = np.ndarray(shape=(N, ), dtype=int)
ans = []
costs = []
money = []
for i in range(N):
    inp = list(map(int, input().split()))
    C[i] = inp[0]
    A[i] = inp[1:]
for r in range(N):
    for c in combinations(range(N), r + 1):
        if min(np.sum(A[list(c)], axis=0)) >= X:
            costs.append(np.sum(C[list(c)]))
if len(costs) == 0:
    print(-1)
else:
    print(min(costs))