qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if depth == N:
    return
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)


Fixed code:
import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  if depth == N:
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)
Buggy code:

def sumList(index,array):
    if index ==n:
        sumArray.append(array)
    else:
        sumList(index+1,array)
        nextArray =[0]*(m+1)
        for i in range(m+1):
            nextArray[i] +=array[i]+ list[index][i]
        sumList(index+1,nextArray)



if __name__ == '__main__':
    n,m,x = map(int, input().split())

    list = []
    for i in range(n):
        a = [int(i) for i in input().split()]
        list.append(a)
    firstArray = [0] * (m + 1)
    sumArray = []
    sumList(0,firstArray)

    min = 100000000
    print(sumArray)
    for i in sumArray:
        amount =0
        count =0
        for j in range(len(i)):
            if j == 0:
                amount =i[j]
            else:
                if i[j] >=x:
                    count+=1
        if count == m and min >= amount:
            min = amount

    if min == 100000000:
        print(-1)
    else:
        print(min)




Fixed code:
def sumList(index,array):
    if index ==n:
        sumArray.append(array)
    else:
        sumList(index+1,array)
        nextArray =[0]*(m+1)
        for i in range(m+1):
            nextArray[i] +=array[i]+ list[index][i]
        sumList(index+1,nextArray)



if __name__ == '__main__':
    n,m,x = map(int, input().split())

    list = []
    for i in range(n):
        a = [int(i) for i in input().split()]
        list.append(a)
    firstArray = [0] * (m + 1)
    sumArray = []
    sumList(0,firstArray)

    min = 100000000
    for i in sumArray:
        amount =0
        count =0
        for j in range(len(i)):
            if j == 0:
                amount =i[j]
            else:
                if i[j] >=x:
                    count+=1
        if count == m and min >= amount:
            min = amount

    if min == 100000000:
        print(-1)
    else:
        print(min)
Buggy code:
N, M , X = map(int, input().split())
C = [0 for i in range(N)]
A = [[]for i in range(N)]


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

def solve():
    ans = float('inf')
    # Total: O(2^N*N*M)
    total = 1 << N
    for mask in range(total):  #O(2^N)
        L = [0 for i in range(M)]
        cost = 0
        
        for i in range(N):  #O(N)
            if (mask >> i) & 1:
                cost += C[i]
                for j in range(M): #O(M)
                    L[j] += A[i][j]
            
        ok = True
        for i in range(M):
            if L[i] < X: 
                ok = False
        print(L, cost, ok)
        if ok:
            ans = min(ans,cost)

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


Fixed code:
N, M , X = map(int, input().split())
C = [0 for i in range(N)]
A = [[]for i in range(N)]


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

def solve():
    ans = float('inf')
    # Total: O(2^N*N*M)
    total = 1 << N
    for mask in range(total):  #O(2^N)
        L = [0 for i in range(M)]
        cost = 0
        
        for i in range(N):  #O(N)
            if (mask >> i) & 1:
                cost += C[i]
                for j in range(M): #O(M)
                    L[j] += A[i][j]
            
        ok = True
        for i in range(M):
            if L[i] < X: 
                ok = False
        #print(L, cost, ok)
        if ok:
            ans = min(ans,cost)

    if ans == float('inf'):
        print(-1)
    else:
        print(ans)
solve()
Buggy code:
N, M, X = map(int, input().split())

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

INF = 10**9
ans = INF
for s in range(0, 1 << N):
    smart = [0] * M
    cost_sum = 0
    for i in range(N):
        if (s >> i) % 2 == 0:continue
        cost_sum += c[i]
        for j in range(M):
            smart[j] += A[i][j]
    ok = True
    for i in range(N):
        if smart[i] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)

print(ans)


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

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

