qyliang/CodeNanoFix huggingface dataset:
Buggy code:
line = input()
N, M, X = [int(v) for v in line.split(" ")]

Ci, Aij = [], []
for i in range(N):
    line = input().split(" ")
    line = [int(v) for v in line]

    Ci.append(line[0])
    Aij.append(line[1:])

ans = []
def dfs(candidate):
    if len(candidate) == M:
        X_ = [0 for _ in range(M)]
        cost = 0
        for i in range(N):
            if candidate[i] == 0:
                continue
            cost += Ci[i]
            for j in range(M):
                X_[j] += Aij[i][j]
        if min(X_) >= X:
            ans.append(cost)
    else:
        for bit in range(2):
            candidate.append(bit)
            dfs(candidate)
            candidate.pop()

dfs([])
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

Fixed code:
line = input()
N, M, X = [int(v) for v in line.split(" ")]

Ci, Aij = [], []
for i in range(N):
    line = input().split(" ")
    line = [int(v) for v in line]

    Ci.append(line[0])
    Aij.append(line[1:])

ans = []
def dfs(candidate):
    if len(candidate) == N:
        X_ = [0 for _ in range(M)]
        cost = 0
        for i in range(N):
            if candidate[i] == 0:
                continue
            cost += Ci[i]
            for j in range(M):
                X_[j] += Aij[i][j]
        if min(X_) >= X:
            ans.append(cost)
    else:
        for bit in range(2):
            candidate.append(bit)
            dfs(candidate)
            candidate.pop()

dfs([])
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))
Buggy code:
N,M,X=map(int,input().split())
C=[]
A=[[] for  _  in range(N)]
for i in range(N):
  tmpA=list(map(int,input().split()))
  C+=[tmpA[0]]
  A[i]=tmpA[1:]
tf=1
for i in range(M):
  s=0
  for j in range(N):
    s+=A[j][i]
  if s<X:
    tf=0
    break
if tf==0:
  print(-1)
else:
  costmin=float('inf')
  for k in range(2**N):
    tansaku=k
    koubai=[0 for i in range(N)]
    rikaido=[0 for i in range(N)]
    cost=0
    for i in range(N-1):
      koubai[i]=tansaku//(2**(N-i-1))
      tansaku=tansaku%(2**(N-i-1))
    koubai[-1]=tansaku
    for i in range(N):
      if koubai[i]==1:
        cost+=C[i]
        for j in range(M):
          rikaido[j]+=A[i][j]
    for i in range(M):
      if rikaido[i]<X:
        break
    else:
      costmin=min(costmin,cost)
      
        
        
  

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

costmin=float('inf')
for k in range(2**N):
  tansaku=k
  koubai=[0 for i in range(N)]
  rikaido=[0 for i in range(M)]
  cost=0
  for i in range(N-1):
    koubai[i]=tansaku//(2**(N-i-1))
    tansaku=tansaku%(2**(N-i-1))
  koubai[-1]=tansaku
  for i in range(N):
    if koubai[i]==1:
      cost+=C[i]
      for j in range(M):
        rikaido[j]+=A[i][j]
  for i in range(M):
    if rikaido[i]<X:
      break
  else:
    costmin=min(costmin,cost)
if costmin!=float('inf'):
  print(costmin)
else:
  print(-1)
Buggy code:
import itertools
import numpy as np

N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)

out = 10**18
for c in itertools.product([False, True], repeat=M):
    tmp = np.sum(items[[np.where(c)]], axis=0)
    if np.any(tmp):
      if M == np.count_nonzero(tmp[1:] >= X):
        out = min(out, tmp[0])
if out == 10**18:
  print(-1)
else:
  print(out) 

Fixed code:
import itertools
import numpy as np

N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)

out = 10**18
for c in itertools.product([False, True], repeat=N):
    tmp = np.sum(items[np.where(c)], axis=0)
    if np.any(tmp):
      if M == np.count_nonzero(tmp[1:] >= X):
        out = min(out, tmp[0])
if out == 10**18:
  print(-1)
else:
  print(out)
Buggy code:
import itertools
N, M, X = map(int, input().split())
book_lists = [list(map(int, input().split())) for i in range(N)]
no_skill_flg = True
for i in range(1, N+1):
    for j in itertools.combinations(book_lists,i):
        sum_list = [0 for _ in range(M+1)]
        for book_date in j:
            for k, l in enumerate(book_date):
                sum_list[k] += l
        print(sum_list)
        if all([s >= X for s in sum_list[1:]]):
            no_skill_flg = False
            if 'ans' in globals():
                ans = min(ans, sum_list[0])
            else:
                ans = sum_list[0]
