Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def StringTransformation(s , t):

    taious = {}
    taiout = {}
    ans = "Yes"

    for i in range(len(s)):
        if t[i] in taiout.keys() or s[i] in taious.keys():
            if taiout[t[i]] != s[i] or taious[s[i]] != t[i]:
                ans = "No"
                break
        else:
            taiout[t[i]] = s[i]
            taious[s[i]] = t[i]

    return ans

def main():
    s = str(input())
    t = str(input())
    print(StringTransformation(s , t))

if __name__ == '__main__':
    main()

Fixed submission:
def StringTransformation(s , t):

    taious = {}
    taiout = {}
    ans = "Yes"

    for i in range(len(s)):
        if t[i] in taiout.keys() and taiout[t[i]] != s[i]:
            ans = "No"
            break
        elif s[i] in taious.keys() and taious[s[i]] != t[i]:
            ans = "No"
            break
        else:
            taiout[t[i]] = s[i]
            taious[s[i]] = t[i]

    return ans

def main():
    s = str(input())
    t = str(input())
    print(StringTransformation(s , t))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def To_Infinity(s , k):

    ans = ""

    s1 = s.lstrip("1")

    if k - (len(s) - len(s1)) >= 0:
        ans = s1[0]
    else:
        ans = "1"

    return ans
def main():
    s = str(input())
    k = int(input())
    print(To_Infinity(s , k))

if __name__ == '__main__':
    main()

Fixed submission:
def To_Infinity(s , k):

    ans = ""

    s1 = s.lstrip("1")

    if k - (len(s) - len(s1)) > 0:
        ans = s1[0]
    else:
        ans = "1"

    return ans
def main():
    s = str(input())
    k = int(input())
    print(To_Infinity(s , k))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def To_Infinity(s , k):

    ans = 0

    if s[0] == 1:
        if k == 1:
            ans = 1
        else:
            ans = s[1]
    else:
        ans = s[0]

    return ans
def main():
    s = list(int(input()))
    k = int(input())
    print(To_Infinity(s , k))

if __name__ == '__main__':
    main()

Fixed submission:
def To_Infinity(s , k):

    ans = ""

    s1 = s.lstrip("1")

    if k - (len(s) - len(s1)) > 0:
        ans = s1[0]
    else:
        ans = "1"

    return ans
def main():
    s = str(input())
    k = int(input())
    print(To_Infinity(s , k))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def Exponential(x):

    ans = 0
    if x == 1:
        ans = 1
    else:
        for i in range(1, x + 1):
            for w in range(2, x + 1):
                if i ** w <= x:
                    ans = max(ans, i ** w)

    return ans

def main():
    x = int(input())
    print(Exponential(x))

if __name__ == '__main__':
    main()

Fixed submission:
def Exponential(x):

    ans = 0
    if x == 1:
        ans = 1
    else:
        for i in range(1, x + 1):
            for w in range(2, x + 1):
                if i ** w > x:
                    break
                else:
                    ans = max(ans, i ** w)

    return ans

def main():
    x = int(input())
    print(Exponential(x))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import copy

def Many_Medians(n , xl):

    ans = []
    ap = n // 2 - 1

    for i in range(n):
        outi = copy.copy(xl)
        outi.pop(i)
        outi.sort()
        ans.append(outi[ap])

    return ans

def main():
    n = int(input())
    xl = list(map(int , input().split()))
    ans = Many_Medians(n, xl)
    for i in range(n):
        print(ans[i])

if __name__ == '__main__':
    main()

Fixed submission:
import copy

def Many_Medians(n , xl):

    ans = []
    left = n // 2
    right = n // 2 - 1
    sort_xl = sorted(xl)

    for x in xl:
        if x < sort_xl[left]:
            ans.append(sort_xl[left])
        else:
            ans.append(sort_xl[right])

    return ans

