Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
l = list(map(int,input().split()))

dp = [0 for i in range(n)]

for i in range(1,n):
    if i <= m-1:
        dp[i] = abs(l[0]-l[i])
    
    else:
        mini = 10**9
        for j in range(1,m+1):
            mini = min(mini, abs(l[i]-l[i-j])+dp[i-j])
        
        dp[i] = mini

print(dp[-1])

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

dp = [float('inf')]*n
dp[0] = 0
for i in range(1,k+1):
    dp[i] = abs(l[0]-l[i])
    
    if i == n-1:
        break

for i in range(k+1,n):
    dp_min = float('inf')
    for j in range(1,k+1):
        tmp = dp[i-j] + abs(l[i] - l[i-j])
        dp_min = min(dp_min, tmp)
    
    dp[i] = dp_min
    
print(dp[n-1])

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

dp = [float('inf')]*n
dp[0] = 0
for i in range(1,k+1):
    dp[i] = abs(l[0]-l[i])
    
    if i == n-1:
        break

for i in range(k+1,n):
    dp_min = float('inf')
    for j in range(1,k+1):
        tmp = dp[i-j] + abs(l[i] - l[i-j])
        dp_min = min(dp_min, tmp)
    
    dp[i] = dp_min
    
print(dp[n-1])

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

dp = [float('inf')]*n
dp[0] = 0
for i in range(1,k+1):
    dp[i] = abs(l[0]-l[i])
    
    if i == n-1:
        break

for i in range(k+1,n):
    dp_min = float('inf')
    for j in range(1,k+1):
        tmp = dp[i-j] + abs(l[i] - l[i-j])
        dp_min = min(dp_min, tmp)
    
    dp[i] = dp_min
    
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, w = map(int, input().split())
l = [list(map(int,input().split())) for i in range(n)]


dp = np.zeros((n + 1, w + 1), dtype=np.int64)

for i in range(n):
    tmp = np.zeros(w + 1, dtype=int)
    tmp[l[i][0]:] = dp[i][:-l[i][0]] + l[i][1]
    dp[i + 1] = np.maximum(dp[i], tmp)
    
print(dp[n][w])

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

items = [list(map(int,input().split())) for i in range(n)]

dp = [[0]*(w+1) for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j >= items[i][0]:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-items[i][0]] + items[i][1])
            
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[n][w])
Buggy python submission (verdict: Time Limit Exceeded):
import math

n,m = map(int,input().split())

max_n = math.floor(m/n)

for i in range(1,max_n+1)[::-1]:
    if m % i == 0:
        print(i)
        break

Fixed submission:
import math

n,m = map(int,input().split())

max_n = math.floor(m/n)

for i in range(1,max_n+1)[::-1]:
    if m % i == 0:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
n =input()

for i in range(n):
	if n[i] == '9':
		n[i] = '1'
	else:
		n[i] = '9'
print(n)

Fixed submission:
n =input()

n = n.replace('9','0')
n = n.replace('1','9')
n = n.replace('0','1')
print(n)
Buggy python submission (verdict: Runtime Error):
import sympy

N,K = map(int,input().split())

cities = list(map(int,input().split()))

cities.append(K)

cities.sort()

dif = []

for i in range(N):
	dif.append(cities[i+1] - cities[i])
    

if len(dif) == 1:
	x = dif[0]

else:
    
	x = sympy.gcd(dif[0],dif[1])

	for i in range(2,N):
		x = sympy.gcd(x,dif[i])

print(x)

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

cities = list(map(int,input().split()))

cities.append(K)

cities.sort()

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

dif = []

for i in range(N):
	dif.append(cities[i+1] - cities[i])
    

if len(dif) == 1:
	x = dif[0]

else:
    
	x = gcd(dif[0],dif[1])

	for i in range(2,N):
		x = gcd(x,dif[i])

print(x)

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

N,K = map(int,input().split())

cities = list(map(int,input().split()))

cities.append(K)

cities.sort()

dif = []

for i in range(N):
    dif.append(cities[i+1] - cities[i])
    

if len(dif) == 1:
    x = dif[0]

else:
    
    x = sympy.gcd(dif[0],dif[1])

    for i in range(2,N):
        x = sympy.gcd(x,dif[i])

print(x)

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

