Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = map(int, input().split())
count = 0
view = 0
for i in range(1, n):
    for con in h:
        if con <= h[i]:
            count += 1
    if n == count:
        view += 1
print(view)

Fixed submission:
n=int(input())
lis=list(map(int,input().split()))
ans=0
 
 
for i in range(1,n):
    if max(lis[:i])<=lis[i]:
        ans+=1
 
print(ans+1)
Buggy python submission (verdict: Runtime Error):
, b, c = map(int, input().split())

if (a + b) <= c:
    print('Yes')
else:
    print('No')

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

if (a + b) >= c:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
blue = []
red = []
for i in range(n):
    blue.append(input())
m = int(input())
for j in range(m):
    red.append(input())

blue_dict = collections.Counter(blue)
red_dict = collections.Counter(red)
count_list = []
for b_key, b_value in blue_dict.items():
    for r_key, r_value in red_dict.items():
        if b_key == r_key:
            count_list.append(b_value - r_value)
print('出力 : {}'.format(max(count_list)))

Fixed submission:
n = int(input())
blue = []
red = []
score_list = []
for i in range(n):
    blue.append(input())
m = int(input())
for j in range(m):
    red.append(input())
for value in blue:
    score = 0
    for s in blue:
        if value == s:
            score += 1
    for t in red:
        if value == t:
            score -= 1
    if score not in score_list:
        score_list.append(score)
if max(score_list) < 0:
    print(0)
else:
    print(max(score_list))
Buggy python submission (verdict: Runtime Error):
row1 = input().split()
row2 = input().split()
row3 = input().split()
print(row1[0]+row2[1]+row3[2])

Fixed submission:
row1 = input()
row2 = input()
row3 = input()
print(row1[0]+row2[1]+row3[2])

Buggy python submission (verdict: Runtime Error):
row1 = list(map(str, input().split()))
row2 = list(map(str, input().split()))
row3 = list(map(str, input().split()))
matrix = [row1, row2, row3]
print(matrix[0][0]+matrix[1][1]+matrix[2][2])

Fixed submission:
row1 = input()
row2 = input()
row3 = input()
print(row1[0]+row2[1]+row3[2])

Buggy python submission (verdict: Runtime Error):
row1 = list(map(str, input().split()))
row2 = list(map(str, input().split()))
row3 = list(map(str, input().split()))
matrix = [row1, row2, row2]
print(matrix[0][0]+matrix[1][1]+matrix[2][2])

Fixed submission:
row1 = input()
row2 = input()
row3 = input()
print(row1[0]+row2[1]+row3[2])

Buggy python submission (verdict: Runtime Error):
row1 = list(map(str, input().split()))
row2 = list(map(str, input().split()))
row3 = list(map(str, input().split()))
matrix = [row1, row2, row2]
print(matrix)
print(matrix[0][0]+matrix[1][1]+matrix[2][2])

Fixed submission:
row1 = input()
row2 = input()
row3 = input()
print(row1[0]+row2[1]+row3[2])

Buggy python submission (verdict: Runtime Error):
matrix = [[], [], []]
for row in matrix:
    for i in range(3):
        row.append(input())
print(matrix[0][0] + matrix[1][1] + matrix[2][2])

Fixed submission:
row1 = input()
row2 = input()
row3 = input()
print(row1[0]+row2[1]+row3[2])

Buggy python submission (verdict: Runtime Error):
matrix = [[], [], []]
for row in matrix:
    for i in range(3):
        row.append(input())
print(matrix)
print(matrix[0][0] + matrix[1][1] + matrix[2][2])

Fixed submission:
row1 = input()
row2 = input()
row3 = input()
print(row1[0]+row2[1]+row3[2])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from sys import stdin
a, b, x = [int(x) for x in stdin.readline().rstrip().split()]
print(len(np.array([num for num in range(a, b+1) if num % x == 0], dtype=np.float32)))

