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())
ans = -1
arr = []

for _ in range(N):
    arr.append(list(map(int, input().split())))

for i1 in range(2):
    for i2 in range(2):
        for i3 in range(2):
            for i4 in range(2):
                for i5 in range(2):
                    for i6 in range(2):
                        for i7 in range(2):
                            for i8 in range(2):
                                for i9 in range(2):
                                    for i10 in range(2):
                                        for i11 in range(2):
                                            for i12 in range(2):
                                                tmp_min = 0
                                                tmp_arr = [0] * M
                                                arr_cnt = 0
                                                N_cnt = 0
                                                while N > N_cnt:
                                                    if N_cnt == 0 and bool(i1):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 1 and bool(i2):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 2 and bool(i3):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 3 and bool(i4):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 4 and bool(i5):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 5 and bool(i6):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 6 and bool(i7):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 7 and bool(i8):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 8 and bool(i9):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 9 and bool(i10):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 10 and bool(i11):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    if N_cnt == 11 and bool(i12):
                                                        tmp_min += arr[arr_cnt][0]
                                                        for i in range(M):
                                                            tmp_arr[i] += arr[arr_cnt][
                                                                i + 1
                                                            ]

                                                    arr_cnt += 1
                                                    N_cnt += 1
                                                if min(tmp_arr) >= X:
                                                    if ans == -1:
                                                        ans = tmp_min
                                                    else:
                                                        ans = min(tmp_min, ans)

print(ans)

Solution (Python):
import numpy as np

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

l = []
for i in range(N):
    l += [np.array(list(map(int, input().split()))).reshape((M + 1, 1))]

r = np.array([0] * (M + 1)).reshape((M + 1, 1))

for x in l:
    r = np.concatenate([r, r + x], axis=1)

fitted = r[:, np.all(r[1:] >= X, axis=0)]

print(min(fitted[0]) if fitted.shape[1] != 0 else -1)

Solution (Python):
import itertools

n, m, x = map(int, input().split())
a_list = []
for _ in range(n):
    lst = list(map(int, input().split()))
    a_list.append(lst)



money = 0
skill = [0]*n
for i in range(n):
    money += a_list[i][0]
    skill = [x+y for (x, y) in zip(skill, a_list[i][1:])]

for s in skill:
    if s < x:
        print(-1)
        exit()

ans = 100100100
for i in range(1, n+1):
    comb = list(itertools.combinations(a_list, i))
    
    for c in comb:
        money = 0
        skill = [0]*n
        for a in c:
            money += a[0]
            skill = [x+y for (x, y) in zip(skill, a[1:])]

        if min(skill) >= x:
            ans = min(ans, money)
print(ans)

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

cost=[]
rikai=[]
for i in range(n):
  temp=list(map(int,input().split()))
  cost.append(temp[0])
  rikai.append(temp[1:])

ans=10**10
for i in range(1,2**n):
  c=0
  t=[0]*m
  for j in range(n):
    if (i>>j) & 1:
      c+=cost[j]
      for k in range(m):
        t[k]+=rikai[j][k]
      
  for l in t:
    if l < x:
      break
  else:
    ans=min(ans,c)
if ans != 10**10:
  print(ans)
else:
  print(-1)

Solution (Python):
import itertools as t
n,m,z=map(int,input().split())
l=[]
answer=set([])
for i in range(n):
    l.append(list(map(int, input().split())))
for k in range(n+1):
    a=list(t.combinations(range(n),k))
    for x in a:
        w=0
        A=[0 for _ in range(m)]
        s=0
        for y in x:
            w+=l[y][0]
            for k in range(m):
                A[k]+=l[y][k+1]
        for u in A:
            if u<z:
                s=1
        if s==0:
            answer.add(w)
if answer:
    print(min(answer))
else:
    print(-1)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def solve():
    n, m, x = LI()
    ca = LIR(n)
    ans = inf
    for mask in range(1 << n):
        tmp = [0] * m
        t = 0
        for i in range(n):
            if mask & (1 << i):
                for j in range(m):
                    tmp[j] += ca[i][j + 1]
                t += ca[i][0]
        if sum(map(lambda a: a < x, tmp)):
            continue
        ans = min(ans, t)
    if ans == inf:
        print(-1)
    else:
        print(ans)
    return



if __name__ == '__main__':
    solve()

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

A = [[0 for i in range(M)]for i in range(N)]
C=[0]*(2**N)
for i in range(N):
    A[i] = list(map(int,input().split()))