def main():
    n = int(input())
    xl = list(map(int , input().split()))
    ans = Many_Medians(n, xl)
    for i in range(n):
        print(ans[i])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':


Fixed submission:

def Same_Integers(abc):

    ans = 0
    abc.sort()
    count = abc[2]*3 - abc[0] - abc[1] - abc[2]

    if count % 2 == 0:
        ans = int(count / 2)
    else:
        ans = int((count + 3) // 2)

    return ans

def main():
    abc = list(map(int , input().split()))
    print(Same_Integers(abc))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def P_Number(a , b):

    ans = 0

    for i in range(a, b + 1):
        rev = str(i[::-1])
        if i == int(rev):
            ans += 1

    return ans

def main():
    a , b = map(int , input().split())
    print(P_Number(a , b))


if __name__ == '__main__':
    main()

Fixed submission:
def P_Number(a , b):

    ans = 0

    for i in range(a, b + 1):
        rev = str(i)
        if str(i) == rev[::-1]:
            ans += 1

    return ans

def main():
    a , b = map(int , input().split())
    print(P_Number(a , b))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def NotsoDiverse(n , k , al):

    lis = [0]*n

    for i in range(n):
        lis[al[i]] += 1

    lis.sort(reverse=True)

    ans = sum(lis[k:])
    return ans

def main():
    n , k = map(int , input().split())
    al = list(map(int , input().split()))
    print(NotsoDiverse(n , k , al))

if __name__ == '__main__':
    main()


Fixed submission:
def NotsoDiverse(n , k , al):

    lis = [0]*(n + 1)

    for i in range(n):
        lis[al[i]] += 1

    lis.sort(reverse=True)

    ans = sum(lis[k:])
    return ans

def main():
    n , k = map(int , input().split())
    al = list(map(int , input().split()))
    print(NotsoDiverse(n , k , al))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def hex(x , y):

    ans = ""

    if int(x, 16) < int(y, 16):
        ans = "<"
    elif int(x, 16) > int(y, 16):
        ans = ">"
    else:
        ans = "="

    return ans

def main():
    x , y = map(int , input().split())
    print(hex(x , y))

if __name__ == '__main__':
    main()

Fixed submission:
def hex(x , y):

    ans = ""

    if int(x, 16) < int(y, 16):
        ans = "<"
    elif int(x, 16) > int(y, 16):
        ans = ">"
    else:
        ans = "="

    return ans

def main():
    x , y = map(str , input().split())
    print(hex(x , y))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def nibunhigh(lister, b):
    ans = 0
    low = 0
    high = len(lister) - 1

    if lister[low] > b:
        return high + 1
    elif lister[high] < b:
        return low
    else:
        while lister[low + 1] < b:
            mid = (low + high) // 2
            if (b < lister[mid]):
                high = mid
            else:
                low = mid
        ans = len(lister) - (low + 1)

    return ans

def nibunlow(lister, b):
    ans = 0
    low = 0
    high = len(lister) - 1
#    while (low + 1) <= high:
    if lister[low] > b:
        return low
    elif lister[high] < b:
        return high + 1
    else:
        while lister[low + 1] < b:
            mid = (low + high) // 2
            if (b <= lister[mid]):
                high = mid
            else:
                low = mid
        ans = low + 1

    return ans

def snukefestival(n , a , b , c):

    ans = 0
    a.sort()
    b.sort()
    c.sort()

    for i in range(n):
        ans += nibunlow(a , b[i]) * nibunhigh(c , b[i])

    return ans

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int , input().split()))
    print(snukefestival(n , a , b , c))

if __name__ == '__main__':
    main()

Fixed submission:
import bisect

def snukefestival(n , a , b , c):

    ans = 0
    a.sort()
    b.sort()
    c.sort()

    for i in b:
        ab = bisect.bisect_left(a , i)
        cb = bisect.bisect_right(c , i)
        ans += ab * (len(b) - cb)

    return ans

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int , input().split()))
    print(snukefestival(n , a , b , c))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def newrating(r , g):

    return (r + g) / 2

