Problem p02683 (python)

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

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n, m, x = map(int, input().split())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
#print(l)
ans = []
mon = [0]*(2**n)

def ok(anss,x):
    for i in range(len(anss)):
        if anss[i]<x:
            return False
    return True

for i in range(2**n):
    #print(bin(i))
    #print(anss, mon)
    anss=[0]*m
    for j in range(n):
        #print(l[j][0])
        #print(i-2**(n-1))
        if ((i >> j) & 1):
            mon[i] += l[j][0]
            for k in range(1,m+1):
                anss[k-1]+=l[j][k]
    #print(anss)
    if ok(anss,x):
        #print(ans)
        ans.append(mon[i])
#print(mon,ans)
if ans != []:
    print(min(ans))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n, m, x = map(int, input().split())
l=[]
for i in range(n):
    l.append(list(map(int, input().split())))
#print(l)
ans=[]
mon = [0]*(2**n)

for i in range(2**n):
    ans1 = 0
    ans2 = 0
    ans3 = 0
    #print(bin(i))
    #print(anss, mon)
    for j in range(n):
        #print(l[j][0])
        #print(i-2**(n-1))
        if ((i>>j)&1):
            mon[i]+=l[j][0]
            ans1+=l[j][1]
            ans2 += l[j][2]
            ans3+=l[j][3]
            #print(mon)
    #print(ans1, ans2, ans3)
    if ans1<x:
        continue
    if ans2<x:
        continue
    if ans3<x:
        continue
    #print(ans1,ans2,ans3)
    ans.append(mon[i])
#print(mon,ans)
if ans!=[]:
    print(min(ans))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n, m, x = map(int, input().split())
l=[]
for i in range(n):
    l.append(list(map(int, input().split())))
#print(l)
ans=[]
mon = [0]*(2**n)

for i in range(2**n):
    ans1 = 0
    ans2 = 0
    ans3 = 0
    #print(bin(i))
    #print(anss, mon)
    for j in range(n):
        #print(l[j][0])
        #print(i-2**(n-1))
        if ((i>>j)&1):
            mon[i]+=l[j][0]
            ans1+=l[j][1]
            ans2 += l[j][2]
            ans3+=l[j][3]
            #print(mon)
    #print(ans1, ans2, ans3)
    if ans1<x:
        continue
    if ans2<x:
        continue
    if ans3<x:
        continue
    #print(ans1,ans2,ans3)
    ans.append(mon[i])
#print(mon,ans)
if ans!=[]:
    print(min(ans))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n, m, x = map(int, input().split())
l=[]
for i in range(n):
    l.append(list(map(int, input().split())))
#print(l)
ans=[]
mon = [0]*(2**n)

for i in range(2**(n)):
    ans1 = 0
    ans2 = 0
    ans3 = 0
    #print(anss, mon)
    for j in range(n):
        #print(l[j][0])
        #print(i-2**(n-1))
        if ((i>>j)&1):
            mon[i-2**(n-1)]+=l[j][0]
            ans1+=l[j][1]
            ans2 += l[j][2]
            ans3+=l[j][3]
    if ans1<x:
        continue
    if ans2<x:
        continue
    if ans3<x:
        continue
    #print(ans1,ans2,ans3)
    ans.append(mon[i-2**(n-1)])

if ans!=[]:
    print(min(ans))
else:
    print(-1)