alexjercan/bugnet huggingface dataset:
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

# D - RGB Triplets
from collections import defaultdict


def main():
    _ = int(input())
    S = input().rstrip()
    indices = defaultdict(set)
    for i, c in enumerate(S):
        indices[c].add(i)
    cnt = len(indices["R"]) * len(indices["G"]) * len(indices["B"])
    for c1, c2, c3 in ["RGB", "GBR", "BRG"]:
        cnt -= sum(
            (i + j) % 2 == 0 and (i + j) // 2 in indices[c3]
            for i in indices[c1]
            for j in indices[c2]
        )
    print(cnt)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

# D - RGB Triplets
def main():
    _ = int(input())
    S = input().rstrip()
    cnt = 0
    for j, b in enumerate(S[1:-1], 1):
        for i, a in enumerate(S[:j]):
            for k, c in enumerate(S[j + 1 :], j + 1):
                if a == b or a == c or b == c:
                    continue
                elif j - i == k - j:
                    continue
                cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
s = list(input())
r_pos = []
g_pos = []
b_pos = []

for i in range(n):
    st = s[i]
    if st == "R":
        r_pos.append(i)

    if st == "G":
        g_pos.append(i)

    if st == "B":
        b_pos.append(i)

colors = [r_pos, g_pos, b_pos]
if len(colors[0]) > len(colors[1]):
    colors[0], colors[1] = colors[1], colors[0]
if len(colors[0]) > len(colors[2]):
    colors[0], colors[2] = colors[2], colors[0]
if len(colors[1]) > len(colors[2]):
    colors[1], colors[2] = colors[2], colors[1]

x_num, y_num, z_num = len(colors[0]), len(colors[1]), len(colors[2])

ans = x_num * y_num * z_num
c = set(colors[2])
for a in colors[0]:
    for b in colors[1]:
        x, y = min(a, b), max(a, b)

        dif = y - x
        left_pos = x - dif
        right_pos = y + dif
        mid_pos = 4000
        if dif % 2 == 0:
            mid_pos = x + dif // 2

        left = 0
        right = 0
        mid = 0
        if left_pos in c:
            left = 1
        if right_pos in c:
            right = 1
        if mid_pos in c:
            mid = 1

        ans -= left + right + mid

print(ans)


Error: TLE

Fixed submission:

n = int(input())
s = list(input())
r_pos = []
g_pos = []
b_pos = []

for i in range(n):
    st = s[i]
    if st == "R":
        r_pos.append(i)

    if st == "G":
        g_pos.append(i)

    if st == "B":
        b_pos.append(i)

colors = [r_pos, g_pos, b_pos]
if len(colors[0]) > len(colors[1]):
    colors[0], colors[1] = colors[1], colors[0]
if len(colors[0]) > len(colors[2]):
    colors[0], colors[2] = colors[2], colors[0]
if len(colors[1]) > len(colors[2]):
    colors[1], colors[2] = colors[2], colors[1]

x_num, y_num, z_num = len(colors[0]), len(colors[1]), len(colors[2])

ans = x_num * y_num * z_num
for a in colors[0]:
    for b in colors[1]:
        x, y = min(a, b), max(a, b)

        dif = y - x
        left_pos = x - dif
        right_pos = y + dif
        mid_pos = 4000
        if dif % 2 == 0:
            mid_pos = x + dif // 2

        left = 0
        right = 0
        mid = 0
        if left_pos in colors[2]:
            left = 1
        if right_pos in colors[2]:
            right = 1
        if mid_pos in colors[2]:
            mid = 1

        ans -= left + right + mid

print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

def check_RGB(c1, c2, c3):
    l = [c1, c2, c3]
    return ("R" in l) and ("G" in l) and ("B" in l)


N = int(input())
S = input()

R, G, B = 0, 0, 0
for i, s in enumerate(S):
    if s == "R":
        R += 1
    elif s == "G":
        G += 1
    else:
        B += 1

result = R * G * B

width = 1
while width * 2 < N:
    i = 0
    first = i
    mid = i + width
    last = i + width * 2

    while last < N:
        if check_RGB(S[first], S[mid], S[last]):
            result -= 1

        i += 1
        first = i
        mid = i + width
        last = i + width * 2

    width += 1

print(result)


Error: TLE

Fixed submission:

N = int(input())
S = input()

R, G, B = [], [], []
for i, s in enumerate(S):
    if s == "R":
        R.append(i)
    elif s == "G":
        G.append(i)
    else:
        B.append(i)

