Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
print(max(C - (A - B), 0)

Fixed submission:
A, B, C = map(int, input().split())

print(max(C - (A - B), 0))
Buggy python submission (verdict: Runtime Error):
N, M = [int(s) for s in input().split(' ')]
A = [int(s) for s in input().split(' ')]

task_days = sum(A)

if N < task_days:
    return -1
else:
    return N - task_days

Fixed submission:
N, M = [int(s) for s in input().split(' ')]
A = [int(s) for s in input().split(' ')]

task_days = sum(A)

if N < task_days:
    print(-1)
else:
    print(N - task_days)
Buggy python submission (verdict: Runtime Error):
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

N=int(input())
input(num2alpha(N).lower())

Fixed submission:
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

N=int(input())
print(num2alpha(N).lower())
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
print(len(set(d)))

Fixed submission:
N = int(input())
d = [input() for i in range(N)]
print(len(set(d)))
print()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))

for i in range(0,N):
  print(A.count(i+1))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
ans=[0]*(N+1)

for i in range(0,N-1):
  ans[A[i]]+=1

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

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

for i in range(0,N):
  print(A.count(i+1))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
ans=[0]*(N+1)

for i in range(0,N-1):
  ans[A[i]]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
B=[0]*N

for i in range(0,N):
  for j in range(0,N-1):
    if A[j]==i+1:
      B[i]+=1
  print(B[i])

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
ans=[0]*(N+1)

for i in range(0,N-1):
  ans[A[i]]+=1

for i in range(1,N+1):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
x = input()

def temp(num):
  if num >= 30:
    print('Yes')
  else:
    print('No')
    
temp(x)

Fixed submission:
x = int(input())

if x >= 30:
  print('Yes')
else:
  print('No')

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

if x >= 30:
  print("Yes")
  
else:
  print("No")

Fixed submission:
x = int(input())

if x >= 30:
  print('Yes')
else:
  print('No')

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

if x >= 30:
  print("Yes")
 
else:
  print("No")

Fixed submission:
x = int(input())

if x >= 30:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
x=input () 
if x>=30:
  print ('Yes') 
else:
  print('No') 

Fixed submission:
x=input() 
x=int(x) 
if x>=30:
  print ('Yes') 
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=input()
n=int(n) 
d=input()
d=int(d) 
count=0
for i in range(n):
  x=input()
  y=input()
  x=int(x)
  y=int(y)
  dist=((x**2) + (y**2))**0.5
  if dist<=d:
    count+=1
print(count) 

Fixed submission:

n,d= input().split(" ")
n=int(n)
d=int(d) 
count=0
for i in range(n):
  x,y= input().split(" ")
  x=int(x)
  y=int(y) 
  dist=((x**2) + (y**2))**0.5
  if dist<=d:
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input()) 
d=int(input())
count=0
for i in range(n):
  x=input()
  y=input()
  x=int(x)
  y=int(y)
  dist=np.sqrt((x**2) + (y**2))
  if dist<=d:
    count+=1
print(count) 

Fixed submission:

n,d= input().split(" ")
n=int(n)
d=int(d) 
count=0
for i in range(n):
  x,y= input().split(" ")
  x=int(x)
  y=int(y) 
  dist=((x**2) + (y**2))**0.5
  if dist<=d:
    count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int,input().split()))
dic = {}
d = {}
for i in arr:
    if i not in dic:
        dic[i]=1
    else:
        dic[i]+=1
for i in arr:
    ans=0
    if i not in d:
        for j in dic.keys():
            if i==j:
                t=dic[j]-1    
            else:t = dic[j]
            ans+=(t*(t-1))//2
        d[i]=ans
    print(d[i])

Fixed submission:
n = int(input())
arr = list(map(int,input().split()))
dic = {}
for i in arr:
    if i not in dic:
        dic[i]=1
    else:
        dic[i]+=1
ans=0
for j in dic.keys():
    t=dic[j]
    ans+=(t*(t-1))//2
for i in arr:
    sm = ans-(dic[i]-1)
    print(sm)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int,input().split()))
dic = {}
for i in arr:
    if i not in dic:
        dic[i]=1
    else:
        dic[i]+=1
