qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,M,X = map(int,input().split())
d=[]
ans = []
for i in range(N):
    l=list(map(int,input().split()))
    d.append(l)
print(d)
for i in range(2**N):
    u=[0]*M
    price=0
    for j in range(N):
           if ((i>>j) & 1):
                price+=d[j][0]
                for k in range(M):
                    u[k]+=d[j][k+1]
    if all(x>=X for x in u):
        ans.append(price)
print(min(ans) if len(ans) > 0 else -1) 

Fixed code:
N,M,X = map(int,input().split())
d=[]
ans = []
for i in range(N):
    l=list(map(int,input().split()))
    d.append(l)
for i in range(2**N):
    u=[0]*M
    price=0
    for j in range(N):
           if ((i>>j) & 1):
                price+=d[j][0]
                for k in range(M):
                    u[k]+=d[j][k+1]
    if all(x>=X for x in u):
        ans.append(price)
print(min(ans) if len(ans) > 0 else -1)
Buggy code:
import numpy as np
n,m,x=map(int,input().split())
flg=np.zeros((m+1),dtype=int)
minimn=-1
data=np.zeros((n,m+1))
for i in range(n):
    data[i]=list(map(int,input().split()))
for i in range(2**n):
    flg=np.zeros((m+1))
    for j in range(n):
        if (i>>j)&1:
            flg+=data[j]
    if all(flg[1:]>=x):
        if minimn==-1:
          minimn=flg[0]
        elif flg[0]<minimn:
          minimn=flg[0]
print(minimn)

Fixed code:
import numpy as np
n,m,x=map(int,input().split())
flg=np.zeros((m+1),dtype=int)
minimn=-1
data=np.zeros((n,m+1))
for i in range(n):
    data[i]=list(map(int,input().split()))
for i in range(2**n):
    flg=np.zeros((m+1))
    for j in range(n):
        if (i>>j)&1:
            flg+=data[j]
    if all(flg[1:]>=x):
        if minimn==-1:
          minimn=flg[0]
        elif flg[0]<minimn:
          minimn=flg[0]
print(int(minimn))
Buggy code:
N, M, X = list(map(int, input().split()))
CA = [list(map(int, input().split())) for i in range(N)]

set_list = []
for i in range(2 ** N):
    select = []
    for j in range(N):
        if ((i >> j) & 1):
            select.append(j)
    if len(select) != 0:
        set_list.append(select)
    
cost = []
for i in range(2 ** N - 1):
    cost.append(sum([CA[set_list[i][j]][0] for j in range(len(set_list[i]))]))

skill = []
for i in range(2 ** N - 1):
    tmp = [0]*M
    for j in set_list[i]:
        for k in range(M):
            tmp[k] += CA[j][k+1]
    skill.append(tmp)

pool = []
for i in range(2**N - 1):
    flag = 0
    for j in skill[i]:
        if j < X:
            flag = 1
    if flag == 0:
        pool.append(cost[i])
        

print(min(pool))


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

set_list = []
for i in range(2 ** N):
    select = []
    for j in range(N):
        if ((i >> j) & 1):
            select.append(j)
    if len(select) != 0:
        set_list.append(select)
    
cost = []
for i in range(2 ** N - 1):
    cost.append(sum([CA[set_list[i][j]][0] for j in range(len(set_list[i]))]))

skill = []
for i in range(2 ** N - 1):
    tmp = [0]*M
    for j in set_list[i]:
        for k in range(M):
            tmp[k] += CA[j][k+1]
    skill.append(tmp)

pool = []
for i in range(2**N - 1):
    flag = 0
    for j in skill[i]:
        if j < X:
            flag = 1
    if flag == 0:
        pool.append(cost[i])
        

if len(pool) == 0:
	print(-1)
else:
    print(min(pool))
Buggy code:
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:M+1])
import itertools
L = []
Num = [i for i in range(N)]
for i in range(1,N+1):
    for j in itertools.combinations(Num,i):
        L.append(list(j))
c = 20000000
for i in range(len(L)):
    Z = [0 for _ in range(M)]
    m = 0
    for j in range(len(L[i])):
        for k in range(M):
            Z[k] += A[L[i][j]][k]
        m += C[L[i][j]]
    for l in range(M):
        if Z[l] < X:
            break
        if l == M-1:
            c = min(c,m)