result = 0
for r in R:
    for g in G:
        for b in B:
            i = min(r, g, b)
            k = max(r, g, b)
            j = (r + g + b) - i - k
            if j - i != k - j:
                result += 1

print(result)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

# https://atcoder.jp/contests/abc162/tasks/abc162_d

N = int(input())
S = input()


def colors(target, a, b):
    for i in range(N):
        for j in range(i + 1, N):
            if S[i] == a and S[j] == b:
                target[i] += 1


rg = [0 for _ in range(N)]
colors(rg, "R", "G")
gr = [0 for _ in range(N)]
colors(gr, "G", "R")

gb = [0 for _ in range(N)]
colors(gb, "G", "B")
bg = [0 for _ in range(N)]
colors(bg, "B", "G")

rb = [0 for _ in range(N)]
colors(rb, "R", "B")
br = [0 for _ in range(N)]
colors(br, "B", "R")

ans = 0
for i in range(N):
    if S[i] == "B":
        for j in range(i + 1, N):
            ans += rg[j]
            ans += gr[j]

            k = j + j - i
            if k >= N:
                continue
            if S[i] == "B" and S[j] == "R" and S[k] == "G":
                ans -= 1
            if S[i] == "B" and S[j] == "G" and S[k] == "R":
                ans -= 1

    if S[i] == "R":
        for j in range(i + 1, N):
            ans += gb[j]
            ans += bg[j]

            k = j + j - i
            if k >= N:
                continue
            if S[i] == "R" and S[j] == "G" and S[k] == "B":
                ans -= 1
            if S[i] == "R" and S[j] == "B" and S[k] == "G":
                ans -= 1

    if S[i] == "G":
        for j in range(i + 1, N):
            ans += rb[j]
            ans += br[j]

            k = j + j - i
            if k >= N:
                continue
            if S[i] == "G" and S[j] == "R" and S[k] == "B":
                ans -= 1
            if S[i] == "G" and S[j] == "B" and S[k] == "R":
                ans -= 1

print(ans)


Error: TLE

Fixed submission:

# https://atcoder.jp/contests/abc162/tasks/abc162_d

N = int(input())
S = input()

ans = 0
for i in range(N):
    for j in range(i, N):
        for k in range(j, N):
            if j - i == k - j:
                continue

            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ans += 1

print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
S = [s for s in input()]
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = j + (j - i)
        if N - 1 < k:
            continue
        if S[k] != S[i] and S[k] != S[j] and S[i] != S[j]:
            ans -= 1

print(ans)


Error: TLE

Fixed submission:

N = int(input())
S = input()
exc = 0
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = j + (j - i)
        if N - 1 < k:
            continue
        if S[k] != S[i] and S[k] != S[j] and S[i] != S[j]:
            ans -= 1

print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
S = input()
a = S.count("R") * S.count("G") * S.count("B")
c = 0
for i in range(N):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k >= N:
            continue
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            c += 1
print(a - c)


Error: TLE

Fixed submission:

N = int(input())
S = input()
c = 0
for i in range(N):
    for j in range(i, N):
        for k in range(j, N):
            if len(set([S[i], S[j], S[k]])) == 3 and j - i != k - j:
                c += 1
print(c)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            x = 2 * j - i
            if x < N and S[i] != S[x] and S[x] != S[j]:
                ans -= 1

print(ans)


Error: TLE

Fixed submission:

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            x = 2 * j - i
            if x <= N - 1 and S[i] != S[x] and S[x] != S[j]:
                ans -= 1

print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
s = list(input())
r = 0
g = 0
b = 0


for i in range(n):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    else:
        b += 1

ans = r * g * b

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = 2 * j - i
        if k < n:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1


print(ans)


Error: TLE

Fixed submission:

n = int(input())
s = list(input())
ans = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        if s[j] == s[i]:
            continue
        for k in range(j + 1, n):
            if s[k] == s[i] or s[k] == s[j] or 2 * j - i == k:
                continue

            ans += 1

print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

def main():
    N = int(input())
    S = input()
    ans = S.count("R") * S.count("G") * S.count("B")
    for i in range(N):
        for d in range(N - 1):
            j = i + d
            k = j + d
            if k < N and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
    print(ans)


main()


Error: TLE

Fixed submission:

N = int(input())
S = input()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[j] != S[i]:
            for k in range(j + 1, N):
                if j - i != k - j and S[k] != S[i] and S[k] != S[j]:
                    ans += 1
print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

def main():
    N = int(input())
    S = input()
    cnt = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = 2 * j - i
            if k >= N:
                continue
            if S[j] != S[i] and S[i] != S[k] and S[k] != S[j]:
                cnt += 1
    print(S.count("R") * S.count("B") * S.count("G") - cnt)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

