qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a, b, c , k = map(int, input().split())
if k <=a:
    print(k)
if k <=(a+b):
    print(a)
if k < a+b+c:
    print(a-c)
    

Fixed code:
a, b, c, k = map(int, input().split())

if k <= a:
    print(k)
elif k <= a + b:
    print(a)
elif k <= a + b + c:
    print(a - (k - a - b))
else:
    print(a - c)
Buggy code:
A, B, C, K = map(int, input().split())
ans = 0

if A < K and K > 0:
    ans += A
    K -= A
elif A >= K and K > 0:
    ans += K
    K = 0

if B < K and K > 0:
    K -= B
elif A >= K and K > 0:
    K = 0

if C < K and K > 0:
    ans -= C
    K -= C
elif A >= K and K > 0:
    K = 0

print(ans)

Fixed code:
A, B, C, K = map(int, input().split())
ans = 0

if A < K and K > 0:
    ans += A
    K -= A
elif A >= K and K > 0:
    ans += K
    K = 0

if B < K and K > 0:
    K -= B
elif B >= K and K > 0:
    K = 0

if C < K and K > 0:
    ans -= C
    K -= C
elif C >= K and K > 0:
    ans -= K
    K = 0

print(ans)
Buggy code:
from sys import stdin

A, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]
if K-A == 0:
    print(A)
elif K-A > 0:
    if K-A-B <= 0:
        print(A)
    else:
        print(int(A-(K-A-B)*-1))

Fixed code:
from sys import stdin
A, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]
if K-A <= 0:
    print(K)
elif K-A > 0:
    if K-A-B <= 0:
        print(A)
    else:
        print(int(A+(K-A-B)*-1))
Buggy code:
a,b,c,k=map(int,input().split())
if k<=a:
    print(1*a)
else:
    if k-a<=b:
        print(1*(k-a))
    else:
        print(1*a-1*(k-a-b))

Fixed code:
a,b,c,k=map(int,input().split())
if k<=a:
    print(1*k)
else:
    if k-a<=b:
        print(1*a)
    else:
        print(1*a-1*(k-a-b))
Buggy code:
A, B, C, K = map(int, input().split())
result = 0
k = K

k -= A
if k < 0:
    k = 0
    result += 1 * K
else:
    result += 1 * ( K - k )

    k -= B
    if k > 0:

        result -= 1 * ( k - C )

print(result)

Fixed code:
A, B, C, K = map(int, input().split())
result = 0
k = K
ca = 0

k -= A
if k < 0:
    k = 0
    result += 1 * K
else:
    result += 1 * ( A )

    k -= B
    if k > 0:

        result -= 1 * ( k )

print(result)
Buggy code:
a,b,c,k=map(int,input().split())

if k<=a:
  print(a)
elif a<k and k<=a+b:
  print(a)
else:
  print(2a+b-k)

Fixed code:
a,b,c,k=map(int,input().split())
if k<=a:
  print(k)
elif a<k<=a+b:
  print(a)
else:
  print(a-(k-a-b))
Buggy code:
def main(A, B, C, K):
    """
    a = [1 for _ in range(A)]
    b = [0 for _ in range(B)]
    c = [-1 for _ in range(C)]
    k = a + b + c
    ans = sum(k[:K])
    """
    if A+B >= K:
        return K
    else:
        return A - (K-A-B)

if __name__ == '__main__':
    A, B, C, K = map(int, input().split())
    ans = main(A, B, C, K)
    print(ans)



Fixed code:
def main(A, B, C, K):
    """
    a = [1 for _ in range(A)]
    b = [0 for _ in range(B)]
    c = [-1 for _ in range(C)]
    k = a + b + c
    ans = sum(k[:K])
    """
    if K <= A:
        return K
    if A <= K <= A+B:
        return A
    else:
        return A - (K-A-B)

if __name__ == '__main__':
    A, B, C, K = map(int, input().split())
    ans = main(A, B, C, K)
    print(ans)
