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

Fixed submission:
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


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


def main():
    H, W = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]
    
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if C[i][j] > C[i][k] + C[k][j]:
                    C[i][j] = C[i][k] + C[k][j]
                    
    ans = 0
    for row in A:
        for n in row:
            if n != -1:
                ans += C[n][1]
    
    print(ans)
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    H, W = map(int, readline().split())
    C = [list(map(int, readline().split())) for _ in range(10)]
    A = list(map(int, read().split()))

    counter = Counter(A)

    for k in range(10):
        for i in range(10):
            for j in range(10):
                if C[i][j] > C[i][k] + C[k][j]:
                    C[i][j] = C[i][k] + C[k][j]

    ans = 0
    for n in A:
        if n != -1:
            ans += C[n][1]

    print(ans)
    return


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

Fixed submission:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W, N, *A = map(int, read().split())

    C = [[0] * W for _ in range(H)]
    vec = [i for i, a in enumerate(A, 1) for _ in range(a)]

    for i in range(H):
        for j in range(W):
            color = vec[i * W + j]
            if i % 2 == 0:
                C[i][j] = color
            else:
                C[i][W - j - 1] = color

    for row in C:
        print(*row)

    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W, N, *A = map(int, read().split())

    C = [[0] * W for _ in range(H)]
    vec = [i for i, a in enumerate(A, 1) for _ in range(a)]

    for i in range(H):
        for j in range(W):
            color = vec[i * H + j]
            if i % 2 == 0:
                C[i][j] = color
            else:
                C[i][W - j - 1] = color

    for row in C:
        print(*row)

    return


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

Fixed submission:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, x, *A = map(int, read().split())

    if A[0] > x:
        ans1 = A[0] - x
        prev = x
    else:
        ans1 = 0
        prev = A[0]
    for i in range(1, N):
        if prev + A[i] > x:
            ans1 += prev + A[i] - x
            prev = x - prev
        else:
            prev = A[i]

    if A[-1] > x:
        ans2 = A[-1] - x
        prev = x
    else:
        ans2 = 0
        prev = A[-1]
    for i in range(N - 2, -1, -1):
        if prev + A[i] > x:
            ans2 += prev + A[i] - x
            prev = x - prev
        else:
            prev = A[i]

    print(min(ans1, ans2))
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b, x = map(int, readline().split())

    if a == 0:
        ans = b // x + 1
    else:
        ans = b // x - (a - 1) // x

    print(ans)
    return


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