def main():
    N = int(input())
    S = input()
    cnt = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                if j - i == k - j:
                    if S[j] != S[i] and S[i] != S[k] and S[k] != S[j]:
                        cnt += 1
    print(S.count("R") * S.count("B") * S.count("G") - cnt)


if __name__ == "__main__":
    main()
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
S = input()

total_comb = S.count("R") * S.count("G") * S.count("B")

minus = 0
for i in range(N - 2):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k < N:
            if (S[i] != S[j]) and (S[j] != S[k]) and (S[k] != S[i]):
                minus += 1

print(total_comb - minus)


Error: TLE

Fixed submission:

from _collections import defaultdict

N = int(input())
S = input()

counted_dict = defaultdict(list)
for i in range(N):
    char = S[i]
    if char == "R":
        counted_dict["R"].append(i)
    elif char == "G":
        counted_dict["G"].append(i)
    else:
        counted_dict["B"].append(i)

count = 0
for x in range(len(counted_dict["R"])):
    r_pos = counted_dict["R"][x]
    for y in range(len(counted_dict["G"])):
        g_pos = counted_dict["G"][y]
        for z in range(len(counted_dict["B"])):
            b_pos = counted_dict["B"][z]
            colors_pos_list = [r_pos, g_pos, b_pos]
            colors_pos_list.sort()
            if not colors_pos_list[2] + colors_pos_list[0] == 2 * colors_pos_list[1]:
                count += 1

print(count)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
s = list(input())

ans = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
    for d in range(n):
        j = i + d
        k = i + 2 * d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
            ans -= 1

print(ans)


Error: TLE

Fixed submission:

n = int(input())
s = list(input())

ans = 0
list1 = ["", "", ""]
for i in range(n):
    for j in range(n):
        if i < j:
            for k in range(n):
                if j < k:
                    if s[i] != s[j]:
                        if s[j] != s[k]:
                            if s[i] != s[k]:
                                if j - i != k - j:
                                    ans += 1
print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
S = input()

# keyは(色、jの位置)のタプル
dp = {}

ans = 0

for i in range(n - 2):
    c_i = S[i]
    for j in range(i + 1, n - 1):
        if S[j] == c_i:
            continue
        c_j = S[j]
        d_ij = j - i
        if (c_i, j) in dp:
            ans += dp[(c_i, j)]
            if j + d_ij < n:
                c_k = S[j + d_ij]
                if c_i != c_j and c_j != c_k and c_k != c_i:
                    ans -= 1
        else:
            tmp = 0
            for k in range(j + 1, n):
                c_k = S[k]
                if c_i != c_j and c_j != c_k and c_k != c_i:
                    tmp += 1
            dp[(c_i, j)] = tmp
            if j + d_ij < n:
                c_k = S[j + d_ij]
                if c_i != c_j and c_j != c_k and c_k != c_i:
                    tmp -= 1
            ans += tmp
print(ans)


Error: TLE

Fixed submission:

n = int(input())
S = input()

# keyは(色、jの位置)のタプル
dp = {}

ans = 0

for i in range(n - 2):
    c_i = S[i]
    for j in range(i + 1, n - 1):
        if S[j] == c_i:
            continue
        c_j = S[j]
        d_ij = j - i
        if (c_i, c_j, j) in dp:
            ans += dp[(c_i, c_j, j)]
            if j + d_ij < n:
                c_k = S[j + d_ij]
                if c_i != c_j and c_j != c_k and c_k != c_i:
                    ans -= 1
        else:
            tmp = 0
            for k in range(j + 1, n):
                c_k = S[k]
                if c_i != c_j and c_j != c_k and c_k != c_i:
                    tmp += 1
            dp[(c_i, c_j, j)] = tmp
            if j + d_ij < n:
                c_k = S[j + d_ij]
                if c_i != c_j and c_j != c_k and c_k != c_i:
                    tmp -= 1
            ans += tmp
print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
s = input()

r = s.count("R")
b = s.count("B")
g = s.count("G")

cnt = 0

for i in range(n):
    for j in range(i + 1, n):
        k = j + j - i
        if k >= n:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            cnt += 1

print(r * b * g - cnt)


Error: TLE

Fixed submission:

n = int(input())
s = input()

cnt = 0

for i in range(n):
    for j in range(i, n):
        for k in range(j, n):
            if (s[i] != s[j] and s[i] != s[k] and s[j] != s[k]) and (j - i != k - j):
                cnt += 1

