Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03148 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from sys import stdin
from collections import Counter
import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, K = ds_in()
t_list = []
d_list = []
for _ in range(N):
    t, d = ds_in()
    t_list.append(t)
    d_list.append(d)
np_t = np.array(t_list)  # sushi kind
np_d = np.array(d_list)  # sushi value

sort_idx = np.argsort(np_d)[::-1][:K]  # top K value sushi
top_sushi = np_t[sort_idx]
top_score = np_d[sort_idx]
kind = len(set(top_sushi))
point = top_score.sum() + kind**2  # temp max point
point_list = [point]
sushi_counter = Counter(top_sushi)

sushi_set = {k: [] for k in set(t_list)}
for i, j in zip(t_list, d_list):
    sushi_set[i].append(j)
max_sushi = {k: max(sushi_set[k]) for k in set(t_list)}

for s in set(top_sushi):
    max_sushi.pop(s)  # temp max point
max_values = list(max_sushi.values())
max_values.sort(reverse=True)
if len(max_values) > 0:
    for sushi, score in zip(top_sushi[::-1], top_score[::-1]):
        if sushi_counter[sushi] > 1:
            sushi_counter[sushi] -= 1
            kind += 1
            point = point - score + max_values.pop(0) + 2*kind - 1
            point_list.append(point)
            if len(max_values) == 0:
                break

print(max(point_list))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin
from collections import Counter
import numpy as np


s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, K = ds_in()
t_list = []
d_list = []
for _ in range(N):
    t, d = ds_in()
    t_list.append(t)
    d_list.append(d)
np_t = np.array(t_list)
np_d = np.array(d_list)

sort_idx = np.argsort(np_d)[::-1][:K]
top_sushi = np_t[sort_idx]
top_score = np_d[sort_idx]
kind = len(set(top_sushi))
point = top_score.sum() + kind**2
point_list = [point]
sushi_counter = Counter(top_sushi)

sushi_set = {k: [] for k in set(t_list)}
for i, j in zip(t_list, d_list):
    sushi_set[i].append(j)
max_sushi = {k: max(sushi_set[k]) for k in set(t_list)}

for s in set(top_sushi):
    max_sushi.pop(s)
max_values = list(max_sushi.values())
max_values.sort(reverse=True)

for sushi, score in zip(top_sushi[::-1], top_score[::-1]):
    if sushi_counter[sushi] > 1:
        sushi_counter[sushi] -= 1
        kind += 1
        point = point - score + max_values.pop(0) + 2*kind - 1
        point_list.append(point)
        if len(max_values) == 0:
            break

print(max(point_list))
Problem p03152 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from sys import stdin
# from bisect import bisect_left
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


MOD = 10**9 + 7


def check_length(list_):
    return len(list_) > len(set(list_))


N, M = ds_in()
NM = N * M
A_list = ds_in()
B_list = ds_in()
if check_length(A_list) or check_length(B_list):
    print(0)
    exit()

A_list.sort()
B_list.sort()

if A_list[-1] < NM or B_list[-1] < NM:
    print(0)
    exit()

ans = 1
a_idx = 0
b_idx = 0
for i in range(1, NM+1):
    flag = 1
    if i == A_list[a_idx]:
        n = 1
        a_idx += 1
        flag = 0
    else:
        n = N - a_idx

    if i == B_list[b_idx]:
        m = 1
        b_idx += 1
        flag = 0
    else:
        m = M - b_idx

    ans *= (n * m - flag * (NM - i))
    ans = ans % MOD

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin
# from bisect import bisect_left
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


MOD = 10**9 + 7


def check_length(list_):
    return len(list_) > len(set(list_))


N, M = ds_in()
A_list = ds_in()
B_list = ds_in()
if check_length(A_list) or check_length(B_list):
    print(0)
    exit()

A_list.sort()
B_list.sort()

NM = N * M
ans = 1
a_idx = 0
b_idx = 0
for i in range(1, NM+1):
    flag = 1
    if i == A_list[a_idx]:
        n = 1
        a_idx += 1
        flag = 0
    else:
        n = N - a_idx

    if i == B_list[b_idx]:
        m = 1
        b_idx += 1
        flag = 0
    else:
        m = M - b_idx

    ans *= (n * m - flag * (NM - i))
    ans = ans % MOD