for i in arr:
    ans=0
    for j in dic.keys():
        if i==j:
            t=dic[j]-1
            
        else:t = dic[j]
        ans+=(t*(t-1))//2
    print(ans)

Fixed submission:
n = int(input())
arr = list(map(int,input().split()))
dic = {}
for i in arr:
    if i not in dic:
        dic[i]=1
    else:
        dic[i]+=1
ans=0
for j in dic.keys():
    t=dic[j]
    ans+=(t*(t-1))//2
for i in arr:
    sm = ans-(dic[i]-1)
    print(sm)
Buggy python submission (verdict: Runtime Error):
x = input()
if x >= 30:
    print("Yes")
else:
    print("No")


Fixed submission:
x = int(input())
if x >= 30:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
rev = False
for _ in range(q):
    query = input()
    if query == "1":
        rev = not rev
    else:
        _, f, c = query.split(" ")
        if f == "1":
            if rev:
                s = s + c
            else:
                s = c + s
        else:
            if rev:
                s = c + s
            else:
                s = s + c

if rev:
    s = s[::-1]
print(s)


Fixed submission:
s = input()
q = int(input())
rev = False
L = ""
R = ""
for _ in range(q):
    query = input()
    if query == "1":
        rev = not rev
    else:
        _, f, c = query.split(" ")
        if f == "1":
            if rev:
                R = R + c
            else:
                L = c + L
        else:
            if rev:
                L = c + L
            else:
                R = R + c

if rev:
    s = s[::-1]
    L = L[::-1]
    R = R[::-1]
    print(R + s + L)
else:
    print(L + s + R)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
queries = []

for _ in range(q):
    query = input()
    if query == "1":
        queries.append({"t": 1})
    else:
        _, f, c = query.split(" ")
        queries.append({"t": 2, "f": int(f), "c": c})

i = 0
while(True):
    if queries[i]["t"] == 1:
        rev = 1
        while(True):
            if i < q-1 and queries[i+1]["t"] == 1:
                rev += 1
                i += 1
            else:
                break
        if rev % 2 == 1:
            s = s[::-1]
        i += 1
    else:
        s = queries[i]["c"] + s if queries[i]["f"] == 1 else s + queries[i]["c"]
        i += 1
    if i > q-1:
        break

print(s)


Fixed submission:
s = input()
q = int(input())
rev = False
L = ""
R = ""
for _ in range(q):
    query = input()
    if query == "1":
        rev = not rev
    else:
        _, f, c = query.split(" ")
        if f == "1":
            if rev:
                R = R + c
            else:
                L = c + L
        else:
            if rev:
                L = c + L
            else:
                R = R + c

if rev:
    s = s[::-1]
    L = L[::-1]
    R = R[::-1]
    print(R + s + L)
else:
    print(L + s + R)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for _ in range(q):
    query = input()
    if query == "1":
        s = s[::-1]
    else:
        _, f, c = query.split(" ")
        s = c + s if f == "1" else s + c

print(s)


Fixed submission:
s = input()
q = int(input())
rev = False
L = ""
R = ""
for _ in range(q):
    query = input()
    if query == "1":
        rev = not rev
    else:
        _, f, c = query.split(" ")
        if f == "1":
            if rev:
                R = R + c
            else:
                L = c + L
        else:
            if rev:
                L = c + L
            else:
                R = R + c

if rev:
    s = s[::-1]
    L = L[::-1]
    R = R[::-1]
    print(R + s + L)
else:
    print(L + s + R)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = input()
a = np.array([int(num) for num in input().split(' ')])

sum = 10000000000
for i in range(1, len(a)):
    sunuke = a[0: i].sum()
    araiguma = a[i:].sum()
    dif = abs(sunuke - araiguma)
    if dif < sum: sum = dif
print(sum)


Fixed submission:
import numpy as np

n = input()
a = np.array([int(num) for num in input().split(' ')])

min = 100000000000
sunuke = 0
araiguma = a.sum()
for i in range(0, len(a) - 1):
    sunuke += a[i]
    araiguma -= a[i]
    dif = abs(sunuke - araiguma)
    if dif < min: min = dif
print(min)
Buggy python submission (verdict: Runtime Error):
n=int(intput())

print(n+n**n+n***n)

Fixed submission:
n = int(input())

