Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = int(input())

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break

if ans == -1:
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if b>0:
            if f(b,N)==S:
                ans = b
                break

print(ans)

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

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break

if ans == -1:
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if b>1:
            if f(b,N)==S:
                ans = b
                break

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = int(input())

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if b>0:
            if f(b,N)==S:
                ans = b
                break

print(ans)

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

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break

if ans == -1:
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if b>1:
            if f(b,N)==S:
                ans = b
                break

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = int(input())

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if f(b,N)==S:
            ans = b
            break

print(ans)

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

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break

if ans == -1:
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if b>1:
            if f(b,N)==S:
                ans = b
                break

print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
print(sum([1 for index,char in enumerate(s) if p[index]!=char])) 
  

Fixed submission:
s=input()
t=input()
print(sum([1 for index,char in enumerate(s) if t[index]!=char]))
Buggy python submission (verdict: Runtime Error):
X,Y=map(int,input().split())
a=(4*X-Y)//2
if a.is_integer() and a>=0 and a<=100:
  print("Yes")
else:
  print("No")

Fixed submission:
X,Y=map(int,input().split())
a=(4*X-Y)/2
if X<=Y and a.is_integer() and a>=0 and a<=50:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
S,T=[input() for i in range(2)]
U=list(S)
W=list(T)
if S in T and len(S)+1==len(T) and U[1]==W[1]:
  print("Yes")
else:
  print("No")

Fixed submission:
S,T=[input() for i in range(2)]
U=list(S)
W=list(T)
if S in T and len(S)+1==len(T) and U[0]==W[0]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
total=0
for i in range(N):
  total+=A[i]
if A[M]>=total/(4*M):
  print("Yes")
else:
  print("No")
  

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
total=0
for i in range(N):
  total+=A[i]
if A[M-1]>=total/(4*M):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
total=0
for i in range(M):
  total+=A[i]
if A[M]>=total/(4*M):
  print("Yes")
else:
  print("No")
  

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
total=0
for i in range(N):
  total+=A[i]
if A[M-1]>=total/(4*M):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N>50:
  N=50
S=list(input())
count=0
for i in range(N):
  if S[i]=="A":
    if S[i+1]=="B":
      if S[i+2]=="C":
        count+=1
print(count)
    

Fixed submission:
N=int(input())
S=list(input())
count=0
for i in range(N-2):
  if S[i]=="A":
    if S[i+1]=="B":
      if S[i+2]=="C":
        count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(input())
count=0
for i in range(N):
  if S[i]=="A":
    if S[i+1]=="B":
      if S[i+2]=="C":
        count+=1
print(count)
    

Fixed submission:
N=int(input())
S=list(input())
count=0
for i in range(N-2):
  if S[i]=="A":
    if S[i+1]=="B":
      if S[i+2]=="C":
        count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(input())
count=0
for i in range(N):
  if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
    count+=1
print(count)
    

Fixed submission:
N=int(input())
S=list(input())
count=0
for i in range(N-2):
  if S[i]=="A":
    if S[i+1]=="B":
      if S[i+2]=="C":
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
def main():
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    a_sum = [0 for x in range(n)]
    b_sum = [0 for x in range(m)]

    a_sum[0] = a[0]
    b_sum[0] = b[0]

    max_counter = 0

    for i in range(1, n):
        a_sum[i] = a[i] + a_sum[i - 1]

    for i in range(1, m):
        b_sum[i] = b[i] + b_sum[i - 1]

    for i in range(n):
        for j in range(m):
            if k >= a_sum[i] + b_sum[j] and max_counter < i + j + 2:
                max_counter = i + j + 2
        
    print(max_counter)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    a = int(input())

    print(a + (a ** 2) + (a ** 3))
 
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
count = 0
for i in range(n):
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":count += 1
print(count)

Fixed submission:
n = int(input())
s = input()
count = 0
for i in range(n - 2):
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
count = 0
for i in range(n):
    if s[i] == "A":
        if s[i+ 1] == "B":
            if s[i + 2] == "C":
                count += 1
print(count)

Fixed submission:
n = int(input())
s = input()
count = 0
for i in range(n - 2):
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i < r + 1; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}