if c == 200000:
    print(-1)
else:
    print(c)

Fixed code:
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:M+1])
import itertools
L = []
Num = [i for i in range(N)]
for i in range(1,N+1):
    for j in itertools.combinations(Num,i):
        L.append(list(j))
c = 20000000
for i in range(len(L)):
    Z = [0 for _ in range(M)]
    m = 0
    for j in range(len(L[i])):
        for k in range(M):
            Z[k] += A[L[i][j]][k]
        m += C[L[i][j]]
    for l in range(M):
        if Z[l] < X:
            break
        if l == M-1:
            c = min(c,m)
if c == 20000000:
    print(-1)
else:
    print(c)
Buggy code:
N, M, X = map(int, input().split())
C = [0] * N
A = []

for __ in range(N):
    nums = list(map(int, input().split()))
    C[__] = nums[0]
    A.append(nums[1:])
mincost = 10e9
ok = False
for i in range(1 << N):
    cost = 0
    skill = [0] * M

    for u in range(N):
        if i & (1<<u):
            cost += C[u]
            for si, s in enumerate(A[u]):
                skill[si] += s
    
    # check
    if all([s >= X for s in skill]):
        ok = True
        if mincost > cost:
            mincost = cost

print(mincost if ok else -1)
 dp


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

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

mincost = 10e9
ok = False
for i in range(1 << N):
    cost = 0
    skill = [0] * M

    for u in range(N):
        if i & (1<<u):
            cost += C[u]
            for si, s in enumerate(A[u]):
                skill[si] += s
    
    # check
    if all([s >= X for s in skill]):
        ok = True
        if mincost > cost:
            mincost = cost

print(mincost if ok else -1)
Buggy code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m,x=map(int,input().split())
A=[[int(i) for i in input().split()] for _ in range(n)]
ans=float("inf")
for i in range(2**n):
  B=[0]*(m+1)
  for j in range(n):
    if i&(1<<j):
      for k in range(m+1):
        B[k]+=A[j][k]
  if min(B[1:])>=x:
    ans=min(ans,B[0])
print(ans)


Fixed code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m,x=map(int,input().split())
A=[[int(i) for i in input().split()] for _ in range(n)]
ans=float("inf")
for i in range(2**n):
  B=[0]*(m+1)
  for j in range(n):
    if i&(1<<j):
      for k in range(m+1):
        B[k]+=A[j][k]
  if min(B[1:])>=x:
    ans=min(ans,B[0])
print(-1 if ans==float("inf") else ans)
Buggy code:
number=list(map(int,input().split()))
n,m,x=number[0],number[1],number[2]
books=[list(map(int,input().split())) for i in range(n)]
U=[x for i in range(m+1)]
U[0]=0
pattern=[]
answer=[]


for i in range(2**n):
    tmp=[False]*n
    for j in range(n):
        if (i>>j)&1:
            tmp[j]=True
    
    pattern.append(tmp)

for i in range(2**n):
    cost=0
    U=[x for i in range(m+1)]
    U[0]=0
    for j in range(n):
        if pattern[i][j]==True:
            cost+=books[j][0]
            for k in range(1,m+1):
                U[k]-=books[j][k]
                if max(U)==0:
                    answer.append(cost)
                    break
                    
print(min(answer))
                

Fixed code:
number=list(map(int,input().split()))
n,m,x=number[0],number[1],number[2]
books=[list(map(int,input().split())) for i in range(n)]
U=[x for i in range(m+1)]
U[0]=0
pattern=[]
answer=[]


for i in range(2**n):
    tmp=[False]*n
    for j in range(n):
        if (i>>j)&1:
            tmp[j]=True
    
    pattern.append(tmp)

for i in range(2**n):
    cost=0
    U=[x for i in range(m+1)]
    U[0]=0
    for j in range(n):
        if pattern[i][j]==True:
            cost+=books[j][0]
            for k in range(1,m+1):
                U[k]-=books[j][k]
                if max(U)==0:
                    answer.append(cost)
                    break
                    
if answer==[]:
    print(-1)
else:
    print(min(answer))