print(ans if not no_skill_flg else -1)

Fixed code:
import itertools
N, M, X = map(int, input().split())
book_lists = [list(map(int, input().split())) for i in range(N)]
no_skill_flg = True
for i in range(1, N+1):
    for j in itertools.combinations(book_lists,i):
        sum_list = [0 for _ in range(M+1)]
        for book_date in j:
            for k, l in enumerate(book_date):
                sum_list[k] += l
        if all([s >= X for s in sum_list[1:]]):
            no_skill_flg = False
            if 'ans' in globals():
                ans = min(ans, sum_list[0])
            else:
                ans = sum_list[0]
print(ans if not no_skill_flg else -1)
Buggy code:
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,7)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,6):
    print(-1)
else:
    print(money)


Fixed code:
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,7)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,7):
    print(-1)
else:
    print(money)
Buggy code:
from itertools import product

N, M, X = [int(x) for x in input().strip().split(" ")]
C = []
A = []

for _ in range(N):
    v = [int(x) for x in input().strip().split(" ")]
    c = v.pop(0)
    C.append(c)
    A.append(v)

sums = []
patterns = product(*[(0, 1) for _ in range(N)])
for pattern in patterns:
    price = 0
    print(pattern)
    status = [0 for _ in range(M)]
    for i, p in enumerate(pattern):
        price += C[i] * p
        for j in range(M):
            status[j] += A[i][j] * p
    if min(status) >= X:
        sums.append(price)

if len(sums) > 0:
    print(min(sums))
else:
    print(-1)

Fixed code:
from itertools import product

N, M, X = [int(x) for x in input().strip().split(" ")]
C = []
A = []

for _ in range(N):
    v = [int(x) for x in input().strip().split(" ")]
    c = v.pop(0)
    C.append(c)
    A.append(v)

sums = []
patterns = product(*[(0, 1) for _ in range(N)])
for pattern in patterns:
    price = 0
    status = [0 for _ in range(M)]
    for i, p in enumerate(pattern):
        price += C[i] * p
        for j in range(M):
            status[j] += A[i][j] * p
    if min(status) >= X:
        sums.append(price)

if len(sums) > 0:
    print(min(sums))
else:
    print(-1)
Buggy code:
INF = 10**18

n, m, x = map(int, input().split())
costs = []
a = []
for i in range(n):
    cost, *tmp = map(int, input().split())
    costs.append(cost)
    a.append(tmp)

ans = INF
for i in range(1 << n):
    cost = 0
    ms = [0] * m
    for j in range(n):
        if (i >> j) & 1 == 1:
            cost += costs[j]
            for k in range(m):
                ms[k] += a[j][k]
    can_learn = True
    for j in range(m):
        if ms[j] < x:
            can_learn = False
            break
    if can_learn:
        print(cost, ms)
        ans = min(ans, cost)

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


Fixed code:
INF = 10**18

n, m, x = map(int, input().split())
costs = []
a = []
for i in range(n):
    cost, *tmp = map(int, input().split())
    costs.append(cost)
    a.append(tmp)

ans = INF
for i in range(1 << n):
    cost = 0
    ms = [0] * m
    for j in range(n):
        if (i >> j) & 1 == 1:
            cost += costs[j]
            for k in range(m):
                ms[k] += a[j][k]
    can_learn = True
    for j in range(m):
        if ms[j] < x:
            can_learn = False
            break
    if can_learn:
        ans = min(ans, cost)

print(-1 if ans == INF else ans)
Buggy code:
import numpy as np

N, M, X = map(int, input().split())
C = np.zeros(N)
A = np.zeros((N, M))


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

C_MIN = 9999999999
for i in range(2 ** N):
    C_SUM = 0
    A_SUM = np.zeros(M)
    for j in range(N):
        if ((i >> j) & 1):
            C_SUM += C[j]
            A_SUM += A[j]
    if np.all(A_SUM >= X):
        if C_SUM < C_MIN:
            C_MIN = C_SUM
            
if C_MIN == 9999999999:
    print("-1")
else:
    print(C_MIN)

Fixed code:
import numpy as np

N, M, X = map(int, input().split())
C = np.zeros(N)
A = np.zeros((N, M))


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

C_MIN = -1
for i in range(2 ** N):
    C_SUM = 0
    A_SUM = np.zeros(M)
    for j in range(N):
        if ((i >> j) & 1):
            C_SUM += C[j]
            A_SUM += A[j]
    if np.all(A_SUM >= X):
        if C_SUM < C_MIN or C_MIN == -1:
            C_MIN = C_SUM
            