Fixed submission:
l, r, d = map(int, input().split())
ans = 0
for i in range(l, r + 1):
    if i % d == 0:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(map(int, input().split()))
a = sorted(a, reverse=True)
comfort = a[0:2]
sum = max(a[0], a[1])
for j in a[2:]:
    key = 0
    for i in range(len(comfort) - 1):
        comfort_value = min(comfort[1], comfort[-1])
        comfort_value_kari = min(comfort[i], comfort[i + 1])
        if comfort_value < comfort_value_kari:
            comfort_value = comfort_value_kari
            key = i
    comfort.insert(key, j)
    sum += comfort_value
print(sum)



Fixed submission:
import heapq
n = int(input())

arr = list(map(int, input().split()))
arr = sorted(arr, reverse=True)
ans = 0
q = []
heapq.heappush(q, -arr[0])
for i in range(1, n):
    tmp = heapq.heappop(q)
    tmp *= -1
    ans += tmp
    heapq.heappush(q, -arr[i])
    heapq.heappush(q, -arr[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a,b,h,m=map(int,input().split())
deg=abs(h*30+m*0.5)-(m*6)
if deg>=180:
 deg=360-deg
c=math.sqrt(a**2+b**2-2*a*b*math.cos(math.pi*deg/180))
print(c)

Fixed submission:
N = int(input())
n = N % 10

if n == 3:
    print('bon')
elif n in [0, 1, 6, 8]:
    print('pon')
else:
    print('hon')

Buggy python submission (verdict: Runtime Error):
import math
a, b, h, m = map(int,input().split())

a_s = (30 * h) % 360 + 0.5 * m
b_s = (6*m)

s = max(a_s,b_s) - min(a_s,b_s)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)

Fixed submission:
N = int(input())
n = N % 10

if n == 3:
    print('bon')
elif n in [0, 1, 6, 8]:
    print('pon')
else:
    print('hon')

Buggy python submission (verdict: Runtime Error):

A, B, H, M = list(map(int, input().split()))

import math
A_x = A * math.cos(2 * math.pi * (H + M / 60.) / 12.)
A_y = A * math.sin(2 * math.pi * (H + M / 60.) / 12.)
B_x = B * math.cos(2 * math.pi * M / 60.)
B_y = B * math.sin(2 * math.pi * M / 60.)

print('{:.15f}'.format(math.sqrt((A_x - B_x) ** 2 + (A_y - B_y) ** 2)))

Fixed submission:
N = int(input())
n = N % 10

if n == 3:
    print('bon')
elif n in [0, 1, 6, 8]:
    print('pon')
else:
    print('hon')

Buggy python submission (verdict: Runtime Error):
import math
A, B, H, M = map(int, input().split())

A_x = A * math.cos(2 * math.pi * (H + M / 60.) / 12.)
A_y =  A * math.sin(2 * math.pi * (H + M / 60.) / 12.)
B_x = B * math.cos(2 * math.pi * M / 60.)
B_y = B * math.sin(2 * math.pi * M / 60.)

print('{:.15f}'.format(math.sqrt((A_x - B_x) ** 2 + (A_y - B_y) ** 2)))

Fixed submission:
N = int(input())
n = N % 10

if n == 3:
    print('bon')
elif n in [0, 1, 6, 8]:
    print('pon')
else:
    print('hon')

Buggy python submission (verdict: Runtime Error):
import math
A, B, H, M = map(int, input().split())

dgree_h = H / 12. * 360.
dgree_m = M / 60. * 360.

ang = math.pi / 180. * abs(dgree_h - dgree_m)
print(ang)


a = '{:.21f}'.format(math.sqrt(A ** 2. + B ** 2. - 2. * A * B * math.cos(ang)))
print((a))

Fixed submission:
N = int(input())
n = N % 10

if n == 3:
    print('bon')
elif n in [0, 1, 6, 8]:
    print('pon')
else:
    print('hon')
Buggy python submission (verdict: Runtime Error):
S, T = input().split()

if S == T[0:-1]:
    print('Yes')
else:
    print('No')

Fixed submission:
S = input()
T = input()

if S == T[0:-1]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
ans=0
for v in range(1,n+1):
 for u in g[v]: #i番目の展望台から1本の道を通っていけるすべての展望台と高さを比較する
   if arr[u]>=arr[v]:
     break
 else: #i番目の展望台の高さが他のすべての展望台の高さより真に大きければ答えを1増やす
   ans+=1
print(ans)

Fixed submission:
S = input()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

road_num = list(map(int, input().split()))
road_num = len(road_num)

way_list = []
goal_list = []

for i in range(road_num - 1):
    way, goal = map(int, input().split())
    if not(way in way_list):
        way_list.append(way)
    if not(goal in way_list) and not(goal in goal_list):
        goal_list.append(goal)

print(len(goal_list))

Fixed submission:
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
ans=0
for v in range(1,n+1):
 for u in g[v]: #i番目の展望台から1本の道を通っていけるすべての展望台と高さを比較する
   if arr[u]>=arr[v]:
     break
 else: #i番目の展望台の高さが他のすべての展望台の高さより真に大きければ答えを1増やす
   ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):

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

