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

Fixed submission:
N = int(input())
Ss = []
for i in range(N):
    k = input().split(" ")
    Ss.append((i+1, k[0], k[1]))

Ss.sort(key = lambda x: (x[1], -int(x[2])))
for i in range(N):
    print(Ss[i][0])

Buggy submission (verdict: Runtime Error):
N = int(input())
Ss = []
for i in range(N):
    Ss.append((i+1, *input().split(" ")))

Ss.sort(key = lambda x: (x[1], -int(x[2])))
for i in range(N):
    print(Ss[i][0])
Problem p02941 (python)

Fixed submission:
n = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
cnt = 0
while B != A:
    for i in range(n):
        a, c = B[i-1], B[(i+1)%n]
        if (B[i] > A[i]) &\
           (B[i] > a) &\
           (B[i] > c):
            d = (B[i]-max(A[i], a, c)+a+c-1)//(a+c)
            B[i] -= (a+c)*d
            cnt += d
        elif B[i] < A[i]:
            print(-1)
            exit()
print(cnt)

Buggy submission (verdict: Runtime Error):
# c
n = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
cnt = 0
while B != A:
    for i in range(n):
        a, c = B[i-1], B[(i+1)%n]
        if (B[i] > A[i]) &\
           (B[i] > a) &\
           (B[i] > c):
            B[i] -= (a+c)*((B[i]-A[i]+a+c-1)//(a+c))
            cnt += 1
        elif B[i] < A[i]:
            print(-1)
            exit()
print(cnt)

Buggy submission (verdict: Runtime Error):
# c
n = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
cnt = 0
while B != A:
    for i in range(n):
        a, c = B[i-1], B[(i+1)%n]
        if (B[i] > A[i]) &\
           (B[i] > a) &\
           (B[i] > c):
            B[i] -= (a+c)*((B[i]-A[i]+a+c)//(a+c))
            cnt += 1
        elif B[i] < A[i]:
            print(-1)
            exit()
print(cnt)
Problem p02957 (python)

Fixed submission:
a, b = map(int, input().split())
if a%2 == b%2:
    print(int((a+b)/2))
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
P=[1,10,9,12,3,4]
m=10**9+7
def f(A,p,N):
    if p==0:return [1&(i in N) for i in range(13)]
    p%=6
    B=[0]*13
    for n in N:
        for i in range(13):
            c=(i+(n*P[p]))%13
            B[c]=(B[c]+A[i])%m
    return B

S=reversed(input())
A=[0]
for p,s in enumerate(S):
    if s=="?":A=f(A,p,range(10))
    else:A=f(A,p,[int(s)])
print(A[5])
Problem p02960 (python)

Fixed submission:
P=[1,10,9,12,3,4]
m=10**9+7
def f(A,p,N):
    if p==0:return [1&(i in N) for i in range(13)]
    p%=6
    B=[0]*13
    for n in N:
        for i in range(13):
            c=(i+(n*P[p]))%13
            B[c]=(B[c]+A[i])%m
    return B

S=reversed(input())
A=[0]
for p,s in enumerate(S):
    if s=="?":A=f(A,p,range(10))
    else:A=f(A,p,[int(s)])
print(A[5])

Buggy submission (verdict: Runtime Error):
P=[1,10,9,12,3,4]
def f(A,p,N):
    if p==0:return [1&(i in N) for i in range(13)]
    B=[0]*13
    for n in N:
        for i in range(13):
            c=(i+(n*P[p]))%13
            B[c]=(B[c]+A[i])%(10**9+7)
    return B
S=reversed(input())
A=[0]
p=0
for s in S
    if s=="?":A=f(A,p,range(10))
    else:A=f(A,p,[int(s)])
    p=(p+1)%6
print(A[5])
Problem p02969 (python)

Fixed submission:
# A - Dodecagon

r = int(input())
print(3*r**2)

Buggy submission (verdict: Runtime Error):
# B - Golden Apple

from math import ceil 
N, D = map(int, input().split())
print(ceil(N/(2*D+1)))

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

Buggy submission (verdict: Runtime Error):
# B - Golden Apple

N, D = map(int, input().split())
# print(int((N+2*D)/(2*D+1)))
print((N+2*D)//(2*D+1))

Buggy submission (verdict: Runtime Error):
# B - Golden Apple

N, D = map(int, input().split())
print(int((N+2*D)/(2*D+1)))

Buggy submission (verdict: Runtime Error):
# B - Golden Apple

N, D = map(int, input().split())
print(int((N+2*D)/(2*D+1)))
Problem p02983 (python)

Fixed submission:
from itertools import combinations as f
l,r=map(int,input().split())
s=set(map(lambda x:x%2019,range(l,r+1)[:2019]))
print(min([i*j%2019 for i,j in f(s,2)]))

Buggy submission (verdict: Runtime Error):
from itertools import combinations as f
l,r=map(int,input().split())
m=l*r%2019
for i,j in f(range(l,r+1),2):m=min(m,i*j%2019)
print(m)

Buggy submission (verdict: Runtime Error):
from itertools import combinations as f
l,r=map(int,input().split())
print(min([i*j%2019 for i,j in f(range(l,r+1),2)]))
Problem p02999 (python)

Fixed submission:
X, A = map(int, input().split())
print(["10", "0"][X < A])

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
print(1+sum(i <= x for i in [sum(l[0:i+1]) for i in range(n)]))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
print(1+sum(i <= x for i in [sum(l[0:i]) for i in range(n)]))
Problem p03032 (python)

Fixed submission:
n, k = map(int, input().split())
*V, = map(int, input().split())
M = [v if v < 0 else 0 for v in V]
S = [0]
for i in range(1, min(k+1, n+1)):
    for j in range(i+1):
        s = sum(V[:i-j])+sum(V[n-j:])
        M_sub = sorted(M[:i-j]+M[n-j:])
        s -= sum(M_sub[:k-i])
        S += [s]
print(max(S))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
*V, = map(int, input().split())
M = [v if v < 0 else 0 for v in V]
S = []
for i in range(min(k, n)):
    for j in range(i):
        s = sum(V[:i-j])+sum(V[n-j:])
        M_sub = sorted(M[:i-j]+M[n-j:])
        s -= sum(M_sub[:k-i])
        S += [s]
print(max(S))
Problem p03043 (python)

Fixed submission:
n, k = map(int, input().split())
p = 0.
for i in range(1, n+1):
    s = i
    q = 1.
    while s < k:
        s *= 2
        q *= 0.5
    p += q
print(p/n)

Buggy submission (verdict: Runtime Error):
n = int(input())
T = []
for _ in range(n-1):
    T += [list(map(int, input().split()))]
T.sort()
P = [0]+[-1]*(n-1)
b = n-1
while b > 0:
    for u, v, w in T:
        pu, pv = P[u-1], P[v-1]
        if (pu >= 0) & (pv < 0):
            P[v-1] = (pu+(w%2))%2
            b -= 1
        if (pv >= 0) & (pu < 0):
            P[u-1] = (pv+(w%2))%2
            b -= 1
for p in P: print(p)
Problem p03088 (python)

Fixed submission:
import numpy as np
n = int(input())
A_1 = np.zeros((4,4), dtype='int64')
A_2 = np.ones((4,4), dtype='int64')
B = np.ones((4,4), dtype='int64')
for _ in range(n-2):
    A_3 = np.dot(B, A_2).T
    A_3 %= 10**9+7
    A_3[2,1] -= A_2[0,2]+A_1[0,2]+A_1[0,3]
    A_3[1,2] -= A_2[0,1]
    A_3[0,1] -= A_2[2,0]
    A_3[3,1] -= A_1[0,2]
    A_1, A_2 = A_2, A_3
print(np.sum(A_3)%(10**9+7))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
A_1 = np.zeros((4,4), dtype='int64')
A_2 = np.ones((4,4), dtype='int64')
B = np.ones((4,4), dtype='int64')
for _ in range(n-2):
    A_3 = (B@A_2).T
    A_3 %= 10**9+7
    A_3[2,1] -= A_2[0,2]+A_1[0,2]+A_1[0,3]
    A_3[1,2] -= A_2[0,1]
    A_3[0,1] -= A_2[2,0]
    A_3[3,1] -= A_1[0,2]
    A_1, A_2 = A_2, A_3
print(np.sum(A_3)%(10**9+7))
Problem p03105 (python)

Fixed submission:
a, b, c = map(int, input().split())
print(min(c, b//a))

Buggy submission (verdict: Runtime Error):
from collections import deque
I = lambda: map(int, input().split())
n, m = I()
bridges = [list(I()) for _ in range(m)][1:]
*set_numbers, = range(n+1)
sets = [{i} for i in range(n+1)]
cnt = n*(n-1)//2
cnts = [cnt]
end_set_number = n
for a, b in bridges[::-1]:
    a, b = set_numbers[a], set_numbers[b]
    if a == b: continue
    set_1, set_2 = sets[a], sets[b]
    cnt -= len(set_1)*len(set_2)
    cnts += max(cnt, 0),
    new_set = set_1|set_2
    sets += new_set,
    end_set_number +=1
    for i in new_set:
        set_numbers[i] = end_set_number
print(*cnts[::-1])
Problem p03109 (python)

Fixed submission:
s = int(input().replace('/', ''))
print(['Heisei', 'TBD'][s > 20190430])

Buggy submission (verdict: Runtime Error):
import bisect
I = lambda n: [int(input()) for _ in range(n)]
def f(S, x):
    p = bisect.bisect_left(S, x)
    return min([S[p-1], S[p]], key = lambda s: abs(x-s))
g = lambda x, s, t: abs(x-s)+abs(s-t)
INF = 10**18
a, b, q = map(int, input().split())
S, T, X = [-INF]+I(a)+[INF], [-INF]+I(b)+[INF], I(q)
for x in X:
    s, t = f(S, x), f(T, x)
    print(min(g(x, s, f(T, s)), g(x, t, f(S, t))))
Problem p03125 (python)

Fixed submission:
a, b = map(int, input().split())
print((-1)**(b%a != 0)*a+b)

Buggy submission (verdict: Runtime Error):
I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -float('inf')
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)+[-1]*9
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == digs[n]-1:
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')

Buggy submission (verdict: Runtime Error):
I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -float('inf')
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == (digs[n]-1):
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')

Buggy submission (verdict: Runtime Error):
I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -10**9
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == digs[n]-1:
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')
Problem p03128 (python)

Fixed submission:
I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -float('inf')
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)+[-1]*9
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == digs[n]-1:
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')

Buggy submission (verdict: Runtime Error):
I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -float('inf')
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == (digs[n]-1):
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')

Buggy submission (verdict: Runtime Error):
I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -10**9
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == digs[n]-1:
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')

Buggy submission (verdict: Runtime Error):
I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -float('inf')
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == digs[n] -1:
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')

Buggy submission (verdict: Runtime Error):
I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -float('inf')
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == digs[n] -1:
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')
Problem p03148 (python)

Fixed submission:
mi = lambda: map(int, input().split())
n, k = mi()
sushis = [list(mi()) for _ in range(n)]
types = set()
sushis.sort(key = lambda x: x[1], reverse = True)
bp = tp = sp = 0
exts = []
for t, d in sushis[:k]:
    bp += d
    if t in types:
        exts += d,
    else:
        types.add(t)
        tp += 1
sp = bp+tp**2
for t, d in sushis[k:]:
    if not exts: break
    if t not in types:
        types.add(t)
        bp += d-exts.pop()
        tp += 1
        sp = max(sp, bp+tp**2)
print(sp)

Buggy submission (verdict: Runtime Error):
mi = lambda: map(int, input().split())
n, k = mi()
sushis = [list(mi()) for _ in range(n)]
types = set()
sushis.sort(key = lambda x: x[1], reverse = True)
bp = tp = sp = 0
exts = []
for t, d in sushis[:k]:
    bp += d
    if t in types:
        exts += d,
    else:
        types.add(t)
        tp += 1
sp = bp+tp**2
for t, d in sushis[k:]:
    if t not in types:
        types.add(t)
        bp += d-exts.pop()
        tp += 1
        sp = max(sp, bp+tp**2)
print(sp)
Problem p02582 (python)

Fixed submission:
S = input()
cnt = 0
cnt_max = 0

for i in S:
    if i == 'R':
        cnt += 1
        cnt_max = cnt
    else:
        
        cnt = 0
print(cnt_max)

Buggy submission (verdict: Runtime Error):
S = input()
cnt = 0

for i in S:
    if i == 'R':
        cnt += 1
        cnt_max = cnt
    else:
        
        cnt = 0
print(cnt_max)

Buggy submission (verdict: Runtime Error):
S = input()
cnt = 0

for i in S:
    if i == 'R':
        cnt += 1
    else:
        cnt_max = cnt
        cnt = 0
print(cnt_max)
Problem p02615 (python)

Fixed submission:
n = int(input())

nums = []
nums = list(map(int, input().split()))
nums = sorted(nums, reverse=True)

cnt = 0

fir_num = nums[0]

del nums[0]

for i in range(n-2):
    fir_num += nums[int(i/2)]


print(fir_num)

Buggy submission (verdict: Runtime Error):
nums = []
nums = list(map(int, input().split()))
nums = sorted(nums, reverse=True)

cf = nums[0]

for i in range(2, n):
    nums_min = min(nums[i-1], nums[i-2])
    cf += nums_min

print(cf)
Problem p02573 (python)

Fixed submission:
from collections import deque, defaultdict


def main():
    people_count, info_count = [int(x) for x in input().split()]
    if info_count == 0:
        return 1
    if info_count == 1:
        return 2

    friends = [set() for _ in range(people_count)]
    for _ in range(info_count):
        a, b = [int(x) - 1 for x in input().split()]
        friends[a].add(b)
        friends[b].add(a)
    seen = [False] * people_count
    circle_id = 0
    counter = defaultdict(int)
    for i, circle in enumerate(friends):
        if seen[i]:
            continue
        circle_id += 1
        qu = deque()
        qu.append(i)
        seen[i] == 1
        while qu:
            now = qu.popleft()
            for new in friends[now]:
                if seen[new]:
                    continue
                qu.append(new)
                seen[new] = True
                counter[circle_id] += 1
    return max(v for v in counter.values())


if __name__ == '__main__':
    print(main())

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


def main():
    people_count, info_count = [int(x) for x in input().split()]
    frieds_circle_ids = [-1] * people_count
    id_counter = defaultdict(int)
    new_id = 0
    for _ in range(info_count):
        a, b = [int(x) - 1 for x in input().split()]
        id_a = frieds_circle_ids[a]
        id_b = frieds_circle_ids[b]
        if id_a == -1 == id_b:
            frieds_circle_ids[a] = new_id
            frieds_circle_ids[b] = new_id
            id_counter[new_id] += 2
            new_id += 1
        elif id_a == -1:
            frieds_circle_ids[a] = id_b
            id_counter[id_b] += 1
        elif id_b == -1:
            frieds_circle_ids[b] = id_a
            id_counter[id_a] += 1
        else:
            pass
    return max(count for count in id_counter.values())


if __name__ == '__main__':
    print(main())
Problem p02608 (python)

Fixed submission:
"""
(x+y+z)^2 = (x^2+y^2+z^2) + 2(xy+yz+zx)
"""
def func(x, y, z): return (x + y + z) ** 2 - x * y - y * z - z * x


def main():
    num = int(input())
    counter = [0] * 20000
    # func(41, 41, 41) = 10086
    # func(99, 1, 1) = 10002
    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 123 - x - y + 1):
                tmp = func(x, y, z)
                counter[tmp] += 1
    for key, count in enumerate(counter):
        if key == 0:
            continue
        if key > num:
            break
        print(count)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
"""
(x+y+z)^2 = (x^2+y^2+z^2) + 2(xy+yz+zx)
"""
def func(x, y, z): return (x + y + z) ** 2 - x * y - y * z - z * x


def main():
    num = int(input())
    counter = [0] * (num + 1)
    # func(41, 41, 41) = 10086
    # func(99, 1, 1) = 10002
    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 123 - x - y + 1):
                if (tmp := func(x, y, z)) <= num:
                    counter[tmp] += 1
    for count in counter[1:]:
        print(count)


if __name__ == '__main__':
    main()
Problem p02615 (python)

Fixed submission:
from collections import deque


def main():
    n = int(input())  # n
    friendliness = [int(x) for x in input().split()]
    friendliness.sort()
    friendliness = deque(friendliness)
    edges = deque()
    popped = friendliness.pop()
    edges.append(popped)
    ans = 0
    counter = 0
    while friendliness:
        ans += edges.popleft()
        counter += 1
        popped = friendliness.pop()
        edges.append(popped)
        edges.append(popped)
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    friendliness = [int(x) for x in input().split()]
    friendliness.sort(reversed=True)
    ans = 0
    for i in range(n):
        ans += friendliness[i // 2 + 1]
    print(ans)


if __name__ == '__main__':
    main()
Problem p02647 (python)

Fixed submission:
from itertools import accumulate


def main():
    number, operations = [int(x) for x in input().split()]
    dists = [int(x) for x in input().split()]

    for ope_count in range(operations):
        temp = [0] * (number + 1)
        for i, v in enumerate(dists):
            left = max(i - v, 0)
            right = min(i + v + 1, number)
            temp[left] += 1
            temp[right] -= 1
        templi = list(accumulate(temp))
        if templi == dists:
            break
        else:
            dists = templi

    print(*list(dists)[:-1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    number, operations = [int(x) for x in input().split()]
    dists = [int(x) for x in input().split()]

    # number = 635
    # dists = [1] * number
    # operations = number
    satulation = any(
        operations >= 40,
        number <= 3000 and operations >= 25,
        number <= 1000 and operations >= 21,
        number <= 625 and operations >= 20
    )
    if satulation:
        print(*([number] * number))
        return

    for xx in range(operations):
        dists_new = [0] * number
        for i, d in enumerate(dists):
            start = max(0, i - d)
            end = min(i + d, number - 1)
            for j in range(start, end + 1):
                dists_new[j] += 1
        dists = dists_new
        if min(dists) == number:
            # すべての光が両端まで届く，変化しなくなる。
            print('Over', xx)
            break

    print(*dists)


if __name__ == '__main__':
    main()
Problem p02660 (python)

Fixed submission:
from collections import Counter
from itertools import accumulate


def prime_factorize(n):
    """素因数分解し，ユニークな素因数のsetを返す。"""
    ans = []
    ans_add = ans.append
    while n % 2 == 0:
        ans_add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans_add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans_add(n)
    return ans


def main():
    n = int(input())
    primes = prime_factorize(n)
    acc = tuple(accumulate(range(1, 42)))
    counted = Counter(primes)
    ans = 0

    for c in counted.values():
        for i, x in enumerate(acc):
            if c >= x:
                tmp = i + 1
            else:
                break
        ans += tmp

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from itertools import accumulate


def main():
    n = int(input())
    prime_counter = [0] * n
    acc = tuple(accumulate(range(1, 42)))  # 10^12 < 2^39

    f = 2
    while f * f <= n:
        if n % f == 0:
            n //= f
            prime_counter[f] += 1
        else:
            f += 2
    if n != 1:
        prime_counter[n] += 1

    ans = 0
    for c in prime_counter:
        for i, x in enumerate(acc):
            if c < x:
                tmp = i
                break
        ans += tmp
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from itertools import accumulate


def main():
    n = int(input())
    prime_counter = [0] * int(n ** 0.5 + 2)
    acc = tuple(accumulate(range(1, 42)))  # 10^12 < 2^39

    f = 2
    while f * f <= n:
        if n % f == 0:
            n //= f
            prime_counter[f] += 1
        else:
            f += 2
    if n != 1:
        prime_counter[n] += 1

    ans = 0
    for c in prime_counter:
        for i, x in enumerate(acc):
            if c < x:
                tmp = i
                break
        ans += tmp
    print(ans)


if __name__ == '__main__':
    main()
Problem p02691 (python)

Fixed submission:
class Map(dict):
    def __missing__(self, key):
        default_value = 0
        self[key] = default_value
        return default_value


def main():
    int(input())

    d = Map()
    ans = 0
    for i, height in enumerate(input().split()):
        height = int(height)
        d[i + height] += 1
        ans += d[i - height]

    return ans


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
# class Map(dict):
#     def __missing__(self, key):
#         # この割当てなしのほうが速い。
#         # self[key] = 0
#         return 0


def main():
    int(input())

    d = {}
    ans = 0
    for i, height in enumerate(input().split()):
        height = int(height)
        # 引き算のほうの i は足し算のよりも大きい。
        # 従って，このように順番に見ていく必要がある。
        got = d.get(i + height) or 0
        d[i + height] += got + 1
        ans += d.get(i - height) or 0

    return ans


if __name__ == '__main__':
    print(main())

# 大いに参考にした。
# https://kmjp.hatenablog.jp/entry/2020/05/03/1030

Buggy submission (verdict: Runtime Error):
def main():
    int(input())
    d = {}
    ans = 0
    for i, height in enumerate(input().split()):
        d[i + height] += 1
        ans += d[i - height]


if __name__ == '__main__':
    print(main())