Buggy code:
a, b, c, k = map(int, input().split())

if a+b>=k:
    print(a)
else:
    print(a-(c-a-b))

Fixed code:
a, b, c, k = map(int, input().split())

if a + b >= k:
  if a >= k:
    print(k)
  else:
    print(a)
else:
  print(a - (k - a - b))
Buggy code:
A, B, C, K = map(int, input().split())

if K <= A:
    print(K)

elif A < K <= A + B:
    print(A)

else:
  print(A+B-c)

Fixed code:
A, B, C, K = map(int, input().split())

if K <= A:
    ans = K
elif K <= (A + B):
    ans = A
else:
    ans = A - (K - A - B)
print(ans)
Buggy code:
a,b,c,k=map(int,input().split())
if(k>a+b):
    print(A-min(k-a-b,c))
elif(k>=a):
    print(a)
else:
    print(k)

Fixed code:
a,b,c,k=map(int,input().split())
if(k>a+b):
    print(a-min(k-a-b,c))
elif(k>=a):
    print(a)
else:
    print(k)
Buggy code:
A,B,C,K = input().split()
a = int(A)
b = int(B)
k = int(K)

B_number = 0
C_number = 0

A_number = min(a,k)
k1 = k - a
if k1 > 0:
    B_number = min(b,k1)
    k2 = k1 - b
    if k2 > 0:
    C_number = min(c,k2)

print(A_number-C_number)

Fixed code:
A,B,C,K = input().split()
a = int(A)
b = int(B)
c = int(C)
k = int(K)

B_number = 0
C_number = 0

A_number = min(a,k)
k1 = k - a
if k1 > 0:
    B_number = min(b,k1)
    k2 = k1 - b
    if k2 > 0:
        C_number = min(c,k2)

print(A_number-C_number)
Buggy code:
N = input()
n =[int(x) for x in N]
A = n[0]
B = n[1]
C = n[2]
K = n[3]
if A>=K:
    print(K)
elif K <= A+B:
    print(A)
else:
    print(2*A+B-K)

Fixed code:
N = input()
n =[int(x) for x in N.split()]
A = n[0]
B = n[1]
C = n[2]
K = n[3]
if A>=K:
    print(K)
elif K <= A+B:
    print(A)
else:
    print(2*A+B-K)
Buggy code:
A,B,C,K = map(int,input().split())
if K >= A:
    K -= A
    if K <= B:
        print(1*A)
    elif K > B:
        K -= B
        print(-1*K)
        print(1*A + -1*K)

Fixed code:
A,B,C,K = map(int,input().split())
if A >= K:
    print(1*K)

else:
    K -= A
    if B >= K:
        print(1*A)
    
    else:
        K -= B
        if K <= C:
            print(1*A + -1*K)
Buggy code:
abcx = input().split(" ")
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
x = int(abcd[3])
if x <= a:
    print(x)
elif x <= a + b:
    print(a)
else:
    print(2*a + b - x)

Fixed code:
abcx = input().split(" ")
a = int(abcx[0])
b = int(abcx[1])
x = int(abcx[3])
if x <= a:
    print(x)
elif x <= a + b:
    print(a)
else:
    print(2 * a + b - x)
Buggy code:
a, b, c, k = map(int,input().split())
if (k <= a):
  print(k)
elif (k <= a + b):
  print(k)
else:
  x = a + b + c - k
  y = c - x
  ans = a - y

Fixed code:
a, b, c, k = map(int,input().split())
if (k <= a):
  print(k)
elif (k <= a + b):
  print(a)
else:
  x = a + b + c - k
  y = c - x
  ans = a - y
  print(ans)
Buggy code:
a,b,c,k =map(int,input().split())

if a >= k:
    print(k)
elif a + b >= k:
    print(k)
else:
    print(2*a + b - k)

Fixed code:
a, b, c, k = map(int, input().split())

if k <= a:
    print(k)
elif a < k <= a+b:
    print(a)
else:
    print(2*a + b -k)
Buggy code:
a,b,c,k =map(int,input().split())