if C_MIN == -1:
    print("-1")
else:
    print(int(C_MIN))
Buggy code:
import numpy as np

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

data = [list(map(int, input().split())) for _ in range(N)]
INF = float('int')

data_all = []
c_min = INF

for i in range(2**N):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

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





Fixed code:
import numpy as np

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

data = [list(map(int, input().split())) for _ in range(N)]
INF = float('inf')

data_all = []
c_min = INF

for i in range(2**N):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

if(c_min == INF):
    print(-1)
else:
    print(c_min)
Buggy code:
def dfs(A):
    if len(A) == n:
        tmp = [0 for i in range(m+1)]
        for i, k in enumerate(A):
            if k:
                for j in range(m+1):
                    tmp[j] += a[i][j]
        chk = 0
        for i in range(1, m+1):
            if tmp[i] >= x:
                chk += 1
        if chk == m:
            ans[0] = min(tmp[0], ans[0])
        return

    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()


n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = [10**10]
dfs([])
print(ans[0])


Fixed code:
def dfs(A):
    if len(A) == n:
        tmp = [0 for i in range(m+1)]
        for i, k in enumerate(A):
            if k:
                for j in range(m+1):
                    tmp[j] += a[i][j]
        chk = 0
        for i in range(1, m+1):
            if tmp[i] >= x:
                chk += 1
        if chk == m:
            ans[0] = min(tmp[0], ans[0])
        return

    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()


n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = [10**10]
dfs([])
if ans[0] != 10**10:
    print(ans[0])
else:
    print(-1)
Buggy code:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

ans = np.inf

for i in range(2**N):
    point = np.zeros(M)
    cost = 0

    for j in range(N):
        if ((i >> j) & 1):
            point += A[j]
            cost += C[j]

    if np.all(point >= X):
        print(point)
        ans = min(ans, cost)

if ans != np.inf:
    print(ans)
else:
    print('-1')


Fixed code:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

ans = np.inf

for i in range(2**N):
    point = np.zeros(M)
    cost = 0

    for j in range(N):
        if ((i >> j) & 1):
            point += A[j]
            cost += C[j]

    if np.all(point >= X):
        ans = min(ans, cost)

if ans != np.inf:
    print(ans)
else:
    print('-1')
Buggy code:
import numpy as np
import sys
from itertools import product

n, m, x = map(int, input().split())
c = []
A = []

ans = 10**9

products = list(product([0,1], repeat=n))

for _ in range(n):
    c_a = list(map(int, input().split()))
    c.append(c_a[0])
    A.append(c_a[1:])

min_price = 10**9

for p in products:
    sum_alg = [0]*m
    price = 0
    for i, pp in enumerate(p):
        if pp == 1:
            for j in range(m):
                sum_alg[j] += A[i][j]
            price += c[i]

    if min(sum_alg) > x: 
        min_price = min(price, min_price)


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





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

n, m, x = map(int, input().split())
c = []
A = []

ans = 10**9

products = list(product([0,1], repeat=n))

for _ in range(n):
    c_a = list(map(int, input().split()))
    c.append(c_a[0])
    A.append(c_a[1:])

min_price = 10**9

for p in products:
    sum_alg = [0]*m
    price = 0
    for i, pp in enumerate(p):
        if pp == 1:
            for j in range(m):
                sum_alg[j] += A[i][j]
            price += c[i]

    if min(sum_alg) >= x: 
        min_price = min(price, min_price)


if min_price == 10**9:
    print(-1)
else:
    print(min_price)
Buggy code:
from itertools import product
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        books.append(tuple(map(int, input().split())))

    books_set_all = []
    books_pattern = product((0, 1), repeat=n)
    for each_pattern in books_pattern:
        books_set = [0] * (m + 1)
        for i in each_pattern:
            if i:
                for i2 in range(m + 1):
                    books_set[i2] += books[i][i2]
        books_set_all.append(books_set)
    price_all = []
    for ebs in books_set_all:
        price = ebs[0]
        ebs[0] = x
        if len([j for j in ebs if j >= x]) == m + 1:
            price_all.append(price)
    if len(price_all) > 0:
        print(min(price_all))
    else:
        print(-1)

if __name__ == '__main__':
    main()