x = min(B - 1, N)
ans = int(a * x / b)
print(ans)

Fixed submission:

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

x = min(B - 1, N)
ans = int(A * x / B)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = str(input())
count = 0
s_len = len(s)
for i in range(s_len - 4):
    for j in range(i + 4, s_len + 1):
        if int(s[i:j]) % 2019 == 0:
            count += 1
print(count)

Fixed submission:
s, w = map(int, input().split())

if s  <= w:
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s_list = []

for i in range(n):
    s = str(input())
    if not(s in s_list):
        s_list.append(s)
print(len(s_list))

Fixed submission:
n = int(input())

s_list = []

for i in range(n):
    s = str(input())
    s_list.append(s)
s_list = list(set(s_list))
print(len(s_list))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

for _ in range(int(n / k) + 1):
    if abs(n - k) < n:
        n = abs(n - k)
    else:
        break

print(n)

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

a = n % k
print(min(a, abs(a - k)))

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

while True:
    if abs(n - k) < n:
        n = abs(n - k)
    else:
        break

print(n)

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

a = n % k
print(min(a, abs(a - k)))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    sum = 0
    b = copy.copy(a)
    b.pop(i)
    c = list(set(b))
    for j in c:
        sum += int(b.count(j) * (b.count(j) - 1) / 2)
    print(sum)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

c = Counter(a)
key = c.keys()
comb = 0
for i in key:
    comb += (c[i]) * (c[i]-1) // 2 #禁止されていない状態の組み合わせを調べる

for i in a:
    ans = comb - (c[i]-1) #a[i]が禁止されている状態の組み合わせ
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import copy
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    sum = 0
    b = copy.copy(a)
    b.pop(i)
    c = collections.Counter(b)
    for j in c.values():
       sum += j * (j - 1) /2
    print(int(sum))


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

c = Counter(a)
key = c.keys()
comb = 0
for i in key:
    comb += (c[i]) * (c[i]-1) // 2 #禁止されていない状態の組み合わせを調べる

for i in a:
    ans = comb - (c[i]-1) #a[i]が禁止されている状態の組み合わせ
    print(ans)
Buggy python submission (verdict: Runtime Error):
input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for i in A):
    A = [a/2 for a in A]
    count += 1
print(count)



Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
while True:
    for i in range(n):
        fin = True
        if a[i] % 2 == 0:
            a[i] = (a[i] / 2)
        else:
            fin = False
            break
    if fin:
        count += 1
    else:
        break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

count = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())

count = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z <= k:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = input()
m = input()

if n == m:
    print("Yes")
else:
    print("No")

Fixed submission:
n , m = input().split()

if n == m:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
memo = [0]*1010

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            z = i**2+j**2+k**2+i*j+j*k+k*i
            if z <= n:
                memo[z] += 1


for i in range(1, n+1):
    print(memo[i])

Fixed submission:
n = int(input())
memo = [0]*10010

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            z = i**2+j**2+k**2+i*j+j*k+k*i
            if z <= n:
                memo[z] += 1


for i in range(1, n+1):
    print(memo[i])
Buggy python submission (verdict: Runtime Error):
import string
lc = string.ascii_lowercase
n = int(input())

lst = [0]
for i in range(1, 1000):
    tmp = pow(26, i)
    lst.append(tmp)
    if tmp > n:
        break