def main():
    r , g = map(int , input().split())
    print(newrating(r , g))

if __name__ == '__main__':
    main()

Fixed submission:
def newrating(r , g):

    return (g - r) + g

def main():
    r = int(input())
    g = int(input())
    print(newrating(r , g))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def writeanderase(n , a):

    ans = {}

    for i in range(n):
        if a[i] in ans:
            ans[a[i]] += 1
        else:
            ans[a[i]] = 1

    for i in ans.values():
        count += i % 2

    return count

def main():
    n = int(input())
    a = [int(input()) for i in range(n)]
    print(writeanderase(n , a))

if __name__ == '__main__':
    main()

Fixed submission:
def writeanderase(n , a):

    ans = {}
    count = 0

    for i in range(n):
        if a[i] in ans:
            ans[a[i]] += 1
        else:
            ans[a[i]] = 1

    for i in ans.values():
        count += i % 2

    return count

def main():
    n = int(input())
    a = [int(input()) for i in range(n)]
    print(writeanderase(n , a))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def writeanderase(n , a):

    ans = []

    for i in range(n):
        if ans.count(a[i]) == 0:
            ans.append(a[i])
        else:
            ans.remove(a[i])

    return len(ans)

def main():
    n = int(input())
    a = [int(input()) for i in range(n)]
    print(writeanderase(n , a))

if __name__ == '__main__':
    main()

Fixed submission:
def writeanderase(n , a):

    ans = {}
    count = 0

    for i in range(n):
        if a[i] in ans:
            ans[a[i]] += 1
        else:
            ans[a[i]] = 1

    for i in ans.values():
        count += i % 2

    return count

def main():
    n = int(input())
    a = [int(input()) for i in range(n)]
    print(writeanderase(n , a))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def together(n , a):

    listans = [0]*(10**5)

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

    return max(listans)


def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(together(n , a))

if __name__ == '__main__':
    main()

Fixed submission:
def together(n , a):

    listans = [0]*(10**5+2)

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

    return max(listans)


def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(together(n , a))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def breaknumbeer(n):

    ans = 0
    maxcount = 0
    for i in range(n):
        count = 0
        w = i
        while w % 2 == 0:
            w = w / 2
            count += 1
        if count >= maxcount:
            ans = i

    return ans

def main():
    n = int(input())
    print(breaknumbeer(n))

if __name__ == '__main__':
    main()

Fixed submission:
def breaknumbeer(n):

    ans = 1

    while ans <= n:
        ans *= 2

    return int(ans / 2)

def main():
    n = int(input())
    print(breaknumbeer(n))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def takahasi(n , m , a):

    ans = "IMPOSSIBLE"
    list1 = []
    listn = []

    for i in range(m):
        if a[i][0] == 1:
            list1.append(a[i][1])
        elif a[i][1] == n:
            listn.append(a[i][0])
    
    for i in range(len(list1)):
        if listn.count(list1[i]) != 0:
            ans = "POSSIBLE"

    return ans

def main():
    n , m = map(int , input().split())
    a = [list(map(int,input().split())) for i in range(m)]
    print(takahasi(n , m , a))

if __name__ == '__main__':
    main()

Fixed submission:
def takahasi(n , m , a):

    ans = "IMPOSSIBLE"
    list1n = []

    for i in range(m):
        if a[i][0] == 1 or a[i][1] == n:
            list1n.append(a[i][1] if a[i][0] == 1 else a[i][0])

    if len(list1n) != len(set(list1n)):
        ans = "POSSIBLE"

    return ans