cities = list(map(int,input().split()))

cities.append(K)

cities.sort()

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

dif = []

for i in range(N):
	dif.append(cities[i+1] - cities[i])
    

if len(dif) == 1:
	x = dif[0]

else:
    
	x = gcd(dif[0],dif[1])

	for i in range(2,N):
		x = gcd(x,dif[i])

print(x)
Buggy python submission (verdict: Runtime Error):
k = int(input())

c=0

for i in range(1,k+1):
	for j in range(1,K+1)
		if i % 2 ==0:
			if j % 2 == 1:
				c += 1
print(c)

Fixed submission:
k = int(input())

c=0

for i in range(1,k+1):
	for j in range(1,k+1):
		if i % 2 ==0:
			if j % 2 == 1:
				c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
n ,k = map(int(input().split()))

print(n-k+1)

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

print(n-k+1)
Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()
print(S)             
        


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

lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 
lst.reverse()

if len(lst) == lst.count(1):
	print(1)

elif K == lst[:K].count(1):
	print(1)
  
else:
	for i in range(K):
		if lst[i] != 1:
			print(lst[i])
			break
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())


print(int((b-a)*(b-a+1)/2-b))

Fixed submission:
n = int(input())

m = 10000000000000000

for i in range(n,m,n):
	if i % 2 == 0:
		print(i)
		break
Buggy python submission (verdict: Runtime Error):
d, n = map(int, input().split())
 
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)
d, n = map(int, input().split())

if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)

Fixed submission:
d, n = map(int, input().split())
 
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)

Buggy python submission (verdict: Runtime Error):
d, n = map(int, input().split())
 
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)
d, n = map(int, input().split())

if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)
提出情報

Fixed submission:
d, n = map(int, input().split())
 
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

c = 0

def sigma(x):
	if x <= 0:
		return x
	return x + sigma(x-1)
  
for i in range(1,1000):
	c += 1
	if sigma(i) > a:
		break
        
print(sigma(c) - a)

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