Fixed code:
from itertools import product
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        books.append(tuple(map(int, input().split())))

    books_set_all = []
    books_pattern = product((0, 1), repeat=n)
    for each_pattern in books_pattern:
        books_set = [0] * (m + 1)
        for i1 in range(n):
            if each_pattern[i1] == 1:
                for i2 in range(m + 1):
                    books_set[i2] += books[i1][i2]
        books_set_all.append(books_set)
    price_all = []
    for ebs in books_set_all:
        price = ebs[0]
        ebs[0] = x
        if len([j for j in ebs if j >= x]) == m + 1:
            price_all.append(price)
    if len(price_all) > 0:
        print(min(price_all))
    else:
        print(-1)

if __name__ == '__main__':
    main()
Buggy code:
import itertools

N, M, X = map(int, input().split())
ca = []
for _ in range(N):
  ca.append(list(map(int, input().split())))
  
ns = [i for i in range(N)]
price = 1000000000000
for r in range(1,N+1):
  for v in itertools.combinations(ns, r):
    flag = True
    for j in range(M):
      s = sum([ca[i][j+1] for i in v])
      print(v, s)
      if s < X:
        flag = False
        continue
    if flag:
      p = sum([ca[i][0] for i in v])
      price = min(price, p)
      
if price == 1000000000000:
  print(-1)
else:
  print(price)

Fixed code:
import itertools

N, M, X = map(int, input().split())
ca = []
for _ in range(N):
  ca.append(list(map(int, input().split())))
  
ns = [i for i in range(N)]
price = 1000000000000
for r in range(1,N+1):
  for v in itertools.combinations(ns, r):
    flag = True
    for j in range(M):
      s = sum([ca[i][j+1] for i in v])
      if s < X:
        flag = False
        continue
    if flag:
      p = sum([ca[i][0] for i in v])
      price = min(price, p)
      
if price == 1000000000000:
  print(-1)
else:
  print(price)
Buggy code:
import numpy as np
n,m,x=map(int,input().split())
a=0
b=[[np.array(list(map(int,input().split())))]for i in range(n)]
for i in range(2**n):
    c=bin(i)
    c="0"*(n-len(c))+c
    l=np.zeros(m)
    q=0
    for j in range(n):
        if c[j]=="1":
            q+=b[j][0]
            l+=b[j]
    if np.min(l)==x:
        a=min(a,q)
if a:
    print(a)

Fixed code:
import numpy as np
n,m,x=map(int,input().split())
a=2**64
b=[np.array(list(map(int,input().split())),"i8")for i in range(n)]
for i in range(2**n):
    c=bin(i)[2:]
    c="0"*(n-len(c))+c
    l=np.zeros(m)
    q=0
    for j in range(n):
        if c[j]=="1":
            q+=b[j][0]
            l+=b[j][1:]
    if np.min(l)>=x:
        a=min(a,q)
if a==2**64:
    print(-1)
else:
    print(a)
Buggy code:
#Skill Up
n,m,x = map(int, input().split())

#ca = [map(int, input().split()) for _ in range(n)]
#ca = [input().split() for l in range(n)]
import sys
ca = [[int(c) for c in l.split()] for l in sys.stdin]
#c, a = [list(i) for i in zip(*ca)]
#print(ca)
#print(ca[0][0])
c=[]
a=[]
for l in range(n):
    c.append(ca[l][0])
#print(c)

for l in range(n):
    del ca[l][0]
#print(ca)
a=ca

INF = float('INF')
min_cost = INF
 
def dfs(i, cost, learn):
    if i == n:
        if min(learn) >= x:
            return cost
        else:
            return INF
    else:
        new_learn = [X + Y for (X, Y) in zip(a[i], learn)]
        cost = min(dfs(i + 1, cost, learn), dfs(i + 1, cost + C[i], new_learn))
        return cost
 
min_cost = dfs(0, 0, [0] * m)
 
if min_cost == INF:
    print(-1)
else:
    print(min_cost)




Fixed code:
#Skill Up
n,m,x = map(int, input().split())

#ca = [map(int, input().split()) for _ in range(n)]
#ca = [input().split() for l in range(n)]
import sys
ca = [[int(c) for c in l.split()] for l in sys.stdin]
#c, a = [list(i) for i in zip(*ca)]
#print(ca)
#print(ca[0][0])
c=[]
for l in range(n):
    c.append(ca[l][0])
#print(c)

for l in range(n):
    del ca[l][0]
#print(ca)

INF = float('INF')
min_cost = INF
 
def dfs(i, cost, learn):
    if i == n:
        if min(learn) >= x:
            return cost
        else:
            return INF
    else:
        new_learn = [X + Y for (X, Y) in zip(ca[i], learn)]
        cost = min(dfs(i + 1, cost, learn), dfs(i + 1, cost + c[i], new_learn))
        return cost
 