Fixed submission:
from sys import stdin
a, b, x = [int(x) for x in stdin.readline().rstrip().split()]
print((b//x) - (a-1)//x)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
a, b, x = map(int, input().split())
count = np.array([num for num in range(a, b+1) if num % x == 0], dtype=np.float32)
print(len(count))

Fixed submission:
from sys import stdin
a, b, x = [int(x) for x in stdin.readline().rstrip().split()]
print((b//x) - (a-1)//x)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
count = [num for num in range(a, b+1) if num % x == 0]

print(len(count))

Fixed submission:
from sys import stdin
a, b, x = [int(x) for x in stdin.readline().rstrip().split()]
print((b//x) - (a-1)//x)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
count = 0
for num in range(a, b+1):
    if num % x == 0:
        count += 1
print(count)

Fixed submission:
from sys import stdin
a, b, x = [int(x) for x in stdin.readline().rstrip().split()]
print((b//x) - (a-1)//x)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
five = 0
seven = 0
check = [A, b, C]
for s in check:
    if s == 5:
        five += 1
    if s == 7:
        seven += 1
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')

Fixed submission:
a, b, c = map(int, input().split())
five = 0
seven = 0
check = [a, b, c]
for s in check:
    if s == 5:
        five += 1
    if s == 7:
        seven += 1
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
n,m = int(input().split())
if m==n:
  print("Yes")
else:
  print("No")

Fixed submission:
n,m = map(int, input().split())
if n==m:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int, input().split())
a = []
for i in range(q):
  a.append(int(input()))
for i in range(n):
  temp = k-q+a.count(i+1)
  if temp>0:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k,q = map(int, input().split())
point = [k-q for i in range(n)]
for i in range(q):
  a = int(input())
  point[a-1] += 1
for i in range(n):
  if point[i]>0:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
  
for i in range(n):
  if i==0:
    temp = a[1:]
  elif i==n-1:
    temp = a[:i]
  else:
    temp = a[:i]+a[i+1:]
  print(max(temp))

Fixed submission:
#全体の最大値が入っているときは、それが部分列の最大値になるので、わざわざ計算しなくて良い
#こういうことに先気づかないと、TLEになる
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

a_max = max(a)
max_idx = a.index(a_max)
c = a.count(a_max)

for i in range(n):
  if i!=max_idx:
    print(a_max)
  elif i==max_idx and c>=2:
    print(a_max)
  else:
    a.remove(a[i])
    print(max(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

import numpy as np
A = np.zeros((n,n))
for i in range(n): #左の行列
  if i<n-1:
    A[i][i]=1
    A[i][i+1]=1
  else:
    A[i][0]=1
    A[i][i]=1
b = np.array(a) #右辺
x = np.linalg.solve(A, b)
x_list = x.tolist()
x_list = [2*i for i in x_list]
for i in range(n):
  print(int(x_list[i]), end=" ")

Fixed submission:
#奇数だから一個仲間外れにできるとの神(ki..sh..ak..i)の啓示

n = int(input())
a = [int(i) for i in input().split()]
w = [] #逆向きの答え
s = sum(a)/2
k = n//2
#w(n-1)を求める
a_odd = [a[2*i] for i in range(0,k)]
w.append(s-sum(a_odd))
for i in reversed(range(n-1)):
  w.append(a[i]-w[-1])
w.reverse()
for i in range(n):
  print(int(2*w[i]), end=" ")
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int, input().split())

#cとdの最大公約数を求める
first = [c,d%c]
first.sort()
if d%c==0:
  cd = c
elif first[0]==1:
  cd = 1
else:
  while first[0]>=2:
    first[1] = first[1]%first[0]
    first.sort()
    if first[0]==0:
      cd = first[1]
    elif first[0]==1:
      cd = 1
lcm = c*d/cd
      
zen = b-a+1
c_num = (b//c) -math.ceil(a/c)+1
d_num = (b//d) -math.ceil(a/d)+1
lcm_num = (b//lcm) - math.ceil(a/lcm)+1
ans = zen - c_num - d_num + lcm_num
print(ans)

Fixed submission:
s = input()
s_list = [i for i in s]
flag = True
for i in range(1,4):
  if s_list[i]==s_list[i-1]:
    print('Bad')
    flag = False
    break

if flag:
  print('Good')
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [-1]
flag = True

if m>0:
  for i in range(m):
    a.append(int(input()))
    if i>0 and a[i+1]==a[i]+1:
      flag = False
    break
  if not flag:
    print(0)
  
  a.append(n+1)
  step = [a[i+1]-a[i]-1 for i in range(m+1)]
  onestep = [1,1]
  if max(step)>=3:
    for i in range(3,max(step)+1):
      onestep.append(onestep[-2]+onestep[-1])
  
  ans = 1
  for i in range(m+1):
    ans *= onestep[step[i]-1]
  if flag:
    print(ans%1000000007)
else:
  onestep=[1,1]
  for i in range(2,n+1):
    onestep.append(onestep[-2]+onestep[-1])
  print(onestep[-1])



Fixed submission:
n,m = map(int,input().split())
a = [-1]
flag = True
 
if m>0:
  for i in range(m):
    a.append(int(input()))
    if a[i+1]==a[i]+1:
      flag = False
      break
  if not flag:
    print(0)
  else:
    a.append(n+1)
    step = [a[i+1]-a[i]-1 for i in range(m+1)]
    onestep = [1,1]
    if max(step)>=3:
      for i in range(3,max(step)+1):
        onestep.append(onestep[-2]+onestep[-1])
  
    ans = 1
    for i in range(m+1):
      ans *= onestep[step[i]-1]
    print(ans%1000000007)
else:
  onestep=[1,1]
  if n==1:
    print(1)
  else:
    for i in range(2,n+1):
      onestep.append(onestep[-2]+onestep[-1])
    print(onestep[-1]%1000000007)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [-1]
flag = True
for i in range(m):
  a.append(int(input()))
  if i>0 and a[i+1]==a[i]+1:
    flag = False
    break
if not flag:
  print(0)
a.append(n+1)

step = [a[i+1]-a[i]-1 for i in range(m+1)]

onestep = [1,1]
if max(step)>=3:
  for i in range(3,max(step)+1):
    onestep.append(onestep[-2]+onestep[-1])

ans = 1
for i in range(m+1):
  ans *= onestep[step[i]-1]
if flag:
  print(ans%1000000007)

Fixed submission:
n,m = map(int,input().split())
a = [-1]
flag = True
 
if m>0:
  for i in range(m):
    a.append(int(input()))
    if a[i+1]==a[i]+1:
      flag = False
      break
  if not flag:
    print(0)
  else:
    a.append(n+1)
    step = [a[i+1]-a[i]-1 for i in range(m+1)]
    onestep = [1,1]
    if max(step)>=3:
      for i in range(3,max(step)+1):
        onestep.append(onestep[-2]+onestep[-1])
  
    ans = 1
    for i in range(m+1):
      ans *= onestep[step[i]-1]
    print(ans%1000000007)
else:
  onestep=[1,1]
  if n==1:
    print(1)
  else:
    for i in range(2,n+1):
      onestep.append(onestep[-2]+onestep[-1])
    print(onestep[-1]%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(5):
  s.append(int(input()))
before = [n,0,0,0,0,0]

def one_step(before):
  #都市1~6にp~u人いる時の、次の時刻での状態
  for i in reversed(range(0,5)):
    if before[i]<=s[i]:
      before[i+1] += before[i]
      before[i] = 0
    else:
      before[i] -= s[i]
      before[i+1] += s[i]
  return before

t=0
while before[-1]<n:
  before = one_step(before)
  t += 1

print(t)

Fixed submission:
import math
n = int(input())
s = []
for i in range(5):
  s.append(int(input()))
s_min = min(s)
min_idx = s.index(s_min)

print(4+math.ceil(n/s_min))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int, input().split())
list = [a,b,c]
s = 0
for i in range (3):
	if list[i] == 1:
		s += 1
print(s)

Fixed submission:
print(list(input()).count("1"))

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int, input().split())
list = [a,b,c]
s = 0
for i in range (3):
  if list[i] == 1:
    s += 1
print(s)

Fixed submission:
print(list(input()).count("1"))
Buggy python submission (verdict: Runtime Error):
N = input()
K = input()
c = 1
for i in range(N):
  c = min(c*2, c+K)
print(c)

Fixed submission:
N = int(input())
K = int(input())
c = 1
for i in range(N):
  c = min(c*2, c+K)
print(c)
Buggy python submission (verdict: Runtime Error):
#include <stdio.h>

int main() {
  int a, b, x=-1;
  scanf("%d %d", &a, &b);
  for(int i=b*10; i<(b+1)*10; ++i) {
    if ((int)(i*0.08) == a) {
      x = i;
      break;
    }
  }
  printf("%d", x);
  return 0;
}


Fixed submission:
a, b = map(int, input().split())
for i in range(b*10, (b+1)*10):
  if int(i*0.08) == a:
    print(i)
    break
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
#include <stdio.h>

int main() {
  int a, b, x=-1;
  scanf("%d %d", &a, &b);
  for(int i=b*10; i<(b+1)*10; ++i) {
    if ((int)(i*0.08) == a) {
      x = i;
      break;
    }
  }
  printf("%d", x);
  return 0;
}


Fixed submission:
a, b = map(int, input().split())
for i in range(b*10, (b+1)*10):
  if int(i*0.08) == a:
    print(i)
    break
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
status = True

for i in range(n):
	com = input().split()
	if len(com) == 1:
		status = not status
	else:
		s = com[2]*bool(((com[1]=='1')+status-1)) + s + com[2]*bool(((com[1]=='2')+status-1))
        
if not status:
	s = s[::-1]
print(s)

Fixed submission:
from collections import deque

s = deque(input())
n = int(input())
status = True

for i in range(n):
	com = input().split()
	if com[0] == '1':
		status = not status
	elif int(com[1])+status == 2:
		s.appendleft(com[2])
	else:
		s.append(com[2])
        
if not status:
	s.reverse()
print("".join(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
for i in range(n):
	com = input().split()
	if com[0] == '1':
		s = s[::-1]
	else:
		s = com[2]*(com[1]=='1') + s + com[2]*(com[1]=='2')
print(s)

Fixed submission:
from collections import deque

s = deque(input())
n = int(input())
status = True

for i in range(n):
	com = input().split()
	if com[0] == '1':
		status = not status
	elif int(com[1])+status == 2:
		s.appendleft(com[2])
	else:
		s.append(com[2])
        
if not status:
	s.reverse()
print("".join(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
for i in range(n):
	com = input().split()
	if len(com) == 1:
		s = s[::-1]
	else:
		s = com[2]*(com[1]=='1') + s + com[2]*(com[1]=='2')
print(s)

Fixed submission:
from collections import deque

s = deque(input())
n = int(input())
status = True

for i in range(n):
	com = input().split()
	if com[0] == '1':
		status = not status
	elif int(com[1])+status == 2:
		s.appendleft(com[2])
	else:
		s.append(com[2])
        
if not status:
	s.reverse()
print("".join(s))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
num = [None]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if n > 1 and s == 0 and c == 0:
        res = -1
        break    
    if num[s] == None:
        num[s] = c
    elif num[s] != c:
        res = -1
        break

print(res) if res == -1 else print(0) if M == 0 else print(*[e if e!=None else 0 if i != 0 else 1 for i, e in enumerate(num)], sep="")

Fixed submission:
N, M = map(int, input().split())
num = [None]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if N > 1 and s == 0 and c == 0:
        res = -1
        break    
    if num[s] == None:
        num[s] = c
    elif num[s] != c:
        res = -1
        break

print(res) if res == -1 else print(*[e if e!=None else 0 if i != 0 or N == 1 else 1 for i, e in enumerate(num)], sep="")
Buggy python submission (verdict: Runtime Error):
n = int(input())

print(n//2-not(n%2))

Fixed submission:
n = int(input())

print(n//2-bool(not(n%2)))
Buggy python submission (verdict: Runtime Error):
n = int(input())

for i in range(1, n**.5+1):
  if n%i == 0:
    p = i

q = n//p

print(p+q-2)

Fixed submission:
n = int(input())

for i in range(1, int(n**.5)+1):
  if n%i == 0:
    p = i

q = n//p

print(p+q-2)

Buggy python submission (verdict: Runtime Error):
from sympy import divisors as d

n = int(input())
p = max([i for i in d(n) if i <= n**.5])
q = n//p

print(p+q-2)

Fixed submission:
n = int(input())

for i in range(1, int(n**.5)+1):
  if n%i == 0:
    p = i

q = n//p

print(p+q-2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))

print(sum([l[i]*x for i in range(len(l)-1) for x in l[i+1:]))

Fixed submission:
n = int(input())
l = list(map(int, input().split()))

print(sum(l[i]*x for i in range(len(l)-1) for x in l[i+1:]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
res = ""
x = ""
for l in s:
  if i != x:
    x = l
    res += x
  else: pass
print(len(res))

Fixed submission:
n = int(input())
s = input()
res = ""
x = ""
for l in s:
  if l != x:
    x = l
    res += x
  else: pass
print(len(res))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=deque(input())
q=int(input())
for i in range(q):
    query=input().split()
    if query[0] == "1":
        s.reverse()
    elif query[1] == "1":
        s.appendleft(query[2])
    else:
        s.append(query[2])
print("".join(s))


Fixed submission:
from collections import deque
s=deque(input())
q=int(input())
flag = 2

for i in range(q):
    query=input().split()
    if query[0] == "1":
        flag = 3 - flag
    elif int(query[1]) - flag :
         s.appendleft(query[2])
    else:
        s.append(query[2])

if flag-2:
    s.reverse()

print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
n,p = tuple(map(int,input().split()))
s = input()
modulo = [0]*p
modulo[0] = 1
if p!= 2 and p != 5:
    for i in range(n):
        modulo[int(s[i:]) % p] += 1

    ans = 0
    for i in modulo:
        ans += (i * (i-1)) // 2

    print(ans)
else:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i+1
    print(ans)


Fixed submission:
n,p = tuple(map(int,input().split()))
s = input()
modlist = [0]*p
modlist[0] = 1
if p!= 2 and p != 5:
    mod = 0
    pwrmod = 1
    for i in s[::-1]:
        mod = (mod + pwrmod * int(i)) % p
        pwrmod = (pwrmod * 10) % p
        modlist[mod] += 1
    ans = 0
    for i in modlist:
        ans += (i * (i-1)) // 2

    print(ans)
else:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i+1
    print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys

input = sys.stdin

def tax(pct8, pct10):
    pct8low_x10 = pct8 * 125
    if pct8low_x10 % 10 == 0:
        pct8low = pct8low_x10 // 10
    else:
        pct8low = pct8low_x10 // 10 + 1

    pct8high_x10 = (pct8 + 1) * 125

    if pct8high_x10 % 10 == 0:
        pct8high = pct8high_x10 // 10 - 1
    else:
        pct8high = pct8high_x10 // 10

    pct10low = pct10 * 10
    pct10high = (pct10 + 1) * 10 - 1

    if pct8high < pct10low or pct10high < pct8low:
        return -1
    else:
        return max(pct8low, pct10low)

def test():
    for i in range(1, 100+1):
        for j in range(1, 100+1):
            price = tax(i, j)
            if price > 0:
                if int(price *.08) != i or int(price * .1) != j:
                    print(f"Wrong! tax({i},{j}) -> {price} but price*0.8={int(price*0.08)} and price*0.1={int(price*0.1)}")

pct8, pct10 = map(int, input.readline().split(" "))
print(tax(pct8, pct10))
#test()


Fixed submission:
#!/usr/bin/env python
import sys

input = sys.stdin

def tax(pct8, pct10):
    pct8low_x10 = pct8 * 125
    if pct8low_x10 % 10 == 0:
        pct8low = pct8low_x10 // 10
    else:
        pct8low = pct8low_x10 // 10 + 1

    pct8high_x10 = (pct8 + 1) * 125

    if pct8high_x10 % 10 == 0:
        pct8high = pct8high_x10 // 10 - 1
    else:
        pct8high = pct8high_x10 // 10

    pct10low = pct10 * 10
    pct10high = (pct10 + 1) * 10 - 1

    if pct8high < pct10low or pct10high < pct8low:
        return -1
    else:
        return max(pct8low, pct10low)

#def test():
#    for i in range(1, 100+1):
#        for j in range(1, 100+1):
#            price = tax(i, j)
#            if price > 0:
#                if int(price *.08) != i or int(price * .1) != j:
#                    print(f"Wrong! tax({i},{j}) -> {price} but price*0.8={int(price*0.08)} and price*0.1={int(price*0.1)}")

pct8, pct10 = map(int, input.readline().split(" "))
print(tax(pct8, pct10))
#test()
Buggy python submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
rem = n%2
return n/2 + 1

Fixed submission:
import sys

n = int(sys.stdin.readline())
rem = n%2
print(n//2 + rem)
Buggy python submission (verdict: Runtime Error):
import sys
rl = sys.stdin.readline

rows = 3
cols = 3
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a31,a32,a33 = [int(x) for x in rl().split(' ')]

n = int(rl())
b = []

for i in range(n):
    b.append(int(rl()))

#####################

card = [a11,a12,a13,a1,a22,a23,a31,a32,a33]

for num in b:
    for i in range(len(card)):
        if card[i] == num:
            card[i] = 0

def check(card):
    for y in range(rows):
        if all([card[y*rows+x] == 0 for x in range(cols)]):
            return True

    # col
    for x in range(cols):
        if all([card[y*rows+x] == 0 for y in range(rows)]):
            return True

    # diagonal
    if all([card[xy*rows+xy] == 0 for xy in range(rows)]):
            return True

    if all([card[xy*rows+cols-1-xy] == 0 for xy in range(rows)]):
            return True

    return False

if check(card):
    print("Yes")
else:
    print("No")


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

rows = 3
cols = 3
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a21,a22,a23 = [int(x) for x in rl().split(' ')]
a31,a32,a33 = [int(x) for x in rl().split(' ')]

n = int(rl())
b = []

for i in range(n):
    b.append(int(rl()))

#####################

card = [a11,a12,a13,a21,a22,a23,a31,a32,a33]

for num in b:
    for i in range(len(card)):
        if card[i] == num:
            card[i] = 0


def check(card):
    for y in range(rows):
        if all([card[y*rows+x] == 0 for x in range(cols)]):
            return True

    # col
    for x in range(cols):
        if all([card[y*rows+x] == 0 for y in range(rows)]):
            return True

    # diagonal
    if all([card[xy*rows+xy] == 0 for xy in range(rows)]):
            return True

    if all([card[xy*rows+cols-1-xy] == 0 for xy in range(rows)]):
            return True

    return False


if check(card):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = []
for i in range(M):
    s,c = map(int, input().split())
    sc.append([s,c])

ans = 0
sc_dic = {}
for i in sc:
    if i[0] in sc_dic:
        if i[1] != sc_dic[i[0]]:
            ans = -1
    else:
        ans += 10**(N-i[0])*i[1]
        sc_dic[i[0]] = i[1]

if sc_dic[1] == 0:
    ans = -1
print(ans)

Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    s,c = map(int, input().split())
    sc.append([s,c])

ans = 0
sc_dic = {}
min_s = N+1
for i in sc:
    min_s = min(min_s, i[0])
    if i[0] in sc_dic:
        if i[1] != sc_dic[i[0]]:
            ans = -1
            break
        break
    else:
        ans += 10**(N-i[0])*i[1]
        sc_dic[i[0]] = i[1]

if ans != -1:
        
    if min_s == N+1:
        if N == 1:
            ans = 0
        else:
            ans = 10**(N-1)
        sc_dic[1]=1

    if 1 not in sc_dic:
        ans += 10**(N-1)
        sc_dic[1] = 1
        min_s = 1

    if sc_dic[1] == 0 and N!=1:
        ans = -1

print(ans)