Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
if A[0] == A[1]:
    pre = 0
elif A[0] > A[1]:
    pre = -1
else:
    pre = 1
prevalue = A[1]
ans = 0
for a in A[2:]:
    if a > prevalue:
        if pre == -1:
            ans += 1
            pre = 0
        else:
            pre = 1
    elif a < prevalue:
        if pre == 1:
            ans += 1
            pre = 0
        else:
            pre = -1
    prevalue = a
print(ans+1)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
if N == 1:
    print(1)
else:
    if A[0] == A[1]:
        pre = 0
    elif A[0] > A[1]:
        pre = -1
    else:
        pre = 1
    prevalue = A[1]
    ans = 0
    for a in A[2:]:
        if a > prevalue:
            if pre == -1:
                ans += 1
                pre = 0
            else:
                pre = 1
        elif a < prevalue:
            if pre == 1:
                ans += 1
                pre = 0
            else:
                pre = -1
        prevalue = a
    print(ans+1)
Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
temp = S[-1]
for s in S[-2::-1]:
    if s != temp:
        count += 1
    temp = s
print(0 if count == 0 else temp-1)

Fixed submission:
S = input()
count = 0
temp = S[-1]
for s in S[-2::-1]:
    if s != temp:
        count += 1
    temp = s
print(0 if count == 0 else count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
la = list(map(int, input().split()))
ans = 0
for i in range(n-1):
  ans = (ans%(10**9+7) + la[i+1]*sum(la[:i+1])%(10**9+7))%(10**9+7)
print(ans)

Fixed submission:
n = int(input())
la = list(map(int, input().split()))
MOD = (10**9+7)
ans = 0
nn = 0
for i in range(n):
  ans %= MOD
  ans += la[i]%MOD
  nn %= MOD
  nn += (la[i]**2)%MOD
ans = (ans**2-nn+10**9+7)*pow(2, -1, MOD)%MOD
print(ans)

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

Fixed submission:
n = int(input())
la = list(map(int, input().split()))
MOD = (10**9+7)
ans = 0
nn = 0
for i in range(n):
  ans %= MOD
  ans += la[i]%MOD
  nn %= MOD
  nn += (la[i]**2)%MOD
ans = (ans**2-nn+10**9+7)*pow(2, -1, MOD)%MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w,m = map(int, input().split())

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

if h == 1 or w == 1:
  print(m)
else:
  from collections import Counter as co
  ch=co(lh).most_common()

  tmp = ch[0][0]
  lh_c = [i for i, x in enumerate(lh) if x == tmp]
  for j in sorted(lh_c, reverse=True):
    lw.pop(j)
  cw = co(lw).most_common()
  ans = ch[0][1]+cw[0][1]

  print(ans)

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

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

if h == 1 or w == 1:
  print(m)
else:
  from collections import Counter as co
  ch=co(lh).most_common()
  cw=co(lw).most_common()
  
  ans = 0
  tmp = ch[0][0]
  lh_c = [i for i, x in enumerate(lh) if x == tmp]
  lw_tmp = lw[:]
  for j in sorted(lh_c, reverse=True):
    lw_tmp.pop(j)
  if len(lw_tmp) == 0:
    print(ch[0][1])
  else:
    cw_tmp = co(lw_tmp).most_common()
    ans = ch[0][1]+cw_tmp[0][1]
    
    tmp = cw[0][0]
    lw_c = [i for i, x in enumerate(lw) if x == tmp]
    lh_tmp = lh[:]
    for j in sorted(lw_c, reverse=True):
      lh_tmp.pop(j)
    if len(lh_tmp) == 0:
      print(cw[0][1])
    else:
      ch_tmp = co(lh_tmp).most_common()
      ans = max(ans, cw[0][1]+ch_tmp[0][1])
      print(ans)

Buggy python submission (verdict: Runtime Error):
h,w,m = map(int, input().split())

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

from collections import Counter as co
c=co(lh).most_common()

ans1 = c[0][1]
ans2 = 0
i = 0
while c[i][1] == c[0][1]:
  tmp = c[i][0]
  lh_c = [j for j, x in enumerate(lh) if x == tmp]
  tmp_lw = lw[:]
  for k in sorted(lh_c, reverse=True):
    tmp_lw.pop(k)
  cw = co(tmp_lw).most_common()
  ans2 = max(ans2, cw[0][1])
  i += 1
  if i >= len(c)-1:
    break
  
print(ans1+ans2)

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

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

if h == 1 or w == 1:
  print(m)
else:
  from collections import Counter as co
  ch=co(lh).most_common()
  cw=co(lw).most_common()
  
  ans = 0
  tmp = ch[0][0]
  lh_c = [i for i, x in enumerate(lh) if x == tmp]
  lw_tmp = lw[:]
  for j in sorted(lh_c, reverse=True):
    lw_tmp.pop(j)
  if len(lw_tmp) == 0:
    print(ch[0][1])
  else:
    cw_tmp = co(lw_tmp).most_common()
    ans = ch[0][1]+cw_tmp[0][1]
    
    tmp = cw[0][0]
    lw_c = [i for i, x in enumerate(lw) if x == tmp]
    lh_tmp = lh[:]
    for j in sorted(lw_c, reverse=True):
      lh_tmp.pop(j)
    if len(lh_tmp) == 0:
      print(cw[0][1])
    else:
      ch_tmp = co(lh_tmp).most_common()
      ans = max(ans, cw[0][1]+ch_tmp[0][1])
      print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(0 if a%1000 == 0 else 1000-a%1000)

Fixed submission:
n = int(input())
print(0 if n%1000 == 0 else 1000-n%1000)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [input() for i in range(N)]
for v in ['AC', 'WA', 'TLE', 'RE']:
print('{0} x {1}'.format(v, s.count(v)))

Fixed submission:
n = int(input())
c1 = 0
c2 = 0
c3 = 0
c4 = 0
for i in range(n):
  s = str(input()) 
  if s == "AC":
    c1 += 1
  if s== "WA":
    c2 += 1
  if s == "TLE":
    c3 += 1
  if s == "RE":
    c4 += 1

print("AC x " + str(c1))
print("WA x " + str(c2))
print("TLE x " + str(c3))
print("RE x " + str(c4))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
la = list(map(int, input().split()))
q = int(input())
sa = sum(la)
for i in range(q):
  b, c = map(int, input().split())
  cnt = la.count(b)
  sa += (c-b)*cnt
  print(sa)
  
  la += [c]*cnt

Fixed submission:
n = int(input())
la = list(map(int, input().split()))
sa = sum(la)
l_cnt = [0]*100001
for i in la:
  l_cnt[i] += 1
q = int(input())
for i in range(q):
  b, c = map(int, input().split())
  sa += (c-b)*l_cnt[b]
  print(sa)  
  l_cnt[c] += l_cnt[b]
  l_cnt[b] = 0

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
la = list(map(int, input().split()))
q = int(input())
sa = sum(la)
lc = []
for i in range(q):
  b, c = map(int, input().split())
  cnt1 = la.count(b)
  cnt2 = lc.count(b)
  sa += (c-b)*(cnt1+cnt2)  
  print(sa)
  
  lc += [c]*cnt1

Fixed submission:
n = int(input())
la = list(map(int, input().split()))
sa = sum(la)
l_cnt = [0]*100001
for i in la:
  l_cnt[i] += 1
q = int(input())
for i in range(q):
  b, c = map(int, input().split())
  sa += (c-b)*l_cnt[b]
  print(sa)  
  l_cnt[c] += l_cnt[b]
  l_cnt[b] = 0

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
la = list(map(int, input().split()))
q = int(input())
ls = sum(la)
lc = []
lc_cnt = []
for i in range(q):
  b, c = map(int, input().split())
  cnt = la.count(b)
  if lc.count(b) > 0:
    j = 0
    for k in lc:
      cnt += lc_cnt[j] if k == b else 0
      j += 1
  ls += (c-b)*cnt
  
  lc.append(c)
  lc_cnt.append(cnt)
  print(ls)

Fixed submission:
n = int(input())
la = list(map(int, input().split()))
sa = sum(la)
l_cnt = [0]*100001
for i in la:
  l_cnt[i] += 1
q = int(input())
for i in range(q):
  b, c = map(int, input().split())
  sa += (c-b)*l_cnt[b]
  print(sa)  
  l_cnt[c] += l_cnt[b]
  l_cnt[b] = 0
Buggy python submission (verdict: Runtime Error):
n = int(input())
la = list(map(int, input().split()))
import sys
if la.index(0) > 0:
  print(0)
  sys.exit()

ans = 1
for i in la:
  ans *= i
  if ans > 10**18:
    print(-1)
    sys.exit()
print(ans)

Fixed submission:
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
      
n = int(input())
la = list(map(int, input().split()))
import sys
if my_index(la, 0) > 0:
  print(0)
  sys.exit()

ans = 1
for i in la:
  ans *= i
  if ans > 10**18:
    print(-1)
    sys.exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
la = list(map(int, input().split()))
import functools
import operator

ans = functools.reduce(operator.mul, la)
if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
      
n = int(input())
la = list(map(int, input().split()))
import sys
if my_index(la, 0) > 0:
  print(0)
  sys.exit()

ans = 1
for i in la:
  ans *= i
  if ans > 10**18:
    print(-1)
    sys.exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
la = list(map(int, input().split()))
ans = 1
for i in la:
  ans *= i

if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
      
n = int(input())
la = list(map(int, input().split()))
import sys
if my_index(la, 0) > 0:
  print(0)
  sys.exit()

ans = 1
for i in la:
  ans *= i
  if ans > 10**18:
    print(-1)
    sys.exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
la = list(map(int, input().split()))
for i in range(n):
  print(la.count(i+1))

Fixed submission:
import collections
n = int(input())
la = list(map(int, input().split()))
c = collections.Counter(la)

for i in range(1,n+1):
  print(c[i])
Buggy python submission (verdict: Runtime Error):
n = str(input())
if n[0]='7' or n[1]='7' or n[2]='7':
  print("Yes")
else:
  print("No")

Fixed submission:
n = str(input())
a=n[0]
b=n[1]
c=n[2]

if a=='7' or b=='7' or c=='7':
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m = (int(x) for x in input().split())

if n==1:
  if m==1:
    print(0)
  else:
    print(comb(m, 2))
elif m==1:
  print(comb(n, 2))
else:
  print(comb(n, 2)+comb(m, 2))

Fixed submission:
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m = (int(x) for x in input().split())

if n<=1:
  if m<=1:
    print(0)
  else:
    print(comb(m, 2))
elif m<=1:
  print(comb(n, 2))
else:
  print(comb(n, 2)+comb(m, 2))
Buggy python submission (verdict: Runtime Error):
import math

a,b = (int(x) for x in input().split())
amin = math.ceil(float(a/0.08))
amax = math.floor(float((a+1)/0.08))
bmin = math.ceil(float(b/0.1))
bmax = math.floor(float((b+1)/0.1))

if amax < bmin or bmax < amin:
  print(-1)
else:
  la = list(range(amin,amax))
  lb = list(range(bmin,bmax))
  print(min(set(la) & set(lb)))

Fixed submission:
import math

a,b = (int(x) for x in input().split())
if (a*100)%8 == 0:
  amin = int(a/0.08)
else:
  amin = math.ceil(a/0.08)
if ((a+1)*100)%8 == 0:
  amax = int((a+1)/0.08)-1
else:
  amax = math.floor((a+1)/0.08)

if (b*100)%10 == 0:
  bmin = int(b/0.1)
else:
  bmin = math.ceil(b/0.1)
if ((b+1)*100)%10 == 0:
  bmax = int((b+1)/0.1)-1
else:
  bmax = math.floor((b+1)/0.1)
  
if amax < bmin or bmax < amin:
  print(-1)
else:
  la = list(range(amin,amax))
  lb = list(range(bmin,bmax))
  print(min(set(la) & set(lb)))
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
q = int(input())
b = 1
for i in range(q):
  la = input()
  if la == "1":
    b ^= 1
  else:
    a,f,c = la.split()
    if (int(f)-1)^b:s=c+s
    else:s=s+c
      
print(s if b==1 else s[::-1])

Fixed submission:
s = str(input())
q = int(input())
b = 1
x=''
y=''
for i in range(q):
  la = input()
  if la == "1":
    b ^= 1
  else:
    a,f,c=la.split()
    if f == "1":
      if b==1:x=c+x
      else:y=y+c
    else:
      if b==1:y=y+c
      else:x=c+x
s = x+s+y      
print(s if b==1 else s[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
q = int(input())
b = 1
for i in range(q):
  la = input()
  if la == "1":
    b ^= 1
  else:
    a,f,c = la.split()
    if f == "1":
      s = c+s if b==1 else s+c
    else:
      s = s+c if b==1 else c+s
      
print(s if b==1 else s[::-1])

Fixed submission:
s = str(input())
q = int(input())
b = 1
x=''
y=''
for i in range(q):
  la = input()
  if la == "1":
    b ^= 1
  else:
    a,f,c=la.split()
    if f == "1":
      if b==1:x=c+x
      else:y=y+c
    else:
      if b==1:y=y+c
      else:x=c+x
s = x+s+y      
print(s if b==1 else s[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
q = int(input())
b = 1
for i in range(q):
  la = input()
  if la == "1":
    b ^= 1
  else:
    a,f,c = la.split()
    if f == "1":
      s = c+s if b==1 else s+c
    else:
      s = s+c if b==1 else c+s
      
print(s if b==1 else s[::-1])

Fixed submission:
s = str(input())
q = int(input())
b = 1
x=''
y=''
for i in range(q):
  la = input()
  if la == "1":
    b ^= 1
  else:
    a,f,c=la.split()
    if f == "1":
      if b==1:x=c+x
      else:y=y+c
    else:
      if b==1:y=y+c
      else:x=c+x
s = x+s+y      
print(s if b==1 else s[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,k = (int(x) for x in input().split())
ln = list(map(float, input().split()))
ln_mean=[1+0.5*(x-1) for x in ln]
#print(ln_mean)

lnk = [0]*(n - k + 1)
for i in range(n - k + 1):
  tmp_lnk = ln_mean[i:i+k]
  lnk[i] = sum(tmp_lnk)

print(max(lnk))

Fixed submission:
n,k = (int(x) for x in input().split())
ln = list(map(float, input().split()))
ln_mean=[1+0.5*(x-1) for x in ln]
#print(ln_mean)

if n == k:
  print(sum(ln_mean))
else:
  lnk = [0]*(n-k+1)
  m_in = 0
  for i in range(k):
    m_in += ln_mean[i]
  m_max = m_in
  tmp_max = m_in
  for i in range(n-k):
    tmp_max = tmp_max - ln_mean[i] + ln_mean[i+k]
    if m_max < tmp_max:
      m_max = tmp_max
  print(m_max)
Buggy python submission (verdict: Runtime Error):
K = int(input())
S = input()
if len(S)<=K:
  print(S)
else:
  print(S[0]+S[1]+S[2]+S[3]+S[4]+S[5]+S[6]+"...")

Fixed submission:
K = int(input())
S = input()
if len(S)<=K:
  print(S)
else:
  print(S[0:K]+"...")
Buggy python submission (verdict: Runtime Error):
S = input()
if S = "ABC":
  print("ARC")
elif S = "ARC":
  print("ABC")

Fixed submission:
S = input()
if S[1]=="B":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

point = 1
points = []
for i in range(n):
    point *= a[i]
    if i >= k - 1:
        points.append(point)
        if i >= k:
            if points[-1] > points[-2]:
                print("Yes")
            else:
                print("No")
        point //= a[i - k + 1]

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
"""
point = 1
points = []

for i in range(n):
    point *= a[i]
    if i >= k - 1:
        points.append(point)
        if i >= k:
            if points[-1] > points[-2]:
                print("Yes")
            else:
                print("No")
        point //= a[i - k + 1]
"""
for i in range(n):
    if i >= k:
        if a[i] > a[i - k]:
            print("Yes")
        else:
            print("No")
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
from bisect import bisect_left

n, m, k = map(int, input().split())
a = [0] + list(accumulate(list(map(int, input().split()))))
b = [0] + list(accumulate(list(map(int, input().split()))))
ans = 0

for i in range(n + 1):
    if a[i] + b[bisect_left(b, k - a[i])] <= k:
        ans = max(ans, i + bisect_left(b, k - a[i]))
    
print(ans)

Fixed submission:
from itertools import accumulate

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

c = [0] + list(accumulate(a))
d = [0] + list(accumulate(b))

ans = 0
i = 0
j = len(b)

while True:
    num = c[i] + d[j]
    if num > k and j >= 1:
        while True:
            j -= 1
            if j == 0 or c[i] + d[j] <= k:
                break
    if c[i] + d[j] <= k:
        ans = max(ans, i + j)
    if i == len(a):
        break
    while True:
        i += 1
        if i == len(a) or c[i] + d[j] > k:
            i -= 1
            break
    if c[i] + d[j] <= k:
        ans = max(ans, i + j)
    i += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
cnt = [0] * (n + 1)

for i in range(1, n + 1):
    for j in range(1, n // i + 1):
        cnt[i * j] += 1

ans = 0
for i in range(1, n + 1):
    ans += cnt[i] * i

print(ans)

Fixed submission:
n = int(input())
cnt = [0] * (n + 1)

for i in range(1, n + 1):
    for j in range(1, n // i + 1):
        cnt[i * j] += 1

ans = 0
for i in range(1, n + 1):
    ans += cnt[i] * i

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = n
for i in range(20):
    tmp = 0
    for j in range(1, i):
        tmp += 26 ** j
    if 26 ** (i - 2) < n <= tmp:
        digit = i - 1
        break
ans = ""
"""
for i in range(digit)[::-1]:
    ans += chr(96 + n // (26 ** i))
    print(n // (26 ** i))
    n = n % (26 ** i)
print(ans)
"""
for i in range(digit)[::-1]:
    m = n // 26 ** i
    if m == 27:
        n -= (m - 1) * 26 ** i
        ans += chr(96 + (m - 1))
    else:
        n -= m * 26 ** i
        ans += chr(96 + m)

print(ans)

Fixed submission:
N = int(input())
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i

print(ans[::-1])
Buggy python submission (verdict: Runtime Error):
import bisect

x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))
tmp = []

for i in range(1, 101):
    if i not in p:
        tmp.append((abs(i - x), i))

print(min(tmp)[1])

Fixed submission:
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))
tmp = []

for i in range(-1, 103):
    if i not in p:
        tmp.append((abs(i - x), i))

print(min(tmp)[1])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k):
    b = [0] * (n + 1)
    for j in range(n):
        b[max(0, j - a[j])] += 1
        b[min(n, j + a[j] + 1)] -= 1
    a = list(accumulate(b))
    if sum(a) == n ** 2:
        a.pop()
        print(*a)
        exit()

a.pop()
print(*a)

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

for i in range(k):
    b = [0] * (n + 1)
    for j in range(n):
        b[max(0, j - a[j])] += 1
        b[min(n, j + a[j] + 1)] -= 1
    a = list(accumulate(b))
    if sum(a) == n ** 2:
        a.pop()
        print(*a)
        exit()

a.pop()
print(*a)

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

for i in range(k):
    tmpa = a[:]
    b = [0] * n
    for j in range(n):
        for k in range(-tmpa[j], tmpa[j] + 1):
            if 0 <= j + k < n:
                b[j + k] += 1
    a = b[:]
    if sum(a) == n ** 2:
        break

print(*b)

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

for i in range(k):
    b = [0] * (n + 1)
    for j in range(n):
        b[max(0, j - a[j])] += 1
        b[min(n, j + a[j] + 1)] -= 1
    a = list(accumulate(b))
    if sum(a) == n ** 2:
        a.pop()
        print(*a)
        exit()

a.pop()
print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]

if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)

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

n, m = map(int, input().split())
path = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    path[a].append(b)
    path[b].append(a)

ans = [0] * (n - 1) 
seen = deque([1])
not_seen = [True] * n
not_seen[0] = False

while sum(not_seen) > 0:
    pre = seen.popleft()
    for now in path[pre]:
        if not_seen[now - 1]:
            #print(now, pre)
            seen.append(now)
            ans[now - 2] = pre
            not_seen[now - 1] = False
            #print(ans)

print("Yes")
for i in ans:
    print(i)



Fixed submission:
from collections import deque

n, m = map(int, input().split())
path = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    path[a].append(b)
    path[b].append(a)

ans = [0] * (n - 1) 
seen = deque([1])
not_seen = [True] * n
not_seen[0] = False
cnt = n - 1

while cnt > 0:
    pre = seen.popleft()
    for now in path[pre]:
        if not_seen[now - 1]:
            seen.append(now)
            ans[now - 2] = pre
            not_seen[now - 1] = False
            cnt -= 1

print("Yes")
for i in ans:
    print(i)

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

ans = [0] * (n - 1) 
seen = [1]
not_seen = [True] * n
not_seen[0] = False

while sum(not_seen) > 0:
    pre = seen.pop(0)
    for now in path[pre]:
        if not_seen[now - 1]:
            #print(now, pre)
            seen.append(now)
            ans[now - 2] = pre
            not_seen[now - 1] = False
            #print(ans)

print("Yes")
for i in ans:
    print(i)



Fixed submission:
from collections import deque

n, m = map(int, input().split())
path = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    path[a].append(b)
    path[b].append(a)

ans = [0] * (n - 1) 
seen = deque([1])
not_seen = [True] * n
not_seen[0] = False
cnt = n - 1

while cnt > 0:
    pre = seen.popleft()
    for now in path[pre]:
        if not_seen[now - 1]:
            seen.append(now)
            ans[now - 2] = pre
            not_seen[now - 1] = False
            cnt -= 1

print("Yes")
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = int(input())
A = []
for i in range(d):
    a = list(map(int, input().split()))
    A += a
A_ = set(A)
print(n - len(A_))

Fixed submission:
n, k = map(int, input().split())
A = []
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    A += a
A_ = set(A)
print(n - len(A_))