Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[0]+SP[1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

Fixed submission:
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[0]+SP[1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
[print(i) for i in ans]

Fixed submission:
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - SP[n][1]).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[0]+SP[1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
[print(i) for i in ans]

Fixed submission:
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = []
for _ in range(N):
  SP.append([i for i in input().split()])
for n in range(N):
  SP[n][1] = str(100 - SP[n]).rjust(3,'0')
SP2 = []
for n in range(N):
  SP2.append(SP[0]+SP[1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
[print(i) for i in ans]

Fixed submission:
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = []
for _ in range(N):
  SP.append(input().split())
print(sorted(range(len(s)), key=lambda k: s[k],reverse=True))

Fixed submission:
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = [int(i) for i in input().split()]
L=[]
R=[]
for n in range(M):
    temp = [int(i) for i in input().split()]
    L.append(temp[0])
    R.append(temp[1])
init_set = set(range(L[0],R[0]+1))
for n in range(M-1):
    now_set = set(range(L[n+1],R[n+1]+1))
    init_set = (init_set & now_set)
print(len(init_set))

Fixed submission:
N,M = [int(i) for i in input().split()]
L_max ,R_min = [int(i) for i in input().split()]
for _ in range(M-1):
    temp = [int(i) for i in input().split()]
    if L_max < temp[0]:
        L_max = temp[0]
    if R_min > temp[1]:
        R_min = temp[1]
print(max(R_min - L_max + 1,0))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])
BC = []
for _ in range(M):
    BC.append([int(i) for i in input().split()])
BC = sorted(BC,reverse=True)
for m in range(M):
    for b in range(BC[m][0]):
        if A[b] > BC[m][1]:
            break
        else:
            A[b] = BC[m][1]
    A = sorted(A)
print(sum(A))

Fixed submission:
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
BC = []
for m in range(M):
    BC.append([int(i) for i in input().split()])
    if BC[m][0] > N:
        BC[m][0] = N
BC = sorted(BC,reverse=True,key=lambda x: x[1])
change_list = []
for m in range(M):
    change_list.extend([BC[m][1] for _ in range(BC[m][0])])
    if len(change_list) >= N:
        change_list = change_list[0:N]
        break
A.extend(change_list)
A = sorted(A,reverse=True)
print(sum(A[0:N]))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
[H,W] = [int(i) for i in input().split()]
A = []
for h in range(H):
    A_temp = input().replace(".","w")
    A_temp = A_temp.replace("#","b")
    A_temp2 = []
    for w in range(W):
        A_temp2.append(A_temp[w])
    A.append(A_temp2)
cnt = 0
while True:
    A2 = copy.deepcopy(A)
    # 白があるかチェック
    chk = True
    for h in range(H):
        chk *= ("w" not in A2[h])
    if chk == True:
        break
    cnt += 1
    # 白があったら書き換え
    for h in range(H):
        for w in range(W):
            if A[h][w] == "b":
                # 左
                if w != 0:
                    A2[h][w-1] = "b_temp"
                # 上
                if h != 0:
                    A2[h-1][w] = "b_temp"
                # 右
                if w != W-1:
                    A2[h][w+1] = "b_temp"
                # 下
                if h != H-1:
                    A2[h+1][w] = "b_temp"
    for h in range(H):
        for w in range(W):
            if A2[h][w] == "b_temp":
                A2[h][w] = "b" 
    A = copy.deepcopy(A2)
print(cnt)

Fixed submission:
import numpy as np

H,W=map(int,input().split(' '))
# 回数の最大値はH+W
max_value = H+W
values =[]

# マス目に回数を入れる。黒なら0、白なら最大値を入れておく
for i in range(H):
    values.append([0 if i == '#' else max_value for i in list(input())])
# numpy配列に
values = np.array(values)

# 右のセルと比較して、
for x in range(W-1):
    values[:,x+1] = np.minimum(values[:,x]+1,values[:,x+1])
for x in range(W-1,0,-1):
    values[:,x-1] = np.minimum(values[:,x-1],values[:,x]+1)
for x in range(H-1):
    values[x+1,:] = np.minimum(values[x,:]+1,values[x+1,:])
for x in range(H-1,0,-1):
    values[x-1,:] = np.minimum(values[x,:]+1,values[x-1,:])
print(np.max(values))
Buggy python submission (verdict: Runtime Error):
import numpy as np
import copy

N = int(input())
A = [int(i) for i in input().split()]
A = list(set(A))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

if N==2:
    print(max(A))
else:
    gcds = []
    for i in range(len(A)-1):
        if i == 0:
            gcds.append(gcd(A[0],A[1]))
        else:
            gcds.append(gcd(gcds[-1],A[i]))
    gcds = np.asarray(gcds)
    
    index = []
    for idx,n in enumerate(gcds.min() == gcds):
        if n==True:
            index.append(idx)
    a = []
    for i in index:
        if i+1 in index:
            None
        else:
            a.append(i+1)
    for i in a:
        index.append(i)
    gcds = []
    for idx in index:
        A_temp = copy.deepcopy(A)
        A_temp.pop(idx)
        gcds_temp = []
        for i in range(len(A_temp)-1):
            if i ==0:
                gcds_temp.append(gcd(A_temp[0],A_temp[1]))
            else:
                gcds_temp.append(gcd(gcds_temp[-1],A_temp[i]))
        gcds.append(min(gcds_temp))
    print(max(gcds))


Fixed submission:
import math
[A,B,T] = [int(i) for i in input().split()]
print(B * math.floor(T  / A ))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [1 if i == "." else 0 for i in input()]
# 黒は#,白が.
# 黒は0,白は1
# 黒の右に白は許されない
# ある場所を境に左は全部白、右は全部黒にするから、それの逆の個数を数える
# ある境より右にある白の数
rw = sum(S)
# ある境より左にある黒の数
lb = 0
min_temp = rw+lb
for idx,s in enumerate(S):
    # 黒の場合
    if s==0:
        # rw pass
        lb *= 1
    # 白の場合
    elif s==1:
        rw += 1
        lb -= 1
    # 小さい方を残す
    min_temp = min([min_temp,rw+lb])
    if min_temp == 0:break
print(min_temp)

Fixed submission:
X= [int(i) for i in input().split()]
if (X[0] > X[2] and X[1] < X[2]) or (X[0] < X[2] and X[1] > X[2]) :
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
cnt1 = 0
cnt2 = 0
for idx,s in enumerate(S):
    if s == "#" and idx < N-1:
        cnt1+=1
    if s=="." and N!=0:
        cnt2+=1
if cnt1 < cnt2:
    print(cnt1)
else:
    print(cnt2)



Fixed submission:
X= [int(i) for i in input().split()]
if (X[0] > X[2] and X[1] < X[2]) or (X[0] < X[2] and X[1] > X[2]) :
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N=int(input())
# S=input()
S = ["#" for i in range(200000)]
S[0] = "."
S = "".join(S)
cnt1 = 0
cnt2 = 0
for idx,s in enumerate(S):
    if s == "#" and idx < N-1:
        cnt1+=1
    if s=="." and N==0:
        cnt2+=1
if cnt1 < cnt2:
    print(cnt1)
else:
    print(cnt2)

Fixed submission:
X= [int(i) for i in input().split()]
if (X[0] > X[2] and X[1] < X[2]) or (X[0] < X[2] and X[1] > X[2]) :
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N = int(input())
S=input()
cnt1 = 0
cnt2 = 0
for idx,s in enumerate(S):
    print(idx)
    if s != "." and idx != N-1:
        cnt1 += 1
    if s!="#":
        cnt2+=1
print(min([cnt1,cnt2]))

Fixed submission:
X= [int(i) for i in input().split()]
if (X[0] > X[2] and X[1] < X[2]) or (X[0] < X[2] and X[1] > X[2]) :
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [1 if i == "." else 0 for i in input()]
# 黒は#,白が.
# 黒は0,白は1
# 黒の右に白は許されない
# ある場所を境に左は全部白、右は全部黒にするから、それの逆の個数を数える
# ある境より右にある白の数
rw = sum(S)
# ある境より左にある黒の数
lb = 0
min_temp = [rw+lb]
for idx,s in enumerate(S):
    # 黒の場合
    if s==0:
        # rw pass
        lb *= 1
    # 白の場合
    elif s==1:
        rw += 1
        lb -= 1
    # 小さい方を残す
    min_temp = min([min_temp,rw+lb])
    if min_temp == 0:break
print(min_temp)

Fixed submission:
N = int(input())
S = [1 if i == "." else 0 for i in input()]
# 黒は#,白が.
# 黒は0,白は1
# 黒の右に白は許されない
# ある場所を境に左は全部白、右は全部黒にするから、それの逆の個数を数える
# ある境より右にある白の数
rw = sum(S)
# ある境より左にある黒の数
lb = 0
min_temp = rw+lb
for idx,s in enumerate(S):
    # 黒の場合
    if s==0:
        # rw pass
        lb += 1
    # 白の場合
    elif s==1:
        rw -= 1
    # 小さい方を残す
    min_temp = min([min_temp,rw+lb])
    if min_temp == 0:break
print(min_temp)
Buggy python submission (verdict: Runtime Error):
t = [int(input()) for i in range(5)]
T = [(-(-i//10))*10 for i in t]
t_min = [i%10 for i in t]
t_min = min([i for i in t_min if i != 0])
print(sum(T) - 10 + t_min)

Fixed submission:
t = [int(input()) for i in range(5)]
T = [(-(-i//10))*10 for i in t]
t_min = [i%10 for i in t]
t_min = min([i for i in t_min if i != 0]) if t_min != [0 for i in range(5)] else 10
print(sum(T) - 10 + t_min)

Buggy python submission (verdict: Runtime Error):
t = [int(input()) for i in range(5)]
T = [(-(-i//10))*10 for i in t]
t_min = [i%10 for i in t]
t_min = min([i for i in t_min if i != 0])
print(sum(T) - 10 + t_min)

Fixed submission:
t = [int(input()) for i in range(5)]
T = [(-(-i//10))*10 for i in t]
t_min = [i%10 for i in t]
t_min = min([i for i in t_min if i != 0]) if t_min != [0 for i in range(5)] else 10
print(sum(T) - 10 + t_min)

Buggy python submission (verdict: Runtime Error):
t = [int(input()) for i in range(5)]
T = [(-(-i//10))*10 for i in t]
t_min = [i%10 for i in t]
t_min = min([i for i in t_min if i != 0])
sum(T) - 10 + t_min

Fixed submission:
t = [int(input()) for i in range(5)]
T = [(-(-i//10))*10 for i in t]
t_min = [i%10 for i in t]
t_min = min([i for i in t_min if i != 0]) if t_min != [0 for i in range(5)] else 10
print(sum(T) - 10 + t_min)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input())
r,c = map(int,input())

import numpy as np

matrix = np.ones((H,W),dtype="uint8")
matrix[0:r,:] = 0
matrix[:,0:c] = 0
print(matrix.sum())


Fixed submission:
H,W = map(int,input().split())
r,c = map(int,input().split())

import numpy as np

matrix = np.ones((H,W),dtype="uint8")
matrix[0:r,:] = 0
matrix[:,0:c] = 0
print(matrix.sum())
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
max_A = max(A)
if sum(A.remove(max_A)) > max(A):
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
max_A = max(A)
A.remove(max_A)
if sum(A) > max_A:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())

if N == 1:
    print("Hello World")
else:
    print(A+B)

Fixed submission:
N = int(input())
if N == 1:
  print("Hello World")
else:
  A = int(input())
  B = int(input())
  print(A+B)
Buggy python submission (verdict: Runtime Error):
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

cnt = 0  
for n in range(1,N+1):
  if len(make_divisiors(n)) == 8:
    cnt += 1
print(cnt)

Fixed submission:
N = int(input())
 
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    return divisors
 
cnt = 0  
for n in range(1,N+1):
    if len(make_divisors(n)) == 8 and n%2==1:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
if A >= 9 or B >= 9:
    print(":(")
else:
    print("Yay!")

Fixed submission:
A,B = map(int,input().split())
if A >= 9 or B >= 9:
    print(":(")
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
if A => 9 or B => 9 :
    print(":(") 
else: 
    print("Yay!")

Fixed submission:
A,B = map(int,input().split())
if A >= 9 or B >= 9:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
D,N = map(int,input().split())
from math import pow
print(int(pow(100,D) * N)) if N != 100 elseprint(int(pow(100,D) * 101))

Fixed submission:
D,N = map(int,input().split())
from math import pow
print(int(pow(100,D) * N)) if N != 100 else print(int(pow(100,D) * 101))
Buggy python submission (verdict: Time Limit Exceeded):
from statistics import median
N = int(input())
X = [int(i) for i in input().split()]
for n in range(N):
    temp = X[:n] + X[n+1:]
    print(median(temp))

Fixed submission:
from statistics import median
N = int(input())
X = [int(i) for i in input().split()]
sort_X = sorted(X)
sort_X = sort_X[N//2-1:N//2+1]
for x in X:
    if sort_X[0] >= x:
        print(sort_X[1])
    else:
        print(sort_X[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
import numpy as np

A = np.array(A)

cnt = 0

while True:
  if (A%2).sum() == 0:
    A = A/2
    cnt += 1
  else
    break
print(cnt)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
import numpy as np

A = np.array(A)

cnt = 0

while True:
    if (A%2).sum() == 0:
        A = A/2
        cnt += 1
    else:
        break
print(cnt)
Buggy python submission (verdict: Runtime Error):
n,t=input(),0

for i in range(len(n)):
  t+=int(n[i])

 print('No' if t%9 else 'Yes')


Fixed submission:
n,t=input(),0

for i in range(len(n)):
  t+=int(n[i])

print('No' if t%9 else 'Yes')
Buggy python submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
A=[int(x) for x in input().split()]+[10**9]
B=[int(x) for x in input().split()]+[10**9]

c,i,j=0,0,0
while K>0 and (i<N or j<M):
  if K<min(A[i],B[i]):
    break
  c+=1
  if A[i]<B[j]:
    K-=A[i]
    i+=1
  elif B[j]<A[i]:
    K-=B[j]
    j+=1
  else:
    if A[i+1]<=B[j+1]:
      K-=A[i]
      i+=1
    else:
      K-=B[j]
      j+=1

print(c)


Fixed submission:
from bisect import bisect_right
from itertools import accumulate

N,M,K=map(int,input().split())
A=list(accumulate([0]+[int(x) for x in input().split()]))
B=list(accumulate([0]+[int(x) for x in input().split()]))

m=0
for i in range(0,N+1):
  if K<A[i]:
    break
  m=max(m,i+bisect_right(B,K-A[i])-1)

print(m)

Buggy python submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
A=[int(x) for x in input().split()]+[10**9]
B=[int(x) for x in input().split()]+[10**9]

c,i,j=0,0,0
while K>0 and (i<N or j<M):
  if K==min(K,A[i],B[i]):
    break
  c+=1
  if A[i]<B[j]:
    K-=A[i]
    i+=1
  elif B[j]<A[i]:
    K-=B[j]
    j+=1
  else:
    if A[i+1]<=B[j+1]:
      K-=A[i]
      i+=1
    else:
      K-=B[j]
      j+=1

print(c)


Fixed submission:
from bisect import bisect_right
from itertools import accumulate

N,M,K=map(int,input().split())
A=list(accumulate([0]+[int(x) for x in input().split()]))
B=list(accumulate([0]+[int(x) for x in input().split()]))

m=0
for i in range(0,N+1):
  if K<A[i]:
    break
  m=max(m,i+bisect_right(B,K-A[i])-1)

print(m)
Buggy python submission (verdict: Runtime Error):
def main():
  N=int(input())
  D=[0]*(10**6+1)

  for a in sorted(map(int,input().split())):
    if D[a]==0:
      D[a]=1
      for i in range(2*a,10**6+1,a):
        D[i]=-1
    else:
      D[a]=-1

  print(D.count(1))

main()


Fixed submission:
print([int(x) for x in input().split()].index(0)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

A=1
for a in [int(x) for x in input().split()]:
  A*=a
print(A if A<=10**18 else -1)


Fixed submission:
N=int(input())

A=sorted([int(x) for x in input().split()],reverse=True)
if A[-1]==0:
  print(0)
else:
  m=1
  for a in A:
    m*=a
    if m>10**18:
      break
  print(m if m<=10**18 else -1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def main():
  N,M=map(int,input().split())
  r=[[]for i in range(N)]
  d,p=[10**6]*N,[10**6]*N

  for i in range(M):
    a,b=map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)

  q=deque([0])
  p[0],d[0]=-1,0

  while len(q)!=0:
    i=q.pop()
    for j in r[i]:
      if d[j]>d[i]+1:
        d[j],p[j]=d[i]+1,i
        q.append(j)

  print('Yes')
  for i in range(1,N):
    print(p[i]+1)

main()


Fixed submission:
def main():
  N,M=map(int,input().split())

  r=[[]for i in range(N)]
  for i in range(M):
    a,b=map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)

  p=[-1]*N
  q=[0]
  while q:
    i=q.pop(0)
    for j in r[i]:
      if p[j]==-1:
        p[j]=i
        q.append(j)

  print('Yes')
  for i in range(1,N):
    print(p[i]+1)

main()

Buggy python submission (verdict: Runtime Error):
from collections import deque

def main():
  N,M=map(int,input().split())
  r=[[]for i in range(M)]
  d,p=[10**6]*N,[10**6]*N

  for i in range(M):
    a,b=map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)

  q=deque([0])
  p[0],d[0]=-1,0

  while len(q)!=0:
    i=q.pop()
    for j in r[i]:
      if d[j]>d[i]+1:
        d[j],p[j]=d[i]+1,i
        q.append(j)

  print('Yes')
  for i in range(1,N):
    print(p[i]+1)

main()


Fixed submission:
def main():
  N,M=map(int,input().split())

  r=[[]for i in range(N)]
  for i in range(M):
    a,b=map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)

  p=[-1]*N
  q=[0]
  while q:
    i=q.pop(0)
    for j in r[i]:
      if p[j]==-1:
        p[j]=i
        q.append(j)

  print('Yes')
  for i in range(1,N):
    print(p[i]+1)

main()

Buggy python submission (verdict: Runtime Error):
from collections import deque

N,M=map(int,input().split())
r=[[]for i in range(M)]
d,p=[10**6]*N,[10**6]*N

for i in range(M):
  a,b=map(int,input().split())
  r[a-1].append(b-1)
  r[b-1].append(a-1)

q=deque([0])
p[0],d[0],c=-1,0,0

while len(q)!=0:
  i=q.pop()
  for j in r[i]:
    if d[j]>d[i]+1:
      d[j],p[j]=d[i]+1,i
      q.append(j)

print('Yes')
for i in range(1,N):
  print(p[i]+1)


Fixed submission:
def main():
  N,M=map(int,input().split())

  r=[[]for i in range(N)]
  for i in range(M):
    a,b=map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)

  p=[-1]*N
  q=[0]
  while q:
    i=q.pop(0)
    for j in r[i]:
      if p[j]==-1:
        p[j]=i
        q.append(j)

  print('Yes')
  for i in range(1,N):
    print(p[i]+1)

main()
Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())

for i in range(int(pow(X,0.5)+1),0,-1):
  if X%i==0:
    s=int(pow(X/i/4,1/4))
    l,u=s-X//i,s+X//i+1
    for j in range(l,u):
      if X==(j+i)**5-j**5:
        print(j+i,j)
        exit()


Fixed submission:
X=int(input())

for a in range(-118,120):
  for b in range(-119,119):
    if X==a**5-b**5:
      print(a,b)
      exit()

Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())

for i in range(1,int(pow(X,0.5)+1)):
  if X%i==0:
    s=int(pow(X/i/4,1/4))
    l,u=s-X//i,s+X//i+1
    for j in range(l,u):
      if X==(j+i)**5-j**5:
        print(j+i,j)
        exit()


Fixed submission:
X=int(input())

for a in range(-118,120):
  for b in range(-119,119):
    if X==a**5-b**5:
      print(a,b)
      exit()
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

N=int(input())
A=list()
for i,a in enumerate(input().split(),1):
  A.append((int(a),i))
A.sort()

t=0
k=[a[0] for a in A]
for i in range(0,bisect_left(k,N)):
  for j in range(0,bisect_left(k,N-A[i][0])):
    if A[i][0]+A[j][0]==abs(A[i][1]-A[j][1]):
      t+=1
print(t//2)


Fixed submission:
import collections

N=int(input())
L,R=[0]*N,[0]*N
for i,a in enumerate(input().split()):
  L[i],R[i]=i+int(a)+1,i+1-int(a)

l=collections.Counter(L)
r=collections.Counter(R)
t=0
for i in l.keys():
  t+=l[i]*r[i]

print(t)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()

T,A=[1]+[0]*2018,0
for i in range(1,len(S)+1):
  T[int(S[-i:])%2019]+=1
print(sum(T[i]*~-T[i]//2 for i in range(2019)))


Fixed submission:
S=input()
C,m,T=2019,0,[1]+[0]*2018
for i,s in enumerate(S[::-1]):
  m=(m+int(s)*pow(10,i,C))%C
  T[m]+=1
print(sum(T[i]*~-T[i]//2 for i in range(2019)))
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
S=set(range(25*A//2,25*(A+1)//2))&set(range(10*B,10*(B+1)))
print(S.pop() if len(S)>0 else -1)


Fixed submission:
c=input().count('A')
print('No' if c==3 or c==0 else 'Yes')
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
d=[-1 for _ in range(N)]
for m in range(M):
  s,c=map(int,input().split())
  if d[s-1]==-1:
    d[s-1]=c
  elif d[s-1]!=c:
    print(-1)
    exit()

if N>1:
	if d[0]==0:
    print(-1)
    exit()
  elif d[0]==-1:
  	d[0]=1

A=0
for i in range(N):
  A=A*10+(d[i] if d[i]!=-1 else 0)

print(A)


Fixed submission:
N,M=map(int,input().split())
d=[-1 for _ in range(N)]
for m in range(M):
  s,c=map(int,input().split())
  if d[s-1]==-1:
    d[s-1]=c
  elif d[s-1]!=c:
    print(-1)
    exit()

if N>1:
  if d[0]==0:
    print(-1)
    exit()
  elif d[0]==-1:
  	d[0]=1

A=0
for i in range(N):
  A=A*10+(d[i] if d[i]!=-1 else 0)

print(A)