qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n, m, x = map(int, input().split(' '))
input_lists = [list(map(int, input().split(' '))) for _ in range(n)]
 
comb = []
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(input_lists[j])
    comb.append(tmp)

result = -1
for i in range(len(comb)):
    understand = [0]*m
    total_fee = 0
    for j in range(len(comb[i])):
        total_fee += comb[i][j][0]
        for k in range(1, m):
            understand[k] += comb[i][j][k]
    boolean = True
    for j in range(m):
        if all(t < x for t in understand):
            boolean = False
    if boolean and (result == -1 or result > understand[0]):
        result = total_fee
 
print(result)

Fixed code:
n, m, x = map(int, input().split(' '))
input_lists = [list(map(int, input().split(' '))) for _ in range(n)]
 
comb = []
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(input_lists[j])
    comb.append(tmp)

result = -1
for i in range(len(comb)):
    understand = [0]*m
    total_fee = 0
    for j in range(len(comb[i])):
        total_fee += comb[i][j][0]
        for k in range(m):
            understand[k] += comb[i][j][k+1]
    if all(t >= x for t in understand) and (result == -1 or result > total_fee):
        result = total_fee
 
print(result)
Buggy code:
N, M, X = map(int,input().split())
a=[]
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
c=[]
for i in range(N):
    a.append(input().split())
    c.append(0)

check=0
ans=-1
for i in range(2**N):
    b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(N):
        if 0x01 & (i >> j):
            for n in range(M+1):
                b[n] = b[n] + int(a[j][n])

        check=0
        print(b)
        for k in range(1,M):
            if b[k] < X:
                check=1

        if check==0:
            if ans == -1 or ans > b[0]:
                ans = b[0]

print(ans)


Fixed code:
N, M, X = map(int,input().split())
a=[]
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

for i in range(N):
    a.append(input().split())

check=0
ans=-1
for i in range(1,pow(2,N)):
    b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    check=0
    for j in range(N):
        if 0x01 & (i >> j):
            for n in range(M+1):
                b[n] = b[n] + int(a[j][n])
    for k in range(1,M+1):
        if b[k] < X:
            check=1
    if check==0:
        if ans == -1 or ans > b[0]:
            ans = b[0]
print(ans)
Buggy code:
def CanIGetEnoughSkills(SkillPoints,M,X):
    for _ in range(M):
        if SkillPoints[_]<X:
            return False
        else:
            pass
    return True


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

BookCost=[]
GetSkillPoints=[]
for i in range (N):
    BookCost.append(books[i][0])
    GetSkillPoints.append(books[i][1:])

temp_cost=10**9

for Cart in range (2**len(GetSkillPoints)):
    TotalCost=0
    SkillPoints=[0]*M

    for book in range(len(GetSkillPoints)):
        if (Cart>>book)&1==0:
            continue
        TotalCost+= BookCost[book]
        for skillelement in range(M):
            SkillPoints[skillelement]+=GetSkillPoints[book][skillelement]

    # print(TotalCost,SkillPoints)
    if CanIGetEnoughSkills(SkillPoints,M,X)== True:
        temp_cost=min(temp_cost,TotalCost)

Answer=temp_cost
if Answer==10**9:
    Answer=-1
    
print(Answer)

Fixed code:
def CanIGetEnoughSkills(SkillPoints,M,X):
    for _ in range(M):
        if SkillPoints[_]<X:
            return False
        else:
            pass
    return True


N,M,X=map(int,input().split())
books=[]
for n in range(N):
    array= list(map(int,input().split()))
    books.append(array)
# print(books)

BookCost=[]
GetSkillPoints=[]
for i in range (N):
    BookCost.append(int(books[i][0]))
    GetSkillPoints.append(books[i][1:])

temp_cost=10**9