INF = 10**9
ans = INF
for s in range(0, 1 << N):
    smart = [0] * M
    cost_sum = 0
    for i in range(N):
        if (s >> i) % 2 == 0:
            continue
        cost_sum += C[i]
        for j in range(M):
            smart[j] += A[i][j]
    ok = True
    for j in range(M):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)
if ans == INF:
    ans = -1
print(ans)
Buggy code:
n,m,x=map(int,input().split())
clis=[]
alis=[]
for _ in range(n):
  tu=list(map(int,input().split()))
  clis.append(tu[0])
  alis.append(tu[1:])


ma_c=[]
for i in range(2**n):
  bag=[]
  price=0
  for j in range(n):
    if ((i>>j)&1):
      price+=clis[j]
      bag.append(alis[j])
  pac=[0]*m
  for t in range(len(bag)):
    for k in range(m):
        pac[k]+=bag[t][k]
  if all([pac[t]>=x for t in range(m)]):
    ma_c.append(price)

print(min(ma_c))

Fixed code:
n,m,x=map(int,input().split())
clis=[]
alis=[]
for _ in range(n):
  tu=list(map(int,input().split()))
  clis.append(tu[0])
  alis.append(tu[1:])


ma_c=[]
for i in range(2**n):
  bag=[]
  price=0
  for j in range(n):
    if ((i>>j)&1):
      price+=clis[j]
      bag.append(alis[j])
  pac=[0]*m
  for t in range(len(bag)):
    for k in range(m):
        pac[k]+=bag[t][k]
  if all([pac[t]>=x for t in range(m)]):
    ma_c.append(price)


if len(ma_c)!=0:
  print(min(ma_c))
else:
  print(-1)
Buggy code:
n,m,x = map(int, input().split())
result = 10**9
for _ in range(n):
	books=list(map(int, input().split()))
	A = A.append(books[0])
	C = C.append(books[1:])
for i in range(1<<n):
	cnt = 0
	rikaido = [0]*m
	for j in range(n):
		if (i<<j)&1:
			for k in range(m):
				rikaido[k]+=C[j][k]
			cnt += A[j]
		else:
			pass
	if min(rikaido)>=x:
		result = min(result, cnt)
if result == 10*9:
	print(-1)
else:
	print(result)

Fixed code:
n,m,x = map(int, input().split())
inf = 10**9
result = inf
A=[]
C=[]
for _ in range(n):
	books=list(map(int, input().split()))
	C.append(books[0])
	A.append(books[1:])
for i in range(1<<n):
	cnt = 0
	rikaido = [0]*m
	for j in range(n):
		if (i>>j)&1:
			for k in range(m):
				rikaido[k]+=A[j][k]
			cnt += C[j]
		else:
			pass
	if min(rikaido)>=x:
		result = min(result, cnt)
if result == inf:
	print(-1)
else:
	print(result)
Buggy code:
def resolve():
    N,M,X = map(int,input().split())
    CA = [list(map(int,input().split())) for i in range(N)]
    mxc = float('inf')
    for r in range(N+1):
        for cmb in itt.combinations(CA,r):
            cost = 0
            tbl = [0]*M
            for x in cmb:
                cost+=x[0]
                for i in range(M):
                    tbl[i]+= x[i+1]

            for i in tbl:
                if i < X:
                    break
            else:
                mxc = min(cost,mxc)
                
    if mxc == float('inf'):
        print(-1)
    else:
        print(mxc)



if __name__ == "__main__":
    resolve()

Fixed code:
import itertools as itt
def resolve():
    N,M,X = map(int,input().split())
    CA = [list(map(int,input().split())) for i in range(N)]
    mxc = float('inf')
    for r in range(N+1):
        for cmb in itt.combinations(CA,r):
            cost = 0
            tbl = [0]*M
            for x in cmb:
                cost+=x[0]
                for i in range(M):
                    tbl[i]+= x[i+1]

            for i in tbl:
                if i < X:
                    break
            else:
                mxc = min(cost,mxc)
                
    if mxc == float('inf'):
        print(-1)
    else:
        print(mxc)



