Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=sorted(map(int,input().split()))[::-1]
ans=A[0]
while True:
    M=A[0]
    m=A[1]
    del A[0]
    if m==0:break
    A.append(M%m)
    A=sorted(A)[::-1]
    ans=min(ans,A[0])
print(ans)

Fixed submission:
import heapq

N=int(input())
A=sorted(map(int,input().split()))[::-1]
que = []
for x in A:
    heapq.heappush(que, -x)

ans=A[0]
while len(que) > 1:
    v1 = abs(heapq.heappop(que))
    v2 = abs(heapq.heappop(que))
    if v2 == 0:
        print (v1)
        break
    heapq.heappush(que, -(v1 % v2))
    heapq.heappush(que, -(v2))
Buggy python submission (verdict: Runtime Error):
#!/bin/python3
mod=10**9+7
from math import gcd
h,w,t=map(int,input().split())
gh,gw=gcd(h,t),gcd(w,t)
h1,w1=h//gh,w//gw
print(
		pow(
			pow(2,w1,mod)+
			pow(2,h1,mod)+
			(mod-1)+
			pow(2,gcd(h1,w1),mod)+mod-2
			,gh*gw,mod)
		)


Fixed submission:
mod=10**9+7
from fractions import gcd
h,w,t=map(int,input().split())
gh,gw=gcd(h,t),gcd(w,t)
h1,w1=h//gh,w//gw
print(
		pow(
			pow(2,w1,mod)+
			pow(2,h1,mod)+
			(mod-1)+
			pow(2,gcd(h1,w1),mod)+mod-2
			,gh*gw,mod)
		)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
count = 0
SCount = [0]*N
new = True

for i in range(N):
  new = True
  sj = input()
  sj = list(sj)
  sj.sort()
  for i in range(len(S)):
    if S[i] == sj:
      SCount[i]+=1
      count+=SCount[i]
      new = False
  if new == True:
      S.append(sj)
print(count)

Fixed submission:
#n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
n = int(input())
sl = []
for i in range(n):
  S = ''.join(sorted(input()))
  sl.append(S)
count = 0
dict ={}

for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
  s = input()
  s = list(s)
  s.sort()
  S.append(s)

count = 0
for i in range(len(S)-1):
  for j in range(len(S)-i-1):
    k=j+i+1
    if S[i] == S[k]:
      count += 1
print(count)

Fixed submission:
#n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
n = int(input())
sl = []
for i in range(n):
  S = ''.join(sorted(input()))
  sl.append(S)
count = 0
dict ={}

for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
  s = input()
  s = list(s)
  s.sort()
  S.append(s)

count = 0
for si in S:
  for sj in S:
    if si == sj:
      count += 1
ans = int((count - N)/2)
print(ans)

Fixed submission:
#n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
n = int(input())
sl = []
for i in range(n):
  S = ''.join(sorted(input()))
  sl.append(S)
count = 0
dict ={}

for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)
Buggy python submission (verdict: Runtime Error):
N,Q = map(int,input().split())
Ki_Oya=dict()
Ki_Dict=dict()
Ki_Count=dict()
for i in range(N-1):
  A,B = input().split()
  if A not in Ki_Dict:
    Ki_Dict[A]=set(A)
    Ki_Count[A]=0
    Ki_Oya[A]=set(A)
  if B not in Ki_Dict:
    Ki_Dict[B]=set(B)
    Ki_Count[B]=0
    Ki_Oya[B]=set(B)|Ki_Oya[A]
  Ki_Dict[A]|set(B)
  if A in Ki_Oya:
    for j in list(Ki_Oya[A]):
      Ki_Dict[j]|set(B)

for i in range(Q):
  P,X = input().split()
  X = int(X)
  for i in list(Ki_Dict[P]):
    Ki_Count[i] += X
Ki_List = list(Ki_Dict.keys())
ans=[]
for i in Ki_List:
  ans.append(str(Ki_Count[i]))
print(" ".join(ans))

Fixed submission:
N,Q = map(int,input().split())
Ki_Oya=dict()
for i in range(N-1):
  A,B = map(int,input().split())
  Ki_Oya[B-1]=A-1
Counter_list=[0]*N
for i in range(Q):
  P,X=map(int,input().split())
  Counter_list[P-1] += X
print(Counter_list[0],end=" ")
for i in range(1,len(Counter_list)):
  Counter_list[i] += Counter_list[Ki_Oya[i]]
  print(Counter_list[i],end=" ")
print("")