for Cart in range (2**len(GetSkillPoints)):
    TotalCost=0
    SkillPoints=[0]*M
    
    for book in range(len(GetSkillPoints)):
        if (Cart>>book)&1==0:
            continue
        TotalCost+= BookCost[book]
        for skillelement in range(M):
            SkillPoints[skillelement]+=GetSkillPoints[book][skillelement]

    # print(TotalCost,SkillPoints)
    if CanIGetEnoughSkills(SkillPoints,M,X)== True:
        temp_cost=min(temp_cost,TotalCost)

Answer=temp_cost
if Answer==10**9:
    Answer=-1
    
print(Answer)
Buggy code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, M, X = map(int, input().split())
    CA_list = [list(map(int,list(input().split(" ")))) for i in range(M)]
    Ci_sum_list = []
    
    for i in range(2 ** N):
        sum_list = [0 for i in range(M + 1)]
        for j in range(N):
            if ((i >> j) & 1):
                sum_list = [x + y for (x, y) in  zip(sum_list, CA_list[j])]
                
        logging.info(sum_list)
        if [x for x in sum_list[1:] if x < X]:
            continue
        else:
            Ci_sum_list.append(sum_list[0])

    if Ci_sum_list:
        print(min(Ci_sum_list))
    else:
        print(-1)
        
if __name__ == "__main__":
    main()


Fixed code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, M, X = map(int, input().split())
    CA_list = [list(map(int,list(input().split(" ")))) for i in range(N)]
    Ci_sum_list = []
    
    for i in range(2 ** N):
        sum_list = [0 for i in range(M + 1)]
        for j in range(N):
            if ((i >> j) & 1):
                sum_list = [x + y for (x, y) in  zip(sum_list, CA_list[j])]
                
        logging.info(sum_list)
        if [x for x in sum_list[1:] if x < X]:
            continue
        else:
            Ci_sum_list.append(sum_list[0])

    if Ci_sum_list:
        print(min(Ci_sum_list))
    else:
        print(-1)
        
if __name__ == "__main__":
    main()
Buggy code:
from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

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


ok = False
mi = [float('inf'), *[0]*(M-1)]

fs = '{:0' + str(N-1) + 'b}'