Buggy code:
n, m, x = map(int, input().split())
C = [0] * n
A = [[] for i in range(n)]
for i in range(n):
    c = list(map(int, input().split()))
    C[i], A[i] = c[0], c[1:]

INF = 10 ** 9
ans = INF

for bit in range(0, 1 << n):
    cost = 0
    flag = True
    tmp = [0] * m
    for i in range(n):
        if bit & 1 << i:
            cost += C[i]
            for j in range(m):
                tmp[j] += A[i][j]
    for i in range(n):
        if tmp[i] < x:
            flag = False
    if flag:
        ans = min(ans, cost)

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

Fixed code:
n, m, x = map(int, input().split())
C = [0] * n
A = [[] for i in range(n)]
for i in range(n):
    c = list(map(int, input().split()))
    C[i], A[i] = c[0], c[1:]

INF = 10 ** 9
ans = INF

for bit in range(0, 1 << n):
    cost = 0
    flag = True
    tmp = [0] * m
    for i in range(n):
        if bit & 1 << i:
            cost += C[i]
            for j in range(m):
                tmp[j] += A[i][j]
    for i in range(m):
        if tmp[i] < x:
            flag = False
    if flag:
        ans = min(ans, cost)

print(-1 if ans == INF else ans)
Buggy code:
N,M,X = map(int,input().split())
C = [0]*N
A = [[0] for _ in range(N)]
for i in range(N):
    tmp = list(map(int,input().split()))
    C[i] = tmp[0]
    A[i] = tmp[1:M+1]
f = False
money_min = 100000000000
for i in range(1,2**N):
    use = format(i,"0{}b".format(N))
    print(use)
    money = 0
    understand = [0]*M
    for j in range(N):
        if use[j] == "1":
            money += C[j]
            for k in range(M):
                understand[k] += A[j][k]
    if min(understand) >= X and money < money_min:
        money_min = money
        f = True

if f:
    print(money_min)
else:
    print(-1)









Fixed code:
N,M,X = map(int,input().split())
C = [0]*N
A = [[0] for _ in range(N)]
for i in range(N):
    tmp = list(map(int,input().split()))
    C[i] = tmp[0]
    A[i] = tmp[1:M+1]
f = False
money_min = 100000000000
for i in range(1,2**N):
    use = format(i,"0{}b".format(N))
    money = 0
    understand = [0]*M
    for j in range(N):
        if use[j] == "1":
            money += C[j]
            for k in range(M):
                understand[k] += A[j][k]
    if min(understand) >= X and money < money_min:
        money_min = money
        f = True

if f:
    print(money_min)
else:
    print(-1)
Buggy code:
import itertools
import sys

n, m, x = map(int, input().split())
num = list(list(map(int, input().split())) for i in range(n))

s = [i for i in range(m)]
t = []
list_num = []

for i in range(m):
  t.append(list(map(list, itertools.combinations(s, i + 1))))

for i in t:
  for j in i:
    k = [0] * (m + 1)
    for z in j:
      k = tuple(x + y for (x,y) in zip(k, num[z]))
    list_num.append(k)


list_num = list(sorted(list_num, key =lambda w : w[0]))
q = []

flag2 = 0

for i in list_num:
  flag = 1
  for j in range(1, m + 1):
    if(i[j] < x):
      flag = 0
  if(flag == 1):
    q.append(i[0])
    flag2 = 1

if(flag2 == 1):
  print(min(q))
else: 
  print(-1)   


Fixed code:
import itertools
import sys

n, m, x = map(int, input().split())
num = list(list(map(int, input().split())) for i in range(n))

s = [i for i in range(n)]
t = []
list_num = []

for i in range(n):
  t.append(list(map(list, itertools.combinations(s, i + 1))))


for i in t:
  for j in i:
    k = [0] * (m + 1)
    for z in j:
      k = tuple(x + y for (x,y) in zip(k, num[z]))
    list_num.append(k)


list_num = list(sorted(list_num, key =lambda w : w[0]))
q = []

flag2 = 0

for i in list_num:
  flag = 1
  for j in range(1, m + 1):
    if(i[j] < x):
      flag = 0
  if(flag == 1):
    q.append(i[0])
    flag2 = 1

if(flag2 == 1):
  print(min(q))
else: 
  print(-1)