Buggy python submission (verdict: Runtime Error):
N,Q = map(int,input().split())
Ki_Oya=dict()
Ki_Dict=dict()
Ki_Count=dict()
for i in range(N-1):
  A,B = input().split()
  if A not in Ki_Dict:
    Ki_Dict[A]=set(A)
    Ki_Count[A]=0
    Ki_Oya[A]=set(A)
  if B not in Ki_Dict:
    Ki_Dict[B]=set(B)
    Ki_Count[B]=0
    Ki_Oya[B]=Ki_Oya[A]
  
  Ki_Dict[A].add(B)
  if A in Ki_Oya:
    for j in list(Ki_Oya[A]):
      Ki_Dict[j].add(B)

for i in range(Q):
  P,X = input().split()
  X = int(X)
  for i in list(Ki_Dict[P]):
    Ki_Count[i] += X
Ki_List = list(Ki_Dict.keys())
ans=[]
for i in Ki_List:
  ans.append(str(Ki_Count[i]))
print(" ".join(ans))

Fixed submission:
N,Q = map(int,input().split())
Ki_Oya=dict()
for i in range(N-1):
  A,B = map(int,input().split())
  Ki_Oya[B-1]=A-1
Counter_list=[0]*N
for i in range(Q):
  P,X=map(int,input().split())
  Counter_list[P-1] += X
print(Counter_list[0],end=" ")
for i in range(1,len(Counter_list)):
  Counter_list[i] += Counter_list[Ki_Oya[i]]
  print(Counter_list[i],end=" ")
print("")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
m=max(l)
for i in range(n):
  if l[i] == m:
    a = l[i]
    l[i] = 0
    print(max(l))
    l[i] = a
  else:print(m)

Fixed submission:
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
m=max(l)
a=l.index(m)
for i in range(n):
  if i==a:
    l[i]=0
    print(max(l)) 
  else:print(m)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
for i in range(n):
  a = l[i]
  l[i] = 0
  print(max(l))
  l[i] = a

Fixed submission:
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
m=max(l)
a=l.index(m)
for i in range(n):
  if i==a:
    l[i]=0
    print(max(l)) 
  else:print(m)
Buggy python submission (verdict: Runtime Error):
K = input()
X = input()

if (X <= 500*K):
    print("Yes")
else:
    print("No")

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

if (X <= 500*K):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):

K = input()
X = input()

if (X <= 500*K):
    print("Yes")
else:
    print("No")

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

if (X <= 500*K):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):

def fn(i):
    return (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999)


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

    x = list(range(n + 1)[1:])
    x = filter(fn, x)

    print(len(x))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())

    c = 0
    for i in range(n + 1)[1:]:
        if len(str(i)) % 2 == 1:
            c += 1

    print(c)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())

    x = list(range(n + 1)[1:])
    x = filter(lambda i: (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999), x)

    print(len(x))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())

    c = 0
    for i in range(n + 1)[1:]:
        if len(str(i)) % 2 == 1:
            c += 1

    print(c)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    s = input()
    max_len = 0
    length = 0

    for i in list(s).append(''):
        if i in ['A', 'C', 'G', 'T']:
            length += 1
        else:
            if length > max_len:
                max_len = length
                length = 0


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    s = input()
    max_len = 0
    length = 0

    s = list(s)
    s.append('')

    for i in s:
        if i in ['A', 'C', 'G', 'T']:
            length += 1
        else:
            if length > max_len:
                max_len = length
                length = 0

    print(max_len)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    INF = 2 ** 60
    n, k = map(int, input().split())
    hs = list(map(int, input().split()))

    dp = [INF for _ in range(n)]
    dp[0] = 0

    for i in range(n):
        for j in range(1, k + 1):
            if i + j >= n:
                break
            dp[i + j] = min(dp[i + j], dp[i] + abs(hs[i] - hs[i + j]))

    print(dp[-1])


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    INF = 2 ** 60
    n, k = map(int, input().split())
    hs = list(map(int, input().split()))

    dp = [INF for _ in range(n)]
    dp[0] = 0

    for i in range(n):
        for j in range(1, k + 1):
            if i + j >= n:
                break
            dp[i + j] = min(dp[i + j], dp[i] + abs(hs[i] - hs[i + j]))

    print(dp[-1])


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


def main():
    a, b, c, x, y = map(int, input())

    min_price = None

    for i in range(max(x, y) + 1):
        nc = i * 2
        na = x - i
        if na < 0:
            na = 0
        nb = y - i
        if nb < 0:
            nb = 0

        price = na * a + nb * b + nc * c
        if min_price is None or price < min_price:
            min_price = price

    print(min_price)


