Buggy python submission (verdict: Runtime Error):

f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(f.readline())
A = list(map(int, f.readline().split()))
A.insert(0, 0)

select_num = N//2
inf = -10e+10

Dp_f = [[inf] * (3) for _ in range(N+1)]
Dp_s = [[inf] * (3) for _ in range(N+1)]
# 3　次元はそれぞれStart~3つに該当

pre_margin = 0
for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    cur_margin = Start
    
    for j in range(Start,End+1):
        Dp_f[i][j-cur_margin] = max(Dp_s[i-1][j-pre_margin], Dp_f[i-1][j-pre_margin])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if Dp_f[i-1][j-1-pre_margin] == inf:
            Dp_s[i][j-cur_margin] = 0 + A[i]
        else:
            Dp_s[i][j-cur_margin] = Dp_f[i-1][j-1-pre_margin]+A[i]
            
    pre_margin = cur_margin
print(max(Dp_f[-1][select_num - cur_margin], Dp_s[-1][select_num - cur_margin]))


Fixed submission:

#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2
inf = -10e+100

Dp_f = [[inf] * (3) for _ in range(N+1)]
Dp_s = [[inf] * (3) for _ in range(N+1)]
# 3　次元はそれぞれStart~3つに該当

pre_margin = 0
for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    cur_margin = Start
    
    for j in range(Start,End+1):
        Dp_f[i][j-cur_margin] = max(Dp_s[i-1][j-pre_margin], Dp_f[i-1][j-pre_margin])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if j-1 == 0:
            Dp_s[i][j-cur_margin] = 0 + A[i]
        else:
            Dp_s[i][j-cur_margin] = Dp_f[i-1][j-1-pre_margin]+A[i]
    
    pre_margin = cur_margin
print(max(Dp_f[-1][select_num - cur_margin], Dp_s[-1][select_num - cur_margin]))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2

Dp_f = [[-9999]*(N+1) for _ in range(N+1)]
Dp_s = [[-9999]*(N+1) for _ in range(N+1)]

for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2

    for j in range(Start,End+1):
        Dp_f[i][j] = max(Dp_s[i-1][j], Dp_f[i-1][j])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if Dp_f[i-1][j-1] == -9999 and j == 1:
            Dp_s[i][j] = 0 + A[i]
        else:
            Dp_s[i][j] = Dp_f[i-1][j-1]+A[i]

print(max(Dp_f[-1][select_num], Dp_s[-1][select_num]))


Fixed submission:

#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2
inf = -10e+100

Dp_f = [[inf] * (3) for _ in range(N+1)]
Dp_s = [[inf] * (3) for _ in range(N+1)]
# 3　次元はそれぞれStart~3つに該当

pre_margin = 0
for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    cur_margin = Start
    
    for j in range(Start,End+1):
        Dp_f[i][j-cur_margin] = max(Dp_s[i-1][j-pre_margin], Dp_f[i-1][j-pre_margin])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if j-1 == 0:
            Dp_s[i][j-cur_margin] = 0 + A[i]
        else:
            Dp_s[i][j-cur_margin] = Dp_f[i-1][j-1-pre_margin]+A[i]
    
    pre_margin = cur_margin
print(max(Dp_f[-1][select_num - cur_margin], Dp_s[-1][select_num - cur_margin]))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

#f = open("/Users/naoki/Documents/Atcoder/input.txt")
N = int(input())

A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2
Dp = [[[-9999] *2] * (select_num+1)] * (N+1)

for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    for j in range(Start,End+1):
        Dp[i][j][0] = max(Dp[i-1][j][1], Dp[i-1][j][0])
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if j == 1:
            Dp[i][j][1] = 0 + A[i]
        else:
            Dp[i][j][1] = Dp[i-1][j-1][0]+A[i]

print(max(Dp[-1][select_num][0], Dp[-1][select_num][1]))

Fixed submission:

#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2
inf = -10e+100

Dp_f = [[inf] * (3) for _ in range(N+1)]
Dp_s = [[inf] * (3) for _ in range(N+1)]
# 3　次元はそれぞれStart~3つに該当

pre_margin = 0
for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    cur_margin = Start
    
    for j in range(Start,End+1):
        Dp_f[i][j-cur_margin] = max(Dp_s[i-1][j-pre_margin], Dp_f[i-1][j-pre_margin])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if j-1 == 0:
            Dp_s[i][j-cur_margin] = 0 + A[i]
        else:
            Dp_s[i][j-cur_margin] = Dp_f[i-1][j-1-pre_margin]+A[i]
    
    pre_margin = cur_margin