print(cnt)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
s = input()
rr = 0
gg = 0
bb = 0
for i in range(n):
    if s[i] == "R":
        rr += 1
    if s[i] == "G":
        gg += 1
    if s[i] == "B":
        bb += 1

ans = rr * gg * bb

for j in range(n):
    for i in range(min(j + 1, n - j)):
        if s[j - i] != s[j] and s[j] != s[j + i] and s[j + i] != s[j - i]:
            ans -= 1
print(ans)


Error: TLE

Fixed submission:

n = int(input())
s = input()
rr = 0
gg = 0
bb = 0
for i in range(n):
    if s[i] == "R":
        rr += 1
    if s[i] == "G":
        gg += 1
    if s[i] == "B":
        bb += 1

ans = rr * gg * bb

for i in range(n):
    for j in range(n):
        if j - i >= 0 and j + i < n:
            if s[j - i] != s[j] and s[j] != s[j + i] and s[j + i] != s[j - i]:
                ans -= 1
print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

cnt = 0

for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i < n:
            if s[i] != s[j] and s[i] != s[2 * j - i] and s[j] != s[2 * j - i]:
                cnt += 1

print(r * g * b - cnt)


Error: TLE

Fixed submission:

n = int(input())
s = input()

count = 0

for i in range(n):
    for j in range(i, n):
        for k in range(j, n):
            if (s[i] != s[j] and s[i] != s[k] and s[j] != s[k]) and (j - i != k - j):
                count += 1
print(count)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

# from bisect import bisect_left

n = int(input())
s = input()
RL = []
GL = []
BL = []
for i in range(1, n + 1):
    word = s[i - 1]
    if word == "R":
        RL.append(i)
    elif word == "G":
        GL.append(i)
    else:
        BL.append(i)
nagasa_r = len(RL)
nagasa_g = len(GL)
nagasa_b = len(BL)
SBL = set(BL)
ans = 0
if nagasa_b == 0 or nagasa_g == 0 or nagasa_r == 0:
    ans = 0
