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

Fixed submission:
S = input()
N = len(S)
S1 = S[:N//2]
S2 = S[N//2 + 1:]
N1 = len(S1)
if S1 != S2:
    print('No')
    exit()

for i in range(N//4):
    if S1[i] != S1[-i - 1]:
        print('No')
        exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
S1 = S[:N//2]
S2 = S[N//2 + 1:]
N1 = len(S1)
if N1 % 2 == 1:
    if S1[N1//2 + 1] != S2[N1//2 + 1]:
        print('No')
        exit()

for i in range(N//4):
    if S1[i] != S2[-i - 1] or S1[i] != S2[i] or S1[i] != S2[-i - 1]:
        print('No')
        exit()
print('Yes')
Problem p02789 (python)

Fixed submission:
n, m = map(int, input().split())
if n == m:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
if n == m:
  print('Yes')
else:
  print('No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
if n == m:
  print('Yes')
else:
  print(('No")
Problem p02909 (python)

Fixed submission:
w = {'Sunny':'Cloudy', 'Cloudy':'Rainy', 'Rainy':'Sunny'}
print(w[input()])

Buggy submission (verdict: Runtime Error):
w = {'Sunny':'Cloud', 'Cloud':'Rainy', 'Rainy':'Sunny'}
print(w[input()])
Problem p02999 (python)

Fixed submission:
x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
x, a = map(int, input())
if 0 < x < a:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
x, a = map(int, input())
if 0 < a < x:
  print(0)
else:
  print(10)
Problem p03477 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l > r:
    print('Left')
elif l < r:
    print('Right')
else:
    print('Balanced')

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l > r:
  print('Left')
elif l < r:
  print('Right')
else:
  pritn('Balanced')
Problem p03285 (python)

Fixed submission:
n = int(input())
for q in range(0, n, 7):
    if q == 0:
        continue
    if (n - q) % 4 == 0:
        print("Yes")
        exit(0)
print("No" if (n % 4 != 0) and (n % 7 != 0) else "Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
for q in range(1, n, 7):
    if q % 4 == 0:
        print("Yes")
        exit(0)
print("No" if (q % 4 != 0) and (q % 7 != 0) else "Yes")
Problem p03433 (python)

Fixed submission:
print("Yes" if (int(input()) % 500) <= int(input()) else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if (input() % 500) < input() else "No")
Problem p03545 (python)

Fixed submission:
a, b, c, d = list(input())
for q in range(1, 3):
    ao = ("+" if q % 2 else "-")
    for w in range(1, 3):
        bo = ("+" if w % 2 else "-")
        for e in range(1, 3):
            if eval(a + ao + b + bo + c + ("+" if e % 2 else "-") + d) == 7:
                print(a + ao + b + bo + c + ("+" if e%2else"-") + d + "=7")
                exit(0)

Buggy submission (verdict: Runtime Error):
a, b, c, d = list(input())
for q in range(1, 3):
    ao = ("+" if q % 2 else "-")
    for w in range(1, 3):
        bo = ("+" if w % 2 else "-")
        for e in range(1, 3):
            if eval(a + ao + b + bo + c + ("+" if e % 2 else "-") + d) == 7:
                print(f'{a}{ao}{b}{bo}{c}{("+" if e%2else"-")}{d}=7')
                exit(0)
Problem p03657 (python)

Fixed submission:
a, b = map(int, input().split())
print("Impossible" if (a % 3) and (b % 3) and ((a + b) % 3) else "Possible")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print("Impossible" if (a % 3) or (b % 3) or(sum(a, b) % 3) else "Possible")
Problem p03807 (python)

Fixed submission:
input()

print("NO" if sum(map(int, input().split())) % 2 else "YES")

Buggy submission (verdict: Runtime Error):
a, b, c = sorted(list(map(int, input().split())))

count  = (b - a) // 2
count += 2 if (a + count * 2) != b else 0
count += c - b
print(count)
Problem p03944 (python)

Fixed submission:
w, h, n = map(int, input().split())
ll_x, ll_y, tr_x, tr_y = 0, 0, w, h
for q in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        ll_x = max(ll_x, x)
    elif a == 2:
        tr_x = min(tr_x, x)
    elif a == 3:
        ll_y = max(ll_y, y)
    elif a == 4:
        tr_y = min(tr_y, y)
ans = (tr_x - ll_x) * (tr_y - ll_y)
if (ll_x > tr_x) or (ll_y > tr_y):
    ans = 0
print(ans if ans > 0 else 0)

Buggy submission (verdict: Runtime Error):
w, h, n = map(int, input().split())
ll_x, ll_y, tr_x, tr_y = 0, 0, w, h
for q in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        ll_x = max(ll_x, x)
    elif a == 2:
        tr_x = min(tr_x, x)
    elif a == 3:
        ll_y = max(ll_y, y)
    elif a == 4:
        tr_y = min(tr_y, y)
print(f"({ll_x}, {ll_y}), ({tr_x}, {tr_y})")
ans = (tr_x - ll_x) * (tr_y - ll_y)
print(ans if ans > 0 else 0)
Problem p02658 (python)

Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]
A = 1
if 0 in a:
  print(0)
  exit()
for i in range(N):
  A = A * a[i]
  if A > 1000000000000000000:
    print(-1)
    exit()
print(A)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]
if 0 in a:
  print(0)
  break
A = 1
for i in range(N):
  A = A * a[i]
  if A > 1000000000000000000:
    print(-1)
    break
print(A)
Problem p02730 (python)

Fixed submission:
s = input()
n = len(s)
sa = s[:int((n-1)/2)]
sb = s[int((n+3)/2)-1:]
if s == s[::-1] and sa == sa[::-1] and sb == sb[::-1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = len(s)
sa = s[:int((n-1)/2)]
sb = s[int((n+3)/2)-1:]
if s == s[::-1] and sa == sa[::-1] and sb == sb[::-1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = len(s)
sa = s[:(n-1)//2]
sb = s[(n+3)//2-1:n]
if s == s[::-1] and sa == sa[::-1] and sb == sb[::-1]:
    print("Yes")
else:
    print("No")
Problem p02818 (python)

Fixed submission:
a,b,k = input().split(None, 3)
A = int(a)
B = int(b)
K = int(k)

if A >= K:
  print(A-K,B)

elif A+B >= K > A :
  print(0, B -K+A)

else:
  print(0,0)

Buggy submission (verdict: Runtime Error):
a,b,k = input().split(None, 3)
A = int(a)
B = int(b)
K = int(k)
Ta = 0
Ao = 0

if A >= K:
  Ta = A-k
  Ao = B

elif A+B >= K > A :
  Ta = 0
  Ao = B - (K-A)

else:
  Ta = 0
  Ao = 0

print(Ta,Ao)
Problem p02675 (python)

Fixed submission:
# coding: utf-8
import sys,pprint

N = int(input())
h = 'hon'
p = 'pon'
b = 'bon'
suffix = [p,p,h,b,h,h,p,h,p,h]

print(suffix[N%10])

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys,pprint, math
from fractions import Fraction
from collections import defaultdict

MOD = 1000000007
N = int(input())
params =[]
hatemasks = []
tilts = defaultdict(lambda: [0,0])
zerozero = 0
zerodiv = 0
for i in range(N):
    (ai, bi) = map(int,input().split())
    if ai == 0 and bi == 0:
        zerozero += 1
        continue
    elif (ai <= 0) or (ai == 0 and bi < 0):
        ai *= -1
        bi *= -1
    g = math.gcd(ai,bi)
    ai = ai // g
    bi = bi // g
    if bi > 0:
        tilts[(ai,bi)][0] += 1
    else:
        tilts[(-bi,ai)][1] += 1
print(tilts,file=sys.stderr)

#sys.exit()
ans = 1
for(v1,v2) in tilts.values():
    ans *= 1 +pow(2,v1,MOD)-1 +pow(2,v2,MOD)-1
    ans %= MOD
ans = (ans+zerozero-1) % MOD
print(ans)
Problem p02684 (python)

Fixed submission:
# coding: utf-8
import sys,pprint,readline

av = {}
passed = set()

(N,K) = [int(x) for x in input().split(" ")]

arrivalary = list(map(int,input().split(" ")))

'''
N =  200000
K = 12345678901234567
arrivalary = []
for i in range(1,N):
    arrivalary.append(i+1)
arrivalary.append(1)
'''

i = 0
loopflg = 0
pos = 1
nextpos = 0
loopstartpos = 0
loopstartnum = 0
loopcount = 0
while i < K:
    passed.add(pos)
    nextpos = arrivalary[pos-1]
    #print(i,pos,nextpos,loopflg,loopstartnum,loopstartpos,loopcount,file=sys.stderr)
    if loopflg == 0 and nextpos in passed:
        loopflg = 1
        loopstartpos = nextpos
        loopstartnum = i
        loopcount = 1
    elif loopflg == 1 and nextpos == loopstartpos:
        left = (K-loopstartnum) % loopcount
        #print("left=",left,file=sys.stderr)
        i = K-left
        if i == K:
            break
    elif loopflg == 1:
        loopcount += 1
    pos = nextpos
    i += 1

print(pos)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys,pprint

av = {}
passed = set()

(N,K) = [int(x) for x in input().split(" ")]

arrivalary = input().split(" ")
i = 1
while len(arrivalary) > 0:
    a = int(arrivalary.pop(0))
    av[i] = a
    i += 1

i = 0
loopflg = 0
pos = 1
nextpos = 0
loopstartpos = 0
loopstartnum = 0
loopcount = 0
while i < K:
    passed.add(pos)
    nextpos = av[pos]
    # print(i,pos,nextpos,loopflg,loopstartpos,loopcount,file=sys.stderr)
    if loopflg == 0 and nextpos in passed:
        loopflg = 1
        loopstartpos = nextpos
        loopstartnum = i
    elif loopflg == 1 and nextpos == loopstartpos:
        left = (K-loopstartnum) % loopcount
        i = K-left
    elif loopflg == 1:
        loopcount += 1
    pos = nextpos
    i += 1

print(pos)
Problem p02658 (python)

Fixed submission:
N=int(input())
A = list(map(int,input().split()))
A.sort()
x=1
y=True
for i in A:
    x= x*i
    if x > 10**18:
        print('-1')
        y=False
        break
if y:
    print(x)

Buggy submission (verdict: Runtime Error):
a,b=map(int and float ,input().split())
b=100*b
c=a*b
print(int(c/100))
Problem p02696 (python)

Fixed submission:
import math

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

if B==1:
    print(0)
else:
    if B > N:
        print(math.floor(A*N/B))

    else:
        print(math.floor(A*(B-1)/B))

Buggy submission (verdict: Runtime Error):
import math

A,B,N=map(int,input().split())
list=[]
t=0
if B > N:
    print(math.floor(A*N/B))
else:
    for x in range(B+1,N):
        if t==0:
            y=math.floor(A*x/B)-A*math.floor(x/B)
        else:
            z=math.floor(A*x/B)-A*math.floor(x/B)
            if y - z>0:
                y = z
            else:
                break

    print(y)
Problem p02741 (python)

Fixed submission:
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(list[K-1])

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
result=0
if H==1 or W==1:
    result=1
elif W%2==0:
    result = (W/2)*H
else:
    if H%2==0:
        result=W*(H/2)
    else :
        result=W*(H-1)/2+(W+1)/2
print(str(round(result)))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
if H==1 or W==1:
    print("1")
elif W%2==0:
    result = (W/2)*H
else:
    if H%2==0:
        result=W*(H/2)
    else :
        result=W*(H-1)/2+(W+1)/2
print(str(round(result)))
Problem p02742 (python)

Fixed submission:
H, W = map(int, input().split())
result=0
if H==1 or W==1:
    result=1
elif W%2==0:
    result = (W/2)*H
else:
    if H%2==0:
        result=W*(H/2)
    else :
        result=W*(H-1)/2+(W+1)/2
print(str(round(result)))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
if H==1 or W==1:
    print("1")
elif W%2==0:
    result = (W/2)*H
elif W%2==1:
    if H%2==0:
        result=W*(H/2)
    elif H%2==1 :
        result=W*(H-1)/2+(W+1)/2
print(str(round(result)))
Problem p02761 (python)

Fixed submission:
N,M=map(int,input().split())
s=[]
c=[]
for i in range(M):
    a,b=map(int,input().split())
    s.append(a)
    c.append(b)
found=False
start=pow(10,N-1)
stop=pow(10,N)
if N==1:
    start=0
for i in range(start,stop):
    i_str=str(i)
    passed=True
    for j in range(M):
        if not i_str[s[j]-1]==str(c[j]):
            passed=False
            break
    if passed:
        found=True
        print(i)
        break
if not found:
    print('-1')

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
s=[0]*m
c=[0]*m
ans=[]
judge=False
for i in range(m):
    s[i],c[i]=map(int,input().split())
for j in range(10**n):
    j=str(j)
    for l in range(m):
        if int(j[s[l]-1])==c[l]:
            pass
        else:
            break
    else:
        ans.append(int(j))
        judge=True
if judge:
    print(min(ans))
else:
    print('-1')

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
s=[0]*m
c=[0]*m
ans=[]
judge=False
for i in range(m):
    s[i],c[i]=map(int,input().split())
for j in range(10**(n-1)-1,10**n):
    j=str(j)
    for l in range(m):
        if int(j[s[l]-1])==c[l]:
            pass
        else:
            break
    else:
        ans.append(int(j))
        judge=True
if judge:
    print(min(ans))
else:
    print('-1')

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
s=[]
c=[]
for i in range(M):
    a,b=map(int,input().split())
    s.append(a)
    c.appemd(b)
found=False
start=pow(10,N-1)
stop=pow(10,N)
if N==1:
    start=0
for i in range(start,stop):
    i_str=str(i)
    passed=True
    for j in range(M):
        if not i_str[s[j]-1]==str(c[j]):
            passed=False
            break
    if passed:
        found=False
        print(i)
        break
if not found:
    print('-1')
Problem p02767 (python)

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
D=[]
for i in range(1,101):
    sum=0
    for j in range(len(X)):
        sum += abs(X[j]-i)**2
    D.append(sum)
print(min(D))

Buggy submission (verdict: Runtime Error):
N=int(input())
X=list(map(int,input().split()))
D=[]
for i in range(min(X),max(X)):
    sum=0
    for j in range(len(X)):
        sum += abs(X[j]-i)**2
    D.append(sum)
print(min(D))
Problem p02801 (python)

Fixed submission:
s = 'abcdefghijklmnopqrstuvwxyz'
C = input(str())

for i in range(len(s)):
    if s[i] == C:
        print(s[i+1])
        break
else:
    print('')

Buggy submission (verdict: Runtime Error):
s = 'abcdefghijklmnopqrstuvwxy'
C = input(str())

for i in range(len(s)):
    if s[i] == C:
        print(s[i+1])
        break

Buggy submission (verdict: Runtime Error):
s = 'abcdefghijklmnopqrstuvwxy'
C = input(str())

for i in range(len(s)):
    if s[i] == C:
        print(s[i+1])
        break
else:
    print('')
Problem p02811 (python)

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

if 500*X >= K:
  print('Yes')
  
else:
    print('No')

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

if 500*x >= k:
  print('YES')
  
  else:
    print('NO')
Problem p02817 (python)

Fixed submission:
S,T=map(str,input().split())

print(T,S,sep='')

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

a = 0
b = 0

if A <= 10**12 and B <=10**12 and K <= 10**12:
    if A >= K :
        a = A-K
    elif  (A + B) >=K:
        a = 0
        b = B-(K-A)
    elif  (A + B)  < K:
        a = 0
        b = 0
else :
    a = 0
    b = 0

print(a,b,end='')
Problem p02818 (python)

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

a = 0
b = 0

if A <= 10**12 and B <=10**12 and K <= 10**12:
    if A >= K :
        a = A-K
        b = B
    elif  (A + B) >=K:
        a = 0
        b = B-(K-A)
    elif  (A + B)  < K:
        a = 0
        b = 0
else :
    a = 0
    b = 0

print(a,b,end='')

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

a = 0
b = 0


    if A >= K :
        a = A-K
    elif  (A + B) > K:
        a = 0
        b = B-(K-A)
    elif  (A + B)  < K:
        a = 0
        b = 0


print(a,b,end='')
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
primeN = []
tmp = 2
for i in range(2, n):
    if primeN:
        for j in range(len(primeN)):
            if i % primeN[j] == 0:
                break
            else:
                if j == len(primeN) - 1:
                    primeN.append(i)
    else:
        if n > tmp:
            primeN.append(i)
#print(primeN)

s = 0
for j in primeN:
  k = j
  while n%k==0:
    s+=1
    n = int(n/j)
    k = k*j
print(s)
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
s = 1
B = sorted(A)
for i in B:
  s = s*i
  if s > 10**18:
    s = -1
    break
  if s == 0:
    break
print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
s = 1
B = sort(A)
for i in B:
  s = s*i
	if s > 10**18:
    	s = -1
        break
    if s == 0
    	break
print(s)
Problem p03261 (python)

Fixed submission:
import sys
def is_unique(seq):
    return len(seq) == len(set(seq))

N = int(input())
W = []
for i in range(N):
    W.append((input()))
if is_unique(W):
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            print("No")
            sys.exit()
    print("Yes")

else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
def is_unique(seq):
    return len(seq) == len(set(seq))

N = int(input())
W = []
for i in range(N):
    w.append((input()))
if is_unique(W):
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            print("No")
            sys.exit()
    print("Yes")

else:
    print("No")
Problem p03288 (python)

Fixed submission:
R=int(input())
if R<1200:
  print("ABC")
elif R<2800:
  print("ARC")
else:
  print("AGC")

Buggy submission (verdict: Runtime Error):
R=int(input())
if R<1200:
  print("ABC")
elsif R<2800:
  print("ARC")
else:
  print("AGC")

Buggy submission (verdict: Runtime Error):
R=int(input())
if R<1200:
  print("ABC")
elseif R<2800:
  print("ARC")
else:
  print("AGC")
Problem p03289 (python)

Fixed submission:
import re
S=input()
if S[0]=="A" and S[2:-1].count("C")==1 and len(re.findall("[A-Z]",S))==2:
  print("AC")
else:
  print("WA")

Buggy submission (verdict: Runtime Error):
import re
S=input()
if S[0]=="A" and S[2:-1].count("C")==1 and len(re.findall("[A-Z]")):
  print("AC")
else:
  print("WA")
Problem p03294 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(sum(a)-n)

Buggy submission (verdict: Runtime Error):
n = int(input())
sum=0
for i in range(n):
    sum += int(input())
print(sum-n)
Problem p03302 (python)

Fixed submission:
a,b = map(int,raw_input().split())
if a + b == 15:
    print("+")
elif a * b  == 15:
    print("*")
else:
    print("x")

Buggy submission (verdict: Runtime Error):
a,b = map(int,raw.input().split())
if a + b == 15:
    print("+")
elif a * b  == 15:
    print("*")
else:
    print("x")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a + b == 15:
    print("+")
elif a * b  == 15:
    print("*")
else:
    print("x")
Problem p03303 (python)

Fixed submission:
s = raw_input()
w = int(raw_input())

ss = ''

for i in xrange(0, len(s), +w): ss += s[i]

print ss

Buggy submission (verdict: Runtime Error):
S = input()
w = int(input())
count=0
str = ""
while count < len(S):
    str += S[count]
    count += w
print str

Buggy submission (verdict: Runtime Error):
S = input()
w = int(input())
count=0
str = ""
while(count <= len(S)-1):
    str += S[count]
    count += w
print(str)

Buggy submission (verdict: Runtime Error):
S = input()
w = int(input())
count=0
str = ""
while(count <= len(S)):
    str += S[count]
    count += w
print(str)
Problem p02678 (python)

Fixed submission:
from collections import deque

N, M = map(int, input().split())
AB = [map(int, input().split()) for _ in range(M)]

links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)

result = [-1] * (N + 1)
q = deque([1])
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))

Buggy submission (verdict: Runtime Error):
from collections import deque
N,M = list(map(int,input().split(" ")))
AB =  [list(map(int,input().split(" "))) for _ in range(M)]
links = [[] for i in range(M+1)]

for a,b in AB:
  links[a].append(b)
  links[b].append(a)

result = [-1] * (N+1)
q = deque([1])
while q:
  i = q.popleft()
  for j in links[i]:
    if result[j] == -1:
      result[j] = i
      q.append(j)
      
print('Yes')
print('\n'.join(str(i) for i in result[2:]))

Buggy submission (verdict: Runtime Error):
from collections import deque
N,M = list(map(int,input().split(" ")))
AB =  [list(map(int,input().split(" "))) for _ in range(M)]
links = [[] for i in range(M+1)]

for a,b in AB:
  links[a].append(b)
  links[b].append(a)

result = [-1] * (N+1)
q = deque([1])
while q:
  i = q.popleft()
  for j in links[i]:
    if result[j] == -1:
      result[j] = i
      q.append(j)
      
print('Yes')
print('\n'.join(str(i) for i in result[2:]))

Buggy submission (verdict: Runtime Error):
from collections import deque
N,M = list(map(int,input().split(" ")))
AB =  [list(map(int,input().split(" "))) for _ in range(M)]
links = [[] for i in range(M+1)]

for a,b in AB:
  links[a].append(b)
  links[b].append(a)

result = [-1] * (N+1)
q = deque([1])
while q:
  i = q.popleft()
  for j in links[i]:
    if result[j] == -1:
      result[j] = i
      q.append(j)
      
print('Yes')
print('\n'.join(str(i) for i in result[2:]))
Problem p02923 (python)

Fixed submission:
N = int(input())
lis = list(map(int, input().split()))
H_lis = []
H = lis[0]
cnt = 0

if N == 1:
    print(0)
    exit()

for i in lis[1:]:
    if i <= H:
       cnt += 1
       H = i
       H_lis.append(cnt)
    else:
        H_lis.append(cnt)
        cnt = 0
        H = i

print(max(H_lis))

Buggy submission (verdict: Runtime Error):
N = int(input())
lis = list(map(int, input().split()))
H_lis = []
H = lis[0]
cnt = 0

for i in lis[1:]:
    if i <= H:
       cnt += 1
       H = i
       H_lis.append(cnt)
    else:
        H_lis.append(cnt)
        cnt = 0
        H = i

print(max(H_lis))
Problem p03030 (python)

Fixed submission:
N = int(input())
lis = [(input() + " " + str(i+1)).split() for i in range(N)]

lis = [k for k in lis]

lis.sort(key=lambda k: int(k[1]), reverse=True)
lis.sort(key=lambda k: k[0])


for j in lis:
    print(j[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
lis = [(input() + " " + str(i+1)).split() for i in range(N)]

lis = [k for k in lis]

lis.sort(key=lambda k: int(k[1]), reverse=True)
lis.sort(key=lambda k: k[0])


for j in lis:
    print(j[2])
N = int(input())
lis = [(input() + " " + str(i+1)).split() for i in range(N)]

lis = [k for k in lis]

lis.sort(key=lambda k: int(k[1]), reverse=True)
lis.sort(key=lambda k: k[0])


for j in lis:
    print(j[2])
Problem p03695 (python)

Fixed submission:
N = int(input())
lank = [0, 0, 0, 0, 0, 0, 0, 0]
a = list(map(int, input().split()))
cnt = 0

for i in range(N):
    if 1 <= a[i] <= 399:
        lank[0] = 1
    elif 400 <= a[i] <= 799:
        lank[1] = 1
    elif 800 <= a[i] <= 1199:
        lank[2] = 1
    elif 1200 <= a[i] <= 1599:
        lank[3] = 1
    elif 1600 <= a[i] <= 1999:
        lank[4] = 1
    elif 2000 <= a[i] <= 2399:
        lank[5] = 1
    elif 2400 <= a[i] <= 2799:
        lank[6] = 1
    elif 2800 <= a[i] <= 3199:
        lank[7] = 1
    else:
        cnt += 1

number_min = max(1, lank.count(1))
number_max = lank.count(1) + cnt

print(number_min, number_max)

Buggy submission (verdict: Runtime Error):
N = int(input())
lank = [0, 0, 0, 0, 0, 0, 0, 0]
a = list(map(int, input().split()))

for i in range(N):
    if 1 <= a[i] <= 399:
        lank[0] = 1
    elif 400 <= a[i] <= 799:
        lank[1] = 1
    elif 800 <= a[i] <= 1199:
        lank[2] = 1
    elif 1200 <= a[i] <= 1599:
        lank[3] = 1
    elif 1600 <= a[i] <= 1999:
        lank[4] = 1
    elif 2000 <= a[i] <= 2399:
        lank[5] = 1
    elif 2400 <= a[i] <= 2799:
        lank[6] = 1
    elif 2800 <= a[i] <= 3199:
        lank[7] = 1
    else:
        idx = lank.index(0)
        lank[idx] = 2

number_min = lank.count(1)
number_max = lank.count(1) + lank.count(2)

print(number_min, number_max)
Problem p02747 (python)

Fixed submission:
S = input()
ok = True
for i in range(0, len(S), 2):
    try:
        if not (S[i] == "h" and S[i + 1] == "i"):
            ok = False
            break
    except IndexError:
        ok = False
        break
print("Yes" if ok else "No")

Buggy submission (verdict: Runtime Error):
S = input()
ok = True
for i in range(0, len(S), 2):
    if not (S[i] == "h" and S[i + 1] == "i"):
        ok = False
        break
print("Yes" if ok else "No")