for i in range(2 ** N):
    Ad = []
    for j in range(N):
        if (i >> j) & 1  == 1:
            Ad.append(A[j])

    
    xs = [0]*(M+1)
    for k in range(len(Ad)):
        C[i]+=Ad[k][0]
        for l in range(1,M+1):
            xs[l] += Ad[k][l]      
        
    flag = True

    for l in range(1,M+1):
        if xs[l] >= X:
            continue
        else:
            flag = False
            

    if flag and m > C[i]:

        m = C[i]

if m < 10000000:
    print(m)
else:
    print(-1)

Solution (Python):
INF = 1001001001
N, M, X = map(int, input().split())
C, A = [], []
for i in range(N):
    _c = list(map(int, (input().split())))
    _a = _c[1:]
    _c = _c[0]
    A.append(_a)
    C.append(_c)
ans = INF
for b in range(1<<N):
    money = 0
    point = [0]*M
    for i in range(N):
        if (b>>i)&1:
            money += C[i]
            for j in range(M):
                point[j] += A[i][j]
    for j in range(M):
        if point[j] < X:
            break
    else:
        ans = min(ans, money)
if ans == INF:
    print(-1)
else:
    print(ans)

Solution (Python):
def C():
    n, m, x = map(int, input().split())
    books = [tuple(map(int, input().split())) for i in range(n)]
    books = list(zip(*books))
    res = []
    for i in range(2**n):
        flag = True
        pattern = list(map(int, bin(i)[2:].zfill(n)))
        for j in range(m):
            skill = sum(map(lambda x,y: x*y, pattern, books[j+1]))
            if skill < x:
                flag = False
                break
        if flag:
            cost = sum(map(lambda x,y: x*y, pattern, books[0]))
            res.append(cost)
    if res != []:
        print(min(res))
    else:
        print(-1)
C()

Solution (Python):
N,M,X = map(int,input().split())
books = [list(map(int,input().split())) for _ in range(N)]
digit = "0"+str(N)+"b"
ans = float("INF")
for i in range(2**N):
    flags = list(format(i,digit))
    rikaid = [0]*(M)
    cost = 0
    for j in range(N):
        if flags[j] == "1":
            cost += books[j][0]
            for k in range(M):
                rikaid[k] += books[j][k+1]
    for r in rikaid:
        if r < X:
            break
    else:
        ans = min(ans,cost)
if ans == float("INF"):
    print(-1)
else:
    print(ans)

Solution (Python):
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, m, x = MAP()
bene = [[0]*(m+1) for i in range(n)]
for i in range(n):
    a = LIST()
    bene[i] = a

def add(in1, in2):
    return [a + b for a, b in zip(in1, in2)]

bene = sorted(bene)
result = []
for n in range(1,len(bene)+1):
    for conb in itertools.combinations(bene, n):
        conb = list(conb)
        res = conb[0]
        for i in range(len(conb)-1):
            res = add(res, conb[i+1])
        result.append(res) 
result = sorted(result)

for i in range(len(result)):
    flag = True
    for j in range(m):
        if result[i][j+1] <x:
            flag = False
    if flag:
        print(result[i][0])
        sys.exit()
print(-1)

Solution (Python):
import sys






from itertools import combinations as comb




stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

n,m,x = map(int, stdin.readline().rstrip().split())
numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]



rikai = [0] * m
l = [i for i in range(1,n+1)]
ans = 10**9
for i in l:
    books = list(comb(l,i))

    for j in books:
        
        pay = 0
        rikaii = rikai[:]
        for u in j:
            cost = numbers[u-1][0]
            skill = numbers[u-1][1:]
            pay += cost
            rikaii = [x + y for (x, y) in zip(rikaii, skill)]
        ok = 0
        for y in range(m):
            if rikaii[y] >= x:
                ok += 1
        if ok == m:
            ans = min(ans,pay)

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

Solution (Python):
N, M, X = map(int, input().split())
AC = [[0 for i in range(M + 1)] for j in range(N)]
for i in range(N):
  AC[i] = list(map(int, input().split()))
x = 2 ** N
ans = -1
for i in range(x):
  p = i
  A = [0] * M
  summ = 0
  for j in range(N):
    y = p // (2 ** (N - j - 1))
    p = p -  (y * (2 ** (N - j - 1)))
    if y == 1 :
      summ = summ + AC[j][0]
      for k in range(M):
        A[k] = A[k] + AC[j][k + 1]
  tip = 0
  for j in range(M):
    if A[j] < X:
      tip = 1
  if tip == 0:
    if (ans == -1):
      ans = summ
    elif summ < ans:
      ans = summ
print(ans)

Solution (Python):
import sys
import itertools
input = sys.stdin.readline
N, M, X = (int(i) for i in input().split())

