Problem p02683 (python)

Fixed submission:
import numpy
N,M,X = map(int,input().split())
A = numpy.array([[int(i) for i in input().split()] for _ in range(N)])
ans = 10**8
for i in range(2**N) :
    i = format(i,'b').zfill(N)
    check = numpy.array([0]*(M+1))
    for j in range(N) :
        if i[j] == '0' :
            continue
        check +=  A[j][0:]
    if all (check[m] >= X for m in range(1,M+1)) :
        ans = min(ans,check[0])

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

Buggy submission (verdict: Runtime Error):
import itertools
N,M,X = map(int,input().split())
A = [0,0,0,0]
C = []
Z = []
cz = []
b = 0
for i in range(N) :
    C.append(list(map(int,input().split())))

for i in range(1,N+1) :
    c = list(itertools.combinations(C,i))
    for j in range(len(c)) :
        A = [0,0,0,0]
        cj = c[j]
        for k in range(i) :
            ck = cj[k]
            A[0]+= ck[0]
            A[1] += ck[1]
            A[2] += ck[2]
            A[3] += ck[3]
            if A[1]>=X and A[2]>= X and A[3]>=X :
                cz.append(A[0])
                b = 1     
                break   
        if b == 1 :
            b = 0
            break

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

Buggy submission (verdict: Runtime Error):
import itertools
N,M,X = map(int,input().split())
A = [0,0,0,0]
C = []
Z = []
cz = []
for i in range(N) :
    C.append(list(map(int,input().split())))

for i in range(1,N+1) :
    c = list(itertools.combinations(C,i))
    for j in range(len(c)) :
        A = [0,0,0,0]
        cj = c[j]
        for k in range(i) :
            ck = cj[k]
            A[0]+= ck[0]
            A[1] += ck[1]
            A[2] += ck[2]
            A[3] += ck[3]
        if A[1]>=X and A[2]>= X and A[3]>=X :
            cz.append(A[0])        

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

Buggy submission (verdict: Runtime Error):
import itertools
N,M,X = map(int,input().split())
A = [0,0,0,0]
C = []
Z = []
cz = []
for i in range(N) :
    C.append(list(map(int,input().split())))

for i in range(2,N+1) :
    c = list(itertools.combinations(C,i))
    for j in range(len(c)) :
        A = [0,0,0,0]
        cj = c[j]
        for k in range(i) :
            ck = cj[k]
            A[0]+= ck[0]
            A[1] += ck[1]
            A[2] += ck[2]
            A[3] += ck[3]
        Z.append(A)

for i in range(len(Z)) :
    zi = Z[i]
    if zi[1]>=X and zi[2]>=X and zi[3]>=X :
        cz.append(zi[0])        

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

Buggy submission (verdict: Runtime Error):
import itertools
N,M,X = map(int,input().split())
A = [0,0,0,0]
C = []
Z = []
cz = []
for i in range(N) :
    C.append(list(map(int,input().split())))

for i in range(2,N+1) :
    c = list(itertools.combinations(C,i))
    for j in range(len(c)) :
        A = [0,0,0,0]
        cj = c[j]
        for k in range(i) :
            ck = cj[k]
            A[0]+= ck[0]
            A[1] += ck[1]
            A[2] += ck[2]
            A[3] += ck[3]
        Z.append(A)

for i in range(len(Z)) :
    zi = Z[i]
    if zi[1]>=X and zi[2]>=X and zi[3]>=X :
        cz.append(zi[0])        

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