print(ans)
Problem p03240 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N = d_in()

cand = [[i,j,0] for i in range(0, 101) for j in range(0, 101)]

info = []
for _ in range(N):
    info.append(ds_in())

info.sort(key=lambda x: x[2], reverse=True)

for i in range(len(cand)):
    x, y, h = info[0]
    cand[i][2] = h + abs(x-cand[i][0]) + abs(y-cand[i][1])

if N > 1:
    idx = 1
    while len(cand) > 1 and idx < N:
        temp = []
        x, y, h = info[idx]
        for c in cand:
            if h == max(0, c[2] - abs(x-c[0]) - abs(y-c[1])):
                temp.append(c)
        cand = temp.copy()
        idx += 1

print(cand[0][0], cand[0][1], cand[0][2])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N = d_in()

cand = [[i,j,0] for i in range(0, 101) for j in range(0, 101)]

info = []
for _ in range(N):
    info.append(ds_in())

for i in range(len(cand)):
    x, y, h = info[0]
    cand[i][2] = h + abs(x-cand[i][0]) + abs(y-cand[i][1])

if N > 1:
    idx = 1
    while len(cand) > 1:
        temp = []
        x, y, h = info[idx]
        for c in cand:
            if h == max(0, c[2] - abs(x-c[0]) - abs(y-c[1])):
                temp.append(c)
        cand = temp.copy()
        idx += 1

print(cand[0][0], cand[0][1], cand[0][2])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N = d_in()

cand = [[i,j,0] for i in range(0, 101) for j in range(0, 101)]

info = []
for _ in range(N):
    info.append(ds_in())

for i in range(len(cand)):
    x, y, h = info[0]
    cand[i][2] = h + abs(x-cand[i][0]) + abs(y-cand[i][1])

if N > 1:
    idx = 1
    while len(cand) > 1:
        temp = []
        x, y, h = info[idx]
        for c in cand:
            if c[2] == h + abs(x-c[0]) + abs(y-c[1]):
                temp.append(c)
        cand = temp.copy()
        idx += 1
print(cand[0][0], cand[0][1], cand[0][2])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N = d_in()

cand = [[i,j,0] for i in range(0, 101) for j in range(0, 101)]

x, y, h = ds_in()
for i in range(len(cand)):
    cand[i][2] = h + abs(x-cand[i][0]) + abs(y-cand[i][1])


info = []
for _ in range(N-1):
    info.append(ds_in())

idx = 0
while len(cand) > 1:
    temp = []
    x, y, h = info[idx]
    for c in cand:
        if c[2] == h + abs(x-c[0]) + abs(y-c[1]):
            temp.append(c)
    cand = temp.copy()
    idx += 1
print(cand[0][0], cand[0][1], cand[0][2])
Problem p03249 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()
D_list = np.array([_i() for _ in range(N)])
idx = np.argsort(D_list)
sorted_D = D_list[idx]
mapping = []
for j in idx:
    mapping.append(j+1)

# 解説を参考に実装
# Dのスコアが大きい方から小さい方へ伸びる有向エッジとみなす
# valueはノードから出ている有向エッジを切った場合の部分木の大きさ
nodes = [1] * N
ans = []
cost = [[0, 1] for _ in range(N)]
# 葉っぱから見て，[エッジにたどり着くまでのコスト, 自分も含めた子ノードの数]
for i in range(N-1, 0, -1):
    d = sorted_D[i]
    sub = nodes[i]
    target = d + 2*sub - N
    cand = np.searchsorted(sorted_D[:i], target)
    if (sorted_D[cand] != target) or (cand == i):
        print(-1)
        exit()
    else:
        ans.append((mapping[i], mapping[cand]))
        nodes[cand] += nodes[i]
        cost[cand][0] += (cost[i][0] + cost[i][1])
        cost[cand][1] += cost[i][1]

# 1番目のノードについてチェック
if cost[0][0] != sorted_D[0]:
    print(-1)
    exit()
else:
    for a in ans:
        print(a[0], a[1])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
""" インプットの時間比較 """
from sys import stdin
import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


# N = _i()
# D_list = np.array([_i() for _ in range(N)])
N = d_in()
D_list = np.array([ds_in() for _ in range(N)])