else:
    out_count = 0
    for r in RL:
        for g in GL:
            bigger = max(r, g)
            smaller = min(r, g)
            delta = bigger - smaller
            if (r + g) % 2 == 0:
                outnumber = [bigger + delta, smaller - delta, (r + g) // 2]
            else:
                outnumber = [bigger + delta, smaller - delta]
            for num in outnumber:
                if num in SBL:
                    out_count += 1
            ans += nagasa_b
    ans -= out_count
print(ans)


Error: TLE

Fixed submission:

n = int(input())
s = input()
RL = []
GL = []
BL = []
for i in range(1, n + 1):
    word = s[i - 1]
    if word == "R":
        RL.append(i)
    elif word == "G":
        GL.append(i)
    else:
        BL.append(i)
ans = 0
for r in RL:
    for g in GL:
        for b in BL:
            delta1 = abs(r - g)
            delta2 = abs(g - b)
            delta3 = abs(b - r)
            if delta1 == delta2:
                continue
            if delta2 == delta3:
                continue
            if delta3 == delta1:
                continue
            ans += 1
print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
s = input()

ans = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        # 三個目が範囲内 かつ 三文字違う かつ 距離が同じはダメ
        if k < n and (s[i] != s[j] and s[j] != s[k] and s[i] != s[k]) and j - i == k - j:
            ans -= 1

print(ans)


Error: TLE

Fixed submission:

n = int(input())
s = input()
ans = 0
for i in range(len(s)):
    one = s[i]
    for j in range(i + 1, len(s)):
        if s[j] == one:
            continue
        dis1 = j - i
        two = s[j]
        for k in range(j + 1, len(s)):
            if s[k] == one or s[k] == two:
                continue
            else:
                dis2 = k - j
                if dis1 != dis2:
                    ans += 1

print(ans)
Problem p02714 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys
from collections import Counter


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = input()
    C = Counter(S)
    R = C.get("R", 0)
    G = C.get("G", 0)
    B = C.get("B", 0)
    ans = R * G * B
    for left in range(N):
        for mid in range(left + 1, N):
            right = mid + mid - left
            if right < N:
                if S[right] != S[mid] and S[mid] != S[left] and S[right] != S[left]:
                    ans -= 1
    print(ans)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

import sys
from itertools import product


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = input()
    r = []
    g = []
    b = []
    for i in range(N):
        if S[i] == "R":
            r.append(i)
        elif S[i] == "G":
            g.append(i)
        else:
            b.append(i)
    A = product(r, g, b)
    ans = 0
    for a in A:
        a = list(a)
        a.sort()
        if a[2] - a[1] != a[1] - a[0]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
Problem p02715 (Python) — buggy submission, verdict: Runtime Error

# YouTube解説
MOD = 1000000007
n, k = [int(x) for x in input().split()]
d = [0] * (k + 1)

for i in range(1, k + 1):
    d[i] = pow(k // i, n, MOD)

for i in range(k, 0, -1):  # 大きいほうから
    for j in range(i * 2, k + 1, i):  # iの倍数
        # d[6] = d'[6] - d[12] - d[18] ...
        d[i] -= d[j]
        d[i] %= MOD
ans = 0
for i, item in enumerate(d):
    ans += i * item
    ans %= MOD
print(ans)


Error: ZeroDivisionError: integer division or modulo by zero
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02715/Python/s098159754.py", line 7, in <module>
    d[i] = pow(k // i, n, MOD)
ZeroDivisionError: integer division or modulo by zero


Fixed submission:

# YouTube解説
MOD = 1000000007
n, k = [int(x) for x in input().split()]
d = [0] * (k + 1)

for i in range(0, k + 1):
    d[i] = pow(k // i, n, MOD)

for i in range(k, 0, -1):  # 大きいほうから
    for j in range(i * 2, k + 1, i):  # iの倍数
        # d[6] = d'[6] - d[12] - d[18] ...
        d[i] -= d[j]
        d[i] %= MOD
ans = 0
for i, item in enumerate(d):
    ans += i * item
    ans %= MOD
print(ans)
Problem p02716 (Python) — buggy submission, verdict: Time Limit Exceeded

def find_max(a):
    n = len(a)

    if n <= 3:
        return max(a)

    dp = [[-(1 << 64)] * (2 + n % 2) for _ in range(n)]

    for i in range(2 + n % 2):
        dp[i][i] = a[i]
        dp[i + 1][i] = a[i]

    for i in range(2, n):
        for j in range(2 + n % 2):
            for extra_space in range(j + 1):
                curr_sum = dp[i - (2 + extra_space)][j - extra_space] + a[i]
                if curr_sum > dp[i][j]:
                    dp[i][j] = curr_sum

    return dp[-1][1 + n % 2]


def main():
    _ = int(input())
    a = list(map(int, input().split()))

    print(find_max(a))


main()


Error: TLE

Fixed submission:

# unfinished
INF = 1 << 64


def find_max(a):
    n = len(a)
    odd_a = [a[i] for i in range(n) if i % 2 == 0]
    even_a = [a[i] for i in range(n) if i % 2 == 1]

    cum_odd_a = [0]
    sum_odd_a = 0
    for odd_a_elem in odd_a:
        cum_odd_a.append(cum_odd_a[-1] + odd_a_elem)
        sum_odd_a += odd_a_elem

    cum_even_a = [0]
    sum_even_a = 0
    for even_a_elem in even_a:
        cum_even_a.append(cum_even_a[-1] + even_a_elem)
        sum_even_a += even_a_elem

    max_sum_half_a = -INF

    if n % 2 == 0:  # nが偶数である場合
        # 奇数と偶数の境目
        for i in range(n // 2 + 1):
            odd_part_sum = cum_odd_a[i]
            even_part_sum = sum_even_a - cum_even_a[i]
            sum_half_a = odd_part_sum + even_part_sum

            if sum_half_a > max_sum_half_a:
                max_sum_half_a = sum_half_a
    else:  # nが奇数である場合
        # 奇数と偶数の境目
        for i in range(n // 2 + 1):
            odd_part_sum_1 = cum_odd_a[i]

            # 偶数と奇数の境目
            for j in range(i, n // 2 + 1):
                even_part_sum = cum_even_a[j] - cum_even_a[i]
                odd_part_sum_2 = sum_odd_a - cum_odd_a[j + 1]

                sum_half_a = odd_part_sum_1 + even_part_sum + odd_part_sum_2

                if sum_half_a > max_sum_half_a:
                    max_sum_half_a = sum_half_a

    return max_sum_half_a


def main():
    _ = int(input())
    a = list(map(int, input().split()))

    print(find_max(a))


main()
Problem p02717 (Python) — buggy submission, verdict: Runtime Error

A, B, C = [int(i) for i in input().split()]

A, B, C = B, A, C
A, B, C = C, B, A

print("%s %s %s" % (A, B, C))


Error: 0

Fixed submission:

A, B, C = [int(i) for i in input().split()]

A, B, C = B, A, C
A, B, C = C, B, A

print(f"{A} {B} {C}")