Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x=int(input())
if x = 7 or x = 5 or x = 3:
  print("YES")
else:
  print("NO")

Fixed submission:
x=int(input())
if x == 7 or x == 5 or x == 3:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
x=int(input())
if x = 7 and x = 5 and x = 3:
  print("YES")
else:
  print("NO")

Fixed submission:
x=int(input())
if x == 7 or x == 5 or x == 3:
  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")
elif N == 2:
  print(A+B)

Fixed submission:
N=int(input())

if N == 1:
  print("Hello World")
elif N == 2:
	A=int(input())
	B=int(input())
	print(A+B)

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")
elif N == 2:
	A=int(input())
	B=int(input())
	print(A+B)
Buggy python submission (verdict: Runtime Error):
n=int(input())
print(n.replace("1","9").replace("9","1").replace("1","1").replace("9","9"))


Fixed submission:
print(input().replace("1","*").replace("9","1").replace("*","9"))

Buggy python submission (verdict: Runtime Error):
n=int(input())
print(n.replace("1","9").replace("9","1").replace("1","a").replace("9","a"))


Fixed submission:
print(input().replace("1","*").replace("9","1").replace("*","9"))

Buggy python submission (verdict: Runtime Error):
n=int(input())
print(n.replace("1","9").replace("9","1"))


Fixed submission:
print(input().replace("1","*").replace("9","1").replace("*","9"))

Buggy python submission (verdict: Runtime Error):
n=int(input())
l = [int(x) for x in list(str(n))]
print(l.replace("1","9").replace("9","1"))


Fixed submission:
print(input().replace("1","*").replace("9","1").replace("*","9"))

Buggy python submission (verdict: Runtime Error):
n=input()
l = [int(x) for x in list(str(n))]
print(l.replace("1","9").replace("9","1"))


Fixed submission:
print(input().replace("1","*").replace("9","1").replace("*","9"))

Buggy python submission (verdict: Runtime Error):
n=int(input())
print(n.replace("1","9").replace("9","1"))


Fixed submission:
print(input().replace("1","*").replace("9","1").replace("*","9"))
Buggy python submission (verdict: Runtime Error):
A,B,C=sorted(map(int,input.split()))
print(A+B+C*10)

Fixed submission:
A,B,C=sorted(map(int,input().split()))
print(A+B+C*10)

Buggy python submission (verdict: Runtime Error):
A,B,C=sorted(map(int.input.split()))
print(A+B+C*10)

Fixed submission:
A,B,C=sorted(map(int,input().split()))
print(A+B+C*10)

Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split())
s.sort()
print(max(10*s[0]+s[1]+s[2],s[0]+s[1]*10+s[2],s[0]+s[1]+s[2]*10))

Fixed submission:
A,B,C=sorted(map(int,input().split()))
print(A+B+C*10)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
if A * B % 2 == 1:
  pritn("Yes")
else:
  print("No")

Fixed submission:
A,B=map(int,input().split())
if A * B % 2 == 1:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
k=int(input())
print((k/2)∗((k+1)/2))

