Buggy python submission (verdict: Runtime Error):
def Solve(acts,first,second,third,index):
    if index == len(acts):
        return 0
    
    if first:
        val1 =  acts[index][0]+Solve(acts,False,True,True,index+1)
    else:
        val1 = 0
    if second:
        val2 = acts[index][1]+Solve(acts,True,False,True,index+1)
    else:
        val2 = 0
    if third:
        val3 =  acts[index][2]+Solve(acts,True,True,False,index+1)
    else:
        val3 = 0

    return max(val1,val2,val3)

def main():
    n = int(input())
    acts = []
    for i in range(n):
        a,b,c = map(int,input().split())
        acts.append((a,b,c))

##    dp = [[0 for x in range(3)] for y in range(n)]
##    dp[0][0] = acts[0][0]
##    dp[0][1] = acts[0][1]
##    dp[0][2] = acts[0][2]
##
##    for i in range(1,n):
##        dp[i][0] = dp[i-1][0]+max(acts[i][1],acts[i][2])
##        dp[i][1] = dp[i-1][1]+max(acts[i][0],acts[i][2])
##        dp[i][2] = dp[i-1][2]+max(acts[i][0],acts[i][1])

    #print(max(dp[-1]))
    #print(dp)

    print(Solve(acts,True,True,True,0))

main()


Fixed submission:
def main():
    n = int(input())
    dp = [[0 for i in range(3)] for j in range(n)]

    for i in range(n):
        a,b,c = map(int,input().split())
        if i == 0:
            dp[i][0] = a
            dp[i][1] = b
            dp[i][2] = c
        else:
            dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
            dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b
            dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c


    print(max(dp[-1]))


main()

Buggy python submission (verdict: Runtime Error):
def Solve(acts,first,second,third,index):
    if index == len(acts):
        return 0
    
    if first:
        val1 =  acts[index][0]+Solve(acts,False,True,True,index+1)
    else:
        val1 = 0
    if second:
        val2 = acts[index][1]+Solve(acts,True,False,True,index+1)
    else:
        val2 = 0
    if third:
        val3 =  acts[index][2]+Solve(acts,True,True,False,index+1)
    else:
        val3 = 0

    return max(val1,val2,val3)

def main():
    n = int(input())
    acts = []
    for i in range(n):
        a,b,c = map(int,input().split())
        acts.append((a,b,c))

##    dp = [[0 for x in range(3)] for y in range(n)]
##    dp[0][0] = acts[0][0]
##    dp[0][1] = acts[0][1]
##    dp[0][2] = acts[0][2]
##
##    for i in range(1,n):
##        dp[i][0] = dp[i-1][0]+max(acts[i][1],acts[i][2])
##        dp[i][1] = dp[i-1][1]+max(acts[i][0],acts[i][2])
##        dp[i][2] = dp[i-1][2]+max(acts[i][0],acts[i][1])

    #print(max(dp[-1]))
    #print(dp)

    print(Solve(acts,True,True,True,0))

main()


Fixed submission:
def main():
    n = int(input())
    dp = [[0 for i in range(3)] for j in range(n)]

    for i in range(n):
        a,b,c = map(int,input().split())
        if i == 0:
            dp[i][0] = a
            dp[i][1] = b
            dp[i][2] = c
        else:
            dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
            dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b
            dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c


    print(max(dp[-1]))


main()

Buggy python submission (verdict: Runtime Error):
def Solve(acts,first,second,third,index):
    if index == len(acts):
        return 0
    
    if first:
        val1 =  acts[index][0]+Solve(acts,False,True,True,index+1)
    else:
        val1 = 0
    if second:
        val2 = acts[index][1]+Solve(acts,True,False,True,index+1)
    else:
        val2 = 0
    if third:
        val3 =  acts[index][2]+Solve(acts,True,True,False,index+1)
    else:
        val3 = 0

    return max(val1,val2,val3)

def main():
    n = int(input())
    acts = []
    for i in range(n):
        a,b,c = map(int,input().split())
        acts.append((a,b,c))

    dp = [[0 for x in range(3)] for y in range(n)]
    dp[0][0] = acts[0][0]
    dp[0][1] = acts[0][1]
    dp[0][2] = acts[0][2]

    for i in range(1,n):
        dp[i][0] = dp[i-1][0]+max(acts[i][1],acts[i][2])
        dp[i][1] = dp[i-1][1]+max(acts[i][0],acts[i][2])
        dp[i][2] = dp[i-1][2]+max(acts[i][0],acts[i][1])

    #print(max(dp[-1]))
    #print(dp)

    print(Solve(acts,True,True,True,0))

main()


Fixed submission:
def main():
    n = int(input())
    dp = [[0 for i in range(3)] for j in range(n)]

    for i in range(n):
        a,b,c = map(int,input().split())
        if i == 0:
            dp[i][0] = a
            dp[i][1] = b
            dp[i][2] = c
        else:
            dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
            dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b
            dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c


    print(max(dp[-1]))


main()