Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import  copy
N, K = map(int,input().split())
p = [int(i) for i in input().split()]
P = []
P_S = [0]
ans_list = []
temp = 0

for i in range(N):
    P.append((p[i] + 1)/2)
    temp = temp + P[i]
    P_S.append(temp)
for i in range(K,N+1):
    ans_list.append(P_S[i] - P_S[i - K])

print(max(ans_list))

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

if U == S:
    print(A-1,B)
elif U == T:
    print(A,B-1)
else:
    print(A,B)
Buggy python submission (verdict: Runtime Error):
import  copy
N, K = map(int,input().split())
p = [int(i) for i in input().split()]
P = []
P_S = []
ans_list = []
temp = 0

for i in range(N):
    P.append((p[i] + 1)/2)
    temp = temp + P[i]
    P_S.append(temp)
for i in range(N - K):
    ans_list.append(P_S[i + K] - P_S[i])

print(max(ans_list))

Fixed submission:
N, K = map(int,input().split())
p = [int(i) for i in input().split()]
P = []
P_S = [0]
ans_list = []
temp = 0

for i in range(N):
    P.append((p[i] + 1)/2)
    temp = temp + P[i]
    P_S.append(temp)
for i in range(K,N+1):
    ans_list.append(P_S[i] - P_S[i - K])

print(max(ans_list))
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()

i = 0
j = 0
k = 0
N = int(N)
count = 0
for a in range(10):
    for i in range(N-2):
        if str(a) == S[i]:
            for b in range(10):
                for j in range(i+1, N-1):
                    if str(b) == S[j]:
                        for c in range(10):
                            for k in range(j+1,N):
                                if str(c) == S[k]:
                                    count += 1
                                    break
                        break
            break
print(count)
                


Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if M1 == M2:
    print(0)

else:
    print(1)
Buggy python submission (verdict: Runtime Error):
h, w, a, b = map(int, input().split())
for i in range(b):
    for j in range(a):
        print(0, end=4)
    for j in range(w - a):
        print(1, end=4)
    print()
for i in range(h - b):
    for j in range(a):
        print(1, end=4)
    for j in range(w - a):
        print(0, end=4)
    print()


Fixed submission:
h, w, a, b = map(int, input().split())
for i in range(b):
    for j in range(a):
        print(0, end='')
    for j in range(w - a):
        print(1, end='')
    print()
for i in range(h - b):
    for j in range(a):
        print(1, end='')
    for j in range(w - a):
        print(0, end='')
    print()

Buggy python submission (verdict: Runtime Error):
LL = [int(i) for i in input().split()]
H = LL[0]
W = LL[1]
A = LL[2]
B = LL[3]

Math = [[0 for a in range(W)] for b in range(H)] 

for i in range(A):
    for j in range(B):
        Math[i][j] = 1

for i in range(W - A):
    for j in range(H - B):
        Math[H - i][W -j] = 1

for i in range(H):
    print(*Math) 

Fixed submission:
h, w, a, b = map(int, input().split())
for i in range(b):
    for j in range(a):
        print(0, end='')
    for j in range(w - a):
        print(1, end='')
    print()
for i in range(h - b):
    for j in range(a):
        print(1, end='')
    for j in range(w - a):
        print(0, end='')
    print()

Buggy python submission (verdict: Runtime Error):
LL = [int(i) for i in input().split()]
H = LL[0]
W = LL[1]
A = LL[2]
B = LL[3]

Math = [[0 for a in range(W)] for b in range(H)] 

for i in range(A):
    for j in range(B):
        Math[i][j] = 1

for i in range(W - A):
    for j in range(H - B):
        Math[W - i][H -B] = 1

for i in range(H):
    print(*Math) 

Fixed submission:
h, w, a, b = map(int, input().split())
for i in range(b):
    for j in range(a):
        print(0, end='')
    for j in range(w - a):
        print(1, end='')
    print()
for i in range(h - b):
    for j in range(a):
        print(1, end='')
    for j in range(w - a):
        print(0, end='')
    print()

Buggy python submission (verdict: Runtime Error):
LL = [int(i) for i in input().split()]
H = LL[0]
W = LL[1]
A = LL[2]
B = LL[3]