cum = [lst[0]]
for i in range(1, len(lst)):
    cum.append(cum[-1] + lst[i])
idx = 0
while True:
    if n-1 < cum[idx]:
        break
    idx += 1
num = n - lst[idx-1] - 1
ans = ''
for i in range(idx)[::-1]:
    tmp = pow(26, i)
    if num >= tmp:
        k = num // tmp
        num = num - 26*k
    else:
        k = num
    ans += lc[k]
print(ans)

Fixed submission:
import string
lc = string.ascii_lowercase
n = int(input())

lst = [0]
for i in range(1, 100000):
    tmp = pow(26, i)
    lst.append(tmp)
    if tmp > n:
        break
cum = [lst[0]]
for i in range(1, len(lst)):
    cum.append(cum[-1] + lst[i])
idx = 0
while True:
    if n-1 < cum[idx]:
        break
    idx += 1
num = n - cum[idx-1] - 1
ans = ''
for i in range(idx)[::-1]:
    tmp = pow(26, i)
    k = num // tmp
    num = num - tmp *k
    ans += lc[k]
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
if 1 in A:
    print(0)
else:
    c = Counter(A)
    lst = []
    for k,v in c.items():
        if v==1:
            lst.append(k)
    lst.sort()
    mx = max(lst)
    ans = 0
    err = [False] + [True]*(mx)
    for l in lst:
        if err[l]:
            ans += 1
            i = 0
            while True:
                err[l*i] = False
                i += 1
                if l*i > mx:
                    break
    print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
A.sort()
c = Counter(A)

if c[1]==1:
    print(1)
elif c[1] > 1:
    print(0)
else:
    mx = 10**6+10
    ok = [True]*mx
    ans = 0
    for a in A:
        if ok[a]:
            if c[a] == 1:
                ans += 1
            for i in range(mx):
                if i*a >= mx:
                    break
                ok[i*a] = False
        else:
            continue
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
ans = 1
for a in A:
    ans *= a
if ans > 1e18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
t = int('1'+'0'*18)
ans = 1
if min(A)==0:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > t:
            print(-1)
            exit()
    print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m = map(int,input().split())
visited = [-1 for _ in range(n)]
g = [[] for _ in range(m)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
pos = 0
que = deque([])
if g[0]:
    visited[0] = 0
    for nx in g[0]:
        que.append((nx, 0))
while que:
    to, now = que.popleft()
    if visited[to] != -1:
        continue
    else:
        visited[to] = now
        for nx in g[to]:
            que.append((nx, to))
visited = visited[1:]
if -1 in visited:
    print('No')
else:
    print('Yes')
    for k in visited:
        print(k+1)

Fixed submission:
from collections import deque
n,m = map(int,input().split())
visited = [-1 for _ in range(n)]
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
pos = 0
que = deque([])
if g[0]:
    visited[0] = 0
    for nx in g[0]:
        que.append((nx, 0))
while que:
    to, now = que.popleft()
    if visited[to] != -1:
        continue
    else:
        visited[to] = now
        for nx in g[to]:
            que.append((nx, to))
visited = visited[1:]
if -1 in visited:
    print('No')
else:
    print('Yes')
    for k in visited:
        print(k+1)

Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m = map(int,input().split())
visited = [False for _ in range(n)]
label = [-1 for _ in range(n)]
g = [[] for _ in range(m)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

pos = 0
que = deque([])
for nx in g[0]:
    que.append((nx, pos))
while que:
    to, now = que.popleft()
    if visited[to] == True:
        continue
    else:
        visited[to] = True
        label[to] = now
        for nx in g[to]:
            que.append((nx, to))
if -1 in label[1:]:
    print('No')
else:
    print('Yes')
    for l in label[1:]:
        print(l+1)

Fixed submission:
from collections import deque
n,m = map(int,input().split())
visited = [-1 for _ in range(n)]
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
pos = 0
que = deque([])
if g[0]:
    visited[0] = 0
    for nx in g[0]:
        que.append((nx, 0))
while que:
    to, now = que.popleft()
    if visited[to] != -1:
        continue
    else:
        visited[to] = now
        for nx in g[to]:
            que.append((nx, to))
visited = visited[1:]
if -1 in visited:
    print('No')
else:
    print('Yes')
    for k in visited:
        print(k+1)