Problem p02760 (python)

Fixed submission:
import math

a1 = list(map(int, input().rstrip().split()))
a2 = list(map(int, input().rstrip().split()))
a3 = list(map(int, input().rstrip().split()))
a = [a1,a2,a3]

m = [[0,0,0],[0,0,0],[0,0,0]]

n = int(input())
b = []
for i in range(n) :
    b = int(input())
    for j in range(3) :
        for k in range(3) :
            if a[j][k] == b :
                m[j][k] = 1

if m[0].count(1) == 3 :
    print('Yes')
elif m[1].count(1) == 3 :
    print('Yes')
elif m[2].count(1) == 3 :
    print('Yes')
elif m[0][0] == 1 and m[1][0] == 1 and m[2][0] ==1 :
    print('Yes')
elif m[0][1] == 1 and m[1][1] == 1 and m[2][1] ==1 :
    print('Yes')
elif m[0][2] == 1 and m[1][2] == 1 and m[2][2] ==1 :
    print('Yes')
elif m[0][0] == 1 and m[1][1] == 1 and m[2][2] ==1 :
    print('Yes')
elif m[0][2] == 1 and m[1][1] == 1 and m[2][0] ==1 :
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
b = []
for i in range(n) :
    b = int(input())
    for j in range(3) :
        for k in range(3) :
            if a[j][k] == b :
                m[j][k] = 1

if a[0].count(1) == 3 :
    print('Yes')
elif a[1].count(1) == 3 :
    print('Yes')
elif a[2].count(1) == 3 :
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
b = []
for i in range(N) :
    b.append(int(input()))

m = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(N) :
    for j in range(3) :
        for k in range(3) :
            if b[i] == a[j][k] :
                m[j][k] = 1
if  m[0].count(1) == 3 or \
    m[1].count(1) == 3 or \
    m[2].count(1) == 3 or \
    [x[0] for x in m].count(1) == 3 or \
    [x[1] for x in m].count(1) == 3 or \
    [x[2] for x in m].count(1) == 3 or \
    (m[0][0] == 1 and m [1][1] == 1 and m [2][2] == 2) or \
    (m[2][0] == 1 and m [1][1] == 1 and m [2][0] == 2) :
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
import math
a1 = list(map(int, input().split())) 
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1,a2,a3]

N = int(input())

b = []
for i in range(N) :
    b.append(int(input()))

m = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(N) :
    for j in range(3) :
        for k in range(3) :
            if b[i] == a[j][k] :
                m[j][k] = 1
if  m[0].count(1) == 3 or \
    m[1].count(1) == 3 or \
    m[2].count(1) == 3 or \
    [x[0] for x in m].count(1) == 3 or \
    [x[1] for x in m].count(1) == 3 or \
    [x[2] for x in m].count(1) == 3 or \
    (x[0][0] == 1 and x [1][1] == 1 and x [2][2] == 2) or \
    (x[2][0] == 1 and x [1][1] == 1 and x [2][0] == 2) :
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
import math
a1 = list(map(int, input().split())) 
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1,a2,a3]

N = int(input())

b = []
for i in range(N) :
    b.append(int(input()))

m = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(N) :
    for j in range(3) :
        for k in range(3) :
            if b[i] == a[j][k] :
                m[j][k] = 1

if  m[0].count(1) == 3 or \
    m[1].count(1) == 3 or \
    m[2].count(1) == 3 or \
    [x[0] for x in m].count(1) == 3 or \
    [x[1] for x in m].count(1) == 3 or \
    [x[2] for x in m].count(1) == 3 or \
    (x[0][0] == 1 and x [1][1] == 1 and x [2][2] == 2) or \
    (x[2][0] == 1 and x [1][1] == 1 and x [2][0] == 2) :
    print('YES')
else :
    print('NO')