Frag = True
Math = [[0 for a in range(W)] for b in range(H)] 

for i in range(A):
    for j in range(B):
        Math[i][j] = 1

for i in range(W - A):
    for j in range(H - B):
        Math[W - i][H -B] = 1
        
for i in range(H):
    print(*Math) 

Fixed submission:
h, w, a, b = map(int, input().split())
for i in range(b):
    for j in range(a):
        print(0, end='')
    for j in range(w - a):
        print(1, end='')
    print()
for i in range(h - b):
    for j in range(a):
        print(1, end='')
    for j in range(w - a):
        print(0, end='')
    print()
Buggy python submission (verdict: Runtime Error):
N = (int(input()))

print(int((1 / 2) * N * (N - 1)))

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

count = 0

for i in range(3):
    if S[i] == T[i]:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = []
s = [input() for i in range(N)]
count = 0
for i in range(N):
    for a in range(i+1,N):
        if sorted(s[i]) == sorted(s[a]):
            count += 1

print(count)


Fixed submission:
N = int(input())
s = []
s = [input() for i in range(N)]
count = 0
a = []
sortdict = {}
for i in range(N):
    a = str(sorted(s[i]))
    if a in sortdict:
        sortdict[a] += 1
    else:
        sortdict[a] = 0
sort_list = list(sortdict.values())
for i in range(len(sort_list)):
    sort_list[i] = int((sort_list[i])*(sort_list[i] + 1)/2)
 

print(sum(sort_list))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H_list = list(map(int,input().split()))
Flag = False
if N == 1:

    print("Yes")
    
else:
    for i in range(N):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            print("No")
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] == 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else:
            continue
     
Flag = True

if Flag == True:
    print("Yes")

Fixed submission:
List = list(map(int,input().split()))
A = List[0]
B = List[1]
C = List[2]

if (C - A + B) >= 0:

	C = C - (A - B)
	print(C)
else:
	print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H_list = list(map(int,input().split()))
Flag = False
if N == 1:

    print("Yes")
    
else:
    for i in range(N):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            print("No")
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] = 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else
    
    Flag = True

if Flag = True:
    print("Yes")


Fixed submission:
N = int(input())
H_list = list(map(int,input().split()))
Flag = True

if N != 1:
    for i in range(N-1):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            Flag = False
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] == 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else:
            continue
    
if Flag == True:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
List = list(map(int,input().split()))

A = List[0]
B = List[1]

Flag = False
for K in range(int((A+B)/2) + 1):
    if abs(A-K) == abs(B-K):
        count = K
        Flag = True

if Flag == True:
    print(K)
else:
    print("IMPOSSIBLE")

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

A = List[0]
B = List[1]

Flag = False
if (A + B) % 2 == 0:
    K = int((A + B)/2)
    Flag = True

if Flag == True:
    print(K)
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
List = list(map(int,input().split()))
L = List[0]
R = List[1]
count_dict = {}
count_list = []
if R - L >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        for j in range(i,R+1):
            count_dict[i,j]  = (i * j) % 2019

    for i in count_dict.values():
        count_list.append(i)

    sort_list = sorted(count_list)
    print(sort_list[0])


Fixed submission:
List = list(map(int,input().split()))
N = List[0]
A = List[1]
B = List[2]

if A*N <= B:
    print(A*N)
else:
    print(B)
Buggy python submission (verdict: Time Limit Exceeded):
List = list(map(int,input().split()))
L = List[0]
R = List[1]
count_dict = {}
count_list = []
if R - L >= 2019:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            count_dict[i,j]  = (i * j) % 2019

    for i in count_dict.values():
        count_list.append(i)

    sort_list = sorted(count_list)
    print(sort_list[0])