if __name__ == "__main__":
    resolve()
Buggy code:
import numpy as np
n, M, X = list(map(int, input().split()))
CA = []
A = []
for _ in range(N):
    L = list(map(int, input().split()))
    CA.append(L[:])
ans = np.zeros(M+1)
S = [0]*n
ANS = list()
def makeCombination():
    for i in range(0, n-1):
        S[i] = 0
    rec(0, ans)
def rec(i,ans):
    if i == n:
        #print(S)
        print(ans)
        print(ans[1:] >= X)
        if all(ans[1:] >= X) == True:
            ANS.append(ans[0])
        return
    rec(i + 1,ans)
    S[i] = 1
    ans = ans   + np.array(CA[i])
    rec(i + 1, ans)
    S[i] = 0
makeCombination()
ANS.sort()
if len(ANS) >= 1:
    print(ANS[0])
else:
    print(-1)

Fixed code:
import numpy as np
n, M, X = list(map(int, input().split()))
CA = []
A = []
for _ in range(n):
    L = list(map(int, input().split()))
    CA.append(L[:])
    
ans = np.zeros(M+1)
S = [0]*n
ANS = list()
def makeCombination():
    for i in range(0, n-1):
        S[i] = 0
    rec(0, ans)
def rec(i,ans):
    if i == n:
        if all(ans[1:] >= X) == True:
            ANS.append(ans[0])
        return
    rec(i + 1,ans)
    S[i] = 1
    ans = ans   + np.array(CA[i])
    rec(i + 1, ans)
    S[i] = 0
makeCombination()
ANS.sort()
if len(ANS) >= 1:
    print(int(ANS[0]))
else:
    print(-1)
Buggy code:
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()
# cost, value
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**6:
    print(-1)
else:
    print(min_cost)
    



Fixed code:
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()
# cost, value
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)
Buggy code:
import numpy as np
import itertools

Cmin = 10**10
N, M, X = map(int, input().split())
L = np.array([[int(j) for j in input().split()] for i in range(N)])
for i in range(N):
  for idx in itertools.combinations(list(range(N)), i+1):
    A = np.zeros(M+1, dtype=int)
    for j in idx:
      A = A + L[j]
    print(A)
    if A[0] < Cmin and (A[1:] >= X).all() == True:
      Cmin = A[0]
if Cmin == 10**10:
  print(-1)
  exit()
print(Cmin)

Fixed code:
import numpy as np
import itertools

Cmin = 10**10
N, M, X = map(int, input().split())
L = np.array([[int(j) for j in input().split()] for i in range(N)])
for i in range(N):
  for idx in itertools.combinations(list(range(N)), i+1):
    A = np.zeros(M+1, dtype=int)
    for j in idx:
      A = A + L[j]
    if A[0] < Cmin and (A[1:] >= X).all() == True:
      Cmin = A[0]
if Cmin == 10**10:
  print(-1)
  exit()
print(Cmin)
Buggy code:
n,m,x=map(int,input().split())
ans=999999999999999999
a=[0]*m
for i in range(n):
  a[i]=list(map(int,input().split()))
for i in range(2**n):
  t=[0]*m
  temp=0
  for j in range(n):
    if (i>>j)&1:
      temp=temp+a[j][0]
      for k in range(m):
        t[k]=t[k]+a[j][k+1]
  if min(t)>=x:
    ans=min(ans,temp)
print(ans)

Fixed code:
n,m,x=map(int,input().split())
ans=999999999999999999
a=[0]*n
for i in range(n):
  a[i]=list(map(int,input().split()))
for i in range(2**n):
  t=[0]*m
  temp=0
  for j in range(n):
    if (i>>j)&1:
      temp=temp+a[j][0]
      for k in range(m):
        t[k]=t[k]+a[j][k+1]
  if min(t)>=x:
    ans=min(ans,temp)