idx = np.argsort(D_list)
sorted_D = D_list[idx]
mapping = []
for j in idx:
    mapping.append(j+1)

# 解説を参考に実装
# Dのスコアが大きい方から小さい方へ伸びる有向エッジとみなす
# valueはノードから出ている有向エッジを切った場合の部分木の大きさ
nodes = [1] * N
ans = []
cost = [[0, 1] for _ in range(N)]
# 葉っぱから見て，[エッジにたどり着くまでのコスト, 自分も含めた子ノードの数]
for i in range(N-1, 0, -1):
    d = sorted_D[i]
    sub = nodes[i]
    target = d + 2*sub - N
    cand = np.searchsorted(sorted_D[:i], target)
    if (sorted_D[cand] != target) or (cand == i):
        print(-1)
        exit()
    else:
        ans.append((mapping[i], mapping[cand]))
        nodes[cand] += nodes[i]
        cost[cand][0] += (cost[i][0] + cost[i][1])
        cost[cand][1] += cost[i][1]

# 1番目のノードについてチェック
if cost[0][0] != sorted_D[0]:
    print(-1)
    exit()
else:
    for a in ans:
        print(a[0], a[1])
Problem p03280 (python)

Fixed submission:
A, B = map(int, input().split())
res = (A-1)*(B-1)

print(int(res))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
res = (A-1)*(B-1)

print(int(res))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

print((A-1)*(B-1))
Problem p03297 (python)

Fixed submission:

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


T = int(input())

