Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02730 (python)

Fixed submission:
S = [i for i in input()]
f = 0
for i in range(len(S)//2):
  #print(S[i], S[-1-i])
  if not S[i] == S[-1-i]:
    f = 1
    print('No')
    break
#print(f)
if f == 0:
  s = S[:int((len(S)-1)/2)]
  for i in range(int(len(s)//2)):
    if not s[i] == s[-1-i]:
      f = 1
      print('No')
      break
#print(f)
if f == 0:
  s = S[int((len(S)+3)/2-1):]
  for i in range(int(len(s)//2)):
    #print(s[i], s[-1-i])
    if not s[i] == s[-1-i]:
      f = 1
      print('No')
      break
if f ==0:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = [i for i in input()]
f = 0
for i in range(len(S)//2):
  if not S[i] == S[-i]:
    f = 1
    print('No')
    break
if f == 0:
  s = S[:int((len(S)-1)/2)]
  for i in range(len(s)//2):
    if not s[i] == s[-i]:
      f = 1
      print('No')
      break
if f == 0:
  s = S[int((len(S)+3)/2):]
  for i in range(len(S)//2):
    if not s[i] == s[-i]:
      f = 1
      print('No')
      break
if f ==0:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = [i for i in input()]
f = 0
for i in range(len(S)//2):
  if not S[i] == S[-i]:
    f = 1
    print('No')
    break
if f == 0:
  s = S[:int((len(S)-1)/2)]
  for i in range(len(s)):
    if not s[i] == s[-i]:
      f = 1
      print('No')
      break
if f == 0:
  s = S[int((len(S)+3)/2):]
  for i in range(len(S)):
    if not s[i] == s[-i]:
      f = 1
      print('No')
      break
if f ==0:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = [i for i in input()]
f = 0
for i in range(len(S)//2):
  if not S[i] == S[-i]:
    f = 1
    print('No')
    break
if f == 0:
  for i in range(int((len(S)-1)/2)):
    if not S[i] == S[int((len(S)-1)/2-i)]:
      f = 1
      print('No')
      break
if f == 0:
  for i in range(int((len(S)+3)/2), len(S)) and f == 0:
    if not S[i] == S[-i]:
      f = 1
      print('No')
      break
if f ==0:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = [i for i in input()]
f = 0
for i in range(len(S)//2):
  if not S[i] == S[-i]:
    f = 1
    print('No')
    break
if f == 0:
  for i in range(int((len(S)-1)/2)):
    if not S[i] == S[int((len(S)-1)/2-i)]:
      f = 1
      print('No')
      break
if f == 0:
  for i in range((len(S)+3)/2, len(S)) and f == 0:
    if not S[i] == S[-i]:
      f = 1
      print('No')
      break
if f ==0:
  print('Yes')
Problem p02767 (python)

Fixed submission:
n = int(input())
X = list(map(int, input().split()))
low = min(X)
high = max(X)
ans = []

for p in range(low, high-low+1):
  dist = 0
  for x in X:
    dist += (x-p)**2
  ans.append(dist)
if len(ans) != 0:
  print(min(ans))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
X = list(map(int, input().split()))
low = min(X)
high = max(X)
ans = []

for p in range(low, high-low+1):
  dist = 0
  for x in X:
    dist += (x-p)**2
  ans.append(dist)
print(min(ans))
Problem p02772 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(N):
  
  if a[i]%2 == 0:
    if a[i]%3 == 0 or a[i]%5 == 0:
      pass
    else:
     c += 1 
if c == 0:
  print('APPROVED')
else:
  print('DENIED')

Buggy submission (verdict: Runtime Error):
N = int(input())
c = 0
for i in range(N):
  a = int(input())
  if a%2 == 0:
    if a%3 == 0 or a%5 == 0:
      pass
    else:
     c += 1 
if c == 0:
  print('APPROVED')
else:
  print('DENIED')
Problem p02813 (python)

Fixed submission:
import math
N=int(input())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
a=b=1
l=[i for i in range(1,N+1)]
m=[i for i in range(1,N+1)]
for i in range(N):
  #print("===P[i]===", P[i])
  #print(l.index(P[i]), math.factorial(N-i-1))
  if N-i-1 < 0:
    pass
  else:
    a += l.index(P[i])*math.factorial(N-i-1)
  #print("l", l)
  if not i==N-1:
    l.pop(l.index(P[i]))
for i in range(N):
  if N-i-1 < 0:
    pass
  else:
    b += m.index(Q[i])*math.factorial(N-i-1)
  if not i==N-1:
    m.pop(m.index(Q[i]))
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import math
a=b=1
l=[i for i in range(1,N+1)]
m=[i for i in range(1,N+1)]
for i in range(N):
  #print("===P[i]===", P[i])
  #print(l.index(P[i]), math.factorial(N-i-1))
  a += l.index(P[i])*math.factorial(N-i-1)
  #print("l", l)
  if not i==N-1:
    l.pop(l.index(P[i]))
for i in range(N):
  b += m.index(Q[i])*math.factorial(N-i-1)
  if not i==N-1:
    m.pop(m.index(Q[i]))
print(abs(a-b))
Problem p03087 (python)

Fixed submission:
n,q = map(int, input().split())
s=input()
a=[0]*n
for i in range(1,n):
    a[i]+=a[i-1]
    if s[i-1]=='A' and s[i]=='C':
        a[i]+=1
for i in range(q):
    l,r=map(int, input().split())
    print(a[r-1]-a[l-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
s=input()

for i in range(n):
    l,r=map(int, input().split())
    print(s[l-1:r].count('AC'))
Problem p03262 (python)

Fixed submission:
import math
n,x = map(int,input().split())
X = list(map(int,input().split()))
diff = []
for i in range(n):
	diff.append(abs(X[i]-x))
res = diff[0]
for i in range(1,n):
	res = math.gcd(res, diff[i])
print(res)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())

xlist = list(map(int, input().split()))
import math

ans = xlist[0]
for i in xlist[1:]:
    ans = math.gcd(ans, i)

print(ans)
Problem p03393 (python)

Fixed submission:
#11208467
t="abcdefghijklmnopqrstuvwxyz"
s=input()
if s==t[::-1]:print(-1);exit()
if len(s)!=26:
  for i in t:
    if i not in s:print(s+i);exit()
i=25
while s[i-1]>s[i]:i-=1
tt=s[i-1]
ss=list(s[i-1:])
ss.sort()
print(s[:i-1]+ss[ss.index(tt)+1])

Buggy submission (verdict: Runtime Error):
s = input()

abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

if s == ''.join(abc)[::-1]:
    print(-1)
    exit()
if len(s) != 26:
    for a in abc:
        if a not in abc:
            print(s+a)
            exit()
i = 25
while s[i-1] > s[i]:
    i -= 1
    #print(s[i-1], s[i])
#print(s[i-1], s[i])
tt = s[i-1]
ss = list(s[i-1:])
ss.sort()
print(s[:i-1]+ss[ss.index(tt)+1])

Buggy submission (verdict: Runtime Error):
s = input()

abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

if s == ''.join(abc)[::-1]:
    print(-1)
    exit()
if len(s) <26:
    for a in abc:
        if a not in abc:
            print(s+a)
            exit()
i = 25
while s[i-1] > s[i]:
    i -= 1
    #print(s[i-1], s[i])
#print(s[i-1], s[i])
tt = s[i-1]
ss = list(s[i-1:])
ss.sort()
print(s[:i-1]+ss[ss.index(tt)+1])
Problem p03612 (python)

Fixed submission:
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(1,n+1):
    if i == n and P[i-1] == n:
        ans +=1
    elif i == P[i-1]:
        P[i] = P[i-1]
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(1,n+1):
    if i == P[i-1]:
        P[i] = P[i-1]
        ans += 1
print(ans)
Problem p03633 (python)

Fixed submission:
import fractions
n = int(input())
T = []
ans = 1
for i in range(n):
    t = int(input())
    T.append(t)
    ans = ans * t // fractions.gcd(ans, t)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
T = []
ans = 1
for i in range(n):
    t = int(input())
    T.append(t)
    ans = ans * t // math.gcd(ans, t)
print(ans)
Problem p03695 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
A = list(map(lambda x: x//400, A))
#print(A)

import collections
c = collections.Counter(A)
#print(c)
f1 = f2 = 0
for k in c.keys():
    if k >= 8:
        f1 += 1
        f2 += c[k]
        
if f1 == 0:
    min_ = max_ = len(c.keys())

else:
    min_ = len(c.keys()) -f1
    max_ = len(c.keys()) -f1 +f2
'''if max_ >8:
    max_ = 8'''
if min_ <1:
    min_ = 1
print(min_, max_)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
A = list(map(lambda x: x//400, A))
#print(A)

import collections
c = collections.Counter(A)
#print(c)
f1 = f2 = 0
for k in c.keys():
    if k >= 8:
        f1 += 1
        f2 += c[k]
if f1 == 0:
    min_ = max_ = len(c.keys())

else:
    min_ = len(c.keys()) -f1
    max_ = len(c.keys()) -f1 +f2
if max_ >8:
    max_ = 8
if mix_ <0:
    min_ = 0
print(min_, max_)
Problem p02786 (python)

Fixed submission:
h = int(input())

count = 1
ans = 0

while h != 0:
    ans += count
    h = h//2
    count *=2

print(ans)

Buggy submission (verdict: Runtime Error):
h,n = map(int,input().split())

x = []
y = []

for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)

def knapsack(N,W,weight,value):
  inf=float("inf")
  dp=[[inf for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=inf

  for i in range(N):
    for w in range(W+1):
        m = dp[i][w]
        p = value[i]
        q = weight[i]
        while w >= q:
            if w - q >= 0:
                m=min(dp[i][w-q]+p,m)
            p += value[i]
            q += weight[i]
        m=min(dp[i][w-q]+p,m,p)
        dp[i+1][w] = m
  return dp[N][W]

k = knapsack(n,h,x,y)
print(k)
Problem p02866 (python)

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

if d[0] != 0:
  print(0)
  exit()

ans=1

a=[0]*(n+1)

for i in d:
  a[i] += 1

if a[0] != 1:
  print(0)
  exit()

for j in range(n):
  if j!=0 and a[j] == 0:
    for k in range(j+1,n):
      if a[k] != 0:
        print(0)
        exit()
    break
  else:
    ans*=(a[j]**a[j+1])
    ans%=998244353

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))

if d[0] != 0:
  print(0)
  exit()

ans=1

a=[0]*n

for i in d:
  a[i] += 1

if a[0] != 1:
  print(0)
  exit()

for j in range(n):
  if j!=0 and a[j] == 0:
    for k in range(j+1,n):
      if a[k] != 0:
        print(0)
        exit()
    break
  else:
    ans*=(a[j]**a[j+1])
    ans%=998244353

print(ans)
Problem p03071 (python)

Fixed submission:
a,b=map(int,input().split())
k=0
for i in range(2):
  if a>b:
    k=k+a
    a-=1
  else:
    k=k+b
    b-=1
print(k)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max(2*a-1,2*b-1,a+b)
Problem p03076 (python)

Fixed submission:
import math

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

k=min((a-1)%10,(b-1)%10,(c-1)%10,(d-1)%10,(e-1)%10)+1

sum=(math.ceil(a/10)*10+math.ceil(b/10)*10+math.ceil(c/10)*10+math.ceil(d/10)*10+math.ceil(e/10)*10)

print(sum-10+k)

Buggy submission (verdict: Runtime Error):
import math

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

A=B=C=D=E=11

if a%10!=0:
  A=a%10
if b%10!=0:
  B=b%10
if c%10!=0:
  C=c%10
if d%10!=0:
  D=d%10
if e%10!=0:
  E=e%10

k=min(A,B,C,D,E)
if A=B=C=D=E=0:
  k=10
sum=(math.ceil(a/10)*10+math.ceil(b/10)*10+math.ceil(c/10)*10+math.ceil(d/10)*10+math.ceil(e/10)*10)

print(sum-10+k)
Problem p03623 (python)

Fixed submission:
x,a,b=map(int,input().split())
if min(abs(x-a),abs(x-b))==abs(x-a):
  print("A")
else:
  print("B")

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,inpur().split())
if min(abs(x-a),abs(x-b))==abs(x-a):
  print("A")
else:
  print("B")
Problem p02797 (python)

Fixed submission:
n,k,s = (int(i) for i in input().split())
ans = ""
if s != 10**9:
    for i in range(k):
        ans += str(s) + " "
    if n > k:
        for j in range(n-k):
            ans += str(10**9) + " "
    print(ans)
else:
    for i in range(k):
        ans += str(s) + " "
    if n > k:
        for j in range(n-k):
            ans += str(1) + " "
    print(ans)

Buggy submission (verdict: Runtime Error):
n,k,s = (int(i) for i in input().split()) 
ans = []
for i in range(k):
    ans.append(s)
if n > k:
for j in range(n-k):
    ans.append(1)
print(ans)
Problem p03000 (python)

Fixed submission:
n, x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
count = 1
current = 0

if sum(l) <= x:
    print(n+1)
else:
    while current <= x:
        current += l[count-1]
        count += 1
    print(count-1)

Buggy submission (verdict: Runtime Error):
n, x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
count = 0
current = 0
while current <= x and  count <= n:
    current += l[count]
    count += 1
if count > n+1:
    print(n+1)
else:
    print(count)

Buggy submission (verdict: Runtime Error):
n, x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
count = 1
current = 0
while current <= x:
    current += l[count-1]
    count += 1
print(count-1)
Problem p03001 (python)

Fixed submission:
W, H, x, y = (int(i) for i in input().split())
area = W * H / 2
if W/2 == x and H/2 == y:
    possible = 1
else:
    possible = 0
print(area, possible)

Buggy submission (verdict: Runtime Error):
W, H, x, y = (int(i) for i in input().split())
area = 0
possible = 0
for b in range(H+1):
    A = ((y - b)/x * W + 2 * b) * W / 2
    B = W * H - A
    targetArea = min(A, B)
    if area == targetArea:
        possible = 1
    elif area < targetArea:
        possible = 0
        area = targetArea

for b in range(W+1):
    A = ((x - b)/y * H + 2 * b) * H / 2
    B = W * H - A
    targetArea = min(A, B)
    if area == targetArea:
        possible = 1
    elif area < targetArea:
        possible = 0
        area = targetArea

print(area, possible)
Problem p02903 (python)

Fixed submission:
H, W, A, B = list(map(int, input().split()))
for _ in range(B):
    print('0' * A + '1' * (W - A))
for _ in range(H - B):
    print('1' * A + '0' * (W - A))

Buggy submission (verdict: Runtime Error):
H, W, A, B = list(map(int, input().split()))
for _ in range(B):
    print('1'*  A+ '0' * (W - A) )
for _ in range(H - B):
    print('0' * A + '1'* (W - A) )

Buggy submission (verdict: Runtime Error):
H, W, A, B = list(map(int, input().split()))
for _ in range(B):
    print('1' * A+ '0' * (W - A) )
for _ in range(H - B):
    print('0' * A + '1' * (W - A) )

Buggy submission (verdict: Runtime Error):
H, W, A, B = list(map(int, input().split()))
for i in range(B):
    print('1' * A+ '0' * (W - A) )
for i in range(H - B):
    print('0' * A + '1' * (W - A) )

Buggy submission (verdict: Runtime Error):
H, W, A, B = list(map(int, input().split()))
for i in range(B):
    print('1' * A+ '0' * (W - A) )
for i in range(H - B):
    print('0' * A + '1' * (W - A) )

Buggy submission (verdict: Runtime Error):
H, W, A, B = list(map(int, input().split()))
for i in range(B):
    print('1' ＊ A+ '0' ＊ (W - A) )
for i in range(H - B):
    print('0' ＊A + '1'＊ (W - A) )
Problem p02601 (python)

Fixed submission:
A, B, C = map(int, input().split())
K = int(input())

tmp = K
for i in range(K):
  if A < B:
    tmp = i
    break
  B = B * 2
  
if B < C:
  print('Yes')
elif B < C * (2 ** (K - tmp)):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
K = int(input())

for i in range(K):
  if A < B:
    tmp = i
    break
  B = B * 2
  
if B < C:
  print('Yes')
elif B < C * (K - tmp):
  print('Yes')
else:
  print('No')
Problem p02612 (python)

Fixed submission:
n = int(input())

if n % 1000 == 0:
  print(0)
else:
  tmp = n // 1000 + 1
  print(tmp * 1000 - n)

Buggy submission (verdict: Runtime Error):
n = int(input())

if n % 1000 == 0:
  print(0)
else:
	tmp = n // 1000 + 1
  print(tmp - n)
Problem p02639 (python)

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

for i in range(5):
    if X[i] == 0:
        ans = i + 1

print(ans)

Buggy submission (verdict: Runtime Error):
package main 

import "fmt"

func main() {
	var x [5]int

	for i := 0; i < 5; i++ {
		fmt.Scan(&x[i])
	}

	for i := 0; i < 5; i++ {
		if x[i] == 0 {
			fmt.Println(i + 1)
		}
	}
}
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

visited = [0 for _ in range(N)]
first_visit = [0 for _ in range(N)]

now = 0
flag = True
for i in range(10 ** 5 * 5):
    if first_visit[now] == 0:
        first_visit[now] = i

    visited[A[now] - 1] += 1
    now = A[now] - 1

    if i == K - 1:
        print(now + 1)
        flag = False
        break

if flag:
    num = 0
    for i in range(N):
        if visited[i] > 2:
            num += 1

    for i in range(N):
        if visited[i] >= 2:
            if K % num == first_visit[i] % num:
                print(i + 1)
                break

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

visited = [0 for _ in range(N)]
first_visit = [0 for _ in range(N)]

now = 0
flag = True
for i in range(10 ** 5 * 3):
    if first_visit[now] == 0:
        first_visit[now] = i

    visited[A[now] - 1] += 1
    now = A[now] - 1

    if i == K - 1:
        print(now + 1)
        flag = False
        break

if flag:
    num = 0
    for i in range(N):
        if visited[i] > 3:
            num += 1

    for i in range(N):
        if K % num == first_visit[i] % num:
            print(i + 1)
Problem p02719 (python)

Fixed submission:
N, K = map(int, input().split())
print(min(N%K, abs(N%K - K)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

print(min(N%K, abs(N%K - K))
Problem p02732 (python)

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))

dic = {}
for i in range(N):
  if A[i] in dic:
    dic[A[i]] += 1
  else:
    dic[A[i]] = 1

memo = [0 for i in range(10 ** 6)]
ans = 0
for k in dic:
  tmp  =dic[k]
  if tmp >= 2:
    if memo[tmp] == 0:
      memo[tmp] = tmp * (tmp - 1) // 2
      ans += memo[tmp]
    else:
      ans += memo[tmp]

for i in range(N):
  tmp = dic[A[i]]
  if tmp == 1:
    print(ans)
  elif tmp == 2:
    print(ans - 1)
  else:
    print(ans - tmp * (tmp - 1) // 2 + (tmp - 1) * (tmp - 2) // 2)

Buggy submission (verdict: Runtime Error):
import math

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)

N = int(input())
A = list(map(int, input().split()))

dic = {}
for i in range(N):
  if A[i] in dic:
    dic[A[i]] += 1
  else:
    dic[A[i]] = 1

memo = 
ans = 0
for k in dic:
  tmp  =dic[k]
  if tmp >= 2:
    memo[k] = C(tmp, 2)
    ans += memo[k]

for i in range(N):
  tmp = dic[A[i]]
  if tmp == 1:
    print(ans)
  elif tmp == 2:
    print(ans - 1)
  else
    print(ans - (memo[A[i]] - C(tmp-1, 2)))
Problem p02756 (python)

Fixed submission:
from collections import deque

s = input()
q = int(input())
Q = [list(map(str, input().split())) for i in range(q)]

ans = deque(s)

reverse_num = 0
for i in range(q):
  if int(Q[i][0]) == 1:
    reverse_num += 1
  else:
    if int(Q[i][1]) == 1:
      if reverse_num % 2 == 0:
        ans.appendleft(Q[i][2])
      else:
        ans.append(Q[i][2])
    else:
      if reverse_num % 2 != 0:
        ans.appendleft(Q[i][2])
      else:
        ans.append(Q[i][2])

res = ''
if reverse_num % 2 == 0: 
  for i in range(len(ans)):
    res += ans.popleft()
  print(res)
else:
  for i in range(len(ans)):
    res += ans.pop()
  print(res)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
Q = [list(map(str, input().split())) for i in range(q)]

ans = ['' for in range(10 ** 5 * 3 + 2)]

for i in range(len(s)):
  ans[10 ** 5 + i + 1] = s[i]

reverse_num = 0
tmp1 = 0
tmp2 = 0
for i in range(q):
  if int(Q[i][0]) == 1:
    reverse_num += 1
  else:
    if int(Q[i][1]) == 1:
      if reverse_num % 2 == 0:
        ans[10 ** 5 - tmp1] = Q[i][2]
        tmp1 += 1
      else:
        ans[10 ** 5 + len(s) + tmp2] = Q[i][2]
        tmp2 += 1
    else:
      if reverse_num % 2 != 0:
        ans[10 ** 5 - tmp1] = Q[i][2]
        tmp1 += 1
      else:
        ans[10 ** 5 + len(s) + tmp2] = Q[i][2]
        tmp2 += 1
      
res = ''
for i in range(len(ans)):
  if ans[i] != '':
    res += ans[i]
    
print(ans)
Problem p02760 (python)

Fixed submission:
bingo = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
number = [int(input()) for _ in range(N)]

check = [[0 for _ in range(3)] for _ in range(3)]

for i in range(N):
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == number[i]:
        check[j][k] = 1
        
ans = 'No'
for i in range(3):
  if check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1:
    ans = 'Yes'
    
for i in range(3):
  if check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1:
    ans = 'Yes'
    
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
  ans = 'Yes'
  
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
  ans = 'Yes'
  
print(ans)

Buggy submission (verdict: Runtime Error):
bingo = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
number = [int(input()) for _ in range(N)]

check = [[0 for _ in range(3)] for _ in range(3)]

for i in range(N):
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == N[i]:
        check[j][k] = 1
        
ans = 'No'
for i in range(3):
  if check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1:
    ans = 'Yes'
    
for i in range(3):
  if check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1:
    ans = 'Yes'
    
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
  ans = 'Yes'
  
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
  ans = 'Yes'
  
print(ans)

Buggy submission (verdict: Runtime Error):
bingo = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
number = [int(input()) for _ in range(N)]

check = [0 for _ in range(3)]

for i in range(N):
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == N[i]:
        check[j][k] = 1
        
ans = 'No'
for i in range(3):
  if check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1:
    ans = 'Yes'
    
for i in range(3):
  if check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1:
    ans = 'Yes'
    
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
  ans = 'Yes'
  
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
  ans = 'Yes'
  
print(ans)
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]

ans = -1
if N == 1:
  s = 0
else:
  s = 10 ** (N - 1)
for i in range(s, 10 ** N + 1):

  flag = True
  for j in range(M):
    try:
      if str(i)[q[j][0] - 1] != str(q[j][1]):
        flag = False
    except:
      flag = False
      break
      
  if flag:
    ans = i
    break
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = -1
for i in range(10 ** 3):
  flag = True
  for j in range(M):
    if str(i)[q[i][0] - 1] != q[i][1]:
      flag = False
      
  if flag:
    ans = i
    break
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = list('0' * N)
for i in range(M):
  if change[q[i][0]-1] == 0:
  	ans[q[i][0] - 1] = q[i][1]
  	change[q[i][0]-1] = 1
  else:
    if ans[q[i][0] - 1] != q[i][1]:
      ans = -1
      break
      
res = ''
for i in range(len(ans)):
  res += str(ans[i])
  
if res[0] == '0':
  print(-1)
else:
  print(int(res))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = list('0' * N)
for i in range(M):
  if change[q[i][0]-1] == 0:
  	ans[q[i][0] - 1] = q[i][1]
    change[q[i][0]-1] = 1
  else:
    if ans[q[i][0] - 1] != q[i][1]:
      ans = -1
      break
      
try:
  print(int(ans))
except:
  print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = list('0' * N)
for i in range(M):
  if change[q[i][0]-1] == 0:    
  	ans[q[i][0] - 1] = q[i][1]
    change[q[i][0]-1] = 1
  else:
    if ans[q[i][0] - 1] != q[i][1]:
      ans = -1
      break
      
try:
  print(int(ans))
except:
  print(-1)