if ans==999999999999999999:
  print(-1)
else:
  print(ans)
Buggy code:
n,m,x=map(int,input().split())
a=[]
c=[]
inf=10**9
result=inf
for i in range(n):
    b=list(map(int,input().split()))
    c.append(b[0])
    a.append(b[1:])
    
for i in range(1<<n):
  cnt=0
  rikaido=[0]*m
  for j in range(n):
    if (i>>j)&1:
      for k in range(m):
        rikaido[k]+=a[j][k]
        cnt+=c[j]
    else:
      pass
  if min(rikaido)>=x:
    result=min(result,cnt)

if result==inf:
  print(-1)
else:
  print(result)

Fixed code:
n,m,x=map(int,input().split())
a=[]
c=[]
inf=10**9
result=inf
for _ in range(n):
    books=list(map(int,input().split()))
    c.append(books[0])
    a.append(books[1:])
    
for i in range(1<<n):
  cnt=0
  rikaido=[0]*m
  for j in range(n):
    if (i>>j)&1:
      for k in range(m):
        rikaido[k]+=a[j][k]
      cnt+=c[j]
    else:
      pass
  if min(rikaido)>=x:
    result=min(result,cnt)

if result==inf:
  print(-1)
else:
  print(result)
Buggy code:
import numpy as np
n,m,x=map(int,input().split())
c=[]
a=[]
ans=10**6
for x in range(n):
  line=list(map(int,input().split()))
  c.append(line[0])
  a.append(line[1:])
a=np.array(a)
for i in range(2**n):
  level=np.zeros(m)
  price=0
  for j in range(n):
    if ((i>>j)&1):
      level+=a[j]
      price+=c[j]
	for k in range(m):
      if np.amin(level)>=x and price<=ans:
        ans=price
if ans==10**6:
  print(-1)
else:
  print(ans)

Fixed code:
import numpy as np

n,m,x=map(int,input().split())
c=[]
a=[]
ans=10**8

for k in range(n):
  line=list(map(int,input().split()))
  c.append(line[0])
  a.append(line[1:])

a=np.array(a)


for i in range(2**n):
  level=np.zeros(m)
  price=0
  for j in range(n):
    if ((i>>j)&1):
      level+=a[j]
      price+=c[j]
  bottom=int(np.amin(level))
  if bottom>=x and price<ans:
    ans=price
if ans==10**8:
  print(-1)
else:
  print(ans)
Buggy code:
N, M, X = map(int, input().split(" "))
B_list = []


for Books in range(N):
    B_list.append(list(map(int, input().split(" "))))
# print(B_list)

bug = []
for k in range(M + 1):
    bug.append(0)
print(bug)
ways = []

for way in range(2**N):
    for book in range(N):
        if ((way >> book) & 1) == 1:
            for i in range(M + 1):
                bug[i] += B_list[book][i]

    # print(bug)
    clear = [l for l in bug if l >= X]
    print(clear)
    if len(bug) == len(clear):
        ways.append(bug[0])

    bug = []
    for k in range(M + 1):
        bug.append(0)

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


Fixed code:
N, M, X = map(int, input().split(" "))
B_list = []


for Books in range(N):
    B_list.append(list(map(int, input().split(" "))))
# print(B_list)

bug = []
for k in range(M + 1):
    bug.append(0)
# print(bug)
ways = []

for way in range(2**N):
    for book in range(N):
        if ((way >> book) & 1) == 1:
            for i in range(M + 1):
                bug[i] += B_list[book][i]

    # print(bug)
    O = bug.pop(0)
    clear = [l for l in bug if l >= X]
    # print(clear)

    if len(bug) == len(clear):
        ways.append(O)

    bug = []
    for k in range(M + 1):
        bug.append(0)

if len(ways) == 0:
    print(-1)
else:
    print(min(ways))