Buggy code:
N, M, X = map(int, input().split())
CA = [0]*N
for i in range(N):
    CA[i] = list(map(int, input().split()))
print(CA)

INF = 10**7
ans = INF
for t in range(2**N):
    tmp = 0
    check = [X]*M
    for i in range(N):
        if (t >> i) & 1 == 1:
            tmp += CA[i][0]
            for j in range(M):
                check[j] -= CA[i][j+1]
    for ch in check:
        if ch > 0:
            break
    else:
        if tmp < ans:
            ans = tmp

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


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

INF = 10**7
ans = INF
for t in range(2**N):
    tmp = 0
    check = [X]*M
    for i in range(N):
        if (t >> i) & 1 == 1:
            tmp += CA[i][0]
            for j in range(M):
                check[j] -= CA[i][j+1]
    for ch in check:
        if ch > 0:
            break
    else:
        if tmp < ans:
            ans = tmp

if ans == INF:
    print(-1)
else:
    print(ans)
Buggy code:
n,m,x=map(int,input().split())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
cursor=n
current=[0]*n
mincost=1000000000000000000000
breakflag=0
while True:
  thing=[0]*m
  cost=0
  for i in range(n):
    if current[i]==1:
      cost+=a[i][0]
      for j in range(m):
        thing[j]+=a[i][j+1]
  success=1
  for j in range(m):
    if thing[j]<x:
      success=0
  if success==1 and cost<mincost:
    mincost=cost
  while True:
    if current[cursor-1]<1:
      current[cursor-1]+=1
      for i in range(cursor,n):
        current[i]=0
      cursor=n
      break
    cursor-=1
    if cursor==0:
      breakflag=1
      break    
  if breakflag==1:
    break
print(mincost)

Fixed code:
n,m,x=map(int,input().split())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
cursor=n
current=[0]*n
mincost=1000000000000000000000
breakflag=0
while True:
  thing=[0]*m
  cost=0
  for i in range(n):
    if current[i]==1:
      cost+=a[i][0]
      for j in range(m):
        thing[j]+=a[i][j+1]
  success=1
  for j in range(m):
    if thing[j]<x:
      success=0
  if success==1 and cost<mincost:
    mincost=cost
  while True:
    if current[cursor-1]<1:
      current[cursor-1]+=1
      for i in range(cursor,n):
        current[i]=0
      cursor=n
      break
    cursor-=1
    if cursor==0:
      breakflag=1
      break    
  if breakflag==1:
    break
if mincost==1000000000000000000000:
  print(-1)
else:
  print(mincost)
Buggy code:
import numpy as np
n,m,x = map(int,input().split())
info = []
for i in range(n):
    info.append(list(map(int,input().split())))
info = np.array(info)

money = np.sum(info, axis = 0)[0]
flag = 0
for i in range(2**n):
    tem = np.zeros(m+1)
    for j in range(n):
        if ((i >> j) & 1):
            tem += info[j]

    non = np.any(tem[1:] < x)
    if non == False:
        flag = 1
        if tem[0] < money:
            money = tem[0]

if flag == 0:
    print(-1)
else:
    print(money)

Fixed code:
import numpy as np
n,m,x = map(int,input().split())
info = []
for i in range(n):
    info.append(list(map(int,input().split())))
info = np.array(info)


money = np.sum(info, axis = 0)[0]
flag = 0
for i in range(2**n):
    tem = np.zeros(m+1, dtype = int)
    for j in range(n):
        if ((i >> j) & 1):
            tem += info[j]
    skill = tem[1:]
    non = np.all(skill >= x)
    if non:
        flag = 1
        if tem[0] < money:
            money = tem[0]

if flag == 0:
    print(-1)
else:
    print(money)
Buggy code:
from itertools import product
from itertools import combinations
import numpy as np

def resolve():
  N, M, X = map(int, input().split(" "))

  books = []
  for i in range(N):
    CA = [int(x) for x in input().split(" ")]
    books.append(CA)

  books = np.array(books).reshape([N, M + 1])

  books_index_pattarns = [list(x) for i in range(1, N) for x in combinations(range(0, N), i)]
  books_result = np.array([np.sum(books[x], axis=0) for x in books_index_pattarns])
  books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)]
  # books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)][:,:1]

  if len(books_result) == 0:
    print(-1)
    return True
  elif len(books_result) == 1:
    print(books_result[0])
    return True
  else:
    print(books_result[:,:1].min())
    return True