Fixed submission:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = map(int, read().split())

    dp = [[0] * (N * 50 + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, -1, -1):
            for k in range(N * 50 + 1):
                if k - X[i] >= 0 and j > 0:
                    dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[j][A * j]

    print(ans)
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = map(int, read().split())

    M = sum(X)
    dp = [[0] * (M + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, 0, -1):
            for k in range(X[i], M + 1):
                dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, min(50, M // A) + 1):
        ans += dp[j][A * j]

    print(ans)
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = map(int, read().split())

    M = sum(X)
    dp = [[0] * (M + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, 0, -1):
            for k in range(X[i], M + 1):
                dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, M // A + 1):
        ans += dp[j][A * j]

    print(ans)
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = map(int, read().split())

    M = sum(X)
    dp = [[0] * (M + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, 0, -1):
            for k in range(X[i], M + 1):
                dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, M // A + 1):
        ans += dp[j][A * j]

    print(ans)
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = map(int, read().split())

    M = sum(X)
    dp = [[0] * (M + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, 0, -1):
            for k in range(X[i], M + 1):
                dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[j][A * j]

    print(ans)
    return


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

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

index=0
for i in range(1000):
	if index==0:
		c=c-b
		if c<=0:
			print("Yes")
			break
		else:
			index=1
	else:
		a=a-d
		if a<=0:
			print("No")
			break
		else:
			index=0

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

index=0
for i in range(1000):
	if index==0:
		c=c-b
		if c<=0:
			print("Yes")
			break
		else:
			index=1
	else:
		a=a-d
		if a<=0:
			print("No")
			break
		else:
			index=0
Problem p02801 (python)

Fixed submission:
try:
  n=input()
  c=chr(ord(n)+1)
  print(c)
except:
  pass

Buggy submission (verdict: Runtime Error):
a=input()
t=chr(ord(a)+1)
print(t
Problem p03844 (python)

Fixed submission:
a=input()
for i in range(len(a)):
	if a[i]=='+':
		a1=int(a[:i])
		a2=int(a[i+1:])
		print(a1+a2)
	elif a[i]=='-':
		a1=int(a[:i])
		a2=int(a[i+1:])
		print(a1-a2)

Buggy submission (verdict: Runtime Error):
a=input()
for i in range(len(a)):
	if a[i]=='+':
		a1=int(a[:i])
		a2=int(a[i+1:])
		print(a1+a2)
	elif a[i]=='-':
		a1=int(a[:i])
		a2=int(a[i+1:])
		print(a1-a2)
Problem p04043 (python)

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

success_cases = [(a[0], a[1], a[2]), (a[1], a[2], a[0]), (a[2], a[0], a[1])]

for c in success_cases:
    if c == (5,7,5):
        print("YES")
        exit(0)
print("NO")

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

success_cases = [(a[0], a[1], a[2]), (a[1], a[2], a[0]), a[2], a[0], a[1])]

for c in success_cases:
    if c == (5,7,5):
        print("YES")
        return
print("NO")
Problem p04045 (python)

Fixed submission:
total, k = map(int, input().split())

d = list(map(int, input().split()))

def total_to_digits(total):
    return map(int, list(str(total)))

def find_lowest_denomination(total, d):
    res = None
    for i in range(total, 99999):
        digits = list(total_to_digits(i))
        if not (set(digits) & set(d)):
            print(i)
            return


find_lowest_denomination(total, d)

Buggy submission (verdict: Runtime Error):
total, k = map(int, input().split())

d = input().split()

def find_lowest_denomination(total, d):
    for i in range(total, 10001):
        if not set(str(i)) & set(d):
            print(i)
            return
    raise ValueError('Should never reach this code block')



find_lowest_denomination(total, d)
Problem p02586 (python)

Fixed submission:
def main():
    r, c, k = map(int, input().split())
    d = [[0]*c for _ in [0]*r]
    for _ in range(k):
        t1, t2, t3 = map(int, input().split())
        d[t1-1][t2-1] = t3
    dp = [[0]*4 for _ in [0]*c]
    dp[0][1] = d[0][0]
    for x in range(r):
        dp2 = [[0]*4 for _ in [0]*c]
        for y in range(c):
            for z in range(4):
                if y != c-1:
                    if z != 3:
                        dp[y+1][z+1] = max(dp[y+1]
                                           [z+1], dp[y][z]+d[x][y+1])
                    dp[y+1][z] = max(dp[y+1][z], dp[y][z])
            if x != r-1:
                dp2[y][1] = max(dp2[y][1],
                                max(dp[y])+d[x+1][y])
                dp2[y][0] = max(dp2[y][0], max(dp[y]))
        if x != r-1:
            dp = dp2
    print(max(dp[c-1]))


main()

Buggy submission (verdict: Runtime Error):
def main():
    r, c, k = map(int, input().split())
    d = [[0]*c for _ in [0]*r]
    for _ in range(k):
        t1, t2, t3 = map(int, input().split())
        d[t1-1][t2-1] = t3
    dp = [[0]*4 for _ in [0]*c]
    dp[0][1] = d[0][0]
    for x in range(r-1):
        d2 = d[x]
        dp2 = [[0]*4 for _ in [0]*c]
        for y in range(c-1):
            d3 = d2[y+1]
            for z in range(3):
                dp[y+1][z+1] = max(dp[y+1][z+1], dp[y][z]+d3)
            for z in range(4):
                dp[y+1][z] = max(dp[y+1][z], dp[y][z])
        d2 = d[x+1]
        for y in range(c):
            dp2[y][1] = max(dp2[y][1], max(dp[y])+d2[y])
            dp2[y][0] = max(dp2[y][0], max(dp[y]))
        dp = dp2
    for y in range(c-1):
        d3 = d2[y+1]
        for z in range(3):
            dp[y+1][z+1] = max(dp[y+1][z+1], dp[y][z]+d3)
        for z in range(4):
            dp[y+1][z] = max(dp[y+1][z], dp[y][z])
    print(max(dp[c-1]))


main()

Buggy submission (verdict: Runtime Error):
def main():
    r, c, k = map(int, input().split())
    d = [[0]*c for _ in [0]*r]
    for _ in range(k):
        t1, t2, t3 = map(int, input().split())
        d[t1-1][t2-1] = t3
    dp = [[0]*4 for _ in [0]*c]
    dp[0][1] = d[0][0]
    for x in range(r-1):
        d2 = d[x]
        dp2 = [[0]*4 for _ in [0]*c]
        for y in range(c-1):
            d3 = d2[y+1]
            dp3 = dp[y+1]
            dp4 = dp[y]
            for z in range(3):
                dp3[z+1] = max(dp3[z+1], dp4[z]+d3)
            for z in range(4):
                dp3[z] = max(dp3[z], dp4[z])
        d2 = d[x+1]
        for y in range(c):
            dp3 = dp2[y]
            M = max(dp[y])
            dp3[1] = max(dp3[1], M+d2[y])
            dp3[0] = max(dp3[0], M)
        dp = dp2
    for y in range(c-1):
        d3 = d2[y+1]
        dp2 = dp[y+1]
        dp3 = dp[y]
        for z in range(3):
            dp2[z+1] = max(dp2[z+1], dp3[z]+d3)
        for z in range(4):
            dp2[z] = max(dp2[z], dp3[z])
    print(max(dp[c-1]))


main()
Problem p02609 (python)

Fixed submission:
def main():
    n = int(input())
    bit = input()[::-1]
    count = bit.count("1")
    count_plus = count+1
    count_minus = count-1
    pow_plus = [1 % count_plus]
    for i in range(n):
        pow_plus.append(pow_plus[-1]*2 % count_plus)
    if count_minus != 0:
        pow_minus = [1 % count_minus]
        for i in range(n):
            pow_minus.append(pow_minus[-1]*2 % count_minus)
    else:
        pow_minus = []

    bit_plus = 0
    bit_minus = 0

    for i in range(n):
        if bit[i] == "1":
            bit_plus = (bit_plus+pow_plus[i]) % count_plus
    if count_minus != 0:
        for i in range(n):
            if bit[i] == "1":
                bit_minus = (bit_minus+pow_minus[i]) % count_minus
    ans = []
    for i in range(n):
        if bit[i] == "1":
            if count_minus == 0:
                ans.append(0)
                continue
            bit_ans = (bit_minus-pow_minus[i]) % count_minus
            count = count_minus
        else:
            bit_ans = (bit_plus+pow_plus[i]) % count_plus
            count = count_plus
        cnt = 1
        while bit_ans:
            b = str(bin(bit_ans)).count("1")
            bit_ans = bit_ans % b
            cnt += 1
        ans.append(cnt)
    for i in ans[::-1]:
        print(i)


main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    bit = input()[::-1]
    count = bit.count("1")
    count_plus = count+1
    count_minus = count-1
    pow_plus = [1 % count_plus]
    pow_minus = [1 % count_minus]
    for i in range(n):
        pow_plus.append(pow_plus[-1]*2 % count_plus)
    for i in range(n):
        pow_minus.append(pow_minus[-1]*2 % count_minus)

    bit_plus = 0
    bit_minus = 0

    for i in range(n):
        if bit[i] == "1":
            bit_plus = (bit_plus+pow_plus[i]) % count_plus
    for i in range(n):
        if bit[i] == "1":
            bit_minus = (bit_minus+pow_minus[i]) % count_minus
    ans = []
    for i in range(n):
        if bit[i] == "1":
            bit_ans = (bit_minus-pow_minus[i]) % count_minus
            count = count_minus
            if count_minus == 0:
                ans.append(0)
                continue
        else:
            bit_ans = (bit_plus+pow_plus[i]) % count_plus
            count = count_plus
        cnt = 1
        while bit_ans:
            b = str(bin(bit_ans)).count("1")
            bit_ans = bit_ans % b
            cnt += 1
        ans.append(cnt)
    for i in ans[::-1]:
        print(i)


main()
Problem p02617 (python)

Fixed submission:
def main():
    n = int(input())
    ans = n * (n + 1) * (n + 2) // 6
    
    for i in range(n-1):
        x, y = map(int, input().split())
        if x > y:
            y, x = x, y
        ans -= x * (n - y + 1)
    print(ans)
    
main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    ans = n * (n + 1) * (n + 2) // 6
    
    for i in range(n):
        x, y = map(int, input().split())
        if x > y:
            y, x = x, y
        ans -= x * (n - y + 1)
    print(ans)
    
main()

Buggy submission (verdict: Runtime Error):
def main() {
    n = int(input())
    ans = n * (n + 1) * (n + 2) // 6;
    for i in range(n):
        x, y = map(int, input().split())
        if (x > y) { y, x = x, y; }
        ans -= x * (n - y + 1);
    }
    print(ans);
}
main()
Problem p02632 (python)

Fixed submission:
def main():
    mod = 10**9+7
    k = int(input())
    s = input()
    n = len(s)
    fact = [1, 1]
    for i in range(2, 2*(10**6)+1):
        fact.append(fact[-1]*i % mod)

    def nCr(n, r, mod=10**9+7):
        return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod

    ans = 0
    for i in range(k+1):
        ans = (ans+nCr(n+k, i)*pow(25, i, mod)) % mod
    print(ans)


main()

Buggy submission (verdict: Runtime Error):
def main():
    mod = 10**9+7
    k = int(input())
    n = len(input())

    @njit(i8[:](i8, i8), cache=True)
    def num_calc(n, mod):
        fact = np.ones(n+1, dtype=np.int64)
        for i in range(2, n+1):
            fact[i] = fact[i-1]*i % mod
        return fact

    @njit(i8[:](i8, i8), cache=True)
    def num_calc2(k, mod):
        power = np.ones(k+1, dtype=np.int64)
        for i in range(1, k+1):
            power[i] = power[i-1]*25 % mod
        return power

    @njit(i8(i8, i8, i8), cache=True)
    def pow(n, k, mod=10**9+7):
        l, now = np.ones(64, np.int64), 1
        l[0] = n
        for i in range(1, 64):
            l[i] = l[i-1]*l[i-1] % mod
        for i in range(64):
            if k & 1:
                now = now*l[i] % mod
            k >>= 1
        return now

    fact = num_calc(n+k, mod)
    nk = fact[n+k]
    fact = fact[n+k:n-1:-1]*fact[:k+1] % mod
    power = (num_calc2(k, mod)*nk) % mod

    print(sum([pow(i, mod-2, mod)*j for i, j in zip(fact, power)]) % mod)


main()
Problem p02678 (python)

Fixed submission:
def main():

    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    import heapq
    h = [(0, 0)]
    heapq.heapify(h)
    d = [10**10]*n
    while h:
        dis, i = heapq.heappop(h)
        if d[i] == 10**10:
            d[i] = dis
            for j in g[i]:
                if d[j] == 10**10:
                    heapq.heappush(h, (dis+1, j))

    print("Yes")
    for i in range(1, n):
        minimum = 10**9
        dire = None
        for j in g[i]:
            if d[j] < minimum:
                minimum = d[j]
                dire = j
        print(dire+1)


main()

Buggy submission (verdict: Runtime Error):
def main():

    n, m = map(int, input().split())

    import numpy as np
    import scipy.sparse as sp
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    data = [1 for a, b in ab]
    row = [a-1 for a, b in ab]
    col = [b-1 for a, b in ab]
    matrix = sp.csr_matrix((data, (row, col)), shape=(n, n), dtype=np.int32)
    d = sp.csgraph.dijkstra(matrix, indices=0)

    print("Yes")
    for i in range(1, n):
        minimum = 10**9
        dire = None
        for j in g[i]:
            if d[j] < minimum:
                minimum = d[j]
                dire = j
        print(dire+1)


main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    import numpy as np
    import scipy.sparse.csgraph as sp
    inf = float('inf')
    d = np.full((n, n), inf)
    for i in range(n):
        d[i][i] = 0
    for a, b in ab:
        d[a-1][b-1] = 1
        d[b-1][a-1] = 1
    # indices=xでxからの単一始点に,return_predecessors=Trueで経路が出る
    s = sp.shortest_path(d, indices=0)
    print("Yes")
    for i in range(1, n):
        minimum = 10**9
        dire = None
        for j in g[i]:
            if s[j] < minimum:
                minimum = s[j]
                dire = j
        print(dire+1)


main()
Problem p02702 (python)

Fixed submission:
def main():
    s = input()
    d = [0]*2019
    d[0] += 1
    now = 0
    for j, i in enumerate(s[::-1]):
        now = (int(i)*pow(10, j, 2019)+now) % 2019
        d[now] += 1
    print(sum([i*(i-1)//2 for i in d]))


main()

Buggy submission (verdict: Runtime Error):
def main():
    import heapq
    inf = 10**16
    n, m, s = map(int, input().split())
    uvab = [list(map(int, input().split())) for _ in [0]*m]
    cd = [list(map(int, input().split())) for _ in [0]*n]
    g = [[] for _ in [0]*n]
    [g[a-1].append([b-1, c, d]) for a, b, c, d in uvab]
    [g[b-1].append([a-1, c, d]) for a, b, c, d in uvab]
    vertex = [[inf]*2501 for _ in [0]*n]
    h = [(0, 0, min(s, 2500))]  # 時刻、位置、所持金
    heapq.heapify(h)
    while h:
        t, p, money = heapq.heappop(h)
        if vertex[p][money] != inf:
            continue
        vertex[p][money] = t
        newmoney = min(money+cd[p][0], 2500)
        if vertex[p][newmoney] == inf:
            heapq.heappush(h, (t+cd[p][1], p, newmoney))
        for a, b, c in g[p]:  # 行き先、運賃、時間
            if money < b:
                continue
            if vertex[a][money-b] != inf:
                continue
            heapq.heappush(h, (t+c, a, money-b))
    for i in vertex[1:]:
        print(min(i))


main()
Problem p02716 (python)

Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if n % 2 == 0:
        dp = [[[-10**18]*2, [-10**18]*2] for _ in [0]*(n+1)]
        dp[0][0][0] = 0
        for i in range(n):
            # 使う場合
            dp[i+1][1][0] = max(dp[i+1][1][0], dp[i][0][0]+a[i])
            dp[i+1][1][1] = max(dp[i+1][1][1], dp[i][0][1]+a[i])
            # 使わない場合
            dp[i+1][0][1] = max(dp[i+1][0][1], dp[i][0][0])
            # 更新
            dp[i+1][0][0] = max(dp[i+1][0][0], dp[i][1][0])
            dp[i+1][0][1] = max(dp[i+1][0][1], dp[i][1][1])
        print(max(dp[n][1][1], dp[n][0][0]))
        return
    dp = [[[-10**18]*3, [-10**18]*3] for _ in [0]*(n+1)]
    dp[0][0][0] = 0
    for i in range(n):
        # 使う場合
        dp[i+1][1][0] = max(dp[i+1][1][0], dp[i][0][0]+a[i])
        dp[i+1][1][1] = max(dp[i+1][1][1], dp[i][0][1]+a[i])
        dp[i+1][1][2] = max(dp[i+1][1][2], dp[i][0][2]+a[i])
        # 使わない場合
        dp[i+1][0][1] = max(dp[i+1][0][1], dp[i][0][0])
        dp[i+1][0][2] = max(dp[i+1][0][2], dp[i][0][1])
        # 更新
        dp[i+1][0][0] = max(dp[i+1][0][0], dp[i][1][0])
        dp[i+1][0][1] = max(dp[i+1][0][1], dp[i][1][1])
        dp[i+1][0][2] = max(dp[i+1][0][2], dp[i][1][2])
    print(max(dp[n][1][2], dp[n][0][1]))


main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if n % 2 == 0:
        print(max(sum(a[::2]), sum(a[1::2])))
        return
    else:
        print(1/0)


main()