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

Fixed submission:
A,B = map(int,input().split())
import fractions
d = fractions.gcd(A,B)
print(A*B//d)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
import math
d = math.gcd(A,B)
print(A*B//d)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
import math
d = math.gcd(A,B)
print(A*B//d)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
import math
d = math.gcd(A,B)
print(A*B//d)
Problem p02711 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def main():

    n = str(input())
    for i in range(len(n)):
        if n[i] == '7':
            print('Yes')
            sys.exit()
    print('No')


main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = int(input())
I = input()

R =0
G =0
B =0
for i in range(N):
    if (I[i] == 'R'):
        R+=1
    if (I[i] == 'G'):
        G+=1
    if (I[i] == 'B'):
        B+=1


sum = R * G * B
count = 0

for i in range(N):
    for j in range(i+1,N):
        if I[i] != I[j]:
            k = j + j - i
            if k >= N:
                continue
            if I[i] != I[k] and I[j] != I[k]:
                count += 1

print(sum - count)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = int(input())
I = input()

R =0
G =0
B =0
for i in range(N):
    if (I[i] == 'R'):
        R+=1
    if (I[i] == 'G'):
        G+=1
    if (I[i] == 'B'):
        B+=1


sum = R * G * B
count = 0

for i in range(N):
    for j in range(i+1,N):
        if I[i] != I[j]:
            k = j + j - i
            if k >= N:
                continue
            if I[i] != I[k] and I[j] != I[k]:
                count += 1

print(sum - count)
Problem p02880 (python)

Fixed submission:
import sys
X=input()
N=int(X)

for i in range(1,10):
    a=N//i
    b=N%i
    if (0<a<10 and b==0):
        print("Yes")
        break
else:
     print("No")

Buggy submission (verdict: Runtime Error):
import sys
N=input()

for i in range(1,9):
    a=N//i
    b=N%i
    if (0<a<10 && b==0):
        print("Yes")
        break
else print("No")
Problem p03775 (python)

Fixed submission:
import math

def make_divisors(n):
    lo_d , up_d = [] , []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lo_d.append(i)
            if i != n // i:
                up_d.append( n // i )
        i += 1
    return lo_d + up_d[::-1]

N = int(input())
List = make_divisors(N)
len_a = len(List)
ans = List[ len_a // 2 ]
print( math.floor(math.log(ans , 10)) + 1 )

Buggy submission (verdict: Runtime Error):
import math
import sympy
#from sympy import sieve

N = int(input())
'''
lenN = math.floor(math.log(N,10)) + 1
# lenN = Nの桁数
rootN = math.floor(math.sqrt(N))
#rootN = floor( N ^ 1/2 )
Primes = list(sieve.primerange(1,rootN))
'''

Divisors = list(sympy.divisors(N))
Len_d = len(Divisors)

Ans = Divisors[ Len_d // 2 ]
print(math.floor(math.log(Ans,10))+1)
Problem p02572 (python)

Fixed submission:
MOD = 10**9 + 7
n = int(input())
A = list(map(int, input().split()))

import numpy
A_CS = numpy.cumsum(sorted(A, reverse=True))
A_CS = A_CS%MOD

A = sorted(A)

#print(A_CS)
ans = 0
for i in range(n-1):
#    print(A[i], A_CS[-i-2])
#    A_CS -= A[i]
    ans = (ans+(A[i]*A_CS[-i-2])%MOD)%MOD
print(ans)

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
n = int(input())
A = list(map(int, input().split()))

import numpy
A_CS = numpy.cumsum(sorted(A, reverse=True))
A_CS = A_CS%MOD

A = sorted(A)

#print(A_CS)
ans = 0
for i in range(n-1):
#    print(A[i], A_CS[-i-2])
#    A_CS -= A[i]
    ans = (ans+(A[i]*A_CS[-i-2])%MOD)%MOD
print(ans)

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

ans = 0
for i in range(n-1):
    ans = (ans+(A[i]*sum(A[i+1:])%MOD)%MOD)%MOD
print(ans)
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

import numpy as np
A0 = [0] + A
B0 = [0] + B
AA = np.cumsum(A0)
BB = np.cumsum(B0)

ans = 0
jmax = M
for i in range(0, N+1):
    a = AA[i]
    if a > K:
        break
    for j in range(jmax, -1, -1):
        b = BB[j]
#        print(a, b)
        if a + b <= K:
            ans = max(ans, i+j)
#            print('ok')
            break
    jmax = j
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

import numpy as np
A_cumsum = np.cumsum(A)
B_cumsum = np.cumsum(B)
#AB_cumsum = np.sort(np.concatenate([A_cumsum, B_cumsum]))


lenA = len(A)
lenB = len(B)

if lenA < lenB:
    A_cumsum = np.concatenate([A_cumsum, [np.inf]*(lenB-lenA)])
else:
    B_cumsum = np.concatenate([B_cumsum, [np.inf]*(lenA-lenB)])


i = 0
j = 0
t = 0
ans = 0
while i < lenA or j < lenB:
    if A_cumsum[i] < B_cumsum[j]:
        ans += 1
        t += A[i]
        i += 1
    else:
        ans += 1
        t += B[j]
        j += 1
#    print(ans, t)
    if t > K:
        ans -= 1
        break
print(ans)
Problem p02689 (python)

Fixed submission:
n, m = map(int, input().split())
H = list(map(int, input().split()))
MaxHeight = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    MaxHeight[a] = max(MaxHeight[a], H[b])
    MaxHeight[b] = max(MaxHeight[b], H[a])
ans = 0
for h, mh in zip(H, MaxHeight):
    ans = ans + 1 if h > mh else ans
print(ans)

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
H.insert(0, 0)

A = np.zeros(M, dtype=int)
B = np.zeros(M, dtype=int)

for i in range(M):
    A[i], B[i] = map(int, input().split())
#print(A, B)

ans = 0
for j in range(1, N+1):
    ind = np.concatenate([[0], A[B==j], B[A==j]])
#    print(j, ind)
    if H[j] > max(list(map(lambda x: H[x], ind))):
        ans += 1
print(ans)

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
H.insert(0, 0)

A = np.zeros(M, dtype=int)
B = np.zeros(M, dtype=int)

for i in range(M):
    A[i], B[i] = map(int, input().split())
print(A, B)

ans = 0
for j in range(1, N+1):
    ind = np.concatenate([[0], A[B==j], B[A==j]])
#    print(j, ind)
    if H[j] > max(list(map(lambda x: H[x], ind))):
        ans += 1
print(ans)
Problem p02693 (python)

Fixed submission:
def hoge(K, A, B):
    ans = 0
    for n in range(A, B+1):
        if n%K == 0:
            ans = 1
            return ans
    return ans

K = int(input())
A, B = map(int, input().split())
if hoge(K, A, B):
    print('OK')
else:
    print('NG')

Buggy submission (verdict: Runtime Error):
def hoge(K, A, B):
    K = int(input())
    A, B = map(int, input().split())
    
    ans = 0
    for n in range(A, B+1):
        if n%K == 0:
            ans = 1
            return ans
    return ans

if hoge(K, A, B):
    print('OK')
else:
    print('NG')
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
strS = input()
S = int(strS)
lenS = len(strS)
 
ans = 0
for i in range(lenS - 3):
    for j in range(i+3, lenS):
#        print(i,j)
        if int(strS[i:j+1])%2019 == 0:
#            print(int(str(S)[i:j]), i, j)
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
strS = input()
S = int(strS)
lenS = len(strS)

ans = 0
for i in range(lenS):
    if i+3 <= lenS:
        for j in range(i+3, lenS):
#            print(i,j)
            if int(strS[i:j+1])%2019 == 0:
#                print(int(str(S)[i:j]), i, j)
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
S = int(input())
lenS = len(str(S))

ans = 0
for i in range(lenS):
    if i+3 <= lenS:
        for j in range(i+3, lenS):
#            print(i,j)
            if int(str(S)[i:j+1])%2019 == 0:
#                print(int(str(S)[i:j]), i, j)
                ans += 1
print(ans)
Problem p02754 (python)

Fixed submission:
n, a, b = map(int, input().split())
print(n//(a+b)*a + min([n%(a+b), a]))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

Que = []
while len(Que) < N:
    Que = Que + [1]*A
    Que = Que + [0]*B
Que[0:N].count(1)
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())

A = [1, 2, 3]
A[a-1]= 0
A[b-1] = 0
print(sum(A))

Buggy submission (verdict: Runtime Error):
a = int(input)
b = int(input)

A = [1, 2, 3]
A.pop(a-1)
A.pop(b-2)
print(A[0])

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

A = [1, 2, 3]
A.pop(a-1)
A.pop(b-2)
print(A[0])

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

A = [1, 2, 3]
A.pop(a-1)
A.pop(b-2)
print(A[0])
Problem p02831 (python)

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

import fractions
print(a*b//fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

import math
print(a*b//math.gcd(a, b))
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e-a > k or d-a >k or c-a>k or b-a>k or e-b > k or d-b > k or c-b>k or e-c >k or d-c >k or e-d>k:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
listA = list(map(int, input().split()))
listB = list(map(int, input().split()))
listC = list(map(int, input().split()))

sumAB =[]
index=0
while index < len(listA):
    index2=0
    while index2 < len(listB):
        sumAB.append(listA[index]+listB[index2])
        index2+=1
    index+=1
sumAB.sort()
sumAB.reverse()
abSL=[]
index3=0
while index3 < min(k, len(sumAB)):
    abSL.append(sumAB[index3])
    index3+=1

answerL=[]
index4=0
while index4 < len(abSL):
    index5=0
    while index5 < min(k,len(listC)):
        answerL.append(abSL[index4]+listC[index5])
        index5+=1
    index4+=1

answerL.sort()
answerL.reverse()
index6=0
while index6 < k:
    print(answerL[index6])
    index6+=1
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
n = int(input())
listA=list(map(int, input().split()))
print(gcd_list(listA))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
n = int(input())
listA=list(map(int, input().split()))
print(gcd_list(listA))
Problem p03242 (python)

Fixed submission:
listN = list(str(input()))

index=0
while index < 3:
    if listN[index] == "1":
        listN[index]="9"
    elif listN[index]=="9":
        listN[index]="1"
    index+=1

print(listN[0]+listN[1]+listN[2])

Buggy submission (verdict: Runtime Error):
n = int(input())
numberL = list(map(int, input().split()))
 
kisuuSyuL=[]
kisuuKosuL=[]
kisuuKosuL2=[]
gusuSyuL=[]
gusuKosuL=[]
gusuKosuL2=[]
 
index=0
while index<n:
    if index==0:
        gusuSyuL.append(numberL[index])
        gusuKosuL.append(1)
        gusuKosuL2.append(1)
    elif index==1:
        kisuuSyuL.append(numberL[index])
        kisuuKosuL.append(1)
        kisuuKosuL2.append(1)
    else:
        if index%2==0:
            if numberL[index] in gusuSyuL:
                tarI = gusuSyuL.index(numberL[index])
                gusuKosuL[tarI]+=1
                gusuKosuL2[tarI]+=1
            else:
                gusuSyuL.append(numberL[index])
                gusuKosuL.append(1)
                gusuKosuL2.append(1)
        else:
            if numberL[index] in kisuuSyuL:
                tarI = kisuuSyuL.index(numberL[index])
                kisuuKosuL[tarI]+=1
                kisuuKosuL2[tarI]+=1
            else:
                kisuuSyuL.append(numberL[index])
                kisuuKosuL.append(1)
                kisuuKosuL2.append(1)
    index+=1

 
if len(kisuuSyuL)==1 and len(gusuSyuL)==1:
    if kisuuSyuL[0]==gusuSyuL[0]:
        print(int(n/2))
    else:
        print(0)
else:
    kiIndex = kisuuKosuL.index(max(kisuuKosuL))
    guIndex = gusuKosuL.index(max(gusuKosuL))
    if kisuuSyuL[kiIndex]!=gusuSyuL[guIndex]:
        noC=max(kisuuKosuL)+max(gusuKosuL)
        print(n-noC)
    else:
        if max(kisuuKosuL) < max(gusuKosuL):
            kisuuKosuL.sort()
            noC=kisuuKosuL[len(kisuuKosuL)-1]+max(gusuKosuL)
            print(n-noC)
        else:
            gusuKosuL.sort()
            noC=gusuKosuL[len(gusuKosuL)-1]+max(kisuuKosuL)
            print(n-noC)
Problem p02623 (python)

Fixed submission:
n,m,k = map(int, input().split())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]

t = sum(b)
j = m
ans = 0
for i in range(n+1):
    while j > 0 and t > k:
        j -= 1
        t -= b[j]
    if t > k: break
    ans = max(ans, i + j)
    if i==n:break
    t+=a[i]

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

n,m,k = map(int, input().split())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]

x = deque(a)
y = deque(b)

ans=0
for i in range(n + m):
    print(x, y)
    try:
        temp = x.popleft() if x[0] < y[0] else y.popleft()
    except:
        if len(x) == 0:
            temp = y.popleft()
        elif len(y) == 0:
            temp=x.popleft()
            print(temp)

    k -= int(temp)
    if k >= 0:
        ans += 1
    else:
        break
print(ans)
Problem p02699 (python)

Fixed submission:
s,w = map(int, input().split())
print('unsafe' if s<=w else 'safe')

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

print('unsafe' if s=<w else 'safe')
Problem p02729 (python)

Fixed submission:
from math import factorial as fact
n,m=map(int,input().split())
i,k=0,0
if n<2 and m<2:
  print(0)
else:
  if n==0:i=0
  elif n==2:
  	i=1
  elif n!=1:
    i=fact(n)/fact(2)/fact(n-2)
  if m==0:k=0
  elif m==2:
  	k=1
  elif m!=1:
    k=fact(m)/fact(2)/fact(m-2)
  print(int(i+k))

Buggy submission (verdict: Runtime Error):
from math import factorial as fact
n,m=map(int,input().split())
i,k=0,0
if n<2 and m<2:
  print(0)
else:
  if n!=0:
  	i=fact(n)/fact(2)/fact(n-2)
  if m!=0:
    k=fact(m)/fact(2)/fact(m-2)
  print(int(i+k))
Problem p02754 (python)

Fixed submission:
n,a,b=map(int,input().split())
ans = n // (a + b) * a
rem = n % (a + b)
ans+=min(a,rem)
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
s = ('b' * a + 'r' * b) * n
print(s[0:n].count('b'))

Buggy submission (verdict: Runtime Error):
n,a,b=[int(i) for i in input().split()]
s=''
s+='b'*a
s+='r'*b
s*=n//(a+b)+1
print(s[:n].count('b'))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
s=''
s+='b'*a
s+='r'*b
s*=n//(a+b)+1
print(s[:n].count('b'))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
s=''
for i in range(n//(a+b)+1):
  s+='b'*a
  s+='r'*b
print(s[:n].count('b'))
Problem p02597 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
C = input()

C = list(C)

d = {0:0}
tot = 0

for i,c in enumerate(C):
    if c == 'R':
        tot += 1
    d[i+1] = tot

ans = tot-d[tot]
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
C = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

C = list(C)

d = {}
tot = 0

for i,c in enumerate(C):
    if c == 'R':
        tot += 1
    d[i+1] = tot

ans = tot-d[tot]
print(ans)

# left = 0
# left2mid = False
# mid = 0
# right = 0
# right2mid = False

# lp = 0
# rp = -1

# while lp < len(C)+rp:
#     if not left2mid and C[lp] == 'W':
#         left += 1
#     elif not left2mid and C[lp] == 'R':
#         left2mid = True
#     elif left2mid and C[lp] == 'R':
#         mid += 1
#     lp += 1

#     if not right2mid and C[rp] == 'R':
#         right += 1
#     elif not right2mid and C[rp] == 'W':
#         right2mid = True
#     elif right2mid and C[lp] == 'R':
#         mid += 1
#     rp -= 1
# print(left, mid, right)
Problem p02623 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]: # 前のループで求めたjから走査すれば良い（毎回Mから始める必要はない）
        j -= 1
    ans = max(ans, i + j)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

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

from collections import deque

a = deque(a)
b = deque(b)

ans = 0
time = k

while time >= 0:
    if a and b:
        tmp_a = time-a[0]
        tmp_b = time-b[0]
        if tmp_a >= 0 and tmp_b >= 0 and a[0] <= b[0]:
            time -= a[0]
            a.popleft()
            ans += 1
        elif tmp_a >= 0 and tmp_b >= 0 and b[0] < a[0]:
            time -= b[0]
            b.popleft()
            ans += 1
        elif tmp_a >= 0:
            time -= a[0]
            a.popleft()
            ans += 1
        elif tmp_b >= 0:
            time -= b[0]
            b.popleft()
            ans += 1
        else:
            break
    elif a:
        tmp_a = time-a[0]
        if tmp_a >= 0:
            time -= a[0]
            a.popleft()
            ans += 1
        else:
            break
    elif b:
        tmp_b = time-b[0]
        if tmp_b >= 0:
            time -= b[0]
            b.popleft()
            ans += 1
        else:
            break
    else:
        break
    print(a,b,ans)

print(ans)
Problem p02629 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())

d = {(i-97+1):chr(i) for i in range(97,97+26)}
d[0] = 'z'

l = []

while n > 0:
    tmp = n%26
    l.append(tmp)
    if tmp == 0:
        n = n//26-1
    else:
        n //= 26

ans = ''

for i in l[::-1]:
    ans += d[i]
    
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n = int(input())

d = {(i-97+1):chr(i)%26 for i in range(97,97+26)}
#d[0] = 'z'

l = []

while n > 0:
    tmp = n%26
    l.append(tmp)
    if tmp == 0:
        n = n//26-1
    else:
        n //= 26

ans = ''

for i in l[::-1]:
    ans += d[i]
    
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

MAX_N = 1000000000000001

d = {(i-97+1):chr(i) for i in range(97,97+26)}

l = []

while n > 0:
    tmp = n%26
    l.append(tmp)
    n -= tmp
    n //= 26

ans = ''

for i in l[::-1]:
    ans += d[i]
    
print(ans)
Problem p02726 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,x,y = [int(i) for i in readline().split()]

ans = [0] * n

for a in range(1, n+1):
    for b in range(a+1, n+1):
        d = b - a
        d2 = abs(x-a) + abs(y-b) + 1
        d = d if d < d2 else d2
        ans[d] += 1

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

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,x,y = [int(i) for i in readline().split()]

ans = [0] * n

for a in range(1, n+1):
    for b in range(a+1, n+1):
        d = b - a
        d2 = abs(X-a) + abs(Y-b) + 1
        d = d if d < d2 else d2
        ans[d] += 1

for i in range(1, n):
    print(ans[i])
Problem p02954 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

s = input()

ans = [0]*len(s)

i = 0
len_left = 1
len_right = 0
intersec_left = 0
now_left = True

while i < len(s)-1:
    if s[i] == s[i+1] and now_left:
        len_left += 1
    elif s[i] != s[i+1] and now_left:
        len_right += 1
        intersec_left = i
        now_left = False
    elif s[i] == s[i+1]:
        len_right += 1
    else:
        if len_left%2 == 0:
            ans[intersec_left] += len_left//2
            ans[intersec_left+1] += len_left//2
        else:
            ans[intersec_left] += len_left//2+1
            ans[intersec_left+1] += len_left//2
        if len_right%2 == 0:
            ans[intersec_left] += len_right//2
            ans[intersec_left+1] += len_right//2
        else:
            ans[intersec_left] += len_right//2
            ans[intersec_left+1] += len_right//2+1
        len_left = 1
        len_right = 0
        intersec_left = i+1
        now_left = True
    i += 1
else:
    if len_left%2 == 0:
        ans[intersec_left] += len_left//2
        ans[intersec_left+1] += len_left//2
    else:
        ans[intersec_left] += len_left//2+1
        ans[intersec_left+1] += len_left//2
    if len_right%2 == 0:
        ans[intersec_left] += len_right//2
        ans[intersec_left+1] += len_right//2
    else:
        ans[intersec_left] += len_right//2
        ans[intersec_left+1] += len_right//2+1
    
print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

s = input()

ans = [0]*len(s)

for _ in range(2):
    cnt = 0
    for i in range(n):
        if s[i] == 'R': cnt += 1
        else:
            ans[i] += cnt//2
            ans[i-1] += (cnt-1)//2
            cnt = 0
        
    ans.sort()
    s = s[::-1]
    for i in range(n):
        if s[i] == 'L': s[i] = 'R'
        else: s[i] = 'L'

print(*ans)
Problem p02729 (python)

Fixed submission:
N, M = map(int, input().split())
print(int(N*(N-1)/2) + int(M*(M-1)/2))

Buggy submission (verdict: Runtime Error):
def main():
    import numpy as np
    inf = 100100100
    ans = inf
    H, W, K = map(int, input().split())
    S = []
    for _ in range(H):
        S.append([int(x) for x in input()])
    S = np.array(S)
    for i in range(2**(H-1)):
        group = [0]
        g = 0
        for j in range(H-1):
            if (i >> j) & 1:
                g += 1
            group.append(g)
        group = np.array(group)
        g += 1
        c = np.array([[0]*W]*g)
        for j in range(H):
            for k in range(W):
                c[group[j],k] += S[j,k]
        num = g-1
        now = np.zeros(g)
        def large(now):
            for n in now:
                if n > K:
                    return True
            else:
                return False
        for k in range(W):
            now += c[:,k]
            if large(now):
                now = c[:,k]
                num += 1
                if large(now):
                    num = inf
                    break
        ans = min(ans, num)
    print(ans)
main()