qyliang/CodeNanoFix huggingface dataset:
Buggy code:
#!/usr/bin/env python3
import itertools

def main():
    N, M, X = map(int, input().split())
    C = [0] * N
    A = []
    for n in range(0, N):
        l = input().split()
        C[n] = int(l[0])
        A.append([int(i) for i in l[1:]])
        print(C[n], A[n])

    min_cost = sum(C) + 1
    for i in range(N):
        for comb in itertools.combinations(range(N), i):
            canAchive = True
            for m in range(M):
                r = 0
                for n in comb:
                    r += A[n][m]
                if (r < X):
                    canAchive = False
                    break
            if (canAchive):
                cost = sum([C[n] for n in comb])
                min_cost = min(min_cost, cost)

    if (min_cost <= sum(C)):
        print(min_cost)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Fixed code:
#!/usr/bin/env python3
import itertools

def main():
    N, M, X = map(int, input().split())
    C = [0] * N
    A = []
    for n in range(0, N):
        l = input().split()
        C[n] = int(l[0])
        A.append([int(i) for i in l[1:]])

    min_cost = sum(C) + 1
    globalCanAchive = False
    for i in range(1,N+1):
        for comb in itertools.combinations(range(N), i):
            canAchive = True
            for m in range(M):
                r = sum([A[n][m] for n in comb])
                if (r < X):
                    canAchive = False
                    break
            if (canAchive):
                globalCanAchive = True
                cost = sum([C[n] for n in comb])
                min_cost = min(min_cost, cost)

    if (globalCanAchive):
        print(min_cost)
    else:
        print(-1)


if __name__ == '__main__':
    main()
Buggy code:
import itertools
import numpy as np
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l = sorted(l)
l = np.array(l)
print(l)
ans = np.sum(l, 0)[0]
ans_s = np.sum(l, 0)
if np.any(ans_s[1:] < x):
    print(-1)
    exit()
count = 0
for i in range(1, m + 1):
    for j in itertools.combinations(l, i):
        tot = np.sum(j, 0)
        if np.all(tot[1:] >= x) and tot[0] < ans:
            ans = tot[0]
            print(int(ans))
            exit()

Fixed code:
import itertools
import numpy as np
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l = np.array(l)
ans = np.sum(l, 0)[0]
ans_s = np.sum(l, 0)
if np.any(ans_s[1:] < x):
    print(-1)
    exit()
for i in range(1, n + 1):
    for j in itertools.combinations(l, i):
        tot = np.sum(j, 0)
        if np.all(tot[1:] >= x) and tot[0] < ans:
            ans = tot[0]
print(int(ans))
Buggy code:
import numpy as np
from itertools import product
INF = 10**9

N, M, X = map(int, input().split())
C = [None]*N
A = [None]*N
for i in range(N):
    line = list(map(int, input().split()))
    C[i] = line[0]
    A[i] = np.array(line[1:])

choose = [True, False]

min_price = INF

