TnT/CodeNet4Repair huggingface dataset:
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
from sys import stdin

n = int(stdin.readline().rstrip())

list = []
i = 0
for i in range(n):
  list.append(stdin.readline().rstrip())

AC = WA = TLE = RE = 0
for k in list:
  if k == 'AC':
    AC = AC + 1
  if k == 'WA':
    WA = WA + 1
  if k == 'TLE':
    TLE = TLE + 1
  if k == 'RE':
    RE = RE + 1
    
print(f'AC × {AC}')
print(f'WA × {WA}')
print(f'TLE × {TLE}')
print(f'RE × {RE}')



Fixed, accepted submission:
from sys import stdin

n = int(stdin.readline().rstrip())

list = []
i = 0
for i in range(n):
  list.append(stdin.readline().rstrip())

AC = WA = TLE = RE = 0
for k in list:
  if k == 'AC':
    AC = AC + 1
  if k == 'WA':
    WA = WA + 1
  if k == 'TLE':
    TLE = TLE + 1
  if k == 'RE':
    RE = RE + 1
    
print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')
Problem:
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.  You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.

Incorrect submission (verdict: Wrong Answer):
pw=[input() for i in range(2)]
length=len(pw[0])
full_pw=[]
i=0
while i < length:
    full_pw.append(pw[0][i])
    if i !=len(pw[0])-1:
        full_pw.append(pw[1][i])
    i+=1

print(*full_pw,sep='')

Fixed, accepted submission:
pw=[input() for i in range(2)]
length=len(pw[0])
full_pw=[]
i=0
while i < length:
    full_pw.append(pw[0][i])
    if i <=len(pw[1])-1:
        full_pw.append(pw[1][i])
    i+=1

print(*full_pw,sep='')
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
strings = input()

word_list = ["dream", "erase", "dreamer", "eraser"]
rev_list = ["maerd", "esare", "remaerd", "resare"]

match = ""

for s in reversed(strings):  
  match += s
  
  if match in rev_list:
    match = ""

if len(match) == 0:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
strings = input()

rev_list = ["maerd", "esare", "remaerd", "resare"]

match = ""

for s in reversed(strings):  
  match += s
  
  if match in rev_list:
    match = ""

if len(match) == 0:
  print("YES")