Buggy code:
a,b,import numpy as np
import itertools
n, m, x = map(int, input().split())
a = np.dot([i for i in itertools.product([0, 1], repeat = n)],
           [list(map(int, input().split())) for _ in range(n)])
b = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)
print(min(a[:, 0][b]) if b.sum() else '-1')


Fixed code:
import numpy as np
import itertools
n, m, x = map(int, input().split())
a = np.dot([i for i in itertools.product([0, 1], repeat = n)],
           [list(map(int, input().split())) for _ in range(n)])
b = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)
print(min(a[:, 0][b]) if b.sum() else '-1')
Buggy code:
n,m,x=map(int,input().split())
ar=[list(map(int,input().split())) for i in range(n)]
cost=1e9
p=pow(2,n)
for i in range(1,p):
    temp=[0 for y in range(m+1)]
    pt=bin(i)[2:].zfill(n)
    for j in range(n):
        if pt[j]=='1':
            for k in range(m+1):
                temp[k]+=ar[j][k]
    z=1
    for j in temp:
        if j<x: z=0
    if z: cost=min(temp[0],cost)
if cost==1e7: print(-1)
else: print(cost)
        
            


Fixed code:
n,m,x=map(int,input().split())
ar=[list(map(int,input().split())) for i in range(n)]
cost=1e9
p=pow(2,n)
for i in range(p):
    temp=[0 for y in range(m+1)]
    pt=bin(i)[2:].zfill(n)
    for j in range(n):
        if pt[j]=='1':
            for k in range(m+1):
                temp[k]+=ar[j][k]
    z=1
    for j in range(1,m+1):
        if temp[j]<x: z=0
    if z: cost=min(temp[0],cost)
if cost==1e9: print(-1)
else: print(cost)
Buggy code:
import itertools

def main():

    n,m,x = map(int,input().split())
    C = []
    A = []
    for i in range(n):
        array = list(map(int,input().split()))
        C.append(array[0])
        A.append(array[1:])
    cost = 10**6
    for i in range(1,n+1):
        combs = itertools.combinations(range(n), i)
        for comb in combs:
            skill = [0]*m
            cost_tmp = 0
            for e in comb:
                # print(comb)
                cost_tmp += C[e]
                for j in range(m):
                    skill[j] += A[e][j]
            for j in range(m):
                if skill[j] < x:
                    break
                if j == m-1:
                    print(cost_tmp, skill)
                    cost = min(cost, cost_tmp)
    if cost == 10**6:
        print(-1)
        return
    print(cost)


if __name__ == '__main__':
    main()


Fixed code:
import itertools

def main():

    n,m,x = map(int,input().split())
    C = []
    A = []
    for i in range(n):
        array = list(map(int,input().split()))
        C.append(array[0])
        A.append(array[1:])
    cost = 10**10
    for i in range(1,n+1):
        combs = itertools.combinations(range(n), i)
        for comb in combs:
            skill = [0]*m
            cost_tmp = 0
            for e in comb:
                cost_tmp += C[e]
                for j in range(m):
                    skill[j] += A[e][j]
            for j in range(m):
                if skill[j] < x:
                    break
                if j == m-1:
                    cost = min(cost, cost_tmp)
    if cost == 10**10:
        print(-1)
        return
    print(cost)


if __name__ == '__main__':
    main()
Buggy code:
n, m, x = map(int, input().split())
books = []
book_total_price = []
for _ in range(n):
    book = list(map(int, input().split()))
    books.append(book)

for i in range(n**2 - 1):
    reference_book = []
    book_price = 0
    for j in range(n):
        if (i >> j) & 1:
            reference_book.append(books[j])
            book_price += books[j][0]
    print(reference_book)
    err = 0
    for k in range(1, m+1):
        r = [row[k] for row in reference_book]
        if sum(r) < x:
            err += 1
    if err == 0:
        book_total_price.append(book_price)
if book_total_price == []:
    print('-1')
else:
    print(min(book_total_price))