print(max(Dp_f[-1][select_num - cur_margin], Dp_s[-1][select_num - cur_margin]))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

#f = open("/Users/naoki/Documents/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2


Dp = [[[-9999 for _ in range(2)] for _ in range(select_num+1)] for _ in range(N+1)]

for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    for j in range(Start,End+1):
        Dp[i][j][0] = max(Dp[i-1][j][1], Dp[i-1][j][0])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if j == 1:
            Dp[i][j][1] = 0 + A[i]
        else:
            Dp[i][j][1] = Dp[i-1][j-1][0]+A[i]

print(max(Dp[-1][select_num][0], Dp[-1][select_num][1]))

Fixed submission:

#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2
inf = -10e+100

Dp_f = [[inf] * (3) for _ in range(N+1)]
Dp_s = [[inf] * (3) for _ in range(N+1)]
# 3　次元はそれぞれStart~3つに該当

pre_margin = 0
for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    cur_margin = Start
    
    for j in range(Start,End+1):
        Dp_f[i][j-cur_margin] = max(Dp_s[i-1][j-pre_margin], Dp_f[i-1][j-pre_margin])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if j-1 == 0:
            Dp_s[i][j-cur_margin] = 0 + A[i]
        else:
            Dp_s[i][j-cur_margin] = Dp_f[i-1][j-1-pre_margin]+A[i]
    
    pre_margin = cur_margin
print(max(Dp_f[-1][select_num - cur_margin], Dp_s[-1][select_num - cur_margin]))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

#f = open("/Users/naoki/Documents/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2


Dp = [[[-9999 for _ in range(2)] for _ in range(N+1)] for _ in range(N+1)]

for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    for j in range(Start,End+1):
        Dp[i][j][0] = max(Dp[i-1][j][1], Dp[i-1][j][0])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if Dp[i-1][j-1][0] == -9999 and j == 1:
            Dp[i][j][1] = 0 + A[i]
        else:
            Dp[i][j][1] = Dp[i-1][j-1][0]+A[i]

print(max(Dp[-1][select_num][0], Dp[-1][select_num][1]))


Fixed submission:

#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2
inf = -10e+100

Dp_f = [[inf] * (3) for _ in range(N+1)]
Dp_s = [[inf] * (3) for _ in range(N+1)]
# 3　次元はそれぞれStart~3つに該当

pre_margin = 0
for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    cur_margin = Start
    
    for j in range(Start,End+1):
        Dp_f[i][j-cur_margin] = max(Dp_s[i-1][j-pre_margin], Dp_f[i-1][j-pre_margin])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if j-1 == 0:
            Dp_s[i][j-cur_margin] = 0 + A[i]
        else:
            Dp_s[i][j-cur_margin] = Dp_f[i-1][j-1-pre_margin]+A[i]
    
    pre_margin = cur_margin
print(max(Dp_f[-1][select_num - cur_margin], Dp_s[-1][select_num - cur_margin]))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

#f = open("/Users/naoki/Documents/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2


Dp = [[[-9999 for _ in range(2)] for _ in range(N+1)] for _ in range(N+1)]

for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    for j in range(Start,End+1):
        Dp[i][j][0] = max(Dp[i-1][j][1], Dp[i-1][j][0])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if Dp[i-1][j-1][0] == -9999 and j == 1:
            Dp[i][j][1] = 0 + A[i]
        else:
            Dp[i][j][1] = Dp[i-1][j-1][0]+A[i]

print(max(Dp[-1][select_num][0], Dp[-1][select_num][1]))


Fixed submission:

#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

select_num = N//2
inf = -10e+100

Dp_f = [[inf] * (3) for _ in range(N+1)]
Dp_s = [[inf] * (3) for _ in range(N+1)]
# 3　次元はそれぞれStart~3つに該当

pre_margin = 0
for i in range(1,N+1):
    Start = (i-1)//2
    End = (i+1)//2
    
    cur_margin = Start
    
    for j in range(Start,End+1):
        Dp_f[i][j-cur_margin] = max(Dp_s[i-1][j-pre_margin], Dp_f[i-1][j-pre_margin])   
        # [0] in 3rd dimension  not chosen at last num
        # must be transfered from [i-1]
    for j in range(Start,End+1):
        if j-1 == 0:
            Dp_s[i][j-cur_margin] = 0 + A[i]
        else:
            Dp_s[i][j-cur_margin] = Dp_f[i-1][j-1-pre_margin]+A[i]
    
    pre_margin = cur_margin
print(max(Dp_f[-1][select_num - cur_margin], Dp_s[-1][select_num - cur_margin]))