else:
  print("NO")
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
N =  int(input())
print(N*800 - (N // 15))

Fixed, accepted submission:
N =  int(input())
print(N*800 - (N // 15)*200)
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
l = list(map(int,input().split()))

s = [5,7,5]
for a in l:
    if a in s:
        s.remove(a)
if s == []:
    print('Yes')
else:
    print('No')


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

s = [5,7,5]
for a in l:
    if a in s:
        s.remove(a)
if s == []:
    print('YES')
else:
    print('NO')
Problem:
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Incorrect submission (verdict: Wrong Answer):
A,B,C,X,Y=map(int,input().split())
M=[A,B,C]

ans=[]

ans.append(A*X+B*Y)
ans.append(C*max(X,Y)*2)

if A>B:
  ans.append(C*min(X,Y)*2+A*(X-min(X,Y)))
if B>A:  
  ans.append(C*min(X,Y)*2+B*(Y-min(X,Y)))

print(min(ans))

Fixed, accepted submission:
A,B,C,X,Y=map(int,input().split())
ans=5000*(10**5)*2+1

for i in range(max(X,Y)+1):
  total=0
  total=2*C*i+A*max(X-i,0)+B*max(Y-i,0)
  if ans>=total:
    ans=total
print(ans)
Problem:
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.  Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.  Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.  Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.

Incorrect submission (verdict: Wrong Answer):
x, a, b = [int(_) for _ in input().split()]
if (a+b)>x:
    print("dangerous")
else:
    print("delicious")

Fixed, accepted submission:
x, a, b = map(int, input().split())

if b <= a:
    ans = "delicious"
elif b > a and b <= a + x:
    ans = "safe"
else:
    ans = "dangerous"
print(ans)
Problem:
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i.  Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.  Now, the following Q operations will be performed:    * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j.  Find the value of the counter on each vertex after all operations.

Incorrect submission (verdict: Wrong Answer):
N, Q = map(int, input().split())

ab = []

for i in range(N-1):
    ab.append(list(map(int, input().split())))

l = [[] for i in range(N)]

for pi in ab:
    l[pi[0]-1].append(pi[1]-1)

cou = [0] * N

for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    cou[p] += x
    for j in l[p]:
        cou[j] += x
        for k in l[j]:
            cou[k] += x
            for h in l[k]:
                cou[h] += x

for i in range(N):
    print(str(cou[i]), end = " ")

Fixed, accepted submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def g(ab: list, ans: list, check: list, i: int = 0):
    if len(ab[i]) == 1 and i != 0:
        return
    check[i] = False
    for j in ab[i]:
        if check[j]:
            ans[j] += ans[i]
            g(ab, ans, check, j)

def main():
    N, Q = map(int, input().split())
    ab = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        ab[a-1].append(b-1)
        ab[b-1].append(a-1)
    ans = [0] * N
    check = [True] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        ans[p-1] += x
    g(ab, ans, check)
    print(' '.join(list(map(str, ans))))
    

if __name__ == '__main__': main()
Problem:
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied:    * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds.  Find all favorite numbers and print the sum of those.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
l = int(-(-(n ** (1/2)) // 1))
print(l)
total = 0
for i in range(1, l):
	if n % i == 0:
		total += (n - i) // i
print(int(total))

Fixed, accepted submission:
n = int(input())
l = int(-(-(n ** (1/2)) // 1))
total = 0
for i in range(1, l):
	if n % i == 0 and n != i * (i+1):
		total += (n - i) // i
print(int(total))
Problem:
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.  She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.

Incorrect submission (verdict: Wrong Answer):
N,K = map(int,input().split())
num_list=[]

kari = 0
N -= 1
num_list.append(input().split())
num_list_3 = sorted(num_list)
while(kari != 1):
    count = 0
    N += 1 
    for i in range(K - 1):
        a = num_list_3[0][i]
        s = str(N).count(a)
        print(s)
        if(s != 0):
            count+= 1
            print(count)  
    if (count == 0):
        kari = 1
print(N)

Fixed, accepted submission:
n,k=map(int,input().split())
d = list(map(int,input().split()))
#print(d)
for i in range(n,10**5):
    count=0
    for j in range(k):
        u = str(d[j])
        if(str(i).count(u)==0):
            count+=1
    #print("count:"+str(count))
    if(count==k):
        print(i)
        break
Problem:
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.     

Incorrect submission (verdict: Wrong Answer):
w,h,x,y,r =[int(i) for i in input().split()]

if(w < x+r ):
	print('YES')
elif(h < y+r):
	print('YES')
else:
	print('NO')

Fixed, accepted submission:
w,h,x,y,r =[int(i) for i in input().split()]

if((x+r <= w) and (y+r <= h) and (0 <= x-r) and (0 <= y-r)):
	print('Yes')
else:
	print('No')
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
S = str(input())
print(S.find("1"))

Fixed, accepted submission:
S = str(input())
print(S.count("1"))
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Incorrect submission (verdict: Wrong Answer):
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    s=sum(map(int, str(i)))
    print(s)
    if a <= s <= b:
        ans += i
print(ans)


Fixed, accepted submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    s=sum(map(int, str(i)))
    if a <= s <= b:
        ans += i
print(ans)
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

Incorrect submission (verdict: Wrong Answer):
a, b, x = [int(m) for m in input().split(" ")]

print("Yes" if 0 <= x-a and x <= a+b else "No" )

Fixed, accepted submission:
a, b, x = [int(m) for m in input().split(" ")]

print("YES" if 0 <= x-a and x <= a+b else "NO")
Problem:
You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes.    * Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i.

Incorrect submission (verdict: Wrong Answer):
n = int(input())

if n == 12:
    print('Yes')
    l = [12,1,2,3,5,6,7,9,10,11]
    p = l[:]
    for i in p:
        l.append(i + n)
    m = [4, 8, 12, 16, 20]
    for i,j in zip(l, l[1:]):
        print(i, j)
    for i,j in zip(m, m[1:]):
        print(i, j)
    exit()

if n == 24:
    print('Yes')
    l = [24,2,4,6,7,8,9,10,11,13,14,15,17,18,19,21,22]
    p = l[:]
    for i in p:
        l.append(i + n)
    m = [1,3,5,12,16,20,23]
    p = m[:]
    m.append(24)
    for i in p:
        m.append(i + n)
    for i,j in zip(l, l[1:]):
        print(i, j)
    for i,j in zip(m, m[1:]):
        print(i, j)
    exit()

if n == 1 or n % 2 == 0:
    print('No')
    exit()

l = [False] * (n + 1)
p = [n]
b = bin(n)[2:][::-1]
pw = 0
for i in b:
    if i == '1':
        p.append(2 ** int(pw))
        l[2 ** pw] = True
    pw += 1

q = []
xr = 0
for i in range(1, n):
    if not l[i]:
        xr ^= i
        q.append(i)
# print(xr)
# print(p)
# print(q)
res1 = []
for i in p:
    res1.append(i)
for i in p:
    res1.append(i + n)

res2 = []
if xr == 0:
    res2 = [n]
    for i in q:
        res2.append(i)
    for i in q:
        res2.append(i + n)
else:
    res2 = []
    for i in q:
        res2.append(i)
    res2.append(xr)
    for i in q:
        res2.append(i + n)

print('Yes')
for i,j in zip(res1, res1[1:]):
    print(i, j)
for i,j in zip(res2, res2[1:]):
    print(i, j)

Fixed, accepted submission:
n = int(input())
nn = n
f = lambda x, y: x + y * nn
g = lambda x: x if x % 2 == 1 else x + nn


b = bin(n)
if b.count('0') == len(b) - 2:
    print('No')
    exit(0)

ret = [
    [f(1, 0), f(2, 0)],
    [f(2, 0), f(3, 0)],
    [f(3, 0), f(1, 1)],
    [f(1, 1), f(2, 1)],
    [f(2, 1), f(3, 1)],
]

if n % 2 == 0:
    p = 2 ** (len(b) - 3)
    q = n ^ 1 ^ p
    ret.append([g(p), f(n, 0)])
    ret.append([g(q), f(n, 1)])
    n -= 1


while n > 3:
    ret.append([f(n - 1, 0), f(n, 0)])
    ret.append([f(n, 0), f(1, 1)])
    ret.append([f(1, 1), f(n - 1, 1)])
    ret.append([f(n - 1, 1), f(n, 1)])
    n -= 2

print('Yes')
for x, y in ret:
    
    
    print(x, y)
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
t,x,y =(0, 0, 0)
for _ in range(n):
    nt, nx, ny =map(int,input().split())
    dis=abs(nx-x)+abs(ny-y)
    tim = nt - t
    print(dis,tim)
    if tim >= dis and (tim - dis) % 2 ==0:
        t,x,y=nt, nx, ny
    else:
        print('No')
        break
else:
    print('Yes')

Fixed, accepted submission:
from sys import stdin
 
input = stdin.readline
lines = stdin.readlines
 
N = int(input())
 
txy = ((map(int, line.split())) for line in lines())
t,x,y =(0, 0, 0)
for nt, nx, ny in txy:
    dis=abs(nx-x)+abs(ny-y)
    tim = nt - t
    if tim >= dis and (tim - dis) % 2 ==0:
        t,x,y=nt, nx, ny
    else:
        print('No')
        break
else:
    print('Yes')
Problem:
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.

Incorrect submission (verdict: Wrong Answer):
s=input()
t=['dream','dreamer','erase','eraser']
t=sorted(t,reverse=True)
a=0
for i in range(4):
  for j in range(4):
    if t[i]+t[j]==s: 
      a+=1
print("YES"if a>0 else "NO")

Fixed, accepted submission:
s=input()
a=['a','e','i','u','o']
print('vowel' if s in a else 'consonant')
Problem:
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.  The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.  One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control.  If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out.    * X < Z \leq Y   * x_1, x_2, ..., x_N < Z   * y_1, y_2, ..., y_M \geq Z  Determine if war will break out.

Incorrect submission (verdict: Wrong Answer):
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
if X>=Y:
    print("War")
    exit()
for Z in range(X,Y):
    if max(x)<=Z<min(y):
        continue
    else:
        print("War")
        exit()
print("No War")


Fixed, accepted submission:
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
if X>=Y:
    print("War")
    exit()
for Z in range(X,Y):
    if max(x)<=Z<min(y):
        print("No War")
        exit()
print("War")
Problem:
先日，オンラインでのプログラミングコンテストが行われた． W大学とK大学のコンピュータクラブは以前からライバル関係にあり，このコンテストを利用して両者の優劣を決めようということになった．  今回，この2つの大学からはともに10人ずつがこのコンテストに参加した．長い議論の末，参加した10人のうち，得点の高い方から3人の得点を合計し，大学の得点とすることにした．  W大学およびK大学の参加者の得点のデータが与えられる．このとき，おのおのの大学の得点を計算するプログラムを作成せよ．

Incorrect submission (verdict: Wrong Answer):
def func():
  lst = []
  for i in range(10):
    lst.append(int(input()))
  lst.sort()
  print(sum(lst[-3:]))
func()
func()



Fixed, accepted submission:
def func():
  lst = []
  for i in range(10):
    lst.append(int(input()))
  lst.sort()
  return sum(lst[-3:])
print(func(),func())
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
import math
goal = int(input())
cnt = 0
money = 100
while goal >= money:
    money = math.floor(money * 1.01)
    cnt +=1
print(cnt)

Fixed, accepted submission:
import math
goal = int(input())
cnt = 0
money = 100
while goal > money:
    money = math.floor(money * 1.01)
    cnt +=1
print(cnt)
Problem:
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.   Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.   Here, both the x\- and y-coordinates before and after each movement must be integers.   He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).   Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).   Under this condition, find a shortest path for him.

Incorrect submission (verdict: Wrong Answer):
sx , sy , tx, ty = map(int , input().split())
print('R'*(tx-sx),end = "")
print('U'*(ty-sy),end = "")
print('L'*(tx-sx),end = "")
print('D'*(ty-sx+1),end = "")
print('R'*(tx-sx+1),end = "")
print('U'*(ty-sx+1),end = "")
print('L',end = "")
print('U',end = "")
print('R'*(tx-sx+1),end = "")
print('D'*(ty-sx+1),end = "")
print('L')

Fixed, accepted submission:
sx , sy , tx, ty = map(int , input().split())
lx = abs(tx - sx)
ly = abs(ty - sy)
print('U'*ly,end = "")
print('R'*lx,end = "")
print('D'*ly,end = "")
print('L'*(lx+1),end = "")
print('U'*(ly+1),end = "")
print('R'*(lx+1),end = "")
print('D',end = "")
print('R',end = "")
print('D'*(ly+1),end = "")
print('L'*(lx+1),end = "")
print('U')
Problem:
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.  Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence.  Here, the distance between two points s and t on a number line is represented by |s-t|.

Incorrect submission (verdict: Wrong Answer):
#from time import time
#t = time()
nvm = input().split(' ')
if int(nvm[1]) - int(nvm[0]) > int(nvm[1]) - int(nvm[2]):
    print('A')
else:
    print('B')

#print(mn[0] * mm[1])
#tt= time()
#print(tt-t)

Fixed, accepted submission:
#from time import time
#t = time()
nvm = input().split(' ')
if abs(int(nvm[0]) - int(nvm[1])) < abs(int(nvm[0]) - int(nvm[2])):
    print('A')
else:
    print('B')

#print(mn[0] * mm[1])
#tt= time()
#print(tt-t)
Problem:
There is a cave.  The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.  It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.  Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.    * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.  Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Incorrect submission (verdict: Wrong Answer):
N, M = map(int,input().split())

room = {}
startRoom = {1:1}

for i in range(M):
  A, B = map(int,input().split())
  room.setdefault(A, []).append(B)
  room.setdefault(B, []).append(A)
  
#print(room)
targetRoom = [1]
while len(targetRoom) != 0:
  nextTarget = []
  for i in targetRoom:
    roomList = room[i]
    for j in roomList:
      if j not in startRoom:
        startRoom[j] = i
        nextTarget.append(j)
  targetRoom = nextTarget
  
#print(startRoom)
if len(startRoom) != N:
  print("no")
else:
  print("yes")
  for i in range(2, N+1):
    print(startRoom[i])

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

room = {}
startRoom = {1:1}

for i in range(M):
  A, B = map(int,input().split())
  room.setdefault(A, []).append(B)
  room.setdefault(B, []).append(A)
  
targetRoom = [1]
while len(targetRoom) != 0:
  nextTarget = []
  for i in targetRoom:
    roomList = room[i]
    for j in roomList:
      if j not in startRoom:
        startRoom[j] = i
        nextTarget.append(j)
  targetRoom = nextTarget
  
if len(startRoom) != N:
  print("No")
else:
  print("Yes")
  for i in range(2, N+1):
    print(startRoom[i])