print(int((b-a)*(b-a+1)/2-b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

b = [0]

for i in range(n):
    b.append(b[i]+a[i])

ans = 0

for i in range(min(b),max(b)+1):
    n = b.count(i)
    
    ans += int((n*(n-1))/2)

print(ans)

Fixed submission:
from itertools import accumulate
from collections import Counter

n = int(input())
l = list(map(int,input().split()))
l.insert(0,0)
a = list(accumulate(l))

count_a = Counter(a)

ans = 0

for i in count_a.values():
    if i < 2:
        continue
    ans += i*(i-1)/2
        

print(int(ans))

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

b = [0]

for i in range(n):
    b.append(b[i]+a[i])

b = sorted(b)
ans = 0

for i in range(min(b),max(b)+1):
    n = b.count(i)
    
    ans += int((n*(n-1))/2)

print(ans)

Fixed submission:
from itertools import accumulate
from collections import Counter

n = int(input())
l = list(map(int,input().split()))
l.insert(0,0)
a = list(accumulate(l))

count_a = Counter(a)

ans = 0

for i in count_a.values():
    if i < 2:
        continue
    ans += i*(i-1)/2
        

print(int(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(map(str,input().split()))

print(s)


if y_n == 0:
	print('Three')  
else:
	print('Four')  

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


y_n = s.count('Y')

if y_n == 0:
	print('Three')  
else:
	print('Four')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

c = 0

for i in a:
    if a.count(i) < i:
        a.remove(i)
        c += 1
    
for i in a:
    if a.count(i) > i:
        a.remove(i)
        c += 1
        
print(c)

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

cnt = [0]*(10**5)
c = 0

for i in a:
    if i <= 10**5:
        cnt[i-1] += 1
    else:
        c += 1



for i in range(10**5):
    if cnt[i] > i+1:
        c += cnt[i] - (i+1)
    
    elif cnt[i] < i+1:
        c += cnt[i]

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

balls = list(map(int,input().split()))

max_n = 200000

ball_counts = [0]*max_n

for ball in balls:
    ball_counts[ball-1] += 1


counts = []

for n in ball_counts:
    if n !=0:
        counts.append(n)
        
counts = sorted(counts)

c = 0

while len(counts) > k:
    c += counts[0]
    del counts[0]

print(c)
    

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

balls = list(map(int,input().split()))

max_n = 200000

ball_counts = [0]*max_n

for ball in balls:
    ball_counts[ball-1] += 1


counts = []

for n in ball_counts:
    if n !=0:
        counts.append(n)
        
counts = sorted(counts)

print(sum(counts[0:len(counts)-k]))

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

balls = list(map(int,input().split()))

unique_ball = []

for ball in balls:
    if not (ball in unique_ball):
        unique_ball.append(ball)

ball_counts = []

for ball in unique_ball:
    ball_counts.append(balls.count(ball))
    
ball_counts = sorted(ball_counts)

c = 0

while len(ball_counts) > k:
    c += ball_counts[0]
    del ball_counts[0]

print(c)

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

balls = list(map(int,input().split()))

max_n = 200000

ball_counts = [0]*max_n

for ball in balls:
    ball_counts[ball-1] += 1


counts = []

for n in ball_counts:
    if n !=0:
        counts.append(n)
        
counts = sorted(counts)

print(sum(counts[0:len(counts)-k]))

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

balls = list(map(int,input().split()))

unique_ball = []

for ball in balls:
    if not (ball in unique_ball):
        unique_ball.append(ball)

ball_counts = []

for ball in unique_ball:
    ball_counts.append(balls.count(ball))

c = 0

while len(unique_ball) > k:
    c += ball_counts[ball_counts.index(min(ball_counts))]
    del unique_ball[ball_counts.index(min(ball_counts))]
    del ball_counts[ball_counts.index(min(ball_counts))]
    
print(c)


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

balls = list(map(int,input().split()))

max_n = 200000

ball_counts = [0]*max_n

for ball in balls:
    ball_counts[ball-1] += 1


counts = []

for n in ball_counts:
    if n !=0:
        counts.append(n)
        
counts = sorted(counts)

print(sum(counts[0:len(counts)-k]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = [int(input()) for i in range(n)]

paper = []

for number in a:
    if not number in paper:
        paper.append(number)
    
    else:
        paper.remove(number)

print(len(paper))
        

Fixed submission:
n = int(input())

a = [int(input()) for i in range(n)]

a = sorted(a)


temp = a[0]
c = 0

cnts = [0]*n

for i in a:
    if temp == i:
        cnts[c] += 1
    
    else:
        temp = i
        c += 1
        cnts[c] += 1

ans = 0

for i in cnts:
    if i == 0:
        break

    if i%2 == 1:
        ans += 1

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

seq = list(map(int,input().split()))

unique = []

seq = sorted(seq)
c = 0
k = seq[0]

for i in seq:
    if not i in unique:
        unique.append(i)

unique_n = [0]*len(unique)

for i in seq:
    if i == k:
        unique_n[c] += 1
    
    else:
        c += 1
        unique_n[c] += 1





if n == 1:
    print(1)

elif n == 2:
    if max(seq) - min(seq) <= 2:
        print(2)
    
    else:
        print(1)

else:
    max_n = 0
    
    for i in range(1,len(unique)-2):
        cnt = 0
        cnt += unique_n[i-1]
        cnt += unique_n[i]
        cnt += unique_n[i+1]
    
        if cnt > max_n:
            max_n = cnt

    
    print(max_n)


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

ans = [0 for i in range(2*10**5+2)]

for i in a:
    ans[i-1] += 1
    ans[i] += 1
    ans[i+1] += 1
    
print(max(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())

length = list(map(int,input().split()))

length = sorted(length)
length.append(0)

temp = length[0]
c = 1

unique_n = []
square = []

for i in range(n):
    if temp == length[i+1]:
        c += 1
    
    else:
        if c >= 2 :
            unique_n.append(length[i-1])
        
        if c >= 4:
            square.append(length[i-1])
            
        
        c = 1
        temp = length[i+1]

if len(unique_n) <= 1:
    print(0)

else:
    print(max(unique_n[-1]*unique_n[-2],(square[-1])**2))



Fixed submission:
n = int(input())

length = list(map(int,input().split()))

length = sorted(length)
length.append(0)

temp = length[0]
c = 1

unique_n = []
square = []

for i in range(n):
    if temp == length[i+1]:
        c += 1
    
    else:
        if c >= 2 :
            unique_n.append(length[i-1])
        
        if c >= 4:
            square.append(length[i-1])
            
        
        c = 1
        temp = length[i+1]

if len(unique_n) <= 1:
    print(0)

else:
    if len(square) >= 1:
        print(max(unique_n[-1]*unique_n[-2],(square[-1])**2))
    
    else:
        print(unique_n[-1]*unique_n[-2])
Buggy python submission (verdict: Runtime Error):
n = int(input())

l = list(map(int,input().split()))

l.reverse()

x = 0

sum_x = []

for i in range(n-1):
    x += l[i]
    sum_x.append(x)

sum_y = [sum(l)]*(n-1)

for i in range(n-1):
    sum_y[i] -= sum_x[i]
    
abs_xy = []

for i in range(n-1):
    abs_xy.append(abs(sum_x[i]-sum_y[i]))

print(min(abs_xy))

Fixed submission:
n = int(input())

l = list(map(int,input().split()))

l.reverse()

x = 0

sum_x = []

for i in range(n-1):
    x += l[i]
    sum_x.append(x)

sum_y = [sum(l)]*(n-1)

for i in range(n-1):
    sum_y[i] -= sum_x[i]
    
abs_xy = []

for i in range(n-1):
    abs_xy.append(abs(sum_x[i]-sum_y[i]))

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

colors = list(map(int,input().split()))

col_n = [0]*9

for c in colors:
    if c >= 1 and c <= 399:
        col_n[0] += 1
    elif c >= 400 and c <= 799:
        col_n[1] += 1
    elif c >= 800 and c <= 1199:
        col_n[2] += 1
    elif c >= 1200 and c <= 1599:
        col_n[3] += 1
    elif c >= 1600 and c <= 1999:
        col_n[4] += 1
    elif c >= 2000 and c <= 2399:
        col_n[5] += 1
    elif c >= 2400 and c <= 2799:
        col_n[6] += 1
    elif c >= 2800 and c <= 3199:
        col_n[7] += 1
    else:
        col_n[8] += 1

if col_n[8] == 0:
    print(8-col_n[:8].count(0),8-col_n[:8].count(0))

else:
    if 8-col_n[:8].count(0) >= col_n[8]:
        print(8-col_n[:8].count(0),(8-col_n[:8].count(0)+col_n[8]))
    
    else:
        print(col[8],(8-col_n[:8].count(0))+col_n[8])


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

color_n = [0 for i in range(9)]

for i in a:
    if 1 <= i <= 399:
        color_n[0] += 1
    
    elif 400 <= i <= 799:
        color_n[1] += 1
    
    elif 800 <= i <= 1199:
        color_n[2] += 1
    
    elif 1200 <= i <= 1599:
        color_n[3] += 1
    
    elif 1600 <= i <= 1999:
        color_n[4] += 1
    
    elif 2000 <= i <= 2399:
        color_n[5] += 1
    
    elif 2400 <= i <= 2799:
        color_n[6] += 1
    
    elif 2800 <= i <= 3199:
        color_n[7] += 1
    
    else:
        color_n[8] += 1

print(max(8-color_n[:-1].count(0), 1),8-color_n[:-1].count(0)+color_n[-1])
Buggy python submission (verdict: Runtime Error):
for i in range(1, n+1):
    while i % 2 == 0:
        if not 2 in divisor_dic:
            divisor_dic[2] = 1
        else:
            divisor_dic[2] += 1
        i //= 2
    f = 3
    while f*f <= i:
        if i % f ==0:
            if not f in divisor_dic:
                divisor_dic[f] = 1
            else:
                divisor_dic[f] += 1
        
            i //= f
        
        else:
            f += 2
    
    if i != 1:
        if not i in divisor_dic:
            divisor_dic[i] = 1
        else:
            divisor_dic[i] += 1
                
c = 1          
for v in divisor_dic.values():
    c *= (v+1)
    c %= 10**9+7

print(c)

Fixed submission:
import math

n = int(input())

prime_n = [2]

for i in range(3,n+1,2):
    if all( i % prime != 0 for prime in prime_n):
        prime_n.append(i)

multiply = []

for i in prime_n:
    k = 1
    temp = 0
    while i**k <= n:
        temp += math.floor(n/(i**k))
        k+=1
    
    multiply.append(temp)

ans = 1

for i in multiply:
    ans*=(i+1)
    ans%=((10**9)+7)

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

cnt = 0

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

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

c=0

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

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

c=0

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

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

c=0

for x in range(k+1):
    for y in range(k+1):
        z = s - x- y
        if 0<=z<=k:
            c+=1
            
                
                
print(c)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
s = input()
t = input()

for i in range(n):
   if s[i:] == t[:n-i]:
		print(n+i)
		exit()

print(2*n)

Fixed submission:
n = int(input())
s = input()
t = input()

for i in range(n):
   if s[i:] == t[:n-i]:
       print(n+i)
       exit()

print(2*n)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int,input().split()))
mod = 10**9 + 7
ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += (l[i] * l[j])
print(ans%mod)

Fixed submission:
N = int(input())
l = list(map(int,input().split()))
mod = 10**9 + 7

area = sum(l) * sum(l)

for i in l:
    area -= i*i

ans = area//2
ans = ans % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
Q = int(input())
bc = [[int(i) for i in input().split()] for j in range(Q)]

counter = [0] * 100000
for i in a:
    counter[i] += 1

ans = sum(a)

for _ in bc:
    ans = ans + counter[_[0]] * _[1] - counter[_[0]] * _[0]
    counter[_[1]] += counter[_[0]]
    counter[_[0]] = 0
    print(ans)


Fixed submission:
N = int(input())
a = list(map(int,input().split()))
Q = int(input())
bc = [[int(i) for i in input().split()] for j in range(Q)]
 
counter = [0] * 1000000
for i in a:
    counter[i] += 1

ans = sum(a)
 
for _ in bc:
    ans = ans + counter[_[0]] * _[1] - counter[_[0]] * _[0]
    counter[_[1]] += counter[_[0]]
    counter[_[0]] = 0
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M = map(int, input().split())
A_B_list = [[int(i) for i in input().split()] for j in range(M)]
ans = np.zeros(N)
next_list = [1]
next_next_list = []
flag = False
while np.any(ans==0):
    for nxt in next_list:
        for ab in A_B_list: #1に繋がってるやつを消す
            if nxt == ab[0] and ans[ab[1]-1] == 0:
                ans[ab[1]-1] = nxt
                next_list.append(ab[1])
                
            elif nxt == ab[1] and ans[ab[0]-1] == 0:
                ans[ab[0]-1] = nxt
                next_list.append(ab[0])
                
    if len(next_list)==0:
        flag = True
        break
    next_list = next_next_list

if flag:
    print("No")
else:
    print("Yes")
    for i in ans[1:]:
        print(int(i))


Fixed submission:
from collections import deque

n,m = map(int,input().split())
graph = [[] for _ in range(n)]
ans = [0] * n
for _ in range(m):
    a, b = map(int,input().split())
    a -= 1; b -= 1
    graph[a].append(b)
    graph[b].append(a)


q = deque([0])
visited = [False] * n
visited[0] = True

while q:
    now = q.popleft()
    
    for i in graph[now]:
        if visited[i]: continue
        
        visited[i] = True
        ans[i] = now
        q.append(i)
        

print("Yes")
for a in ans[1:]:
    print(a+1)
Buggy python submission (verdict: Runtime Error):
A,B,C,K = map(int, input().split())
num = 0
ans = 0
 
if(A>=K):
  print(K)
elif(A<K　and K<=(A+B)):
  print(A)
else:
  ans = A-(K-(A+B))
  print(ans)

Fixed submission:
A,B,C,K = map(int, input().split())
num = 0
ans = 0
 
if(A>=K):
  print(K)
elif (A<K) and (K<=(A+B)):
  print(A)
else:
  ans = A-(K-(A+B))
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

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

ans = 0
for x in range(min(B,N+1)):
    ans = max(ans,math.floor((A*x)/B) - A * math.floor(x/B))

print(ans)

Fixed submission:
import math

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

x = min(B-1,N)
ans = math.floor((A*x)/B) - A * math.floor(x/B)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

ans = 0
for x in range(N+1):
    ans = max(ans,math.floor((A*x)/B) - A * math.floor(x/B))

print(ans)

Fixed submission:
import math

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

x = min(B-1,N)
ans = math.floor((A*x)/B) - A * math.floor(x/B)

print(ans)