def main():
    n , m = map(int , input().split())
    a = [list(map(int,input().split())) for i in range(m)]
    print(takahasi(n , m , a))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def takahasi(n , m , a):

    ans = "IMPOSSIBLE"
    list1 = []
    listn = []

    for i in range(m):
        if a[i][0] == 1:
            list1.append(a[i][1])
        elif a[i][1] == n:
            listn.append(a[i][0])
    
    for i in range(len(list1)):
        if listn.count(list1[i]) != 0:
            ans = "POSSIBLE"

    return ans

def main():
    n , m = map(int , input().split())
    a = [list(map(int,input().split())) for i in range(m)]
    print(takahasi(n , m , a))

if __name__ == '__main__':
    main()

Fixed submission:
def takahasi(n , m , a):

    ans = "IMPOSSIBLE"
    list1n = []

    for i in range(m):
        if a[i][0] == 1 or a[i][1] == n:
            list1n.append(a[i][1] if a[i][0] == 1 else a[i][0])

    if len(list1n) != len(set(list1n)):
        ans = "POSSIBLE"

    return ans

def main():
    n , m = map(int , input().split())
    a = [list(map(int,input().split())) for i in range(m)]
    print(takahasi(n , m , a))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def splittingplie(n , a):

    ans = 100000000000000

    for i in range(1 , n):
        rldifference = abs(sum(a[:i]) - sum(a[i:]))
        ans = min(ans , rldifference)
    return ans

def main():
    n = int(input())
    a = list(map(int , input().split()))
    print(splittingplie(n , a))

if __name__ == '__main__':
    main()

Fixed submission:
def splittingplie(n , a):

    ans = 10**18
    allsum = int(sum(a))
    asum = 0

    for i in range(n - 1):
        asum += a[i]
        rldifference = abs(allsum - asum*2)
        ans = min(ans , rldifference)

    return ans

def main():
    n = int(input())
    a = list(map(int , input().split()))
    print(splittingplie(n , a))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def ntukusi(a,b,c):
    ans = "YES" if b - a = c - b else "NO"
    return ans

def main():
    a , b , c = map(int, input().split())
    print(ntukusi(a , b , c))

if __name__ == '__main__':
    main()

Fixed submission:
def ntukusi(a,b,c):
    return "YES" if (b - a) == (c - b) else "NO"

def main():
    a , b , c = map(int, input().split())
    print(ntukusi(a , b , c))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def ntukusi(a,b,c):
    return "YES" if b - a = c - b else "NO"

def main():
    a , b , c = map(int, input().split())
    print(ntukusi(a , b , c))

if __name__ == '__main__':
    main()

Fixed submission:
def ntukusi(a,b,c):
    return "YES" if (b - a) == (c - b) else "NO"

def main():
    a , b , c = map(int, input().split())
    print(ntukusi(a , b , c))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
ans = 0
mod = 10**9+7

kai = math.factorial(N)


for i in range(1,kai+1):
    if kai % i == 0:
        ans += 1

print(ans % mod)


Fixed submission:
N = int(input())
count = [1]*(N+1)
ans = 1
mod = 10**9+7

for i in range(2,N+1):
    wari = i
    for w in range(2,i+1):
        while wari % w == 0:
            count[w] += 1
            wari /= w

for i in range(N+1):
    ans *= count[i]

print(ans % mod)

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

N = int(input())
ans = 0
mod = 10**9+7

kai = math.factorial(N)
i = 2

while kai == 0:
    if kai % i == 0:


#for i in range(1,kai+1):
#    if kai % i == 0:
#        ans += 1

print(ans % mod)


Fixed submission:
N = int(input())
count = [1]*(N+1)
ans = 1
mod = 10**9+7

for i in range(2,N+1):
    wari = i
    for w in range(2,i+1):
        while wari % w == 0:
            count[w] += 1
            wari /= w

for i in range(N+1):
    ans *= count[i]

print(ans % mod)

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

N = int(input())
ans = 0

kai = math.factorial(N)

for i in range(1,kai+1):
    if kai % i == 0:
        ans += 1

print(ans)