if __name__ == '__main__':
    main()


Fixed submission:
import sys


def main():
    a, b, c, x, y = map(int, input().split())

    min_price = None

    for i in range(max(x, y) + 1):
        nc = i * 2
        na = x - i
        if na < 0:
            na = 0
        nb = y - i
        if nb < 0:
            nb = 0

        price = na * a + nb * b + nc * c
        if min_price is None or price < min_price:
            min_price = price

    print(min_price)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(A-2B)


Fixed submission:
A, B = map(int, input().split())
if A-2*B > 0:
  print(A-2*B)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
dic = {}
dic2 = {}
A = list(map(int, input().split()))
k = []
ANS = []
for i in range(1, N+1):
  k.append(i)

dic = dict(zip(k, A))
dic2 = dict(sorted(dic.items(), key=lambda x:x[1]))

for key in dic2:
  ANS.append(key)

for b in range(N):
  print(ANS[b], end=" \n"[b + 1 == N

Fixed submission:
N = int(input())
d = []

A = list(map(int, input().split()))
k = []
ANS = []
for i in range(1, N+1):
  k.append(i)

d = list(zip(k, A))
d.sort(key=lambda x:x[1])

for b in range(N):
  print(d[b][0], end=" \n"[b + 1 == N])
Buggy python submission (verdict: Time Limit Exceeded):
N, k, Q = map(int, input().split())
A =[]

j = 0
c = 0
 
def calc_de(n):
    return n - 1
 

A = [int(input()) for index in range(Q)]
 
S = [k]*N
 
for j in A:
    S = list(map(calc_de, S))
    S[j-1] += 1
 
for c in range(N):
    if S[c] > 0:
        print('Yes')
    else:
        print('No')

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

A = [K]*N
C = [0]*N

for r in range(Q):
    correct = int(input())
    C[correct-1] = C[correct-1] + 1

for i in range(N):
    A[i] = A[i] - Q + C[i]
    if A[i] > 0:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N, k, Q = map(int, input().split())
A =[]
i = 0
j = 0
c = 0
 
def calc_de(n):
    return n - 1
 
for i in range(Q):
  A.append(int(input()))
 
S = [k]*N
 
for j in A:
    S = list(map(calc_de, S))
    S[j-1] += 1
 
for c in range(N):
    if S[c] > 0:
        print('Yes')
    else:
        print('No')

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

A = [K]*N
C = [0]*N

for r in range(Q):
    correct = int(input())
    C[correct-1] = C[correct-1] + 1

for i in range(N):
    A[i] = A[i] - Q + C[i]
    if A[i] > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [0]*n
B = list(map(int, input()))

A[0] = B[0]
A[-1] = B[-1]

for i in range(1, n-1):
  A[i] = min(B[i-1], B[i])
  
print(sum(A))



Fixed submission:
n = int(input())
A = [None for i in range(n)]
B = list(map(int, input().split()))
A[0] = B[0]
A[-1] = B[-1]
 
for i in range(1, n-1):
  A[i] = min(B[i-1], B[i])
print(sum(A))

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [0]*n
B = list(map(int, input()))

A[0] = B[0]
A[-1] = B[-1]

for i range(1, n-1):
  A[i] = min(B[i-1], B[i])
  
print(sum(A))



Fixed submission:
n = int(input())
A = [None for i in range(n)]
B = list(map(int, input().split()))
A[0] = B[0]
A[-1] = B[-1]
 
for i in range(1, n-1):
  A[i] = min(B[i-1], B[i])
print(sum(A))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
n = B // A

if n == B / A:
  print(n)
else:
  print(n+1)

  
  

Fixed submission:
import math

A = list(map(int, input().split()))
a = A[1] - 1
b = A[0] - 1
n = math.floor(a / b)

if n == a / b:
    print(n)
elif n < a / b:
    print(n + 1)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
  S += 1 / A[i]

ans = 1 / S
print('[:.6g]'.format(ans))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S =0
for i in range(N):
  S += 1 / A[i]

ans = 1 / S
print('{:.6g}'.format(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
cnt = 0

for i, j in enumerate(A)
  if i + 1 != j:
    cnt +=1
if cnt <= 2:
  print('YES')
else:
  print('NO')
  

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
cnt = 0
 
for i, j in enumerate(A):
  if i + 1 != j:
    cnt +=1
if cnt <= 2:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
K,X=map(int,input().split())
ans=YES
if 500*K<X:
    ans=NO
print(ans)


Fixed submission:
k, x = map(int, input().split())
if x <= k*500:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
ef main():
    dict = {"SUN": 7,
            "MON": 6,
            "TUE": 5,
            "WED": 4,
            "THU": 3,
            "FRI": 2,
            "SAT": 1,
            }
    day = input()
    ans = dict[day]
    print(ans)



if __name__ == "__main__":
    main()

Fixed submission:
def main():
    dict = {"SUN": 7,
            "MON": 6,
            "TUE": 5,
            "WED": 4,
            "THU": 3,
            "FRI": 2,
            "SAT": 1,
            }
    day = input()
    ans = dict[day]
    print(ans)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from itertools import permutations
from math import factorial


# メインプログラム
def func(N, lst):

    # N! を求める
    N_fact = factorial(N)

    # lst から座標のすべての組合せを求める。
    perm_grid_xy = permutations(lst)

    # すべての組合せを全探索して、総合距離を計算する
    total_dist = total_distance(N, perm_grid_xy)

    # 平均距離 = 総合距離 / N!
    average_dist = total_dist / N_fact

    return average_dist


def total_distance(N, perm_grid_xy):

  	ret = 0
    
    for grid_xy in perm_grid_xy:
        for i in range(N-1):
            x0, y0 = grid_xy[i][0], grid_xy[i][1]
            x1, y1 = grid_xy[i+1][0], grid_xy[i+1][1]
            dist = ((x0 - x1)**2 + (y0 - y1)**2) ** 0.5
            ret += dist
            
    return ret


if __name__ == "__main__":
    N = int(input())
    lst = [tuple(map(int, input().split())) for _ in range(N)]
    print(func(N, lst))

Fixed submission:
from itertools import permutations
from math import factorial


# メインプログラム
def func(N, lst):

    # N! を求める
    N_fact = factorial(N)

    # lst から座標のすべての組合せを求める。
    perm_grid_xy = permutations(lst)

    # すべての組合せを全探索して、総合距離を計算する
    total_dist = total_distance(N, perm_grid_xy)

    # 平均距離 = 総合距離 / N!
    average_dist = total_dist / N_fact

    return average_dist


def total_distance(N, perm_grid_xy):
    
    ret = 0
    
    for grid_xy in perm_grid_xy:
        tmp = sum(
            ((grid_xy[i][0] - grid_xy[i+1][0]) ** 2 
            + (grid_xy[i][1] - grid_xy[i+1][1]) ** 2) ** 0.5 
            for i in range(N-1)
            )
        ret += tmp

    return ret


if __name__ == "__main__":
    N = int(input())
    lst = [tuple(map(int, input().split())) for _ in range(N)]
    print(func(N, lst))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    ans = sum(range(1, N + 1)) - N
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    ans = N * (N - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb
from operator import mul
from functools import reduce


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()

cnt_s = Counter(lst_s)

ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += cmb(v, 2)
print(ans)

Fixed submission:
from collections import Counter
from operator import mul
from functools import reduce


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()

cnt_s = Counter(lst_s)

ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += cmb(v, 2)
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()
# print(lst_s)


cnt_s = Counter(lst_s)
# print(cnt_s)

ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += comb(v, 2, exact=True)
print(ans)

Fixed submission:
from collections import Counter
from operator import mul
from functools import reduce


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()

cnt_s = Counter(lst_s)

ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += cmb(v, 2)
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()


cnt_s = Counter(lst_s)


ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += comb(v, 2, exact=True)
print(ans)

Fixed submission:
from collections import Counter
from operator import mul
from functools import reduce


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()

cnt_s = Counter(lst_s)

ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += cmb(v, 2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


def split_RL_block(S):
    N = len(S)
    ret = []

    RL = "R"
    c = "R"
    for i in range(1, N):
        now = S[i]
        if RL == "R" and now == "R":
            c += "R"
        elif RL == "R" and now == "L":
            RL = "L"
            c += "L"
        elif RL == "L" and now == "R":
            ret.append(c)
            RL = "R"
            c = "R"
        else:
            c += "L"
    else:
        ret.append(c)
    return ret


def count_children_RL_border(RL):
    N = len(RL)
    ret = [0] * N
    
    cnt_RL = Counter(RL)
    idx_r = cnt_RL["R"] - 1
    idx_l = idx_r + 1

    r = 0
    l = 0
    for i in range(N):
        if abs(i - idx_r) % 2 == 0:
            r += 1
        else:
            l += 1
    ret[idx_r] = r
    ret[idx_l] = l

    return ret


def main():
    S = input()
    N = len(S)
    RL = split_RL_block(S)
    ans = []
    for rl in RL:
        tmp = count_children_RL_border(rl)
        ans += tmp
    
    print(*ans)


if __name__ == "__main__":
    main()

Fixed submission:
from collections import Counter


def split_RL_block(S):
    N = len(S)
    ret = []

    RL = "R"
    c = "R"
    for i in range(1, N):
        now = S[i]
        if RL == "R" and now == "R":
            c += "R"
        elif RL == "R" and now == "L":
            RL = "L"
            c += "L"
        elif RL == "L" and now == "R":
            ret.append(c)
            RL = "R"
            c = "R"
        else:
            c += "L"
    else:
        ret.append(c)
    return ret


def count_children_RL_border(RL):
    N = len(RL)
    ret = [0] * N
    
    cnt_RL = Counter(RL)
    idx_r = cnt_RL["R"] - 1
    idx_l = idx_r + 1

    r = 0
    l = 0
    for i in range(N):
        if abs(i - idx_r) % 2 == 0:
            r += 1
        else:
            l += 1
    ret[idx_r] = r
    ret[idx_l] = l

    return ret


def main():
    S = input()
    N = len(S)
    RL = split_RL_block(S)
    ans = []
    for rl in RL:
        tmp = count_children_RL_border(rl)
        ans += tmp
    
    print(*ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import Counter


def main():
    N = int(input())
    lst_a = list(map(int, input().split()))

    cnt_a = Counter(lst_a)

    if len(cnt_a) > 3:
        print("No")
        exit()
    
    if len(cnt_a) == 1:
        print("Yes" if lst_a[0] == 0 else "No")
        exit()
    
    if N % 3:
        print("No")
        exit()
    
    if len(cnt_a) == 2:
        if cnt_a[0] != N//3:
            print("No")
        else:
            print("Yes")
    else:
        if any(v != N//3 for v in C.values()):
            print("No")
        else:
            x, y, z = list(cnt_a)
            print("Yes" if x ^ y ^ z == 0 else "No")


if __name__ == "__main__":
    main()

Fixed submission:
from collections import Counter


def main():
    N = int(input())
    lst_a = list(map(int, input().split()))

    cnt_a = Counter(lst_a)

    if len(cnt_a) > 3:
        print("No")
        exit()
    
    if len(cnt_a) == 1:
        print("Yes" if lst_a[0] == 0 else "No")
        exit()
    
    if N % 3:
        print("No")
        exit()
    
    if len(cnt_a) == 2:
        if cnt_a[0] != N//3:
            print("No")
        else:
            print("Yes")
    else:
        if any(v != N//3 for v in cnt_a.values()):
            print("No")
        else:
            x, y, z = list(cnt_a)
            print("Yes" if x ^ y ^ z == 0 else "No")


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from collections import Counter


def main():
    N = int(input())
    lst_a = list(map(int, input().split()))

    cnt_a = Counter(lst_a)

    if len(cnt_a) > 3:
        print("No")
        exit()
    
    if len(cnt_a) == 1:
        print("Yes" if lst_a[0] == 0 else "No")
        exit()
    
    if N % 3:
        print("No")
        exit()
    
    if len(cnt_a) == 2:
        if cnt_a[0] != N//3:
            print("No")
        else:
            print("Yes")
    else:
        if any(v != N//3 for v in C.values()):
            print("No")
        else:
            x, y, z = list(cnt_a)
            print("Yes" if a ^ b ^ c == 0 else "No")


if __name__ == "__main__":
    main()

Fixed submission:
from collections import Counter


def main():
    N = int(input())
    lst_a = list(map(int, input().split()))

    cnt_a = Counter(lst_a)

    if len(cnt_a) > 3:
        print("No")
        exit()
    
    if len(cnt_a) == 1:
        print("Yes" if lst_a[0] == 0 else "No")
        exit()
    
    if N % 3:
        print("No")
        exit()
    
    if len(cnt_a) == 2:
        if cnt_a[0] != N//3:
            print("No")
        else:
            print("Yes")
    else:
        if any(v != N//3 for v in cnt_a.values()):
            print("No")
        else:
            x, y, z = list(cnt_a)
            print("Yes" if x ^ y ^ z == 0 else "No")


if __name__ == "__main__":
    main()