Fixed code:
n, m, x = map(int, input().split())
books = []
book_total_price = []
for _ in range(n):
    book = list(map(int, input().split()))
    books.append(book)
 
for i in range(2**n):
    reference_book = []
    book_price = 0
    for j in range(n):
        if (i >> j) & 1:
            reference_book.append(books[j])
            book_price += books[j][0]
    err = 0
    for k in range(1, m+1):
        r = [row[k] for row in reference_book]
        if sum(r) < x:
            err += 1
    if err == 0:
        book_total_price.append(book_price)
if book_total_price == []:
    print('-1')
else:
    print(min(book_total_price))
Buggy code:
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)
    print(cost, us, cost_list)

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


Fixed code:
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))
Buggy code:
import itertools

N,M,X=map(int, input().split())
data=[]
ans=999999999
b=[]
b_pairs=[]
for i in range(N):
    b.append(i)
for i in range(N):
    data.append(list(map(int, input().split())))

for i in range(2,N+1):
    b_pairs+=itertools.combinations(b,i)

for i in range(N):
    flag=1
    skill=[0]*M
    for j in range(M):
        skill[j]+=data[i][j+1]
    for j in range(M):
        if skill[j]<X:
            flag=0
    if flag==1:
        ans=min(ans,data[i][0])

for i in range(len(b_pairs)):
    skill=[0]*M
    sum=0
    flag=1
    for k in range(len(b_pairs[i])):
        sum+=data[b_pairs[i][k]][0]
        for j in range(1,M+1):
            skill[j-1]+=data[b_pairs[i][k]][j]
    for h in range(M):
        if skill[h]<X:
            flag=0
    print(flag)
    if flag==1:
        ans=min(ans,sum)

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

Fixed code:
import itertools

N,M,X=map(int, input().split())
data=[]
ans=999999999
b=[]
b_pairs=[]
for i in range(N):
    b.append(i)
for i in range(N):
    data.append(list(map(int, input().split())))

for i in range(2,N+1):
    b_pairs+=itertools.combinations(b,i)

for i in range(N):
    flag=1
    skill=[0]*M
    for j in range(M):
        skill[j]+=data[i][j+1]
    for j in range(M):
        if skill[j]<X:
            flag=0
    if flag==1:
        ans=min(ans,data[i][0])

for i in range(len(b_pairs)):
    skill=[0]*M
    sum=0
    flag=1
    for k in range(len(b_pairs[i])):
        sum+=data[b_pairs[i][k]][0]
        for j in range(1,M+1):
            skill[j-1]+=data[b_pairs[i][k]][j]
    for h in range(M):
        if skill[h]<X:
            flag=0
    if flag==1:
        ans=min(ans,sum)

if ans==999999999:
    ans=-1
print(ans)
Buggy code:
import itertools

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

p_list = list(itertools.product([0,1], repeat=N))
#print((p_list))
cost_min = 10**9
for p in p_list:
  #p = list(p)
  und=[0]*M
  cost = 0
  for i in range(N):
    if p[i]==1:
      cost += tex[i][0]
      for j in range(M):
        und[j]+=tex[i][j+1]
  #print(und)
  f=True
  for k in range(M):
    if und[k]<X:
      f=False
      break
  if f and cost_min>cost:
    cost_min = cost
print(cost_min)

Fixed code:
import itertools

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

p_list = list(itertools.product([0,1], repeat=N))
#print((p_list))
cost_min = 10**9
for p in p_list:
  #p = list(p)
  und=[0]*M
  cost = 0
  for i in range(N):
    if p[i]==1:
      cost += tex[i][0]
      for j in range(M):
        und[j]+=tex[i][j+1]
  #print(und)
  f=True
  for k in range(M):
    if und[k]<X:
      f=False
      break
  if f and cost_min>cost:
    cost_min = cost
    
if cost_min==10**9:
  print(-1)
else:
  print(cost_min)