Fixed submission:
N = int(input())
count = [1]*(N+1)
ans = 1
mod = 10**9+7

for i in range(2,N+1):
    wari = i
    for w in range(2,i+1):
        while wari % w == 0:
            count[w] += 1
            wari /= w

for i in range(N+1):
    ans *= count[i]

print(ans % mod)
Buggy python submission (verdict: Runtime Error):
import sys

N = int(input())
A = sorted(list(map(int,input().split())))
amari = 10**9 + 7

if N % 2 == 0:
    ans = list(int(i) for i in range(1,N,2)*2)

else:
    ans = list(int(i) for i in range(0,N,2)*2)
    A.insert(0,0)

if ans == A:
    print(2**(N//2) % amari)
else:
    print("0")

Fixed submission:
N = int(input())
A = sorted(list(map(int,input().split())))
amari = 10**9 + 7
ans = []
han = 0

if N % 2 == 0:
    han = 1
else:
    han = 0
    A.insert(0,0)


ans = list(int(i) for i in range(han,N,2))
ans += ans
ans.sort()

if ans == A:
    print(2**(N//2) % amari)
else:
    print("0")

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

#計算量O(n/2)
N = int(input())
A = list(map(int,input().split()))
amari = 10**9 + 7
A.sort()

if N % 2 == 0:
    for i in range(1,N,2):
        if A.count(i) != 2:
            print("0")
            sys.exit()
else:
    if A.count(0) != 1:
        print("0")
        sys.exit()
    for i in range(2,N,2):
        if A.count(i) != 2:
            print("0")
            sys.exit()

print(2**(N//2) % amari)

Fixed submission:
N = int(input())
A = sorted(list(map(int,input().split())))
amari = 10**9 + 7
ans = []
han = 0

if N % 2 == 0:
    han = 1
else:
    han = 0
    A.insert(0,0)


ans = list(int(i) for i in range(han,N,2))
ans += ans
ans.sort()

if ans == A:
    print(2**(N//2) % amari)
else:
    print("0")

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

N = int(input())
A = list(map(int,input().split()))
amari = 10**9 + 7

if N % 2 == 0:
    for i in range(1,N,2):
        if A.count(i) != 2:
            print("0")
            sys.exit()
else:
    if A.count(0) != 1:
        print("0")
        sys.exit()
    for i in range(2,N,2):
        if A.count(i) != 2:
            print("0")
            sys.exit()

print(2**(N//2) % amari)

Fixed submission:
N = int(input())
A = sorted(list(map(int,input().split())))
amari = 10**9 + 7
ans = []
han = 0

if N % 2 == 0:
    han = 1
else:
    han = 0
    A.insert(0,0)


ans = list(int(i) for i in range(han,N,2))
ans += ans
ans.sort()

if ans == A:
    print(2**(N//2) % amari)
else:
    print("0")

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

N = int(input())
A = list(map(int,input().split()))
amari = 10**9 + 7

if N % 2 == 0:
    for i in range(1,N,2):
        if A.count(i) != 2:
            print("0")
            sys.exit()
else:
    if A.count(0) != 1:
        print("0")
        sys.exit()
    for i in range(2,N,2):
        if A.count(i) != 2:
            print("0")
            sys.exit()

print(2**(N//2) % amari)

Fixed submission:
N = int(input())
A = sorted(list(map(int,input().split())))
amari = 10**9 + 7
ans = []
han = 0

if N % 2 == 0:
    han = 1
else:
    han = 0
    A.insert(0,0)


ans = list(int(i) for i in range(han,N,2))
ans += ans
ans.sort()

if ans == A:
    print(2**(N//2) % amari)
else:
    print("0")
Buggy python submission (verdict: Runtime Error):
c = input()
clist = ['a','e','i','o','u']

if clist.count(c) == 0:
    print(consonant)
else:
    print(vowel)

Fixed submission:
c = input()
clist = ['a','e','i','o','u']

if clist.count(c) == 0:
    print("consonant")
else:
    print("vowel")
Buggy python submission (verdict: Time Limit Exceeded):
a , b , x = map(int, input().split())
ans = 0

for i in range(a , b + 1):
    if(i % x == 0):
        ans += 1

print(ans)

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

if a == 0:
    print(ans + 1)
else:
    print(ans - (a - 1) // x)
Buggy python submission (verdict: Time Limit Exceeded):
N,x = map(int, input().split())
alist = list(map(int,input().split()))
ans = 0

for al in range(1,N):
    while (alist[al-1]+alist[al]) > x:
        alist[al] -= 1
        ans += 1

print(ans)

Fixed submission:
N,x = map(int, input().split())
alist = list(map(int,input().split()))
ans = 0

if alist[0] > x:
    ans += (alist[0] - x)
    alist[0] -= (alist[0] - x)

for al in range(1,N):
    if (alist[al-1]+alist[al]) > x:
        ans += (alist[al-1]+alist[al]) - x
        alist[al] -= (alist[al-1]+alist[al]) - x

print(ans)
Buggy python submission (verdict: Runtime Error):
def anordinarygame(s):

    flag = True
    count = 0
    while flag:
        for i in range(len(s)):
            if len(s) != i and i != 0 and str(s[i-1]) != str(s[i+1]):
                count += 1
                s.pop(i)
                continue
            elif len(s) == i:
                return "Second" if count % 2 == 0 else "First"
        if len(s) < 3:
            return "Second" if count % 2 == 0 else "First"

def main():
    s = list(str(input()))
    print(anordinarygame(s))

if __name__ == '__main__':
    main()

Fixed submission:
def anordinarygame(s):

    ans = ""
    if s[0] == s[-1]:
        ans = "Second" if len(s) % 2 else "First"
    else:
        ans = "First" if len(s) % 2 else "Second"

    return ans

def main():
    s = list(str(input()))
    print(anordinarygame(s))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())

print("YES" if A+B+C == 17 else "NO")

Fixed submission:
ans = 0
A = list(map(int, input().split()))

for x in A:
    ans += x

print("YES" if ans == 17 else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
res = a[0]
for i in range(1, n): res *= a[i]
print(-1) if res > 10**18 else print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
a = sorted(a, reverse=True)
res = a[0]
for ai in a[1:]:
    res *= ai
    if res > 10**18:
        print(-1)
        exit()
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
res = a[0]
for i in range(1, n): res *= a[i]
print(-1) if res > 10**18 else print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
a = sorted(a, reverse=True)
res = a[0]
for ai in a[1:]:
    res *= ai
    if res > 10**18:
        print(-1)
        exit()
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
INF = 10**9 + 7
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
g = [[] for _ in range(n+1)]
for a, b in ab:
    g[a].append([a, b])
    g[b].append([b, a])
res = [[0, INF] for _ in range(n+1)]
res[1][0] = 1
res[1][1] = 0
q = deque(g[1])
while q:
    q_ = q.pop()
    if res[q_[1]][1] == INF or res[q_[1]][1] > res[q_[0]][1] + 1:
        for gi in g[q_[1]]: q.append(gi)
        res[q_[1]][0] = q_[0]
        res[q_[1]][1] = res[q_[0]][1] + 1
print("Yes")
for i in res[2:]: print(i[0])

Fixed submission:
from collections import deque
INF = 10**9 + 7
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append([a, b])
    g[b].append([b, a])
res = [[0, INF] for _ in range(n+1)]
res[1][1] = 0
q = deque(g[1])
while q:
    q_ = q.popleft()
    if res[q_[1]][1] == INF:
        for gi in g[q_[1]]: q.append(gi)
        res[q_[1]][0] = q_[0]
        res[q_[1]][1] = res[q_[0]][1] + 1
print("Yes")
for i in res[2:]: print(i[0])