Buggy python submission (verdict: Runtime Error):
def dp(i,k):
    if k<=0:
        return 0
    tmp=N-i
    if k>(tmp//2)+(tmp%2):
        return -float('inf')
    return max(A[i]+dp(i+2,k-1),dp(i+1,k))

N=int(input())
A=[int(_) for _ in input().split()]
print(dp(0,N//2))


Fixed submission:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache

@lru_cache(None)
def dp(N,A,i,k):
    if k<=0:
        return 0
    tmp=N-i
    if k>(tmp//2)+(tmp%2):
        return -float('inf')
    return max(A[i]+dp(N,A,i+2,k-1),dp(N,A,i+1,k))

def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    print(dp(N,A,0,N//2))

main()


Fixed submission:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache

def main():
    N=int(input())
    A=[int(_) for _ in input().split()]

    @lru_cache(None)
    def dp(i,k):
        if k<=0:
            return 0
        tmp=N-i
        if k>(tmp//2)+(tmp%2):
            return -float('inf')
        return max(A[i]+dp(i+2,k-1),dp(i+1,k))
    print(dp(0,N//2))

main()

Fixed submission:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()

Buggy python submission (verdict: Runtime Error):
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]

    def dp(i,k):
        if k<=0:
            return 0
        tmp=N-i
        if k>(tmp//2)+(tmp%2):
            return -float('inf')
        return max(A[i]+dp(i+2,k-1),dp(i+1,k))
    print(dp(0,N//2))

main()


Fixed submission:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()

Buggy python submission (verdict: Runtime Error):
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]

    def dp(i,k):
        if k<=0:
            return 0
        tmp=N-i
        if k>tmp//2+tmp%2:
            return -float('inf')
        return max(A[i]+dp(i+2,k-1),dp(i+1,k))

    print(dp(0,N//2))

main()

Fixed submission:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()

Buggy python submission (verdict: Runtime Error):
from math import ceil

def main():
    N=int(input())
    A=[int(_) for _ in input().split()]

    def dp(i,k):
        if k<=0:
            return 0
        tmp=N-i
        if k>ceil(tmp/2):
            return -float('inf')
        return max(A[i]+dp(i+2,k-1),dp(i+1,k))

    print(dp(0,N//2))

main()

Fixed submission:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()

Buggy python submission (verdict: Runtime Error):
from math import ceil

def main():
    N=int(input())
    A=[int(_) for _ in input().split()]

    def dp(i,k):
        print(i,k)
        if k<=0:
            return 0
        tmp=N-i
        if k>ceil(tmp/2):
            return -float('inf')
        return max(A[i]+dp(i+2,k-1),dp(i+1,k))

    print(dp(0,N//2))

main()

Fixed submission:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()

Buggy python submission (verdict: Runtime Error):
from math import ceil
INF=float('inf')

def main():
    N=int(input())
    A=[int(_) for _ in input().split()]

    def dp(i,k):
        print(i,k)
        if k<=0:
            return 0
        tmp=N-i
        if k>ceil(tmp/2):
            return -INF
        return max(A[i]+dp(i+2,k-1),dp(i+1,k))

    print(dp(0,N//2))

main()

Fixed submission:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()