if a >= k:
    print(a)
elif a + b >= k:
    print(a)
else:
    print(a - c)

Fixed code:
a,b,c,k = map(int, input().split())
if k<=a:
    print(k)
elif k-a<=b:
    print(a)
else:
    print(a - (k-(a+b)))
Buggy code:
a, b, c, k = map(int, input().split())

if k >= a:
    print(k)

elif k >= (a + b):
    print(a)

else:
    print(k - (k-(a+b)))
    

Fixed code:
a,b,c,k = map(int,input().split())
if k<=a:
    print(k)
elif k<=a+b:
    print(a)
else:
    print(a-(k-(a+b)))
Buggy code:
a,b,c,k = map(int, input().split())

ans = 0

if k <= a:
  ans = k
elif a < k < a+b:
  ans = a
elif k > a+b:
  ans = 2 * a - k + b
  
print(ans)
  


Fixed code:
a,b,c,k = map(int, input().split())

ans = 0

if k <= a:
  ans = k
elif a < k <= a+b:
  ans = a
elif k > a+b:
  ans = 2 * a - k + b
  
print(ans)
Buggy code:
A, B, C, K = map(float, input().split())

if A>K:
    print(K)
elif (A+B)>=K:
    print(A)
else:
    print(A-(K-A-B))


Fixed code:
A, B, C, K = map(int, input().split())

if A>K:
    print(K)
elif (A+B)>=K:
    print(A)
else:
    print(A-(K-A-B))
Buggy code:
abck = input().split()

a = int(abck[0])
b = int(abck[1])
c = int(abck[2])
k = int(abck[3])


if k <= a+b:
  print(k)
else:
  print(a - (k-(a+b)))

Fixed code:
abck = input().split()

a = int(abck[0])
b = int(abck[1])
c = int(abck[2])
k = int(abck[3])


if k <= a:
  print(k)
elif k <= a+b:
  print(a)
else:
  print(a - (k-(a+b)))
Buggy code:
l = input().split()
A, B, C, K = int(l[0]), int(l[1]), int(l[2]), int(l[3])

if A >= K:
  print(K)
elif A+B >= K:
  print(A)
else:
  print(A-C)

Fixed code:
l = input().split()
A, B, C, K = int(l[0]), int(l[1]), int(l[2]), int(l[3])

if A >= K:
  print(K)
elif A+B >= K:
  print(A)
else:
  print(A-(K-A-B))
Buggy code:
a,b,c,k = list(map(int,input().split()))
ans = 0
if a>=k:
    ans=k
else:
    ans+=a
    k-=a
    if b>=k:
        print(ans)
    else:
        k-=b
        ans-=k
print(ans)

Fixed code:
a,b,c,k = list(map(int,input().split()))
ans = 0
if a>=k:
    ans=k
else:
    ans+=a
    k-=a
    if b<k:
        k-=b
        ans-=k
print(ans)
Buggy code:
a, b, c, k = map(int, input().split())

for i in range(3):
    if i == 0:
        k -= a
        if k <= 0:
            print(k)
            break

    elif i == 1:
        k -= b
        if k <= 0:
            print(a)
            break

    elif i == 2:
        if k < c:
            print(a+(-1*k))
        else:
            print(a+c)


Fixed code:
a, b, c, k = map(int, input().split())

for i in range(3):
    if i == 0:
        if k <= a:
            print(k)
            break
        else:
            k -= a

    elif i == 1:
        if k <= b:
            print(a)
            break
        else:
            k -= b

    elif i == 2:
        if k <= c:
            print(a+(-1*k))
        else:
            print(a+c)
Buggy code:
N,M,X = map(int,input().split())

A =  []
S = [0 for _ in range(N)] 
min_value = 0 
score=[0 for _ in range(N)] 

for x in range(N):
  A.append(list(map(int,input().split())))

for x in range(N):
  min_value += A[x][0]
  
sucess = 0