print(n + pow(n,2)+pow(n,3))
Buggy python submission (verdict: Runtime Error):
k, n = map(int,input().split())
a = list(map(int, input().split()))
ans1 = max(a) - min(a)
for i in range (0,n):
    if a[i] >= (k/2):
        a[i] = a[i] - k
ans2 = abs(max(a) - min(a))
print(min(ans1,ans2))

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
r=-1
for i in range(1001):
    if i*8//100==a and i*10//100==b:
        r=i
        break
print(r)

Fixed submission:
s = input()
if s == "AAA":
  print("No")
elif s == "BBB":
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
r=-1
for i in range(1001):
    if i*8//100==a and i*10//100==b:
        r=i
        break
print(r)

Fixed submission:
n,a,b=map(int,input().split())
ans = n//(a+b)*a + min(n%(a+b),a)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, *l = map(int, open(0).read().split())
sl = sorted(l,reverse=True)
ans = 0
for i in range (n):
  for j in range (i+1,n):
    for k in range(j+1,n):
      if sl[i]-sl[j] < sl[j] and sl[i]<sl[j]+sl[k]:
        ans = ans + 1
print(ans)

Fixed submission:
a,b=map(int,input().split())
ans = max (0, a - b*2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, *a = map(int, open(0).read().split())

for i in range (1,n+1):
  print(a.index(i)+1, end=" ")


Fixed submission:
n, *a = map(int, open(0).read().split())

ans=[0]*(n)
for i, j in enumerate (a, 1):
  ans[j-1] = i
print(" ".join(map(str,ans)))
Buggy python submission (verdict: Runtime Error):
#一日ごとに晴れ(Sunny)、くもり(Cloudy)、雨(Rainy)、
w = int(input())
if w == "Sunny":
  print("Cloudy")
elif w == "Cloudy":
  print("Rainy")
elif w == "Rainy":
  print("Sunny")
else:
  print("Check")

Fixed submission:
s = input()
if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
elif s == "Rainy":
  print("Sunny")
else:
  print("Check")
Buggy python submission (verdict: Runtime Error):
D = 3 * (r**2)

Fixed submission:
r = int(input())
D = 3 * (r**2)
print(D)

Buggy python submission (verdict: Runtime Error):
D = 3 * r**2

Fixed submission:
r = int(input())
D = 3 * (r**2)
print(D)
Buggy python submission (verdict: Runtime Error):
N,D = map(int,input().split())
if N % (D*2+1) != 0:
  p = n // (d*2+1) + 1
else:
  p = n // (d*2+1)
  
print(p)

Fixed submission:
N,D = map(int,input().split())
if N % (D*2+1) != 0:
  p = N // (D*2+1) + 1
else:
  p = N // (D*2+1)
  
print(p)

Buggy python submission (verdict: Runtime Error):
import math
N, D = map(int, input().split())
person = math.cell(N / (D*2+1))
print(person)


Fixed submission:
N,D = map(int,input().split())
if N % (D*2+1) != 0:
  p = N // (D*2+1) + 1
else:
  p = N // (D*2+1)
  
print(p)

Buggy python submission (verdict: Runtime Error):
import math
N, D = int(input())
person = math.cell(N / (D*2+1))
print(person)

Fixed submission:
N,D = map(int,input().split())
if N % (D*2+1) != 0:
  p = N // (D*2+1) + 1
else:
  p = N // (D*2+1)
  
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lists = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= lists[i]
    if sorted(lists)[0] == 0:
        ans = 0
        break
    if ans > 10**18:
        ans = -1
        break
print(ans)

Fixed submission:
n = int(input())
lists = list(map(int,input().split()))
ans = 1
if sorted(lists)[0] == 0:
    ans = 0
else:
    for i in range(n):
        ans *= lists[i]
        if ans > 10**18:
            ans = -1
            break
print(ans)

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

Fixed submission:
n = int(input())
lists = list(map(int,input().split()))
ans = 1
if sorted(lists)[0] == 0:
    ans = 0
else:
    for i in range(n):
        ans *= lists[i]
        if ans > 10**18:
            ans = -1
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n = 2 or n = 4 or n = 5 or n = 7 or n = 9 :
    print("hon")
elif n = 0 or n = 1 or n = 6 or n = 8 :
    print("pon")
else:
    print("bon")

Fixed submission:
n = input()
if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9" :
    print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8" :
    print("pon")
else:
    print("bon")
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()
if a < 3200:
    print("red")
else:
  	print(b)

Fixed submission:
a = int(input())
s = input()
if a < 3200:
    print("red")
else:
  	print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input().replace(".","")
lists = s.split()
print(lists.count("TAKAHASHIKUN")+lists.count("takahashikun")+lists.count("Takahashikun")

Fixed submission:
print("Yes" if len(set(input()))==3 else"No")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ss = sorted(s)
tt = sorted(t)
print("Yes" if ss < tt[::-1] else "No")


Fixed submission:
a,b =map(int,input().split())
print(-(-(a+b)//2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
 a = (i/2 for i in a )
 ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
	a = [i/2 for i in a ]
	ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
    a = (i/2 for i in a )
    ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
	a = [i/2 for i in a ]
	ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
a = (i/2 for i in a )
ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
	a = [i/2 for i in a ]
	ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
a = (i/2 for i in a )
ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
	a = [i/2 for i in a ]
	ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = int(n**0.5)
print(int(m**2))

Fixed submission:
a = input()
b = input()
print("YES" if a == b[::-1] else"NO")
Buggy python submission (verdict: Runtime Error):
s = input()
all = "abcdefghijklmnopqrstuvwxyz"
ans = sorted(set(s)^set(all)) 
print("None" if ans == 0 else ans[0])

Fixed submission:
s = input()
all = "abcdefghijklmnopqrstuvwxyz"
ans = sorted(set(s)^set(all)) 
print("None" if len(ans) == 0 else ans[0])
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print("GREATER" if a > b else "EQUAL" if a == b else "LESS") 

Fixed submission:
a,b,c = input().split()
print(a[0].upper()+b[0].upper()+c[0].upper())
Buggy python submission (verdict: Runtime Error):
s = input()
print(len(s)-s[::-1].index("z")-s.index("a"))

Fixed submission:
s = input()
print(len(s)-s[::-1].index("Z")-s.index("A"))
Buggy python submission (verdict: Runtime Error):
n,l = map(int,input().split())
s = sorted([input() for i in range(n)] )
print(*s,sep="")

Fixed submission:
a = list(map(int,input().split()))
b = [x for x in a if x !=" "]
c = sorted(b)
d =[5,5,7]
print("YES" if c == d else "NO")
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split()) ans = 'No'
for a in range(X + 1):
b=X-a
if 2 * a + 4 * b == Y:
ans = 'Yes' print(ans)

Fixed submission:
X,Y=map(int, input().split())
ans = 'No'
for a in range(X + 1):
  b=X-a
  if 2 * a + 4 * b == Y:
    ans = 'Yes'
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%10=7:
  print('Yes')
else:
  n=n//10
  if n%10=7:
    print('Yes')
  else if n//10=7:
    print('Yes')
  else:
    print('No')



Fixed submission:
n = int(input())
if n%10==7:
  print('Yes')
else:
  n=n//10
  if n%10==7:
    print('Yes')
  elif n//10==7:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a,b = (int, input().split())
if a*b%2 == 0:
  print("Even")
else:
  print("Odd")

Fixed submission:
a,b = map(int, input().split())
if (a*b)%2 == 0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
temp = input()
if temp > 30:
    print('Yes')
else:
    print('No')

Fixed submission:
if int(input()) >= 30:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
if k%2==0:
    print(-1)
else:
    n=7
    cnt=1
    while n%k!=0:
        n=(n*10+7)%k
        cnt+=1
    print(cnt)

Fixed submission:
k=int(input())
if k%2==0:
    print(-1)
else:
    n=7
    cnt=1
    l={}
    while n%k!=0:
        if n not in l:
            l[n]=1
        else:
            print(-1)
            exit()
        n=(n*10+7)%k
        cnt+=1
    print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))

s1=1
for i in range(k):
    s1*=a[i]

s2=1
for i in range(n-k):
    s2=s1*a[i+k]//a[i]
    if s2>s1:
        print("Yes")
    else:
        print("No")
    s1=s2

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

for i in range(n-k):
    if a[i]<a[i+k]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
from decimal import Decimal
ans=Decimal(a)*Decimal(b)
print(int(ans))a,b=input().split()
from decimal import Decimal
ans=Decimal(a)*Decimal(b)
print(int(ans))

Fixed submission:
a,b=input().split()
from decimal import Decimal
ans=Decimal(a)*Decimal(b)
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

p=[0]*n
p[0]=1
now=1
cnt=0
while 0 in p and cnt<=m:
    for to in l[now-1]:
        if p[to]==0:
            p[to]=now
            cnt+=1
    now=to+1
if 0 in p:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(p[i])

Fixed submission:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

from collections import deque

p=[0]*n
ans=[0]*n
d=deque()
d.append(0)
while len(d)!=0:
    now=d.popleft()
    for to in l[now]:
        if p[to]==0:
            p[to]=p[now]+1
            d.append(to)
            ans[to]=now
print("Yes")
for i in range(1,n):
    print(ans[i]+1)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

p=[0]*n
p[0]=1
now=1
cnt=0
while 0 in p and k>0:
    for to in l[now-1] and cnt<=m:
        if p[to]==0:
            p[to]=now
            cnt+=1
    now=to+1
    k-=1
if 0 in p:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(p[i])



Fixed submission:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

from collections import deque

p=[0]*n
ans=[0]*n
d=deque()
d.append(0)
while len(d)!=0:
    now=d.popleft()
    for to in l[now]:
        if p[to]==0:
            p[to]=p[now]+1
            d.append(to)
            ans[to]=now
print("Yes")
for i in range(1,n):
    print(ans[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

p=[0]*n
p[0]=1
now=1
cnt=1
k=10**8
while 0 in p and k>0:
    for to in l[now-1]:
        if p[to]==0:
            p[to]=now
    now=to+1
    cnt+=1
    k-=1
if 0 in p:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(p[i])



Fixed submission:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

from collections import deque

p=[0]*n
ans=[0]*n
d=deque()
d.append(0)
while len(d)!=0:
    now=d.popleft()
    for to in l[now]:
        if p[to]==0:
            p[to]=p[now]+1
            d.append(to)
            ans[to]=now
print("Yes")
for i in range(1,n):
    print(ans[i]+1)
Buggy python submission (verdict: Runtime Error):
MOD=10**9+7
n=int(input())
p=[]
m=[]
for i in range(n):
    a,b=map(int,input().split())
    if a*b<0:
        m.append(a*b)
    else:
        p.append(a*b)
m.sort()
p=sorted(p,reverse=True)
r=0
l=0
cnt=0
while l<len(m) and r<len(p):
    if p[r]+m[l]>0:
        l+=1
    elif p[r]+m[l]<0:
        r+=1
    else:
        print(0)
        cnt+=1
        if len(m)-l<len(p)-r:
            r+=1
        else:
            l+=1
if l==len(m):
    cnt+=p.count(m[-1])
else:
    cnt+=m.count(p[-1])
print(cnt)
ans=(pow(2,n,MOD)-1-pow(2,n-2,MOD)*cnt)%MOD

print(ans)

Fixed submission:
import functools
MOD=10**9+7

def euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b)

def gcd(nums):
  return functools.reduce(euclid, nums)

n=int(input())
t=[]
for i in range(n):
    a,b=map(int,input().split())
    t.append((a,b))
z=0
y={}
for i in range(n):
    if t[i][0]==0 and t[i][1]==0:
        z+=1
    else:
        g=abs(gcd([t[i][0],t[i][1]]))
        if t[i][1]==0:
            a=(1,0)
        elif t[i][1]>0:
            a=(t[i][0]//g , t[i][1]//g)
        else:
            a=(-t[i][0]//g , -t[i][1]//g)
        if a not in y:
            y[a]=1
        else:
            y[a]+=1

cnt=0
x=1
for i in y:
    if (-i[1],i[0]) in y:
        x  *= pow(2,y[(-i[1],i[0])],MOD) + pow(2,y[(i[0],i[1])],MOD)-1
        cnt+= y[(-i[1],i[0])] + y[(i[0],i[1])]

ans = pow(2,n-z-cnt,MOD) *x -1
print((ans+z)%MOD)