min_cost = dfs(0, 0, [0] * m)
 
if min_cost == INF:
    print(-1)
else:
    print(min_cost)
Buggy code:
import sys
N,M,X=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
#print(L)
price=[]
list_X=[X for i in range(M)]
print(list_X)
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])] 
  #print(A)
  large = 0
  for i in range(M):
    if A[i+1] >= list_X[i]:
      large += 1
  if large == M:
    price.append(A[0])
  #if A[1:] >= list_X:
    #price.append(A[0])
#print(price)
if price ==[]:
  print(-1)
else:
  print(min(price))

Fixed code:
import sys
N,M,X=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
#print(L)
price=[]
list_X=[X for i in range(M)]
#print(list_X)
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])] 
  #print(A)
  large = 0
  for i in range(M):
    if A[i+1] >= list_X[i]:
      large += 1
  if large == M:
    price.append(A[0])
  #if A[1:] >= list_X:
    #price.append(A[0])
#print(price)
if price ==[]:
  print(-1)
else:
  print(min(price))
Buggy code:
n,m,x = map(int,input().split())
li = [list(map(int,input().split())) for i in range(n)]

ans   = 10**30
cost  = 0
score = [0]*m

for i in range(1<<(n+1)):
  for j in range(n):
    if (j>>i)&1:
      for k in range(m):
        score[k] += li[j][k+1]
      cost += li[j][0]
      print(cost,min(score))
  if min(score)>=x:
    ans = min(ans,cost)
  score = [0]*m
  cost = 0

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

Fixed code:
n,m,x = map(int,input().split())
li = [list(map(int,input().split())) for i in range(n)]

ans   = 10**30
cost  = 0
score = [0]*m

for i in range(1<<(n+1)):
  for j in range(n):
    # if (j>>i)&1:
    if i&(1<<j):
      for k in range(m):
        score[k] += li[j][k+1]
      cost += li[j][0]
  if min(score)>=x:
    ans = min(ans,cost)
  score = [0]*m
  cost = 0

if ans==10**30:
  print(-1)
else:
  print(ans)
Buggy code:
def main():
  N, M, X = map(int, input().split())
  ans = float('inf')
  table = []
  for i in range(N):
    table.append(list(map(int, input().split())))
                 
  for i in range(2 ** N):
    tmp = [0] * (M+1)
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(M+1):
              tmp[k] += table[j][k]
    for l in range(1, len(tmp)):
      if tmp[l] < X:
        break
    else:
      if ans > tmp[0]:
        ans = tmp[0]
  if ans != float('inf'):
    print(ans)
  else:
    print(-1)  

Fixed code:
def main():
  N, M, X = map(int, input().split())
  ans = float('inf')
  table = []
  for i in range(N):
    table.append(list(map(int, input().split())))
                 
  for i in range(2 ** N):
    tmp = [0] * (M+1)
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(M+1):
              tmp[k] += table[j][k]
    for l in range(1, len(tmp)):
      if tmp[l] < X:
        break
    else:
      if ans > tmp[0]:
        ans = tmp[0]
  if ans != float('inf'):
    print(ans)
  else:
    print(-1)  
    
if __name__ == '__main__':
  main()
Buggy code:
def check(pair,m,x):
  l = len(pair)
  sum = 0
  
  for i in range(1,m):
    p= 0
    for j in range(l):
      p += pair[j][i]
    if(p < x):
      return -1
    
  for i in range(l):
    sum += pair[i][0]
  return sum
      
n,m,x = (int(x) for x in input().split())
a = []
for i in range(n):
  a.append(tuple([int(x) for x in input().split()]))
  
min = -1
  
for i in range(2 ** n):
  pair = []
  for j in range(n):
    if((i >> j) & 1):
      pair.append(a[j])
  sum = check(pair,m,x)
  if min == -1 and sum >= 0:
    min = sum
  elif min > sum:
    min = sum
    
print(min)

Fixed code:
def check(pair,m,x):
  sum = 0
  
  for i in range(1,m+1):
    p= 0
    for e in pair:
      p += e[i]
    if(p < x):
      return -1
    
  for e in pair:
    sum += e[0]
  return sum
      
n,m,x = (int(x) for x in input().split())
a = []
for i in range(n):
  a.append(tuple([int(x) for x in input().split()]))
  
min = -1
  
for i in range(2 ** n):
  pair = []
  for j in range(n):
    if((i >> j) & 1):
      pair.append(a[j])
  sum = check(pair,m,x)
  
  if min == -1:
    min = sum
  elif sum != -1 and min > sum:
    min = sum
    
print(min)