for bit in range(2**N):
  for i in range(N):
    if (bit >> i) & 1:
      S.append(A[i][0])
      for x in range(M):
        score[x] += A[i][x+1]
  flag = 0

  for k in score:
    if k >= 10:
      flag += 1
    if flag ==len(score):
      if min_value >= sum(S):
        min_value = sum(S)
        sucess += 1 
        
  score=[0 for _ in range(N)]
  S =[]
  
if sucess > 0:
	print(min_value)
else:
  print("-1")

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

A =  []
S = [0 for _ in range(N)] 
min_value = 0 
score=[0 for _ in range(M)] 

for x in range(N):
  A.append(list(map(int,input().split())))

for x in range(N):
  min_value += A[x][0]


sucess = 0

for bit in range(2**N):
  for i in range(N):
    if (bit >> i) & 1:
      S.append(A[i][0])
      for x in range(M):
        score[x] += A[i][x+1]
  flag = 0
  #print(score)
  for k in score:
    if k >= X:
      flag += 1
    if flag ==len(score):
      #print("S",S)
      if min_value >= sum(S):
        min_value = sum(S)
        sucess += 1 
        
  score=[0 for _ in range(M)]
  S =[]
  
if sucess > 0:
	print(min_value)
else:
  print("-1")
Buggy code:
# coding: utf-8
# Your code here!
n,m,x=map(int,input().split())
A=[]
ALL=[]
ans=10**7
for i in range(n):
    A.append(list(map(int,input().split())))
for i in range(2**n):
    S=[0 for _ in range(m+1)]
    buy=[]
    for j in range(n):
        if ((i>>j) & 1):
            buy.append(A[j])
        #for k in range(m+1):
    for j in range(m+1):
        for k in range(len(buy)):
            S[j]+=buy[k][j]
    #print(S)
    flag=0
    for j in range(1,m+1):
        if S[j]<x:
            flag=1
    if flag==0:
        ans=min(ans,S[0])
print(ans)

Fixed code:
# coding: utf-8
# Your code here!
n,m,x=map(int,input().split())
A=[]
ALL=[]
ans=10**7
for i in range(n):
    A.append(list(map(int,input().split())))
for i in range(2**n):
    S=[0 for _ in range(m+1)]
    buy=[]
    for j in range(n):
        if ((i>>j) & 1):
            buy.append(A[j])
        #for k in range(m+1):
    for j in range(m+1):
        for k in range(len(buy)):
            S[j]+=buy[k][j]
    #print(S)
    flag=0
    for j in range(1,m+1):
        if S[j]<x:
            flag=1
    if flag==0:
        ans=min(ans,S[0])
if ans==10**7:
    print(-1)
else:
    print(ans)
Buggy code:
from itertools import combinations
N, M, X = map(int, input().split())
CAs = [[int(n) for n in input().split()] for _ in range(N)]

MAX = 10**5 * 12 + 1

print(CAs)
CAs.sort()
print(CAs)

for i in range(1, N + 1):
    # min_ = MAX
    for cas in combinations(CAs, i):
        rikai = [0] * M
        kakaku = 0
        for ca in cas:
            for j in range(M):
                rikai[j] += ca[j + 1]
            kakaku += ca[0]
        if len(list(filter(lambda x: x < X, rikai))) == 0:
            print(kakaku)
            break
    else:
        continue
    break
        #     min_ = min(min_, kakaku)
        # # print(cas, min_)
    # if min_ < MAX:
    #     print(min_)
    #     break
else:
    print('-1')

Fixed code:
from itertools import combinations
N, M, X = map(int, input().split())
CAs = [[int(n) for n in input().split()] for _ in range(N)]

MAX = 10 ** 5 * 12 + 1
min_ = MAX

for i in range(1, N + 1):
    for cas in combinations(CAs, i):
        rikai = [0] * M
        kakaku = 0
        for ca in cas:
            for j in range(M):
                rikai[j] += ca[j + 1]
            kakaku += ca[0]
        if len(list(filter(lambda x: x < X, rikai))) == 0:
            min_ = min(min_, kakaku)