Fixed submission:
List = list(map(int,input().split()))
L = List[0]
R = List[1]
count_list = []
if R - L >= 2019:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            count_list.append((i * j) % 2019)

    sort_list = sorted(count_list)
    print(sort_list[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())

position = []
for n in range(N):
    x, y = map(int, input().split())
    position.append((x, y))

dis_dic = {}
for n in range(N):
    for m in range(N):
        if (n != m):
            distance_tuple = (position[n][0] - position[m]
                              [0], position[n][1] - position[m][1])

            if distance_tuple in dis_dic.keys():
                dis_dic[distance_tuple] += 1
            else:
                dis_dic[distance_tuple] = 1

print(N - max(dis_dic.values()))


Fixed submission:
N = int(input())

position = []
for n in range(N):
    x, y = map(int, input().split())
    position.append((x, y))

if (N != 1):
    dis_dic = {}
    for n in range(N):
        for m in range(N):
            if (n != m):
                distance_tuple = (position[n][0] - position[m]
                                  [0], position[n][1] - position[m][1])

                if distance_tuple in dis_dic.keys():
                    dis_dic[distance_tuple] += 1
                else:
                    dis_dic[distance_tuple] = 1

    print(N - max(dis_dic.values()))
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
x, k, d = map(int, input().split())
ans = 1000000000000000
for i in range(k+1):
    ans = abs(min(ans, x+d*(2*i-k)))
    if ans < d:
        break
print(ans)

Fixed submission:
x, k, d = map(int, input().split())
x = abs(x)
ans = 1000000000000000
m = x // d
if m > k:
    print(abs(x-k*d))
else:
    if (k%2==0 and m%2==1) or (k%2==1 and m%2==0):
        m += 1
    ans = min(ans,x-m*d)
    """
    if m+2 <= k:
        ans = min(ans,ans+2*d)
        ans = min(ans,ans-2*d)
        """
    print(abs(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = [0] * 10010
for x in range(1,n//2):
    for y in range(1,n//2):
        for z in range(1,n//2):
            tmp = x*x + y*y + z*z + x*y + y*z + z*x
            ans[tmp] = ans[tmp] + 1

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

Fixed submission:
n = int(input())

ans = [0] * 10050
for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            tmp = x*x + y*y + z*z + x*y + y*z + z*x
            if tmp<10050:
                ans[tmp] += 1

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

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

ans = [0] * 10010
for x in range(1,n):
    for y in range(1,n):
        for z in range(1,n):
            tmp = x*x + y*y + z*z + x*y + y*z + z*x
            ans[tmp] = ans[tmp] + 1

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

Fixed submission:
n = int(input())

ans = [0] * 10050
for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            tmp = x*x + y*y + z*z + x*y + y*z + z*x
            if tmp<10050:
                ans[tmp] += 1

for i in range(n):
    print(ans[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
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)

    divisors.sort()
    return len(divisors)

n = int(input())

ans = 0
for i in range(1, n+1):
    ans += i * make_divisors(i)
    
print(ans)

Fixed submission:
n = int(input())

ans = 0
for x in range(1, n+1):
    y = n // x
    ans += y * (y+1) * x // 2
    
print(ans)

Buggy python submission (verdict: Runtime Error):
import sympy

n = int(input())

ans = 0
for i in range(1, n+1):
    ans += i * sympy.divisor_count(i)
    
print(ans)

Fixed submission:
n = int(input())

ans = 0
for x in range(1, n+1):
    y = n // x
    ans += y * (y+1) * x // 2
    
print(ans)
Buggy python submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7
n, k = map(int, input().split())

def calc(a):
  smallest = a * (a-1) / 2
  largest = smallest + a * (n-a+1)
  return latgest -smallest + 1

ans = 0
for a in range(k, n+2):
  ans += calc(a)
  ans %= MOD
  
print(ans)

Fixed submission:
MOD = 10 ** 9 + 7
n, k = map(int, input().split())

def calc(a):
  smallest = a * (a-1) // 2
  largest = smallest + a * (n-a+1)
  return largest - smallest + 1

ans = 0
for a in range(k, n+2):
  ans += calc(a)
  ans %= MOD
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#158_D
s = input()
q = int(input())

rev = 1
for _ in range(q):
    a = list(input().split())
    if a[0] == "1":
        rev *= -1
    elif a[0] == "2":
        if (a[1]=="1" and rev==1) or (a[1]=="2" and rev==-1):
            s = a[2] + s
        elif (a[1]=="2" and rev==1) or (a[1]=="1" and rev==-1):
            s = s + a[2]
if rev == -1:
    s = s[::-1]
print(s)

Fixed submission:
#158_D
s = input()
q = int(input())

from collections import deque

s = deque(s)

rev = 1
for _ in range(q):
    Q = list(input().split())
    if Q[0] == "1":
        rev *= -1
    elif Q[0] == "2":
        if (Q[1]=="1" and rev==1) or (Q[1]=="2" and rev==-1):
            s.appendleft(Q[2])
        elif (Q[1]=="2" and rev==1) or (Q[1]=="1" and rev==-1):
            s.append(Q[2])
            
s = "".join(s)
            
if rev == -1:
    s = s[::-1]

print(s)

Buggy python submission (verdict: Time Limit Exceeded):
#158_D
s = input()
q = int(input())
for _ in range(q):
    a = list(input().split())
    if a[0] == "1":
        s = s[::-1]
    elif a[0] == "2":
        if a[1] == "1":
            s = a[2] + s
        elif a[1] == "2":
            s = s + a[2]
print(s)

Fixed submission:
#158_D
s = input()
q = int(input())

from collections import deque

s = deque(s)

rev = 1
for _ in range(q):
    Q = list(input().split())
    if Q[0] == "1":
        rev *= -1
    elif Q[0] == "2":
        if (Q[1]=="1" and rev==1) or (Q[1]=="2" and rev==-1):
            s.appendleft(Q[2])
        elif (Q[1]=="2" and rev==1) or (Q[1]=="1" and rev==-1):
            s.append(Q[2])
            
s = "".join(s)
            
if rev == -1:
    s = s[::-1]

print(s)
Buggy python submission (verdict: Runtime Error):
#156_B
n, k = map(int, input().split())
for i in range(30):
    if k ** i > n:
        ans = i
        break
print(ans)

Fixed submission:
#156_B ans
n, k = map(int, input().split())
ans = 0
while n > 0:
    n = n // k
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(n):
    li = p[:i+1]
    if min(li) == p[i]:
        count += 1
        
print(count)

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

m = p[0]
count = 1
for i in range(1,n):
    if m >= p[i]:
        m = p[i]
        count += 1
        
print(count)

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

count = 0
for i in range(n):
    li = p[:i+1]
    li.sort()
    if li[0] == p[i]:
        count += 1
        
print(count)

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

m = p[0]
count = 1
for i in range(1,n):
    if m >= p[i]:
        m = p[i]
        count += 1
        
print(count)

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

m = []
count = 0
for i in range(n):
    li = p[:i+1]
    li.sort()
    m.append(li[0])
    if m[i] == p[i]:
        count += 1
        
print(count)

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

m = p[0]
count = 1
for i in range(1,n):
    if m >= p[i]:
        m = p[i]
        count += 1
        
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
lmax = len(S)
modulo = list([0]*2019)
if(len(S) < 4):
    print(0)
    exit()
for i in range(lmax):
    s = int(S[i:])%2019
    modulo[s] += 1
ans = sum(list(map(lambda x: x*(x-1)//2, modulo)))+modulo[0]
print(ans)

Fixed submission:
S = input()
lmax = len(S)
modulo = list([0]*2019)
mod10 = 10%2019
mod = int(S[-1])%2019
modulo[mod] += 1
for s in reversed(S[:-1]):
    mod = (mod + mod10*int(s))%2019
    modulo[mod] += 1
    mod10 = (mod10*10)%2019
ans = sum(list(map(lambda x: x*(x-1)//2, modulo)))+modulo[0]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
import math

def gcd_three(a, b, c):
    r = math.gcd(a, b)
    if( r == 1 ):
        return 1
    else:
        return math.gcd(r, c)
sum = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            sum += gcd_three(a,b,c)
print(sum)

Fixed submission:
K = int(input())
import math
def gcd_three(a, b, c):
    r = math.gcd(a, b)
    if( r == 1 ):
        return 1
    else:
        return math.gcd(r, c)
sum = 0
if(K>2):
    for a in range(1, K-1):
        for b in range(a+1, K):
            for c in range(b+1, K+1):
                sum += gcd_three(a,b,c)*6
for a in range(1, K):
    for b in range(a+1, K+1):
        sum += math.gcd(a,b)*6
sum += K*(K+1)//2
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = []
for j in range(1,N):
    B.append(sum(A[j:])%(10**9+7))
count = 0
for i in range(N-1):
    count += (A[i]*B[i])%(10**9+7)
print(count%(10**9+7))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = []
p = sum(A)
for j in range(N-1):
    p -= A[j]
    B.append(p%(10**9+7))
count = 0
for i in range(N-1):
    count += (A[i]*B[i])%(10**9+7)
print(count%(10**9+7))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.append(-1)
up = []
pre = False 
for i in range(1,N+1):
    if A[i] > A[i-1]:
        sw = True
    elif A[i] < A[i-1]:
        sw = False
    if sw != pre:
        up.append(i-1)
    pre = sw
if up == []:
    print(1000)
    exit()
money = 1000
p = False
for j in up:
    if p == False:
        stock = money//A[j]
        money -= stock*A[j]
    else:
        money += stock*A[j]
        stock = 0
    p = not p
print(money)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.append(-1)
up = []
pre = False
sw = False
for i in range(1,N+1):
    if A[i] > A[i-1]:
        sw = True
    elif A[i] < A[i-1]:
        sw = False
    if sw != pre:
        up.append(i-1)
    pre = sw
if up == []:
    print(1000)
    exit()
money = 1000
p = False
for j in up:
    if p == False:
        stock = money//A[j]
        money -= stock*A[j]
    else:
        money += stock*A[j]
        stock = 0
    p = not p
print(money)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
A = [0 for _ in range(N)]
u = math.floor((2*N)**0.5)
for x in range(1,u+1):
    for y in range(1,u+1):
        for z in range(1,u+1):
            c = x**2+y**2+z**2+x*y+y*z+z*x
            if c <= N:
                A[c-1] += 1
for i in range(N):
    print(A[i])

Fixed submission:
import math
N = int(input())
A = [0 for _ in range(N)]
for x in range(1,math.floor(N**0.5)+1):
    for y in range(1,math.floor((N-x**2)**0.5)+1):
        for z in range(1,math.floor((N-x**2-y**2)**0.5)+1):
            c = x**2+y**2+z**2+x*y+y*z+z*x
            if c <= N:
                A[c-1] += 1
for i in range(N):
    print(A[i])
Buggy python submission (verdict: Runtime Error):
print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = set()
for o in range(N):
    lis.add(o)
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis.discard(p)
for l in que:
    U = lis & set(path[l])
    for m in U:
        ind[m] = l
        lis.discard(m)
    que = U
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])

Fixed submission:
N = int(input())
H = [2,4,5,7,9]
P = [0,1,6,8]
B = [3]
if N%10 in H:
    print("hon")
if N%10 in P:
    print("pon")
if N%10 in B:
    print("bon")
Buggy python submission (verdict: Runtime Error):
print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = []
for o in range(N):
    lis.append(o)
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis.discard(p)
for l in que:
    U = path[l]
    for m in U:
        if m in lis:
            ind[m] = l
            lis.discard(m)
    que += U
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])

Fixed submission:
print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = [0] + [1 for _ in range(N-1)]
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis[p] = 0
for l in que:
    U = path[l]
    for m in U:
        if lis[m] ==1:
            ind[m] = l
            lis[m] = 0
            que.append(m)
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])

Buggy python submission (verdict: Time Limit Exceeded):
print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = set()
for o in range(N):
    lis.add(o)
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis.discard(p)
for l in que:
    U = lis & set(path[l])
    for m in U:
        ind[m] = l
        lis.discard(m)
    que.extend(list(U))
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])

Fixed submission:
print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = [0] + [1 for _ in range(N-1)]
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis[p] = 0
for l in que:
    U = path[l]
    for m in U:
        if lis[m] ==1:
            ind[m] = l
            lis[m] = 0
            que.append(m)
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])