for i in range(2**N):
  s = fs.format(i)
  t = [0]*M
  for i, f in enumerate(s):
    if f == '1':
      t = [a+b for a, b in zip(CAS[i], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print(mi[0])
else:
  print(-1)


Fixed code:
from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

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


ok = False
mi = [float('inf'), *[0]*(M)]

fs = '{:0' + str(N) + 'b}'

for i in range(2**N):
  s = fs.format(i)
  t = [0]*(M+1)
  for i, f in enumerate(s):
    if f == '1':
      t = [a+b for a, b in zip(CAS[i], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print(mi[0])
else:
  print(-1)
Buggy code:
n, m, x = list(map(int, input().split()))

c_list = []
a_matrix = []

for i in range(n):
    items = list(map(int, input().split()))
    c_list.append(items[0])
    a_matrix.append(items[1:])

min_cost = 1000000 * (n+1)

for i in range(2^n):
    cost = 0
    skill_sum = [0 for _ in range(m)]
    bit_pattern = format(i, '0' + str(n) + 'b')[::-1]
    for i, a_line in enumerate(a_matrix):
        if bit_pattern[i] == "1":
            cost += c_list[i]
            for j, a in enumerate(a_line):
                skill_sum[j] += a
    
    if all(map(lambda skill_s: skill_s >= x, skill_sum)) and cost < min_cost:
        min_cost = cost

if min_cost >= 1000000 * (n+1):
    print(-1)
else:
    print(min_cost)

Fixed code:
n, m, x = list(map(int, input().split()))

c_list = []
a_matrix = []

for i in range(n):
    items = list(map(int, input().split()))
    c_list.append(items[0])
    a_matrix.append(items[1:])

min_cost = 1000000 * (n+1)

for i in range(2**n):
    cost = 0
    skill_sum = [0 for _ in range(m)]
    bit_pattern = format(i, '0' + str(n) + 'b')[::-1]
    for i, a_line in enumerate(a_matrix):
        if bit_pattern[i] == "1":
            cost += c_list[i]
            for j, a in enumerate(a_line):
                skill_sum[j] += a
    
    if all(map(lambda skill_s: skill_s >= x, skill_sum)) and cost < min_cost:
        min_cost = cost

if min_cost >= 1000000 * (n+1):
    print(-1)
else:
    print(min_cost)
Buggy code:
n,m,x = map(int,input().split())
book = [list(map(int, input().split())) for _ in range(n)]
cos_min=10**10
for i in range(1,2**n):
    s_c= [0]*(m+1)
    choose = bin(i).zfill(n)

    for j in range(n):
        if choose[n-j-1]=="1":  
            s_c = [a+b for (a,b)in zip(s_c,book[j])]

    for j in s_c[1:]:
        if j<x:
            break
    else:
        cos_min=min(cos_min,s_c[0])

if cos_min!=10**10 :
    print(cos_min)
else:
    print(-1)   

Fixed code:
n,m,x = map(int,input().split())
book = [list(map(int, input().split())) for _ in range(n)]
cos_min=10**10*n
for i in range(1,2**n):
    s_c= [0]*(m+1)
    choose = bin(i)[2:].zfill(n)

    for j in range(n):
        if choose[n-j-1]=="1":  
            s_c = [a+b for (a,b)in zip(s_c,book[j])]

    for j in s_c[1:]:
        if j<x:
            break
    else:
        cos_min=min(cos_min,s_c[0])

if cos_min!=10**10*n :
    print(cos_min)
else:
    print(-1)
Buggy code:
big_int = 10 ** 9

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

L = []
for i in range(N):
  L.insert( tuple(map(int, input().split())) )

def foo(i):
  T = [0 for j in range(M+1)]
  for j in range(N):
    for k in range(M+1):
      T[k] += L[j][k] * (i%2)
      i //= 2
  for k in range(1,M+1):
    if T[k] < X:
      return big_int
  return T[0]
  
ans = big_int

for i in range(2**N):
  ans = min(ans, foo(i))
  
if ans == big_int:
  print(-1)
else:
  print(ans)

Fixed code:
big_int = 10 ** 9

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

L = [0 for i in range(N)]
for i in range(N):
  L[i] = tuple(map(int, input().split()))

def foo(i):
  t = i
  T = [0 for j in range(M+1)]
  for j in range(N):
    for k in range(M+1):
      T[k] += L[j][k] * (t%2)
    t //= 2
  for k in range(1,M+1):
    if T[k] < X:
      return big_int
  return T[0]
  
ans = big_int

for i in range(2**N):
  ans = min(ans, foo(i))
  
if ans == big_int:
  print(-1)
else:
  print(ans)
Buggy code:
from itertools import combinations
n, m, x = map(int, input().split())
ca = list(map(int, input().split()))

ans = 10**9
for i in range(1,n+1):
  for j in combinations(ca, i):
    s = [0]*(m+1)
    for k in j:
      for l in range(m+1):
        s[l] += k[l]
    if min(s[1:]) <= x:
      ans += min(ans, s[0])
if ans == 10**9:
  print(-1)
else:
  print(ans)
    

Fixed code:
from itertools import combinations
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = 10**9
for i in range(1,n+1):
  for j in combinations(ca, i):
    s = [0]*(m+1)
    for k in j:
      for l in range(m+1):
        s[l] += k[l]
    if min(s[1:]) >= x:
      ans = min(ans, s[0])
if ans == 10**9:
  print(-1)
else:
  print(ans)
Buggy code:
n, m, x = map(int, input().split())
prace = []
know = []
for i in range(n):
    acc = list(map(int, input().split()))
    prace.append(acc[0])
    know.append(acc[1:])

ans = 10**10
for i in range(2**n):
    und = [0 for i in range(m)]
    f = "{:b}".format(i)
    s = f.zfill(n)
    mm = 0
    print(s)
    for j in range(len(s)):
        if s[j] == '1':
            for k in range(m):
                und[k] += know[j][k]
            mm += prace[j]
    for j in range(m):
        if und[j] < x:
            break
    else:
        ans = min(ans, mm)
if ans == 10**10:
    print(-1)
else:
    print(ans)


Fixed code:
n, m, x = map(int, input().split())
prace = []
know = []
for i in range(n):
    acc = list(map(int, input().split()))
    prace.append(acc[0])
    know.append(acc[1:])

ans = 10**10
for i in range(2**n):
    und = [0 for i in range(m)]
    f = "{:b}".format(i)
    s = f.zfill(n)
    mm = 0
    for j in range(len(s)):
        if s[j] == '1':
            for k in range(m):
                und[k] += know[j][k]
            mm += prace[j]
    for j in range(m):
        if und[j] < x:
            break
    else:
        ans = min(ans, mm)
if ans == 10**10:
    print(-1)
else:
    print(ans)
Buggy code:
n,m,x = map(int,input().split())
costlst = []
scorelst = []
ans = float("inf")
for _ in range(m):
    cost,*score = map(int,input().split())
    costlst.append(cost)
    scorelst.append(score)
for i in range(2**n):
    cost = 0
    defaultscore = [0]*m
    for j in range(n):
        if (i>>j)&1:
            cost += costlst[j]
            for k in range(m):
                defaultscore[k] += scorelst[j][k]
        if all([defaultscore[p] >= x for p in range(m)]):
            ans = min(ans,cost)
        
            
                
                
                 
print(ans if ans != float("inf") else "-1")            
    

Fixed code:
n,m,x = map(int,input().split())
costlst = []
scorelst = []
ans = float("inf")
for _ in range(n):
    cost,*score = map(int,input().split())
    costlst.append(cost)
    scorelst.append(score)
for i in range(2**n):
    cost = 0
    defaultscore = [0]*m
    for j in range(n):
        if (i>>j)&1:
            cost += costlst[j]
            for k in range(m):
                defaultscore[k] += scorelst[j][k]
    if all([defaultscore[p] >= x for p in range(m)]):
            ans = min(ans,cost)
        
            
                
                
                 
print(ans if ans != float("inf") else "-1")
Buggy code:
n,m,p = map(int,input().split())
L = []
for i in range(n):
    a = list(map(int,input().split()))
    L.append(a)

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

Fixed code:
n,m,p = map(int,input().split())
L = []
for i in range(n):
    a = list(map(int,input().split()))
    L.append(a)

ans = 10**10
for i in range(1<<n):
    score = 0
    li = [0]*m
    for j in range(n):
        LL = L[j][1:]
        
        if (i>>j)&1:
            score += L[j][0]
            for k in range(m):
                li[k] +=LL[k]
    if all(x >= p for x in li):
        ans = min(ans,score)
if ans != 10**10:
    print(ans)
else:
    print(-1)
Buggy code:
import itertools

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

ok = False
cur_price = (10 ** 5) * n + 1
for i in range(1, n + 1):
    answers = list(itertools.combinations(range(n), i))
    # print(answers)
    for ans_list in answers:
        sum_list = [0] * (m + 1)
        print(sum_list)
        for ans in ans_list:
            # print(all_list[int(ans[0])])
            sum_list = [a + b for a, b in zip(sum_list, all_list[int(ans)])]
        # print(sum_list)
        if min(sum_list[1:]) >= x:
            if sum_list[0] < cur_price:
                cur_price = sum_list[0]
                ok = True

if ok:
    print(cur_price)
else:
    print(-1)


Fixed code:
import itertools

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

ok = False
cur_price = (10 ** 5) * n + 1
for i in range(1, n + 1):
    answers = list(itertools.combinations(range(n), i))
    # print(answers)
    for ans_list in answers:
        sum_list = [0] * (m + 1)
        # print(sum_list)
        for ans in ans_list:
            # print(all_list[int(ans[0])])
            sum_list = [a + b for a, b in zip(sum_list, all_list[int(ans)])]
        # print(sum_list)
        if min(sum_list[1:]) >= x:
            if sum_list[0] < cur_price:
                cur_price = sum_list[0]
                ok = True

if ok:
    print(cur_price)
else:
    print(-1)
Buggy code:
n,m,x = map(int, input().split())
ca = []
for i in range(m):
    ca.append(list(map(int, input().split())))

c = []
a = []
for i in range(len(ca)):
    c.append(ca[i][0])
    a.append(ca[i])
    del a[i][0]

ans = 12345678
for i in range(2 ** n):
    cost = 0
    level = [0] * m
    for j in range(n):
        if(i>>j&1):
            cost += c[j]
            for k in range(m):
                level[k] += a[j][k]
    flag = True
    for k in range(m):
        if(level[k] < x):
            flag = False
    if(flag):
        ans = min(ans,cost)
if(ans == 12345678):
    print(-1)
else:
    print(ans)

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

c = []
a = []
for i in range(len(ca)):
    c.append(ca[i][0])
    a.append(ca[i])
    del a[i][0]

ans = 12345678
for i in range(2 ** n):
    cost = 0
    level = [0] * m
    for j in range(n):
        if((i>>j)&1):
            cost += c[j]
            for k in range(m):
                level[k] += a[j][k]
    flag = True
    for k in range(m):
        if(level[k] < x):
            flag = False
    if(flag):
        ans = min(ans,cost)
if(ans == 12345678):
    print(-1)
else:
    print(ans)
Buggy code:
import itertools
N,M,X=map(int,input().split())
A=[0]*(N);C=[0]*(N);c=0;D=[0]*(M);m=10**5;n=0;x=[];z=0;R=[0]*N;f=-1;cost=10**5;p=0
for i in range(N):
  S=list(map(int,input().split()))
  C[i]=S[0]
  A[i]=S[1:len(S)]
#print(C)
#print(A)
for i in range(len(C)):
  x.append(i)

for i, _ in enumerate(x, 1):     
    for j in itertools.permutations(x, r=i):
        for k in x:
          for l in range(M):
            D[l]=D[l]+A[k][l]
        for v in range(M):
          if D[v]<X:
            f=1
        if f!=1:
          for y in x:
            p=p+C[y]
            if p<cost:
              cost=p
          p=0
print(cost if cost!=100000 else -1)

Fixed code:
import itertools
N,M,X=map(int,input().split())
A=[0]*(N);C=[0]*(N);c=0;D=[0]*(M);m=10**5;n=0;x=[];z=0;R=[0]*N;f=-1;cost=10**7;p=0
for i in range(N):
  S=list(map(int,input().split()))
  C[i]=S[0]
  A[i]=S[1:len(S)]
#print(C)
#print(A)
for i in range(len(C)):
  x.append(i)

for i, _ in enumerate(x, 1):     
    for j in itertools.combinations(x, r=i):
        f=-1
        D=[0]*(M)
        for k in j:
          for l in range(M):
            D[l]=D[l]+A[k][l]
        for v in range(M):
          if D[v]<X:
            f=1
        if f!=1:
          for y in j:
            p=p+C[y]
          if p<cost:
            cost=p
          p=0
print(cost if cost!=10000000 else -1)
Buggy code:
def main():
    N, M, X = map(int, input().split())

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

    min_total_cost = 10**9

    for i in range(2**N):
        total_cost = 0
        learned = [0] * M

        for j in range(N):
            if (i >> j) & 1:
                cost, points = books[j]
                total_cost += cost
                
                learned = [x + y for x, y in zip(learned, points)]

        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)

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


if __name__ == "__main__":
    main()


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

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

    min_total_cost = 10**9

    for i in range(2**N):
        total_cost = 0
        learned = [0] * M

        for j in range(N):
            if (i >> j) & 1:
                cost, *points = books[j]
                total_cost += cost

                learned = [x + y for x, y in zip(learned, points)]

        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)

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


if __name__ == "__main__":
    main()
Buggy code:
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 else -1)

Fixed code:
import numpy as np
N,M,X = map(int,input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 else -1)
Buggy code:
#https://atcoder.jp/contests/abc167/tasks/abc167_c C - Skill Up
import numpy as np
from itertools import combinations
N,M,X=list(map(int,input().split()))
book_dict={}
for i in range(M):
    book_dict[i] = list(map(int,input().split()))

answer = 10**5*12+1
for i in range(M,0,-1):
    for v in combinations(book_dict.keys(), i):
        search_book = list(map(lambda x:book_dict[x],list(v)))
        sum_search_book = np.array(np.sum(search_book,axis = 0))
        if (np.count_nonzero(sum_search_book[1:] >= X) == N) and sum_search_book[0] < answer:
            answer = sum_search_book[0]
                                                                                 
           
        
        
    

print(answer)


Fixed code:
#https://atcoder.jp/contests/abc167/tasks/abc167_c C - Skill Up
import numpy as np
from itertools import combinations
N,M,X=list(map(int,input().split()))
book_dict={}
for i in range(N):
    book_dict[i] = list(map(int,input().split()))

answer = (10**5*12)+1
for i in range(N,0,-1):
    for v in combinations(book_dict.keys(), i):
        search_book = list(map(lambda x:book_dict[x],list(v)))
        sum_search_book = np.array(np.sum(search_book,axis = 0))
        if (np.count_nonzero(sum_search_book[1:] >= X) == M) and sum_search_book[0] < answer:
            answer = sum_search_book[0]
                                                                                 
    
if answer == (10**5*12)+1:
    answer = -1

print(answer)
Buggy code:
#n=int(input())
n,m,x=map(int,input().split())
#a=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(n)]

def tas(l1,l2):
    l3=[]
    for i in range(m+1):
        l3.append(l1[i]+l2[i])
    return l3


ll=[[0 for i in range(m+1)]]
for i in range(n):
    for j in range(len(ll)):
        ll.append(tas(ll[j],l[i]))

lm=[]
for i in ll:
    lll=[]
    for j in range(1,i):
        if i[j]>=x:
            lll.append(True)
        else:
            lll.append(False)
    if all(lll)==True:
        lm.append(i[0])

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


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

def tas(l1,l2):
    l3=[]
    for i in range(m+1):
        l3.append(l1[i]+l2[i])
    return l3


ll=[[0 for i in range(m+1)]]
for i in range(n):
    for j in range(len(ll)):
        ll.append(tas(ll[j],l[i]))

lm=[]
for i in ll:
    lll=[]
    for j in range(1,len(i)):
        if i[j]>=x:
            lll.append(True)
        else:
            lll.append(False)
    if all(lll)==True:
        lm.append(i[0])

if len(lm)>0:
    print(min(lm))
else:
    print(-1)
Buggy code:
def bitsearch(n, a, x):
  mincost = 10**10
  for b in range(2**n):
    bit = format(b, f"0{n}b")
    total = [sum([int(bit[i])*a[i][j] for i in range(n)]) for j in range(m+1)]
    if min(total[1:]) >= x:
      mincost = min(mincost, total[0])
  return mincost

n, m, x = map(int, input().split())
a = []
for i in range(n):
  line = list(map(int, input().split()))
  a.append(line)
print(bitsearch(n, a, x))

Fixed code:
def bitsearch(n, a, x):
  mincost = 10**10
  for b in range(2**n):
    bit = format(b, f"0{n}b")
    total = [sum([int(bit[i])*a[i][j] for i in range(n)]) for j in range(m+1)]
    # print(total)
    if min(total[1:]) >= x:
      # print(min(total[1:]), x)
      mincost = min(mincost, total[0])
  if mincost == 10**10:
    return -1
  return mincost

n, m, x = map(int, input().split())
a = []
for i in range(n):
  line = list(map(int, input().split()))
  a.append(line)
print(bitsearch(n, a, x))