Fixed submission:
k=int(input())
print((k//2)*((k+1)//2))

Buggy python submission (verdict: Runtime Error):
K=int(input())
print((k/2)*((k+1)/2))

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

Fixed submission:
N,i=map(int,input().split())
print(N+1-i)

Buggy python submission (verdict: Runtime Error):
a,b=int(input.split())
print(a-b+1)

Fixed submission:
N,i=map(int,input().split())
print(N+1-i)

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

Fixed submission:
N,i=map(int,input().split())
print(N+1-i)

Buggy python submission (verdict: Runtime Error):
N,i=map(int,input.split())
print((N-i)+1)

Fixed submission:
N,i=map(int,input().split())
print(N+1-i)
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N % 2 = 0:
  print(N)
else:
  print(N*2)

Fixed submission:
N=int(input())
if N % 2 == 0:
  print(N)
else:
  print(N*2)

Buggy python submission (verdict: Runtime Error):
N=int(input())
if N // 2 = 0:
  print(N)
else:
  print(2*N)

Fixed submission:
N=int(input())
if N % 2 == 0:
  print(N)
else:
  print(N*2)

Buggy python submission (verdict: Runtime Error):
N=int(input())
if N // 2 = 0:
  print(N)
else:
  print(N*2)

Fixed submission:
N=int(input())
if N % 2 == 0:
  print(N)
else:
  print(N*2)
Buggy python submission (verdict: Runtime Error):
n=int(input())

if (n % sum(map(int,list(n))) == 0):
  print("Yes")
else:
  print("No")

Fixed submission:
n=input()

if (int(n) % sum(map(int,list(n))) == 0):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N=int(input())

if N < 1000:
  print("ABC"+N)
else:
  print("ABD"+N)

Fixed submission:
N=int(input())

if N < 1000:
  print("ABC")
else:
  print("ABD")
Buggy python submission (verdict: Runtime Error):
a.b=map(int,input().split())
print((b-a)*(b-a+1)/2-b)

Fixed submission:
a,b=map(int,input().split())
print(((b-a)**2-a-b)//2)
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
c=int(input())
D=int(input())
print(min(A,B)+min(C,D))

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
print(min(A,B)+min(C,D))

Buggy python submission (verdict: Runtime Error):
s=[int(input()) for i in range(4)]
print(s.sort(s[0]+s[1]))

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
print(min(A,B)+min(C,D))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(str,input().split())
d,e,f=map(str,input().split())
g,h,q=map(str,input().split())

print(a+e+q)

Fixed submission:
a=input()
b=input()
c=input()

print(a[0]+b[1]+c[2])
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(map(input().split()))

if len(s) == 4:
  print("Four")
else:
  print("Three")

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

if s.count("Y") >= 1:
  print("Four")
else:
  print("Three")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
sort_a=sorted(a)

alice = sum(sort_a[::2])
bob = sum(a[1::2])

print(alice - bob)  

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

alice = sum(a[::2])
bob = sum(a[1::2])

print(alice - bob)
Buggy python submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
print((x-a)%b)

Fixed submission:
x=int(input())
a=int(input())
b=int(input())
print((x-a)%b)

Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
print((x-a)%b)

Fixed submission:
x=int(input())
a=int(input())
b=int(input())
print((x-a)%b)

Buggy python submission (verdict: Runtime Error):
A,B,X=map(int,input().split())
print((X - A) % B)

Fixed submission:
x=int(input())
a=int(input())
b=int(input())
print((x-a)%b)

Buggy python submission (verdict: Runtime Error):
A,B,X=map(int,input().split())
print((X-A)%B)

Fixed submission:
x=int(input())
a=int(input())
b=int(input())
print((x-a)%b)
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0

for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if (500*i + 100*j + 50*k) == X
      cnt += 1

print(cnt)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0

for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if (500*i + 100*j + 50*k) == X:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=[int(input()) for i in range(n)]
print(len(set(d))

Fixed submission:
n=int(input())
d=[int(input()) for _ in range(n)]

print(len(set(d)))
Buggy python 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("Balanced")
elif L < R:
  print("Right")

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("Balanced")
elif L < R:
  print("Right")
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

cnt=0

while all(a % 2 == 0 for a in A)
	A = [a /2 for a in A]
	cnt += 1

print(cnt)

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

cnt=0

while all(a % 2 == 0 for a in A):
	A = [a /2 for a in A]
	cnt += 1

print(cnt)

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

cnt=0

while all(a % 2 == 0 for a in A)
	A = [a /2 for a in A]
	cnt += 1

print(cnt)

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

cnt=0

while all(a % 2 == 0 for a in A):
	A = [a /2 for a in A]
	cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
x,y=input().split()

if x==y:
  print("=")
elif a>b:
  print(">")
else:
  print("<")

Fixed submission:
x,y=input().split()

if x<y:
  print("<")
elif x>y:
  print(">")
else:
  print("=")

Buggy python submission (verdict: Runtime Error):
x,y = input().split()

if x==y:
  print("=")
elif a>b:
  print(">")
else:
  print("<")

Fixed submission:
x,y=input().split()

if x<y:
  print("<")
elif x>y:
  print(">")
else:
  print("=")
Buggy python submission (verdict: Runtime Error):
x,y,z=map(int,input().split())
cnt=0

for i in range(49999):
  if (y*i) + z+(i+1) <= x
  cnt += 1
  
print(cnt)

Fixed submission:
x,y,z=map(int,input().split())

print((x-z)//(y+z))
Buggy python submission (verdict: Runtime Error):
x = list(map(input().split()))
y = list(map(input().split()))

if x[0]==y[2] and x[1]==y[1] and x[2]==y[0]:
  print("YES")
else:
  print("NO")

Fixed submission:
x = input()
y = input()

if x[0]==y[2] and x[1]==y[1] and x[2]==y[0]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
n=math.sqart(N)

print(int(n)**2)

Fixed submission:
import math
N=int(input())
n=math.sqrt(N)

print(int(n)**2)

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
n=math.sqart(n)

print(int(n)**2)

Fixed submission:
import math
N=int(input())
n=math.sqrt(N)

print(int(n)**2)
Buggy python submission (verdict: Runtime Error):
N=int(input())
k=int(input())

ans=1

for i in range(1,n):
  if ans*2 < ans+k:
    ans = ans*2
  else:
    ans = ans+k

print(ans)

Fixed submission:
n=int(input())
k=int(input())

ans=1

for i in range(n):
  if ans*2 < ans+k:
    ans = ans*2
  else:
    ans = ans+k

print(ans)
Buggy python submission (verdict: Runtime Error):
x=input().split("")

if x[0]==9 or x[1]==9:
  print("Yes")
else:
  ("No")

Fixed submission:
x=input()

if x[0]=="9" or x[1]=="9":
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
x=list(int,input().split())

if x[0]==9 or x[1]==9:
  print("Yes")
else:
  ("No")

Fixed submission:
x=input()

if x[0]=="9" or x[1]=="9":
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
X,t=map(int,input().split())

if X-t >= o:
  print(X-t)
else:
  print(0)

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

if X-t >= 0:
  print(X-t)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
print(s[0]+str[n-2]+s[n-1])

Fixed submission:
s=input()
n=len(s)
print(s[0]+str(n-2)+s[n-1])
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())

if A%3==0 or B%3== or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")

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

if A%3==0 or B%3==0 or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")
Buggy python submission (verdict: Runtime Error):
r,g,b=map(int,input().split()))
ans=100*r+10*g+b

if ans % 4 == 0:
  print("YES")
else:
  print("NO")

Fixed submission:
r,g,b=map(int,input().split())
ans=100*r+10*g+b

if ans % 4 == 0:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
l=list(map(int,input().split()))
l="".join([int(n) for n in l])

if l % 4 == 0:
  print("YES")
else:
  print("NO")

Fixed submission:
r,g,b=map(int,input().split())
ans=100*r+10*g+b

if ans % 4 == 0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
A,B=int(input().split())

if A+B < 10:
  print(A+B)
else:
  print("error")

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

if A+B < 10:
  print(A+B)
else:
  print("error")
Buggy python submission (verdict: Runtime Error):
a = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x,y = map(int,input().split())

if x[a] == y[a]:
	print("Yes")
else:
    print("No")

Fixed submission:
a = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x,y = map(int,input().split())

if a[x] == a[y]:
	print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x,y = map(int,input().split())

if x[a] == y[a]:
	print("Yes")
else:
    print("No")

Fixed submission:
a = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x,y = map(int,input().split())

if a[x] == a[y]:
	print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x,y = map(int(input().split())

if x[a] == y[a]:
	print("Yes")
else:
    print("No")

Fixed submission:
a = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x,y = map(int,input().split())

if a[x] == a[y]:
	print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()

if a[len(a-1)] == b[0] and b[len(b-1)] == c[0]:
  print("YES")
else:
  print("NO")

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

if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
a,b=input().split()

if a == "H":
  print("H")
else if a == "D" and b == "H":
  print("D")
else:
  print("H")

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

if a == b:
  print("H")
else:
  print("D")
Buggy python submission (verdict: Runtime Error):
A,c,B=input().split()

if c == "+":
  print(A+B)
else:
  print(A-B)

Fixed submission:
A=input()
print(eval(A))
Buggy python submission (verdict: Runtime Error):
a,b,c=sorted(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 or b == a+c or c == a+b:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
a=int(input()
b=int(input()
h=int(input()
print((a+b)*h//2)

Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)

Buggy python submission (verdict: Runtime Error):
a,b,h=map(int,inpuut().split())
print((a+b)*h/2)

Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)

Buggy python submission (verdict: Runtime Error):
a,b,h=map(int,inpuut().split())
print((a+b)*2/2)

Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
Buggy python submission (verdict: Runtime Error):
N,K,X,Y=map(int,input().split())

if N >= K:
  print((N-K)*Y + (K*X))
else:
  print(N*X)

Fixed submission:
N,K,X,Y=[int(input()) for i in range(4)]

if N >= K:
  print(Y*(N-K) + K*X)
else:
  print(N*X)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

Q = int(input())

s = sum(A)

for i in range(Q):
    b, c = map(int, input().split())
    diff = c - A[b - 1]
    A[b - 1] = c
    s += diff
    print(s)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ma = [0] * (100000 + 1)

for i in range(N):
    ma[A[i]] += 1

Q = int(input())

s = sum(A)

for i in range(Q):
    b, c = map(int, input().split())
    diff = c * ma[b] - ma[b] * b
    ma[c] += ma[b]
    ma[b] = 0
    s += diff
    print(s)

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

Q = int(input())

s = sum(A)

for i in range(Q):
    b, c = map(int, input().split())
    diff = c - A[b - 1]
    A[b - 1] = c
     diff
    print(s)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ma = [0] * (100000 + 1)

for i in range(N):
    ma[A[i]] += 1

Q = int(input())

s = sum(A)

for i in range(Q):
    b, c = map(int, input().split())
    diff = c * ma[b] - ma[b] * b
    ma[c] += ma[b]
    ma[b] = 0
    s += diff
    print(s)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
AA = [0] * (N)
for i in range(N):
    AA[i] = list(format(A[i], 'b'))

ans = [0] * 22
for i in range(N):
    AA[i].reverse()
    for j in range(len(AA[i])):
        ans[j] += int(AA[i][j])

ret = []
for i in range(N):
    temp = 0
    for j in range(len(AA[i])):
        if (ans[j] - int(AA[i][j])) % 2 == 1:
            temp += 1 << j

    ret.append(temp)

print(*ret)

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

AA = [0] * (N)
for i in range(N):
    AA[i] = list(format(A[i], 'b').zfill(42))

ans = [0] * 42
ma = 0
for i in range(N):
    AA[i].reverse()
    for j in range(len(AA[i])):
        ma = max(ma, j)
        ans[j] += int(AA[i][j])

ret = []
for i in range(N):
    temp = 0
    for j in range(ma):
        if (ans[j] + int(AA[i][j])) & 1 == 1:
            temp += 1 << j

    ret.append(temp)

print(*ret)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
AA = [0] * (N)
for i in range(N):
    AA[i] = list(format(A[i], 'b'))

ans = [0] * 20
for i in range(N):
    AA[i].reverse()
    for j in range(len(AA[i])):
        ans[j] += int(AA[i][j])

ret = []
for i in range(N):
    temp = 0
    for j in range(len(AA[i])):
        if (ans[j] - int(AA[i][j])) % 2 == 1:
            temp += 1 << j

    ret.append(temp)

print(*ret)

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

AA = [0] * (N)
for i in range(N):
    AA[i] = list(format(A[i], 'b').zfill(42))

ans = [0] * 42
ma = 0
for i in range(N):
    AA[i].reverse()
    for j in range(len(AA[i])):
        ma = max(ma, j)
        ans[j] += int(AA[i][j])

ret = []
for i in range(N):
    temp = 0
    for j in range(ma):
        if (ans[j] + int(AA[i][j])) & 1 == 1:
            temp += 1 << j

    ret.append(temp)

print(*ret)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

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

q = [0]
ans = [-1] * N
while(len(q) > 0):
    now = q.pop(0)

    for i in node[now]:
        if ans[i] == -1:
            q.append(i)
            ans[i] = now


print("Yes")
for i in range(1, N):
    print(ans[i] + 1)



Fixed submission:
from collections import deque
N, M = map(int, input().split())

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

q = deque([0])
ans = [-1] * N
while(len(q) > 0):
    now = q.popleft()

    for i in node[now]:
        if ans[i] == -1:
            q.append(i)
            ans[i] = now


print("Yes")
for i in range(1, N):
    print(ans[i] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

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

q = [0]
ans = [-1] * N
kyo = [99999999999999] * N
kyo[0] = 0
while(len(q) > 0):
    now = q.pop()
    for i in node[now]:
        if kyo[i] > kyo[now] + 1:
            q.append(i)
            ans[i] = now
            kyo[i] = kyo[now] + 1


print("Yes")
for i in range(1, N):
    print(ans[i] + 1)


Fixed submission:
from collections import deque
N, M = map(int, input().split())

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

q = deque([0])
ans = [-1] * N
while(len(q) > 0):
    now = q.popleft()

    for i in node[now]:
        if ans[i] == -1:
            q.append(i)
            ans[i] = now


print("Yes")
for i in range(1, N):
    print(ans[i] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

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

q = [0]
ans = [-1] * N
kyo = [99999999999999] * N
kyo[0] = 0
while(len(q) > 0):
    now = q.pop()
    for i in node[now]:
        if kyo[i] > kyo[now] + 1:
            q.append(i)
            ans[i] = now
            kyo[i] = kyo[now] + 1


print("Yes")
for i in range(1, N):
    print(ans[i] + 1)


Fixed submission:
from collections import deque
N, M = map(int, input().split())

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

q = deque([0])
ans = [-1] * N
while(len(q) > 0):
    now = q.popleft()

    for i in node[now]:
        if ans[i] == -1:
            q.append(i)
            ans[i] = now


print("Yes")
for i in range(1, N):
    print(ans[i] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
SS = input()

S = [0] * (2 * N + 1)
for i in range(N):
    if SS[i] == "R":
        S[i] = 1

    if SS[i] == "G":
        S[i] = 2

    if SS[i] == "B":
        S[i] = 4

cnt = [[0] * 3 for i in range(N)]
if S[0] == 1:
    cnt[0][0] = 1
elif S[0] == 2:
    cnt[0][1] = 1
else:
    cnt[0][2] = 1


for i in range(1, N):
    cnt[i][0] = cnt[i - 1][0]
    cnt[i][1] = cnt[i - 1][1]
    cnt[i][2] = cnt[i - 1][2]
    if S[i] == 1:
        cnt[i][0] += 1

    if S[i] == 2:
        cnt[i][1] += 1

    if S[i] == 4:
        cnt[i][2] += 1


ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            to = S[i] + S[j]

            if to == 3:
                ans += cnt[N - 1][2] - cnt[j][2]
                if S[j + j - i] == 4:
                    ans -= 1

            if to == 5:
                ans += cnt[N - 1][1] - cnt[j][1]
                if S[j + j - i] == 2:
                    ans -= 1

            if to == 6:
                ans += cnt[N - 1][0] - cnt[j][0]
                if S[j + j - i] == 1:
                    ans -= 1


print(ans)



Fixed submission:
N = int(input())
SS = input()

S = [0] * (2 * N + 1)
for i in range(N):
    if SS[i] == "R":
        S[i] = 1

    if SS[i] == "G":
        S[i] = 2

    if SS[i] == "B":
        S[i] = 4

cnt = [[0] * 3 for i in range(N)]
if S[0] == 1:
    cnt[0][0] = 1
elif S[0] == 2:
    cnt[0][1] = 1
else:
    cnt[0][2] = 1


for i in range(1, N):
    cnt[i][0] = cnt[i - 1][0]
    cnt[i][1] = cnt[i - 1][1]
    cnt[i][2] = cnt[i - 1][2]
    if S[i] == 1:
        cnt[i][0] += 1

    if S[i] == 2:
        cnt[i][1] += 1

    if S[i] == 4:
        cnt[i][2] += 1


ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            to = S[i] + S[j]

            if to == 3:
                ans += cnt[N - 1][2] - cnt[j][2]
                if S[j + j - i] == 4:
                    ans -= 1

            if to == 5:
                ans += cnt[N - 1][1] - cnt[j][1]
                if S[j + j - i] == 2:
                    ans -= 1

            if to == 6:
                ans += cnt[N - 1][0] - cnt[j][0]
                if S[j + j - i] == 1:
                    ans -= 1


print(ans)