for _ in range(T):
    A, B, C, D = map(int, input().split())
    if (A < B) or (D < B):
        print('No')
        continue
    elif (C+1 >= B):
        print('Yes')
        continue
    else:
        s_res = A % B
        s_k = int((C + 1 - s_res - 0.1) // B + 1)
        X = gcd(B, (D%B))
        if X == 1:
            print('No')
            continue
        else:
            s_0 = s_k * B + s_res
            if (s_0 - (C+1)) % X > (B-C-2):
                print('Yes')
            else:
                print('No')

Buggy submission (verdict: Runtime Error):
import math

T = int(input())

for _ in range(T):
    A, B, C, D = map(int, input().split())
    if (A < B) or (D < B):
        print('No')
        continue
    elif (C+1 >= B):
        print('Yes')
        continue
    else:
        s_res = A % B
        s_k = int((C + 1 - s_res - 0.1) // B + 1)
        X = math.gcd(B, (D%B))
        if X == 1:
            print('No')
            continue
        else:
            s_0 = s_k * B + s_res
            if (s_0 - (C+1)) % X > (B-C-2):
                print('Yes')
            else:
                print('No')
Problem p03304 (python)

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

if d == 0:
    print((m-1)/n)
else:
    print((m-1) * 2 * (n-d) / n ** 2)

Buggy submission (verdict: Runtime Error):
n, m, d = map(int, input().split())

tot = n ** m

if d == 0:
    c = n
else:
    c = 2 * (n - d)
   
print(c/(n-1) * ((1 - 1/tot)/(n-1) - m/tot))
Problem p03305 (python)

Fixed submission:
import heapq

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

Yen_cost = dict([[i, []] for i in range(n)])
Snuuk_cost = dict([[i, []] for i in range(n)])
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    Yen_cost[u].append((v, a))
    Yen_cost[v].append((u, a))
    Snuuk_cost[u].append((v, b))
    Snuuk_cost[v].append((u, b))

def Digkstra(Cost_dict, start):   
    dist = [float('inf') for _ in range(n)]
    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while len(q) != 0:
        prov_cost, src = heapq.heappop(q)

        if dist[src] < prov_cost:
            continue

        for dest, cost in Cost_dict[src]:
            if dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost
                heapq.heappush(q, (dist[dest], dest))
    return dist

Yen_dist = Digkstra(Yen_cost, s-1)
Snuuk_dist = Digkstra(Snuuk_cost, t-1)

First = 10**15
Money = []
Money.append(int(First - Yen_dist[-1] - Snuuk_dist[-1]))
for year in range(n-2, -1, -1):
    temp = First - Yen_dist[year] - Snuuk_dist[year]
    if temp > Money[-1]:
        Money.append(temp)
    else:
        Money.append(Money[-1])

for i in range(n):
    print(Money[-1-i])

Buggy submission (verdict: Runtime Error):
import heapq
import numpy as np

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

Yen_cost = np.ones((n, n)) * np.inf
Snuuk_cost = np.ones((n, n)) * np.inf

for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    Yen_cost[u, v] = a
    Yen_cost[v, u] = a
    Snuuk_cost[u, v] = b
    Snuuk_cost[v, u] = b


def Digkstra(Cost_list, start):   
    dist = np.ones(n) * np.inf
    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while len(q) != 0:
        prov_cost, src = heapq.heappop(q)

        if dist[src] < prov_cost:
            continue

        for dest in range(n):
            cost = Cost_list[src, dest]
            if dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost
                heapq.heappush(q, (dist[dest], dest))
    return dist

Yen_dist = Digkstra(Yen_cost, s-1).astype(int)
Snuuk_dist = Digkstra(Snuuk_cost, t-1).astype(int)

First = 10**15
Money = []
Money.append(int(First - Yen_dist[-1] - Snuuk_dist[-1]))
for year in range(n-2, -1, -1):
    temp = First - Yen_dist[year] - Snuuk_dist[year]
    if temp > Money[-1]:
        Money.append(temp)
    else:
        Money.append(Money[-1])

for i in range(n):
    print(Money[-1-i])
Problem p02642 (python)

Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    max=a[-1]
    check=[0 for i in range(max+10)]
    sum=0
    #print(a)
    if len(a)==1:
        print(1)
        exit()
    if a[0]==1:
        if a[1]==1:
            print(0)
        else:
            print(1)
        exit()
    for i in range(n):
        if check[a[i]]==0:
            sum+=1
            j=1
            x=a[i]*j
            while x<max+1:
                check[x]=1
                j+=1
                x=a[i]*j
            if i<n-1 and a[i+1]==a[i]:
                sum-=1
        else:
            continue
    print(sum)
        
    
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    max=a[-1]
    check=[0 for i in range(max+10)]
    sum=0
    if len(a)==1:
        print(1)
        exit()
    tmp=a[1]
    for i in range(n):
        if tmp==a[i]:
            continue
        tmp=a[i]
        if check[a[i]]==0:
            sum+=1
            j=1
            x=a[i]*j
            while x<max+1:
                x=a[i]*j
                check[x]=1
                j+=1
        else:
            continue
    print(sum)
        
    
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    max=a[-1]
    check=[0 for i in range(max+10)]
    sum=0
    tmp=a[1]
    for i in range(n):
        if tmp==a[i]:
            continue
        tmp=a[i]
        if check[a[i]]==0:
            sum+=1
            j=1
            x=a[i]*j
            while x<max+1:
                x=a[i]*j
                check[x]=1
                j+=1
        else:
            continue
    print(sum)
        
    
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    max=a[-1]
    check=[0 for i in range(max+10)]
    sum=0
    tmp=a[1]
    for i in range(n):
        if tmp==a[i]:
            continue
        tmp=a[i]
        if check[a[i]]==0:
            sum+=1
            j=1
            x=a[i]*j
            while x<max+1:
                x=a[i]*j
                check[x]=1
                j+=1
        else:
            continue
    print(sum)
        
    
    
if __name__=="__main__":
    main()
Problem p02647 (python)

Fixed submission:
import sys
input=sys.stdin.readline
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    zeros=[0]*n

    if min(a)==n:
        print(*a)
        exit()

    for i in range(k):
        x=zeros.copy()
        for j in range(n):
            if a[j]==0:
                l=j
                r=min(j+1,n)
                #print(l,r)
                x[l]+=1
                if r!=n:
                #print(r)
                    x[r]+=-1
                #print(x)
            else:
                l=max(0,j-a[j])
                r=min(j+a[j]+1,n)
                #print(l,r)
                x[l]+=1
                if r!=n:
                    #print(r)
                    x[r]+=-1
                #print(x)
        ruiseki=[0]*n
        ruiseki[0]=x[0]
        a[0]=ruiseki[0]
        for i in range(1,n):
            ruiseki[i]=ruiseki[i-1]+x[i]
            a[i]=ruiseki[i]
        if min(a)==n:
            print(*a)
            exit()
 
        #print(*ruiseki)
    print(*a)
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    zeros=[0 for i in range(n)]
    if max(a)==0:
        print(*a)
        exit()
    if min(a)==n:
        print(*a)
        exit()
    for i in range(k):
        x=zeros.copy()
        for j in range(n):
            if a[j]==0:
                l=j
                r=j+1
            else:
                l=max(0,j-a[j])
                r=min(j+a[j]+1,n-1)
           # print(l,r)
            x[l]+=1
            if r!=n-1:
                x[r]+=-1
            #print(x)
        ruiseki=[0]*n
        ruiseki[0]=x[0]
        a[0]=ruiseki[0]
        mina=a[0]
        for i in range(1,n):
            ruiseki[i]=ruiseki[i-1]+x[i]
            a[i]=ruiseki[i]
            if a[i]<mina:
                mina=a[i]
        if mina==n:
            print(*a)
            exit()
        #print(*ruiseki)
    print(*a)
if __name__=="__main__":
    main()
Problem p02662 (python)

Fixed submission:
import numpy as np
def main():
    n,s=map(int,input().split())
    A=list(map(int,input().split()))
    dp=np.array([0 for i in range(min(3001,s+1))])
    dp[0]=1
    for ai in A:
        tmp=dp[:-ai].copy()
        #print(tmp)
        dp*=2
        dp[ai:]+=tmp
        dp%=998244353
    print(dp[s])
    

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
def main():
    n,s=map(int,input().split())
    A=list(map(int,input().split()))
    maxA=max(A)
    dp=np.array([0 for i in range(s+1)])
    dp[0]=1
    for ai in A:
        tmp=dp[:-ai].copy()
        #print(tmp)
        dp*=2
        dp[ai:]+=tmp
    print(dp[s])
    

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,s=map(int,input().split())
    N=[i+1 for i in range(n)]
    list1=[]
    pattern=[]
    A=list(map(int,input().split()))

    ft=0  
    dict={}
    for i in range(n+1):
        dict[i]=[]
    for i in range(1,2**n):
        list2=[]
        for j in range(n):
            if (i >> j) &1 == 1:
                list2.append(N[j])
        pattern=[]
        for x in range(1,2**len(list2)):
            pt=[]
            for y in range(len(list2)):
                if (x>>y)&1==1:
                    pt.append(list2[y])
            pattern.append(pt)
    # print(pattern)

        for p in pattern:
            sum=0
            if p in dict[len(p)]:
                ft+=1
            else:
                for x in p:
                    sum+=A[x-1]
                if sum==s:
                    dict[len(p)].append(p)
                    ft+=1
                    ft=ft%998244353
    print(ft%998244353)

if __name__"__main__":
    main()
Problem p02675 (python)

Fixed submission:
n=input()

if n[-1]=="3":
    print("bon")
elif n[-1]=="0" or n[-1]=="1" or n[-1]=="6" or n[-1]=="8":
    print("pon")
else:
    print("hon")

Buggy submission (verdict: Runtime Error):
import queue
def main():
    n,m=map(int,input().split())
    root=[[0 for i in range(n)] for i in range(n)]
    for i in range(m):
        a,b=map(int,input().split())
        root[a-1][b-1]=1
        root[b-1][a-1]=1
    min=[-1 for i in range(n)]
    min[0]=2
    dict={}
    for i in range(n):
        dict[i]=-1

    start=0
    check=[False]*n
    toVis=queue.Queue()
    check[start]=True
    for i in range(len(root[0])):
        if root[0][i]==1:
            toVis.put(i)
            dict[i]=start
        #   print(i,":",start)
            check[i]=True
    while(toVis.empty()!=True):
        now=toVis.get()
        #print(now)
        check[now]=True
        for i in range(n):
            if root[now][i]==1 and check[i]==False:
                toVis.put(i)
                dict[i]=now
            # print(i,":",now)
                check[i]=True
    #print(dict)  
    for i in range(1,n):
        if dict[i]==-1:
            print("No")
            return 0
    print("Yes")
    for i in range(1,n):
        print(dict[i]+1)         


if __name__=="__main__":
    main()