if __name__ == "__main__":
    resolve()

Fixed code:
from itertools import product
from itertools import combinations
import numpy as np

def resolve():
  N, M, X = map(int, input().split(" "))

  books = []
  for i in range(N):
    CA = [int(x) for x in input().split(" ")]
    books.append(CA)

  books = np.array(books)


  if N == 1:
    if np.all(books[:, 1:] >= X):
      print(books[0][0])
    else:
      print(-1)
    return True
  books_index_pattarns = [list(x) for i in range(1, N+1) for x in combinations(range(0, N), i)]
  books_result = np.array([np.sum(books[x], axis=0) for x in books_index_pattarns])
  books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)]

  if len(books_result) == 0:
    print(-1)
    return True
  elif len(books_result) == 1:
    print(books_result[0][0])
    return True
  else:
    # print(books_result)
    print(books_result[:,:1].min())
    return True

if __name__ == "__main__":
    resolve()
Buggy code:
import numpy as np
from itertools import combinations

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

ans = 10 ** 9
for i in range(1, n+1):
    combination = combinations(range(n), i)
    for comb in combination:
        init = np.zeros(m+1)
        for ind in list(comb):
            init = init + np.array(lis[ind])
        if np.amin(init) >= x:
            ans = min(ans,init[0])
    if ans < 10**9:
      print(int(ans))
      exit()
      
print(-1,-1,-1)


Fixed code:
import numpy as np
from itertools import combinations

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

ans = 10 ** 9
for i in range(1, n+1):
    combination = combinations(range(n), i)
    for comb in combination:
        init = np.zeros(m+1)
        for ind in list(comb):
            init = init + np.array(lis[ind])
        if np.amin(init[1:]) >= x:
            ans = min(ans, init[0])
if ans < 10**9:
    print(int(ans))
else:
    print(-1)
Buggy code:
M,N,X=map(int,input().split())
C=[list(map(int,input().split())) for i in range(N)]
INF=float("inf")
ans=INF

for i in range(1,2**N):
    skills=[0]*M
    total_cost=0
    for j in range(N):
        if ((i>>j)&1):
            total_cost+=C[j][0]
            for k in range(M):
                skills[k]+=C[j][k+1]
    if min(skills)>=X:
        ans=min(ans,total_cost)
        
print(ans if ans != INF else -1)

Fixed code:
N,M,X=map(int,input().split())
C=[list(map(int,input().split())) for i in range(N)]
INF=float("inf")
ans=INF

for i in range(1,2**N):
    skills=[0]*M
    total_cost=0
    for j in range(N):
        if ((i>>j)&1):
            total_cost+=C[j][0]
            for k in range(M):
                skills[k]+=C[j][k+1]
    if min(skills)>=X:
        ans=min(ans,total_cost)
        
print(ans if ans != INF else -1)
Buggy code:
# C
# Skill Up

import itertools
import numpy as np

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

data_tensor = np.empty((n,m))
c_list = np.empty((n,1))

ans = 100000000
flag = True

for i in range(n):
    _list = list(map(int, input().split()))
    c_list[i], data_tensor[i] = _list[0], _list[1:]
    
buy_tensor = itertools.combinations_with_replacement([0,1],n)

for _list in buy_tensor:
    _list_np = np.array(_list)
    _list_np = _list_np.reshape(-1,1)
    _sum_list = np.sum(data_tensor * _list_np, axis=0)
    if np.min(_sum_list) >= x:
        _ans = np.sum(c_list * _list_np)
        if _ans < ans:
            ans = int(_ans)
            flag = False
        
if flag:
    ans = -1

print(ans)

Fixed code:
# C
# Skill Up

import itertools
import numpy as np

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

data_tensor = np.empty((n,m))
c_list = np.empty((n,1))

ans = 100000000
flag = True

for i in range(n):
    _list = list(map(int, input().split()))
    c_list[i], data_tensor[i] = _list[0], _list[1:]
    
buy_tensor = itertools.product([0,1],repeat=n)