A = [[int(i) for i in input().split()] for i in range(N)]

combs = itertools.product(range(2), repeat=N)
ans = float('inf')
for comb in combs:
    mycomb = list(comb)
    
    cur = 0
    allm = [0]*M
    for i in range(N):
        if mycomb[i]:
            cur += A[i][0]
            for j in range(M):
                allm[j] += A[i][j+1]
    
    for j in range(M):
        if allm[j] < X:
            break
    else:
        ans = min(ans, cur)
        

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

Solution (Python):
N,M,X=map(int,input().split())
L=[]
ans=[0]*(M+1)
A=float("inf")
for i in range(N):
	L.append(list(map(int,input().split())))
for i in range(N):
	for j in range(1,M+1):
		ans[j]+=L[i][j]
if min(ans[1:M+1])<X:
	print(-1)
	exit()
for i in range(1,2**N+1):
	ans=[0]*(M+1)
	i+=8192
	for j in range(N):
		if ((i>>j)&1):
			for k in range(M+1):
				ans[k]+=L[j][k]
	if min(ans[1:M+1])>=X:
		A=min(ans[0],A)
print(A)

Solution (Python):
n,m,x = map(int,input().split())
l = [[]]*n
for i in range(n):
    l[i] = list(map(int,input().split()))
cnt_min = 10**7
for j in range(2**n):
    u = [x]*m
    cnt = 0
    b = str(bin(j))[2:].zfill(n)
    for k in range(n):
        if b[k] == '1':
            cnt += l[k][0]
            for o in range(m):
                u[o] -= l[k][o+1]
    flg = 1
    for p in range(m):
        if u[p] > 0:
            flg = 0
    if flg == 1:
        if cnt < cnt_min: 
            cnt_min = cnt
if cnt_min == 10**7:
    print(-1)
else:
    print(cnt_min)

Solution (Python):
def solve(i, cost, sums):
    global x
    if min(sums) >= x:
        global min_cost
        min_cost = min(cost, min_cost)
        return
    if i == n:
        return
    solve(i + 1, cost, list(sums))
    for i_, a in enumerate(C[i][1]):
        sums[i_] += a
    cost += C[i][0]
    solve(i + 1, cost, list(sums))


n, m, x = map(int, input().split())
C = []
ans = 0
for _ in range(n):
    __ = [int(x) for x in input().split()]
    C.append([__[0], __[1:]])
min_cost = int(1e9)
solve(0, 0, [0] * m)
print(-1 if min_cost == int(1e9) else min_cost)

Solution (Python):
import numpy as np
import itertools

NMX = input()
NMX = NMX.split()
N = int(NMX[0])
M = int(NMX[1])
X = int(NMX[2])

CA = []
for i in range(N):
    ca = input()
    ca = ca.split()
    CA.append(ca)

CA = np.array(CA, dtype = int)
C = CA[:,0]
A = CA[:,1:]

bb = np.array(list(itertools.product([0, 1], repeat = N)))


cost = 9999999
for b in bb:
    AA = (A.T * b).T
    ss = np.sum(AA, axis=0)
    if np.all(ss >= X):
        CC = np.sum(C.T * b)
        if CC < cost:
            cost = CC

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

Solution (Python):
import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict



sys.setrecursionlimit(10**6 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7

n, m, x = map(int, input().split())
prices = []
mat = []
for _ in range(n):
    nums = read_n_item()
    prices.append(nums[0])
    mat.append(nums[1:])


def check(nums):
    for num in nums:
        if num < x:
            return False
    return True


def dfs(cur, pos, price, min_price):
    if check(cur):
        min_price = min(price, min_price)
        return min_price
    if pos == n:
        return min_price

    min_price = min(dfs(cur, pos+1, price, min_price), min_price)

    nxt = [0] * len(cur)
    for i in range(len(cur)):
        nxt[i] = cur[i] + mat[pos][i]
    min_price = min(min_price, dfs(nxt, pos+1, price+prices[pos], min_price))
    return min_price

min_price = dfs([0]*m, 0, 0, float('inf'))

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

Solution (Python):
import itertools
N,M,X = map(int,input().split())
A=[]
ANS=[]
for i in range(N):
    A.append(list(map(int,input().split())))
A.sort()
for n in range(1,len(A)+1):
    for conb in itertools.combinations(A, n):
        S=[0]*(M+1)
        for L in conb:
            for i in range(M+1):
                S[i] += L[i]
        if min(S[1:])>=X:
            ANS.append(S)
if ANS==[]:
    print(-1)
else:
    ANS.sort()
    print(ANS[0][0])

Solution (Python):

import collections
import itertools as it
import math

 


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




ans = 10**9
for i in range(2**n): 
    s = f'{i:012b}'[12-n:]

    

    rikaido = [0] * m
    price = 0
    for i2, b in enumerate(s): 
        if b == '1':
            price += li[i2][0]
            for i3 in range(m): 
                rikaido[i3] += li[i2][i3+1]

    
    for r_ in rikaido:
        if r_ < x:
            break
    else:
        if price < ans:
            ans = price

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

Solution (Python):
import itertools


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


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


zero_one_list = list(itertools.product(range(2), repeat=n))


money_list = []

for z in zero_one_list:
    sum_skills = [0] * m
    sum_money = 0
    for i in range(n):
        if z[i] == 1:
            sum_money += skills[i][0]
            sum_skills = [x + y for (x,y) in zip(sum_skills,skills[i][1:])]
        else:
            continue

    if (all(elem >= x for elem in sum_skills)):
        money_list.append(sum_money)
    else:
        continue

if money_list == []:
    print(-1)
    exit()
else:
    print(min(money_list))
    exit()

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

price=[]
list_X=[X for i in range(M)]

for i in range(2**N):
  A=[0 for i in range(M+1)]
  for j in range(N):
    if (i>>j) & 1:
      A = [x+y for (x,y) in zip(A,L[j])] 
  
  large = 0
  for i in range(M):
    if A[i+1] >= list_X[i]:
      large += 1
  if large == M:
    price.append(A[0])
  
    

if price ==[]:
  print(-1)
else:
  print(min(price))

Solution (Python):

n, m, x = map(int, input().split())
L = []
J = []
for i in range(n):
    l = list(map(int, input().split()))
    L.append(l)
for i in range(2**n):
    cost = 0
    f = 0
    M = [0]*m
    for j in range(n):
        
        if (i>>j)&1 == 1:
            cost += L[j][0]
            for k in range(m):
                M[k] += L[j][k+1]
    for p in M:
        if p < x:
            f = 1
    if f == 0:
        J.append(cost)
if J != []:
  print(min(J))
else:
  print(-1)

Solution (Python):
import numpy as np
n,m,x=map(int,input().split())
c=[0]*n
a=[0]*n
for i in range(n):
    ca=list(map(int,input().split()))
    c[i]=ca[0]
    a[i]=ca[1:]

ans=sum(c)+1
for i in range(2**n):
    bag=[]
    money=0
    point=np.zeros(m, dtype=int)
    for j in range(n):
        if ((i>>j) &1):
            bag.append(j)
            money+=c[j]
    for k in range(len(bag)):
        point+=a[bag[k]][:]
    if min(point)>=x:
        ans=min(ans,money)

if ans>sum(c):
    print(-1)
else:
    print(ans)

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

Solution (Python):
n, m, x = map(int, input().split())
a = [list(map(int,input().split())) for i in range(n)]
A = []
for i in range(n):
  A.append(i)
sum =10**9+7
for i in range(1 << len(A)):
    output = []
    for j in range(len(A)):
        if ((i >> j) & 1) == 1:
            output.append(A[j])
    ans = [0]*(m+1)
    for i in output:
      ans = [x + y for (x, y) in zip(ans, a[i])]
    for j in ans[1:]:
      if j >= x:
        continue
      else: break
    else: sum = min(sum, ans[0])
if sum == 10**9+7:
  print(-1)
else:
  print(sum)

Solution (Python):
import numpy as np

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

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

ans = 10**10
flag = 1
for i in range(1, 2**N):
    tmp = np.zeros(M)
    tmp_m = 0
    for j in range(N):
        if (i >> j) & 1:
            tmp = tmp + hon[j][1:]
            tmp_m += hon[j][0]
    if (tmp >= X).sum() == M:
        if tmp_m < ans:
            ans = tmp_m
            flag = 0
if flag:
    print(-1)
else:
    print(ans)

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


fg = 0
cost = sum([ i[0] for i in c_list])
for i in range(2**N):
    t_cost = []
    l = [ 0 for _ in range(M)]
    for j in range(N):
        if ((i>>j) & 1 ):
            t_cost.append(c_list[j][0])
            l = [ x+y for x,y in zip(l,c_list[j][1:])]
    if len([ 0 for k in l if k < X ]) == 0:
        fg = 1
        cost = min(cost, sum(t_cost))
if fg != 0:
    print(cost)
else:
    print('-1')

Solution (Python):
import itertools
import numpy as np

N,M,X=list(map(int,input().split()))
C=[]
A=[]
for i in range(N):
  s=list(map(int,input().split()))
  C.append(s[0])
  A.append(np.array(s[1:]))
combs=[]
lis = range(N)
for i in range(1,N+1):
  for team in itertools.combinations(lis, i):
    combs.append(team)
lp=0
for comb in combs:
  price=0
  skill=np.array([0 for i in range(M)])
  for i in comb:
    price+=C[i]
    skill+=A[i]
  if min(skill)>=X:
    if lp==0:
      lp=price
    elif lp>price:
      lp=price
if lp==0:
  print(-1)
else:
  print(lp)

Solution (Python):

def q3():
    N, M, X = [int(i) for i in input().split(" ")]
    books = []
    for i in range(N):
        values = [int(i) for i in input().split(" ")]
        C = values[0]
        A = values[1:]
        books.append([C, A])
    
    def dfs(i, points, value, values):
        if i == N:
            for p in points:
                if p < X:
                    return
            values.append(value)
            return
        dfs(i + 1, list(points), value, values)
        for ind in range(len(points)):
            points[ind] += books[i][1][ind]
        dfs(i + 1, list(points), value + books[i][0], values)
    
    point = []
    for i in range(M):
        point.append(0)
    values = []
    dfs(0, point, 0, values)
    
    if not values:
        print(-1)
    else:
        print(min(values))

q3()

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

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

min_val=-1

for i in range(2 ** n):
    tmp = [False] * n
    for j in range(n):
        if i >> j & 1:
            tmp[j] = True
    
    ss=[0]*m
    val=0
    for j,f in enumerate(tmp):
        if f:
            for k in range(m):
                ss[k]+=ab_list[j][1+k]

            val+=ab_list[j][0]
        
    if min(ss) >=x:
        if min_val==-1:
            min_val=val
        elif min_val>val:
            min_val=val

print(min_val)

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

Book = [[int(x) for x in input().split()] for j in range(n)]
Cost = 10 ** 7
for i in range(2**n):
  bag = [0 for k in range(n+1)]
 
  for j in range(n):
    if ((i >> j) &1):
      bag = [ x + y for (x,y) in zip (bag,Book[j])]
  if all(b >= x for b in bag[1:]):
    if Cost >= bag[0]:
      Cost = bag[0]
if Cost != 10 ** 7:
  print(Cost)
else:
  print(-1)

Solution (Python):
N,M,X=map(int,input().split())
ans=float("inf")
flag2=1
c=[]
for i in range(N):
    cc=list(map(int,input().split()))
    c.append(cc)
for i in range(2**N):
    flag=0
    score=[0 for _ in range(M+1)]
    for j in range(N):
        if i>>j & 1:
            for k in range(M+1):
                score[k]+=c[j][k]
    for j in range(1,M+1):
        if score[j]<X:
            flag=1
            break
    if flag==0:
        flag2=0
        ans=min(score[0],ans)
if flag2==1:
    print(-1)
else:
    print(ans)

Solution (Python):
def make_patterns(num_digits):
    res = []
    for i in range(2 ** num_digits):
        res.append(format(i, 'b').zfill(num_digits))
    return res


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

patterns = make_patterns(n)

res = -1
for pattern in patterns:
    lst = list(pattern)
    cost = 0
    score = [0 for _ in range(m)]
    for i, binary in enumerate(lst):
        if "0" == binary:
            continue
        for j in range(m):
            score[j] += books[i][j + 1]
        cost += books[i][0]
    if all(map(lambda elm: elm >= x, score)):
        if res == -1:
            res = cost
        else:
            res = min(res, cost)
print(res)

Solution (Python):
import numpy as np
N,M,X=map(int, input().split())  
y=[list(map(int,list(input().split()))) for i in range(N)]

tmp = sum([y[k][0] for k in range(N)]) + 1
ans = tmp

for i in range(2**N):
  c = 0
  A=[0]*M
  A = np.array(A)
  for j in range(N):
    if ((i >> j) & 1):
      c += y[j][0]
      A += np.array(y[j][1:M+1])
  
  if np.all(A>=X):
    ans = min(ans, c)

if ans==tmp:
  ans = -1

print(ans)

Solution (Python):
from collections import defaultdict

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

C=[]
A=[]
min_price=-1

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

for j in range(2**N):
    kekka=True
    taisho=[]
    for k in range(N):
        if ((j>>k)&1):
            taisho.append(k)
    
    
    price=0
    rikai=defaultdict(int)
    for l in taisho:
        price += C[l]
        for m in range(M):
            rikai[m] += A[l][m]
    
    
    for n in range(M):
        if rikai[n]<X:
            kekka=False
            break
    
    
    if kekka == True:
        if min_price==-1 or price<min_price:
            min_price=price

print(min_price)