if min_ == MAX:
    print('-1')
else:
    print(min_)
Buggy code:
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
p = float("inf")

for i in range(1, 2**n):
    s = [0]*m
    count = 0
    ps = 0
    for j in range(n):
        if (i >> j) & 1:
            ps += a[j][0]
            for k in range(m):
                s[k] += a[j][k+1]
                if s[k] >= x:
                    count += 1
    if count == m:
        p = min(ps, p)
        
if p == float('inf'):
    print(-1)
else:
    print(p)

Fixed code:
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
p = float("inf")

for i in range(1, 2**n):
    s = [0]*m
    count = 0
    ps = 0
    for j in range(n):
        if (i >> j) & 1:
            ps += a[j][0]
            for k in range(m):
                s[k] += a[j][k+1]
                
    for k in range(m):
        if s[k] >= x:
            count += 1
            
    if count == m:
        p = min(ps, p)
        
if p == float('inf'):
    print(-1)
else:
    print(p)
Buggy code:
import numpy as np
n,m,x = map(int,input().split())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)
  
c = np.array(c)
ans = float('inf')
for i in range(1,2**n):
  chk = [0]*m
  cost = 0
  for j in range(n):
    if (i>>j)&1 == 1:
      cost += c[j][0]
      chk += c[j][1:]
  if min(chk) >= x:
    ans = min(ans,cost)
    
print(ans)

Fixed code:
import numpy as np
n,m,x = map(int,input().split())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)
  
c = np.array(c)
ans = float('inf')
for i in range(1,2**n):
  chk = [0]*m
  cost = 0
  for j in range(n):
    if (i>>j)&1 == 1:
      cost += c[j][0]
      chk += c[j][1:]
  if min(chk) >= x:
    ans = min(ans,cost)
  
if ans == float('inf'):
  ans = -1
print(ans)
Buggy code:
import itertools as it

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

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
    # print(comb)
    bag = [0] * M+1
    for i in range(N):
        if comb[i] == 0:
            continue
        else:
            for j in range(M+1):
                bag[j] += book[i][j]

    if min(bag[1:]) < X:
        continue
    else:
        prices.append(bag[0])

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

Fixed code:
import itertools as it

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

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
    # print(comb)
    bag = [0] * (M+1)
    for i in range(N):
        if comb[i] == 0:
            continue
        else:
            for j in range(M+1):
                bag[j] += book[i][j]

    if min(bag[1:]) < X:
        continue
    else:
        prices.append(bag[0])

if len(prices) == 0:
    print(-1)
else:
    print(min(prices))
Buggy code:
N, M, X = map(int, input().split())
Ca = [list(map(int, input().split())) for _ in range(N)]
pattern = []
for i in range(2**N):
    lis = []
    for j in range(N):
        if ((i>>j)&1):
            lis.append(Ca[j])
    pattern.append(lis)

cnt = []
for i in range(2**N):
    g = [0] * (M+1)
    for j in range(len(pattern[i])):
        for k in range(M+1):
            g[k] += pattern[i][j][k]
    if g[1:M] < X:
        continue
    else:
        cnt.append(g[0])
if len(cnt) ==0:
    print(-1)
else:
    print(min(cnt))

Fixed code:
N, M, X = map(int, input().split())
Ca = [list(map(int, input().split())) for _ in range(N)]
pattern = []
for i in range(2**N):
    lis = []
    for j in range(N):
        if ((i>>j)&1):
            lis.append(Ca[j])
    pattern.append(lis)

cnt = []
for i in range(2**N):
    g = [0] * (M+1)
    for j in range(len(pattern[i])):
        for k in range(M+1):
            g[k] += pattern[i][j][k]
    if M==1 and g[1]< X:
        continue
    elif M>1 and min(g[1:M+1]) < X:
        continue
    else:
        cnt.append(g[0])
if len(cnt) ==0:
    print(-1)
else:
    print(min(cnt))
Buggy code:
import itertools

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