for _list in buy_tensor:
    _list_np = np.array(_list)
    _list_np = _list_np.reshape(-1,1)
    _sum_list = np.sum(data_tensor * _list_np, axis=0)
    if np.min(_sum_list) >= x:
        _ans = np.sum(c_list * _list_np)
        if _ans < ans:
            ans = int(_ans)
            flag = False
        
if flag:
    ans = -1

print(ans)
Buggy code:
def main():
  import itertools
  from sys import stdin
  N, M, X = map(int, input().split())
  s_list = [list(map(int, stdin.readline().split())) for _ in range(N)]
  nums = [0, 1]
  min_cos = 10 ** 10
  for balls in itertools.product(nums, repeat=N):
    cos = 0
    score = [0] * M
    v = list(balls)
    for i in range(N):
      if v[i] == 1:
        cos += s_list[i][0]
        score = [x + y for (x, y) in zip(score, s_list[i][1:])]
    if min(score) >= X and cos < min_cos:
      min_cos = cos
  print(min_cos)
  
main()
        
        
    

Fixed code:
def main():
  import itertools
  from sys import stdin
  N, M, X = map(int, input().split())
  s_list = [list(map(int, stdin.readline().split())) for _ in range(N)]
  nums = [0, 1]
  min_cos = 10 ** 10
  for balls in itertools.product(nums, repeat=N):
    cos = 0
    score = [0] * M
    v = list(balls)
    for i in range(N):
      if v[i] == 1:
        cos += s_list[i][0]
        score = [x + y for (x, y) in zip(score, s_list[i][1:])]
    if min(score) >= X and cos < min_cos:
      min_cos = cos
  if min_cos == 10 ** 10:
    print(-1)
  else:
    print(min_cos)
    
  
main()
Buggy code:
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(n)]
result=-1
for i in range(2**n):
  t=[0]*m
  money=0
  for j in range(n):
    if (i>>j)&1==0:
      continue
    money+=c[j][0]
    for k in range(1,m):
      t[k]+=c[j][k]
  if all(xx>=x for xx in t):
    if result==-1:
      result=money
    else:
      result=min(result,money)
print(result)

Fixed code:
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(n)]
result=-1
for i in range(2**n):
  t=[0]*m
  money=0
  for j in range(n):
    if (i>>j)&1==0:
      continue
    money+=c[j][0]
    for k in range(1,m+1):
      t[k-1]+=c[j][k]
  if all(xx>=x for xx in t):
    if result==-1:
      result=money
    else:
      result=min(result,money)
print(result)
Buggy code:
from itertools import product

N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float("inf")

for now in product(range(2), N):
    res = 0
    An = [0 for _ in range(M)]
    for n in range(N):
        if now[n] == 1:
            res += A[n][0]
            An = [An[j] + A[n][j+1] for j in range(M)]
    if min(An) >= X:
        ans = min(ans, res)

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


Fixed code:
from itertools import product

N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float("inf")

for now in product(range(2), repeat=N):
    res = 0
    An = [0 for _ in range(M)]
    for n in range(N):
        if now[n] == 1:
            res += A[n][0]
            An = [An[j] + A[n][j+1] for j in range(M)]
    if min(An) >= X:
        ans = min(ans, res)

if ans == float("inf"):
    print(-1)
else:
    print(ans)
Buggy code:
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
cost = 0
flag = 0
min = 10000000000000

for i in range(1<<n):
  r = [0]*m
  flag = 0
  cost = 0
  for j in range(n):
    if(i>>j&1):
      cost += a[j][0]
      for k in range(m):
        r[k] += a[j][k+1]
  for k in range(m):
    if(r[k] < x):
      flag = 1
      break
  if(flag == 0 and min > cost):
    min = cost
print(min)

Fixed code:
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
cost = 0
flag = 0
min = 10000000000000

for i in range(1<<n):
  r = [0]*m
  flag = 0
  cost = 0
  for j in range(n):
    if(i>>j&1):
      cost += a[j][0]
      for k in range(m):
        r[k] += a[j][k+1]
  for k in range(m):
    if(r[k] < x):
      flag = 1
      break
  if(flag == 0 and min > cost):
    min = cost
if(min == 10000000000000):
  print(-1)
else:
  print(min)