for s in product([True, False], repeat=N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if s >> i & 1:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

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


Fixed code:
import numpy as np
INF = 10**9

N, M, X = map(int, input().split())
C = [None]*N
A = [None]*N
for i in range(N):
    line = list(map(int, input().split()))
    C[i] = line[0]
    A[i] = np.array(line[1:])

choose = [True, False]

min_price = INF

for s in range(1 << N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if s >> i & 1:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

if min_price == INF:
    print(-1)
else:
    print(min_price)
Buggy code:
n,m,x = map(int,input().split())

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

res=float('inf')

for i in range(2**n):
  sc=0
  a=[0]*m
  for j in range(n):
    if ((i >> j) & 1) :
      sc=+ca[j][0]
      a+=ca[j][1:]
  if min(a)>=x:
    res=min (sc,res)

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


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

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

res=float('inf')

for i in range(2**n):
  sc=0
  a=[0]*m
  for j in range(n):
    if ((i >> j) & 1) :
      sc+=ca[j][0]
      for k in range(m):
        a[k]+=ca[j][k+1]
  if min(a)>=x:
    res=min(sc,res)

if res == float('inf'):
    print(-1)
else:
    print(res)
Buggy code:
N, M, X = map(int,input().split())
skill_book = []
for i in range(N):
    skill_book.append(list(map(int, input().split())))
box = []
flag = 1
for i in range(1 << M):
    total = [0] * (M + 1)
    for j in range(M):
        if (i >> j) & 1:
            total = [x + y for (x, y) in zip(total, skill_book[j])]
    over = 1
    for j in range(1, len(total)):
        if not (total[j] >= X):
            over = 0
    if over == 1 and len(total) > 0:
        box.append(total[0])

print(min(box))

Fixed code:
N, M, X = map(int,input().split())
skill_book = []
for i in range(N):
    skill_book.append(list(map(int, input().split())))
box = []
flag = 1
for i in range(1 << N):
    total = [0] * (M + 1)
    for j in range(N):
        if (i >> j) & 1:
            total = [x + y for (x, y) in zip(total, skill_book[j])]
    over = 1
    for j in range(1, len(total)):
        if not (total[j] >= X):
            over = 0
    if over == 1 and len(total) > 0:
        box.append(total[0])
if len(box) > 0:
    print(min(box))
else:
    print('-1')
Buggy code:
from sys import maxsize
import numpy as np


def check(ls, x):
    for i in range(1, len(ls)):
        if ls[i] < x:
            return False
    return True


def convert(b, n):
    diff = n - len(b)
    return ('0' * diff + b)[::-1]


n, m, x = map(int, input().split())
ls = []
a = [i for i in range(n)]
for i in range(n):
    ls.append(list(map(int, input().split())))
dp = [0] * ((1 << n) + 1)
for i in range(n):
    dp[1 << i] = np.array(ls[i])
total_cost = maxsize
for subset in range(1, (1 << n)):
    b = bin(subset)[2:]
    b = convert(b, n)
    a = np.zeros(m + 1)
    for i in range(n):
        if int(b[i]):
            a += dp[1 << i]
    dp[subset] = a
    if check(dp[subset], x):
        total_cost = min(total_cost, dp[subset][0])
print(int(total_cost))


Fixed code:
from sys import maxsize
import numpy as np


def check(ls, x):
    for i in range(1, len(ls)):
        if ls[i] < x:
            return False
    return True


def convert(b, n):
    diff = n - len(b)
    return ('0' * diff + b)[::-1]


n, m, x = map(int, input().split())
ls = []
a = [i for i in range(n)]
for i in range(n):
    ls.append(list(map(int, input().split())))
dp = [0] * ((1 << n) + 1)
for i in range(n):
    dp[1 << i] = np.array(ls[i])
total_cost = maxsize
for subset in range(1, (1 << n)):
    b = bin(subset)[2:]
    b = convert(b, n)
    a = np.zeros(m + 1)
    for i in range(n):
        if int(b[i]):
            a += dp[1 << i]
    dp[subset] = a
    if check(dp[subset], x):
        total_cost = min(total_cost, dp[subset][0])
if total_cost ==maxsize:
    print(-1)
else:  
    print(int(total_cost))
Buggy code:
import numpy as np
import itertools
N, M, X = (int(i) for i in input().split())
Y = np.zeros((N, M+1))
for i in range(N):
    Y[i,:] = [int(i) for i in input().split()]
C = Y[:,0]
A = np.matrix(Y[:,1:])
res = np.inf
f = '0'+str(N)+'b'
for i in range(2**N):
    z = np.array([int(s) for s in list(format(i, f))])
    cost = z @ C
    skill = z * A
    if (skill >= X).all() and (cost < res):
        res = cost
if np.isinf(res):
    print(-1)
else:
    print(res)

Fixed code:
import numpy as np
import itertools
N, M, X = (int(i) for i in input().split())
Y = np.zeros((N, M+1))
for i in range(N):
    Y[i,:] = [int(i) for i in input().split()]
C = Y[:,0]
A = np.matrix(Y[:,1:])
res = np.inf
f = '0'+str(N)+'b'
for i in range(2**N):
    z = np.array([int(s) for s in list(format(i, f))])
    cost = z @ C
    skill = z * A
    if (skill >= X).all() and (cost < res):
        res = cost
if np.isinf(res):
    print(-1)
else:
    print(int(res))
Buggy code:
n,m,x=map(int,input().split())
c=[]
a=[]
for i in range(n):
  tmp = list(map(int, input().split()))
  c.append(tmp[0])
  a.append(tmp[1:])
  
result = -1
for i in range(2**n):
  skill = [0]*m
  cost = 0
  for j in range(m):
    if (i >> j) & 1 == 0:
      continue
    cost += c[j]
    for s in range(m):
      skill[s] += a[j][s]
      
  if all(s >= x for s in skill):
    if result == -1:
      result = cost
    else:
      result = min(result,cost)
print(result)

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


result = -1
for i in range(2**n):
  skill = [0]*m
  cost = 0
  for j in range(n):
    if (i >> j) & 1 == 0:
      continue
    cost += c[j]
    for s in range(m):
      skill[s] += a[j][s]

  if all(s >= x for s in skill):
    if result == -1:
      result = cost
    else:
      result = min(result,cost)
print(result)
Buggy code:
import sys
input = sys.stdin.readlinedef


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

    MONEY = []
    UNDERSTAND = []
    for i in range(n):
        lst = [int(i) for i in input().split()]
        MONEY.append(lst[0])
        UNDERSTAND.append(lst[1:])

    ans = []
    for i in range(1 << n):
        understand = [0] * m
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += MONEY[j]
            for k in range(m):
                understand[k] += UNDERSTAND[j][k]
        if all([i >= x for i in understand]):
            ans.append(money)

    print(min(ans))


if __name__ == '__main__':
    main()

Fixed code:
import sys
input = sys.stdin.readline


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

    MONEY = []
    UNDERSTAND = []
    for i in range(n):
        lst = [int(i) for i in input().split()]
        MONEY.append(lst[0])
        UNDERSTAND.append(lst[1:])

    ans = -1
    for i in range(1 << n):
        understand = [0] * m
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += MONEY[j]
            for k in range(m):
                understand[k] += UNDERSTAND[j][k]
        if all([i >= x for i in understand]):
            if ans == -1:
                ans = money
            else:
                ans = min(ans, money)
    print(ans)


if __name__ == '__main__':
    main()
Buggy code:
blist = []
def createBitline(N, p, bl):
	if(N == p and len(bl) == N):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

def checkClear(X, list):
	for i in range(1, len(list)):
		if int(list[i]) < X:
			return False
	return True

listCA = []
N,M,X = map(int, input().split())
for i in range(N):
	listCA.append(input().split())
for i in listCA:
	print(i)
createBitline(N, 0, "")
cost = []
for x in range(len(blist)):
	sumCA = [0] * (M + 1)
	for i in range(N):
		if blist[x][i] == "1":
			for j in range(len(listCA[i])):
				sumCA[j] += int(listCA[i][j])
	if checkClear(X, sumCA):
		cost.append(sumCA[0])
if cost:
	print(min(cost))
else:
	print('-1')

Fixed code:
blist = []
def createBitline(N, p, bl):
	if(N == p and len(bl) == N):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")
 
def checkClear(X, list):
	for i in range(1, len(list)):
		if int(list[i]) < X:
			return False
	return True
 
listCA = []
N,M,X = map(int, input().split())
for i in range(N):
	listCA.append(input().split())
createBitline(N, 0, "")
cost = []
for x in range(len(blist)):
	sumCA = [0] * (M + 1)
	for i in range(N):
		if blist[x][i] == "1":
			for j in range(len(listCA[i])):
				sumCA[j] += int(listCA[i][j])
	if checkClear(X, sumCA):
		cost.append(sumCA[0])
if cost:
	print(min(cost))
else:
	print('-1')
Buggy code:
N , M , X = map(int,input().split())
C = []
A = []
for _ in range(N):
    CA = list(map(int,input().split()))
    C.append(CA[0])
    A.append(CA[1:])

ans = float('inf')
for i in range(2**N):
    Level = [0]* M
    Cost = 0
    
    for j in range(N):
        if (i>>j)&1:
            Cost += C[j]
            for k in range(M):
                Level[​ Cost)

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

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

ans = float('inf')
for i in range(2**N):
    Level = [0]* M
    Cost = 0
    
    for j in range(N):
        if (i>>j)&1:
            Cost += C[j]
            for k in range(M):
                Level[k] += A[j][k]
                
    if all([Level[l] >= X for l in range(M)]):
        ans = min(ans, Cost)

if ans != float('inf'):
    print(ans)
else:
    print('-1')
Buggy code:
import itertools

N, M, X = map(int, input().split())
a = [list(map(int, input().split())) for l in range(N)]

ans = 10**8

for i in range(2**N):
    score = [0] * M
    total = 0
    for j in range(1,N+1):
        if ((i >> j) & 1):
            total += a[j][0]
            for k in range(M):
                score[k] += a[j][k+1]
        
    if min(score) >= X:
        ans = min(ans, total)

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


Fixed code:
import itertools

N, M, X = map(int, input().split())
a = [list(map(int, input().split())) for l in range(N)]

ans = 10**8

for i in range(2**N):
    score = [0] * M
    total = 0
    for j in range(N):
        if ((i >> j) & 1):
            total += a[j][0]
            for k in range(M):
                score[k] += a[j][k+1]
        
    if min(score) >= X:
        ans = min(ans, total)

if ans == 10**8:
    print(-1)
else:
    print(ans)
Buggy code:
n,m,x=map(int,input().split())
a=[]
e=10**8
for i in range(n):
    b=list(map(int,input().split()))
    a.append(b)
for i in range(2**n):
    c=[0]*(m+1)
    s=0
    for j in range(n):
        if i>=2**(n-j-1):
            i-=2**(n-j-1)
            c=[x+y for (x,y) in zip(a[j],c)]
    for j in range(m):
        if c[1+j]<x:
            s+=1
    print(c)
    if s==0 and e>c[0]:
        e=c[0]
if e==100000000:
    print(-1)
else:
    print(e)

Fixed code:
n,m,x=map(int,input().split())
a=[]
e=10**8
for i in range(n):
    b=list(map(int,input().split()))
    a.append(b)
for i in range(2**n):
    c=[0]*(m+1)
    s=0
    for j in range(n):
        if i>=2**(n-j-1):
            i-=2**(n-j-1)
            c=[x+y for (x,y) in zip(a[j],c)]
    for j in range(m):
        if c[1+j]<x:
            s+=1
    if s==0 and e>c[0]:
        e=c[0]
if e==100000000:
    print(-1)
else:
    print(e)
Buggy code:
n,m,x=map(int,input().split())
c=[0]*n
a=[0]*n
ans=10**10
for i in range(n):
  d,*b=map(int,input().split())
  c[i]=d
  a[i]=b
import numpy as np
a=np.array(a)
from itertools import product
r=list(product([0,1],repeat=n))
for i in r:
  tmp=np.array([0]*m)
  cost=0
  for j,k in enumerate(i):
    tmp+=k*a[j]
    cost+=k*c[j]
  if all(tmp>=x):
    ans=min(ans,cost)
print(ans)

Fixed code:
n,m,x=map(int,input().split())
c=[0]*n
a=[0]*n
ans=10**10
for i in range(n):
  d,*b=map(int,input().split())
  c[i]=d
  a[i]=b
import numpy as np
a=np.array(a)
from itertools import product
r=list(product([0,1],repeat=n))
for i in r:
  tmp=np.array([0]*m)
  cost=0
  for j,k in enumerate(i):
    tmp+=k*a[j]
    cost+=k*c[j]
  if all(tmp>=x):
    ans=min(ans,cost)
if ans>10**9:
  ans=-1
print(ans)
Buggy code:
import sys
import numpy as np
sys.setrecursionlimit(10**8)

def dfs(i,a,value):
  global ans
  if i==n:
    if all(a[i]>=x for i in range(m)):
      ans=min(ans,value)

    else:
      ans=-1

  else:
    dfs(i+1,a,value)
    dfs(i+1,a+np.array(pc[i][1:]),value+pc[i][0])


ans=float('inf')
n,m,x=map(int,input().split())
pc=[]
for i in range(n):
  s=list(map(int,input().split()))
  pc.append(s)

dfs(0,np.array([0]*(m)),0)
print(ans)

Fixed code:
import sys
import numpy as np
sys.setrecursionlimit(10**8)

def dfs(i,a,value):
  global ans
  if i==n:
    if all(a[i]>=x for i in range(m)):
      ans=min(ans,value)


  else:
    dfs(i+1,a,value)
    dfs(i+1,a+np.array(pc[i][1:]),value+pc[i][0])


ans=float('inf')
n,m,x=map(int,input().split())
pc=[]
for i in range(n):
  s=list(map(int,input().split()))
  pc.append(s)

dfs(0,np.array([0]*(m)),0)
if ans==float('inf'):
  ans=-1
print(ans)
Buggy code:
import numpy as np
n,m,x = map(int, input().split())

#A = np.zeros((n, m))
CA = np.zeros((n,m+1))

for i in range(n):
    CA[i]=list(map(int, input().split()))
    # C[i],A[i]=T[0],T[1:]
#print(A,C)

min_cost = 9999999999999999

for i in range(2**n):
    T = np.zeros((m+1))
    for j in range(n):
        if i&(2**j) > 0:
            T += CA[j]
    if all(T[1:] >= x):
        min_cost = min(min_cost,T[0])        

print(min_cost)

Fixed code:
import numpy as np
n,m,x = map(int, input().split())

#A = np.zeros((n, m))
CA = np.zeros((n,m+1))

for i in range(n):
    CA[i]=list(map(int, input().split()))
    # C[i],A[i]=T[0],T[1:]
#print(A,C)

min_cost = -1

for i in range(2**n):
    T = np.zeros((m+1))
    for j in range(n):
        if i&(2**j) > 0:
            T += CA[j]
    if all(T[1:] >= x):
        if min_cost == -1:
            min_cost = T[0]
        else: 
            min_cost = min(min_cost,T[0])        

print(int(min_cost))
Buggy code:
mod=1000000007
n,m,x=map(int,input().split())
w=[]
for i in range(n):
    w.append([int(i) for i in input().split()])
ans=mod
for i in range(2**n):
    d=0
    chk=[0]*m
    for j in range(n):
        if (i>>j&1):
            d+=w[j][0]
            for k in range(m):
                chk[k]+=w[j][k+1]

    if min(chk)>=x:
        ans=min(ans,d)
print(ans)


Fixed code:
mod=1000000007
n,m,x=map(int,input().split())
w=[]
for i in range(n):
    w.append([int(i) for i in input().split()])
ans=mod
for i in range(2**n):
    d=0
    chk=[0]*m
    for j in range(n):
        if (i>>j&1):
            d+=w[j][0]
            for k in range(m):
                chk[k]+=w[j][k+1]

    if min(chk)>=x:
        ans=min(ans,d)
#print(ans)
print(ans if ans!=mod else -1)
Buggy code:
n , m , x = map(int,input().split())
san = []
for i in range(n):
    san.append(list(map(int,input().split())))
ans = 10**8
for b in range(2**n):
    bs = format(b, 'b')
    bs = str(bs).rjust(n,'0')
    one = 0
    p = [0 for i in range(m)]
    for i in range(n):
        if bs[i] == "1":
            one += san[i][0]
            for j in range(1,m+1):
                p[j-1] += san[i][j]
    if min(p) >= x:
        ans = min(ans,one)
print(ans)

Fixed code:
n , m , x = map(int,input().split())
san = []
for i in range(n):
    san.append(list(map(int,input().split())))
ans = 10**8
for b in range(2**n):
    bs = format(b, 'b')
    bs = str(bs).rjust(n,'0')
    one = 0
    p = [0 for i in range(m)]
    for i in range(n):
        if bs[i] == "1":
            one += san[i][0]
            for j in range(1,m+1):
                p[j-1] += san[i][j]
    if min(p) >= x:
        ans = min(ans,one)
if ans == 10**8:
    print(-1)
else:
    print(ans)
Buggy code:
import itertools
n,m,x=map(in,input().split())
l=[list(map(int,input().split())) for i in range(n)]
costl=[]
for p in itertools.product([0,1],n):
  al=[0]*m
  cost=0
  for i in range(n):
    if p[i]==1:
      cost+=l[i][0]
      for j in range(1,m):
        al[j-1]+=l[i][j]
  if all(mm>=x for mm in m):
    costl.append(cost)
print(min(cost))
      
        
      

Fixed code:
import itertools
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
costl=[]
for p in itertools.product([0,1],repeat=n):
  al=[0]*m
  cost=0
  for i in range(n):
    if p[i]==1:
      cost+=l[i][0]
      for j in range(1,m+1):
        al[j-1]+=l[i][j]
  if all(mm>=x for mm in al):
    costl.append(cost)
print(min(costl) if len(costl)>=1 else -1)
Buggy code:
N,M,X=map(int,input().split())
B=[list(map(int,input().split())) for _ in range(N)]
ans=(10**5)*12+1
for i in range(1,2**N):
  tmp=[0]*M
  c=0
  for j in range(N):
    if i>>j&1:
      for k in range(M):
        tmp[k]+=B[j][k+1]
      c+=B[j][0]
  if len([i for i in tmp if i>=X])==M:
    ans=min(c,ans)
print(ans)

Fixed code:
N,M,X=map(int,input().split())
B=[list(map(int,input().split())) for _ in range(N)]
inf=(10**5)*12+1
ans=inf
for i in range(1,2**N):
  tmp=[0]*M
  c=0
  for j in range(N):
    if i>>j&1:
      for k in range(M):
        tmp[k]+=B[j][k+1]
      c+=B[j][0]
  if len([i for i in tmp if i>=X])==M:
    ans=min(c,ans)
print(ans if ans<inf else -1)
Buggy code:
# -*- coding: utf-8 -*-
n, m, x = map(int, input().split())
L = []
J = []
for i in range(n):
    l = list(map(int, input().split()))
    L.append(l)
for i in range(2**n):
    cost = 0
    f = 0
    M = [0]*m
    for j in range(n):
        
        if (i>>j)&1 == 1:
            cost += L[j][0]
            for k in range(m):
                M[k] += L[j][k+1]
    for p in M:
        if p < x:
            f = 1
    if f == 0:
        J.append(cost)
print(min(J))

Fixed code:
# -*- coding: utf-8 -*-
n, m, x = map(int, input().split())
L = []
J = []
for i in range(n):
    l = list(map(int, input().split()))
    L.append(l)
for i in range(2**n):
    cost = 0
    f = 0
    M = [0]*m
    for j in range(n):
        
        if (i>>j)&1 == 1:
            cost += L[j][0]
            for k in range(m):
                M[k] += L[j][k+1]
    for p in M:
        if p < x:
            f = 1
    if f == 0:
        J.append(cost)
if J != []:
  print(min(J))
else:
  print(-1)
Buggy code:
import sys
import itertools
n, m, x=map(int, input().split())
text = [list(map(int, i.strip('\n').split())) for i in sys.stdin]
num_tex = [i for i in range(1, len(text) + 1)]
all_c = []
for comb in num_tex:
    for v in itertools.combinations(text, comb):
        sum_a = []
        for j in range(1, len(v[0])):
            sum_a.append(sum([v_[j] for v_ in v]))
        if all([x <= sum_a_ for sum_a_ in sum_a]):
            all_c.append(sum([v_[0] for v_ in v]))
print(sorted(all_c)[0])


Fixed code:
import sys
import itertools
n, m, x=map(int, input().split())
text = [list(map(int, i.strip('\n').split())) for i in sys.stdin]
num_tex = [i for i in range(1, len(text) + 1)]
all_c = []
for comb in num_tex:
    for v in itertools.combinations(text, comb):
        sum_a = []
        for j in range(1, len(v[0])):
            sum_a.append(sum([v_[j] for v_ in v]))
        if all([x <= sum_a_ for sum_a_ in sum_a]):
            all_c.append(sum([v_[0] for v_ in v]))
if len(all_c)!=0:
    print(sorted(all_c)[0])
else:
    print(-1)
Buggy code:
import itertools
n,m,x=map(int,input().split())
l=[[0]]*n
ln=[0]*m
kan=0
for i in range(n):
  l[i]=list(map(int,input().split()))
  for j in range(m+1):
    if j==0:
      kan+=l[i][j]
    else:
      ln[j-1]+=l[i][j]
if sorted(ln)[0]<x:
  print(-1)
else:
  mkan=-1
  for i in range(n):
    itr=itertools.combinations(range(n),i)
    for comb in itr:
      kan=0
      ln=[0]*m
      for j in comb:
        kan+=l[int(j)][0]
        for ii in range(m):
          ln[ii]+=l[int(j)][ii+1]
      if sorted(ln)>=x:
        if mkan==-1 or mkan>kan:
          mkan=kan
  print(mkan)

Fixed code:
import itertools
n,m,x=map(int,input().split())
l=[[0]]*n
ln=[0]*m
kan=0
for i in range(n):
  l[i]=list(map(int,input().split()))
  for j in range(m+1):
    if j==0:
      kan+=l[i][j]
    else:
      ln[j-1]+=l[i][j]
if sorted(ln)[0]<x:
  print(-1)
else:
  mkan=-1
  for i in range(n+1):
    itr=itertools.combinations(range(n),i)
    for comb in itr:
      kan=0
      ln=[0]*m
      for j in comb:
        kan+=l[int(j)][0]
        for ii in range(m):
          ln[ii]+=l[int(j)][ii+1]
      if sorted(ln)[0]>=x:
        if mkan==-1 or mkan>kan:
          mkan=kan
  print(mkan)