books = []

for _ in range(n):
    c = list(map(int, input().split()))
    books.append(c)

patern = []

for i in range(1, n+1):
    patern += itertools.combinations(range(n), i)

cost = 10**6


for j in patern:
    total = 0
    flag = 1
    for k in range(1,m+1):
        cnt = 0
        for l in list(j):
            cnt += books[l][k]
        if cnt < x:
            flag *= 0
    if flag == 1:
        for l in j:
            total += books[l][0]
        cost = min(cost, total)

if cost == 10**7:
    print(-1)
else:
    print(cost)

Fixed code:
import itertools

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

books = []

for _ in range(n):
    c = list(map(int, input().split()))
    books.append(c)

patern = []

for i in range(1, n+1):
    patern += itertools.combinations(range(n), i)

cost = 10**7


for j in patern:
    total = 0
    flag = 1
    for k in range(1,m+1):
        cnt = 0
        for l in list(j):
            cnt += books[l][k]
        if cnt < x:
            flag *= 0
    if flag == 1:
        for l in j:
            total += books[l][0]
        cost = min(cost, total)

if cost == 10**7:
    print(-1)
else:
    print(cost)
Buggy code:

n,m,k=map(int,input().split())
A=[]
for i in range(n):
    row=list(map(int,input().split()))
    A.append(row)
mn=10**9
for i in range(int(2**n)):
    x=bin(i)[2:]
    x=("0"*(n-len(x)))+x
    curr=[0 for ptr in range(m)]
    s=0
    for j in range(n):
        if(x[j]=="1"):
            s+=A[j][0]
            curr=[curr[ptr]+A[j][ptr+1] for ptr in range(m) ]

    curr=[curr[ptr]>=k for ptr in range(m)]
    curr=list(set(curr))
    if(curr==[True]):
        if(s<mn):
            mn=s
print(mn)

Fixed code:

n,m,k=map(int,input().split())
A=[]
for i in range(n):
    row=list(map(int,input().split()))
    A.append(row)
mn=10**9
for i in range(int(2**n)):
    x=bin(i)[2:]
    x=("0"*(n-len(x)))+x
    curr=[0 for ptr in range(m)]
    s=0
    for j in range(n):
        if(x[j]=="1"):
            s+=A[j][0]
            curr=[curr[ptr]+A[j][ptr+1] for ptr in range(m) ]

    curr=[curr[ptr]>=k for ptr in range(m)]
    curr=list(set(curr))
    if(curr==[True]):
        if(s<mn):
            mn=s
if(mn==10**9):
    print(-1)
else:
    print(mn)
Buggy code:
import numpy as np
from itertools import product

def readlines(n):
    for _ in range(n):
        yield list(map(int, input().split()))

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

    books = np.array(list(readlines(N)))
    ans = np.inf
    for bit in product([0, 1], repeat=N):
        comb_sum = np.dot(np.array(bit), books)
        if all(comb_sum[1:] >= X):
            ans = min(ans, comb_sum[0])

    print(ans)
        


main()

Fixed code:
import numpy as np
from itertools import product

def readlines(n):
    for _ in range(n):
        yield list(map(int, input().split()))

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

    books = np.array(list(readlines(N)))
    ans = np.inf
    for bit in product([0, 1], repeat=N):
        comb_sum = np.dot(np.array(bit), books)
        if all(comb_sum[1:] >= X):
            ans = min(ans, comb_sum[0])

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


main()
Buggy code:
Books,Cost,X=None,None,None
DP={}

def getUnderstanding(prev,curr):
    global Books
    L=[]
    for i in range(len(prev)):
        L.append(prev[i]+Books[curr][i])
    return L
def isUnderstandingReached(prev):
    global X
    for u in prev:
        if u<X:
            return False
    return True

def F(curr,prev):
    global Books,Cost,X,DP
    if (curr,tuple(prev)) in DP:
        return DP[(curr,prev)]
    if isUnderstandingReached(prev):
        return 0
    if curr==len(Books):
        return float('inf')
    DP[(curr,tuple(prev))]=min(Cost[curr]+F(curr+1,getUnderstanding(prev,curr)),F(curr+1,prev))
    return DP[(curr,tuple(prev))]

N,M,X=map(int,input().strip().split())
Books=[]
Cost=[]
for i in range(N):
    L=list(map(int,input().strip().split()))
    Books.append(L[1:])
    Cost.append(L[0])
print(F(0,[0]*len(Books[0])))

Fixed code:
Books,Cost,X=None,None,None
DP={}

def getUnderstanding(prev,curr):
    global Books
    L=[]
    for i in range(len(prev)):
        L.append(prev[i]+Books[curr][i])
    return L
def isUnderstandingReached(prev):
    global X
    for u in prev:
        if u<X:
            return False
    return True

def F(curr,prev):
    global Books,Cost,X,DP
    #if (curr,tuple(prev)) in DP:
    #    return DP[(curr,prev)]
    if isUnderstandingReached(prev):
        return 0
    if curr==len(Books):
        return float('inf')
    DP[(curr,tuple(prev))]=min(Cost[curr]+F(curr+1,getUnderstanding(prev,curr)),F(curr+1,prev))
    return DP[(curr,tuple(prev))]

N,M,X=map(int,input().strip().split())
Books=[]
Cost=[]
for i in range(N):
    L=list(map(int,input().strip().split()))
    Books.append(L[1:])
    Cost.append(L[0])
res=F(0,[0]*len(Books[0]))
if res==float('inf'):
    print(-1)
else:
    print(res)
Buggy code:
n,m,x=map(int,input().split())
l=[]

for i in range(n):
    a=list(map(int,input().split()))
    l.append(a)
print(l)
ans=99999999
for i in range(2 ** n):
    bag = []
    for j in range(n):  
        if ((i >> j) & 1): 
            bag.append(l[j])  
    skill=[0]*m
    enou=[0]*m
    mone=0
    for sub in bag:
        mone+=sub[0]
        for kk in range(1,m):
            skill[kk-1]+=sub[kk]
            if skill[kk-1]>=x:
                enou[kk-1]+=1
    if sum(enou)==m:
        if ans>mone:
            ans=mone
if ans==99999999:
    print(-1)
else:
    print(ans)

Fixed code:
n,m,x=map(int,input().split())
l=[]

for i in range(n):
    a=list(map(int,input().split()))
    l.append(a)
ans=99999999
for i in range(2 ** n):
    bag = []
    for j in range(n):  
        if ((i >> j) & 1): 
            bag.append(l[j])  
    skill=[0]*m
    enou=[0]*m
    mone=0
    for sub in bag:
        mone+=sub[0]
        for kk in range(1,m+1):
            skill[kk-1]+=sub[kk]
            if skill[kk-1]>=x:
                enou[kk-1]+=1
    if 0 not in enou:
        if ans>mone:
            ans=mone
if ans==99999999:
    print(-1)
else:
    print(ans)
Buggy code:
n,m,x = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]

ans = 10**5 + 1

for i in range(2 ** n):
  skill = [0] * m
  overTen = False
  money = 0
  for j in range(n):
    if ((int(bin(i)[2:]) >> j) & 1):
      money += a[j][0]
      for h in range(m):
        skill[h] += a[j][h+1]
  for k in skill:
    if k >= x:
      overTen = True
    else:
      overTen = False
      break

  if overTen == True:
    if money < ans:
      ans = money

print(ans)

Fixed code:
n,m,x = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
ans = 10**9
for i in range(2 ** n):
  skill = [0] * m
  overTen = False
  money = 0
  for j in range(n):
    if ((int(bin(i)[2:]) >> j) & 1):
      money += a[j][0]
      for h in range(m):
        skill[h] += a[j][h+1]
  for k in skill:
    if k >= x:
      overTen = True
    else:
      overTen = False
      break
  if overTen == True:
    if money < ans:
      ans = money

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