qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def vacation(mat):
    temp = [0] * 3
    dp = mat[0]
    for i in range(1, len(mat)):
        temp[0] = mat[i][0] + max(dp[1], dp[2])
        temp[1] = mat[i][1] + max(dp[0], dp[2])
        temp[2] = mat[i][2] + max(dp[0], dp[1])
        dp = temp[:]
    print(dp)
    return max(dp)


if __name__ == '__main__':
    n = int(input())
    mat = [[0] * 3 for _ in range(n)]
    for i in range(n):
        mat[i] = list(map(int, input().split()))

    print(vacation(mat))


Fixed code:
def vacation(mat):
    temp = [0] * 3
    dp = mat[0]
    for i in range(1, len(mat)):
        temp[0] = mat[i][0] + max(dp[1], dp[2])
        temp[1] = mat[i][1] + max(dp[0], dp[2])
        temp[2] = mat[i][2] + max(dp[0], dp[1])
        dp = temp[:]
    return max(dp)


if __name__ == '__main__':
    n = int(input())
    mat = [[0] * 3 for _ in range(n)]
    for i in range(n):
        mat[i] = list(map(int, input().split()))

    print(vacation(mat))
Buggy code:
N = int(input())
happy = []
result = [[0 for i in range(3)] for j in range(N)]

for i in range(3):
    t = list( map( int, input().split() ) )
    happy.append(t)

for i in range(3):
    result[0][i] = happy[0][i] 

for i in range(1,N):
    for j in range(3):
        result[i][j] = max( [ result[i-1][k] + happy[i][j] for k in range(3) if k != j ] )

print( max( result[N-1] ) )

Fixed code:
N = int(input())
happy = []
result = [[0 for i in range(3)] for j in range(N)]

for i in range(N):
    t = list( map( int, input().split() ) )
    happy.append(t)

for i in range(3):
    result[0][i] = happy[0][i] 

for i in range(1,N):
    for j in range(3):
        result[i][j] = max( [ result[i-1][k] + happy[i][j] for k in range(3) if k != j ] )

print( max( result[N-1] ) )
Buggy code:
N = int(input())
dp = [[0]*(N+1) for _ in range(3)]
happy = [[0]*N for _ in range(3)]

for i in range(N):
    a, b, c = [int(s) for s in input().split()]
    happy[i][0] = a
    happy[i][1] = b
    happy[i][2] = c

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j!= k:
                dp[i+1][j] = max(dp[i+1][j], dp[i][j] + happy[i][k])

ans = max(dp[N][0],dp[N][1],dp[N][2])
print(ans)

Fixed code:
N = int(input())
dp = [[0]*3 for _ in range(N+1)]
happy = [[0]*3 for _ in range(N)]

for i in range(N):
    a, b, c = [int(s) for s in input().split()]
    happy[i][0] = a
    happy[i][1] = b
    happy[i][2] = c

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j!= k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + happy[i][j])

ans = max(dp[N][0],dp[N][1],dp[N][2])
print(ans)
Buggy code:
N = int(input())
sel = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * N for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if not j == k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j]+sel[i][k])

print(max(dp[N]))

Fixed code:
N = int(input())
sel = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * 3 for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if not j == k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j]+sel[i][k])

print(max(dp[N]))
Buggy code:
# -*- coding: utf-8 -*-
import sys


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


N = int(input())
DATA = [map(int, input().split()) for i in range(N)]

  dp = [[0 for _ in range(3)] for _ in range(N + 1)]

   for i in range(N):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + DATA[i][k])

    res = 0

    for v in range(3):
        res = max(res, dp[N][v])

    print(res)


Fixed code:
# -*- coding: utf-8 -*-
import sys


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


N = int(input())
DATA = [list(map(int, input().split())) for i in range(N)]

dp = [[0 for _ in range(3)] for _ in range(N + 1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + DATA[i][k])

res = 0

for v in range(3):
    res = max(res, dp[N][v])

print(res)
Buggy code:
n=int(input())
a,b,c=map(int,input().split())
dp=[[a,b,c] for i in range(n)]
for i in range(1,n):
  a,b,c=map(int,input().split()¥
  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[n-1]))

Fixed code:
n=int(input())
a,b,c=map(int,input().split())
dp=[[a,b,c] for i in range(n)]
for i in range(1,n):
  a,b,c=map(int,input().split())
  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[n-1]))
Buggy code:
N = int(input())
dp = [[0 for _ in range(N+1)] for i in range(3)]

for i in range(1,N+1):
  ai,bi,ci = map(int,input().split())
  
  dp[i][0] = ai + max(dp[i-1][1],dp[i-1][2])
  dp[i][1] = bi + max(dp[i-1][0],dp[i-1][2])
  dp[i][2] = ci + max(dp[i-1][1],dp[i-1][0])
  
print(max(dp[N]))
  

Fixed code:
N = int(input())
dp = [[0 for i in range(3)] for _ in range(N+1)] 

for i in range(1,N+1):
  ai,bi,ci = map(int,input().split())
  
  dp[i][0] = ai + max(dp[i-1][1],dp[i-1][2])
  dp[i][1] = bi + max(dp[i-1][0],dp[i-1][2])
  dp[i][2] = ci + max(dp[i-1][1],dp[i-1][0])
  
print(max(dp[N]))
Buggy code:
n=int(input())
INF=float('inf')

h=[]
for _ in range(n):
  a,b,c=map(int,input().split())
  h.append(a,b,c)

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

print(max(dp[n][0],dp[n][1],dp[n][2]))

Fixed code:
n=int(input())
INF=float('inf')

h=[]
for _ in range(n):
  a,b,c=map(int,input().split())
  h.append([a,b,c])

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

print(max(dp[n][0],dp[n][1],dp[n][2]))
Buggy code:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    act = np.array([[int(item) for item in input().split()] for _ in range(N)])

    dp = np.zeros((2, 3), dtype='int64')
    selector = np.array([[0,1,1], [1,0,1], [1,1,0]])

    for i in range(0,N):
        print(dp[i%2]*selector)
        print(np.max(dp[i%2]*selector, axis=1))
        dp[i%2^1] = np.max(dp[i%2]*selector, axis=1) + act[i]
        print(dp)

    print(max(dp[N%2]))

main()


Fixed code:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    act = np.array([[int(item) for item in input().split()] for _ in range(N)])

    dp = np.zeros((2, 3), dtype='int64')
    selector = np.array([[0,1,1], [1,0,1], [1,1,0]])

    for i in range(0,N):
        # print(dp[i%2]*selector)
        # print(np.max(dp[i%2]*selector, axis=1))
        dp[i%2^1] = np.max(dp[i%2]*selector, axis=1) + act[i]
        # print(dp)

    print(max(dp[N%2]))

main()
Buggy code:
def main(n, choices):
    results = [[0, 0, 0] for _ in range(n)]
    results[0] = choices[0]
    for i in range(1, n):
        results[i][0] = choices[i][0] + max(results[i - 1][1], results[i - 1][2])
        results[i][1] = choices[i][1] + max(results[i - 1][0], results[i - 1][2])
        results[i][2] = choices[i][2] + max(results[i - 1][0], results[i - 1][1])
    return max(results[-1])


if __name__ == '__main__':
    N = int(input())
    C = []
    for _ in range(N):
        C.append(list(map(int, input().split())))
    print(N, C)


Fixed code:
def main(n, choices):
    results = [[0, 0, 0] for _ in range(n)]
    results[0] = choices[0]
    for i in range(1, n):
        results[i][0] = choices[i][0] + max(results[i - 1][1], results[i - 1][2])
        results[i][1] = choices[i][1] + max(results[i - 1][0], results[i - 1][2])
        results[i][2] = choices[i][2] + max(results[i - 1][0], results[i - 1][1])
    return max(results[-1])


if __name__ == '__main__':
    N = int(input())
    C = []
    for _ in range(N):
        C.append(list(map(int, input().split())))
    print(main(N, C))
Buggy code:
n = int(input())
total = []
for i in range(n):
    a, b, c = map(int, input().split())
    total.append((a,b,c))


dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = total[0][0]
dp[0][1] = total[0][1]
dp[0][2] = total[0][2]

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

print(max(dp[-1]))

Fixed code:
n = int(input())
total = []
for i in range(n):
    a, b, c = map(int, input().split())
    total.append((a,b,c))


dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = total[0][0]
dp[0][1] = total[0][1]
dp[0][2] = total[0][2]

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

print(max(dp[-1]))
Buggy code:
N = int(input())
abcList = [list(map(int, input().split())) for i in range(N)]
dp = [abcList[0]]

if len(abcList) == 1:
    print(max(abcList[0][0], abcList[0][1], abcList[0][2]))
    return

dp.append(abc(abcList[1], dp[0]))

for i in range(2, N):
    dp.append(abc(abcList[i], dp[i-1]))
print(max(dp[-1]))

Fixed code:
N = int(input())
abcList = [list(map(int, input().split())) for i in range(N)]
dp = [abcList[0]]

if len(abcList) == 1:
    print(max(abcList[0][0], abcList[0][1], abcList[0][2]))
else:
    for i in range(1, N):
        dp.append([abcList[i][0] + max(dp[i - 1][1], dp[i - 1][2]),
                   abcList[i][1] + max(dp[i - 1][0], dp[i - 1][2]),
                   abcList[i][2] + max(dp[i - 1][0], dp[i - 1][1])])
    print(max(dp[-1]))
Buggy code:
n = int(input())
happiness = [list(map(int, input().split())) for i in range(n)]
dp = [[0] * 3 for i in range(n + 1)]

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

print(dp)
print(max(dp[n]))


Fixed code:
n = int(input())
happiness = [list(map(int, input().split())) for i in range(n)]
dp = [[0] * 3 for i in range(n + 1)]

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

print(max(dp[n]))
Buggy code:
n = int(input())
dp = [[0]*3 for _ in range(n)]
a, b, c = map(int, input().split())
dp[0][0] = a
dp[0][1] = b
dp[0][2] = c
for i in range(n-1):
    a, b, c = map(int, input().split())
    dp[i+1][0] = max(dp[i][1]+b, dp[i][2]+c)
    dp[i+1][1] = max(dp[i][0]+a, dp[i][2]+c)
    dp[i+1][2] = max(dp[i][1]+b, dp[i][0]+a)


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


Fixed code:
n = int(input())
dp = [[0]*3 for _ in range(n)]
a, b, c = map(int, input().split())
dp[0][0] = a
dp[0][1] = b
dp[0][2] = c
for i in range(n-1):
    a, b, c = map(int, input().split())
    dp[i+1][0] = max(dp[i][1]+a, dp[i][2]+a)
    dp[i+1][1] = max(dp[i][0]+b, dp[i][2]+b)
    dp[i+1][2] = max(dp[i][0]+c, dp[i][1]+c)


print(max(dp[n-1]))
Buggy code:
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
a,b,c = [list(i) for i in zip(*l)]
dp = [[0,0,0] for i in range(n+1)]
for i in range(n):
    dp[i+1][0] = max(dp[i][1]+a[i],dp[i][2]+a[i])
    dp[i+1][1] = max(dp[i][0]+b[i],dp[i][2]+b[i])
    dp[i+1][2] = max(dp[i][0]+c[i],dp[i][1],c[i])
print(max(dp[-1]))

Fixed code:
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
a, b, c = [list(i) for i in zip(*l)]
dp = [[0, 0, 0] for i in range(n+1)]
for i in range(n):
    dp[i+1][0] = max(dp[i][1]+a[i], dp[i][2]+a[i])
    dp[i+1][1] = max(dp[i][0]+b[i], dp[i][2]+b[i])
    dp[i+1][2] = max(dp[i][0]+c[i], dp[i][1]+c[i])
print(max(dp[-1][0], dp[-1][1], dp[-1][2]))
Buggy code:
n = int(input())
abc = []
for _ in range(n):
    abc_ = list(map(int, input().split()))
    abc.append(abc_)
dp = [[0]*3 for _ in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, n):
    dp[i][0] = max(abc[i][1]+dp[i-1][0], abc[i][2]+dp[i-1][0])
    dp[i][1] = max(abc[i][0]+dp[i-1][1], abc[i][2]+dp[i-1][1])
    dp[i][2] = max(abc[i][0]+dp[i-1][2], abc[i][1]+dp[i-1][2])
print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))

Fixed code:
n = int(input())
abc = []
for _ in range(n):
    abc_ = list(map(int, input().split()))
    abc.append(abc_)
dp = [[0]*3 for _ in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, n):
    dp[i][0] = max(abc[i][0]+dp[i-1][1], abc[i][0]+dp[i-1][2])
    dp[i][1] = max(abc[i][1]+dp[i-1][0], abc[i][1]+dp[i-1][2])
    dp[i][2] = max(abc[i][2]+dp[i-1][0], abc[i][2]+dp[i-1][1])
print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))
Buggy code:
N = int(input())
activity = [list(map(int, input().split())) for i in range(N)]

dp = [[0]*3 for i in range(N+1)]
print(dp)
for i in range(N):
    for k in range(3):
        dp[i+1][k] = max(
            dp[i][k-1] + activity[i][k],
            dp[i][k-2] + activity[i][k]
        )
        print(dp)
print(max(dp[N]))

Fixed code:
N = int(input())
activity = [list(map(int, input().split())) for i in range(N)]

dp = [[0]*3 for i in range(N+1)]
for i in range(N):
    for k in range(3):
        dp[i+1][k] = max(
            dp[i][k-1] + activity[i][k],
            dp[i][k-2] + activity[i][k]
        )
print(max(dp[N]))
Buggy code:
N=int(input())
a=[0]*N
b=[0]*N
c=[0]*N

for i in range(N):
	a[i],b[i],c[i]=map(int,input().split())

dp=[[0 for j in range(3)] for k in range(N)]

for l in range(N):
	if l==0:
		dp[0][l]=a[l]
		dp[1][l]=b[l]
		dp[2][l]=c[l]
	else:
		dp[0][l]=max(dp[1][l-1],dp[2][l-1])+a[l]
		dp[1][l]=max(dp[0][l-1],dp[2][l-1])+b[l]
		dp[2][l]=max(dp[0][l-1],dp[1][l-1])+c[l]

print(max(dp[0][N-1],dp[1][N-1],dp[2][N-1]))

Fixed code:
N=int(input())
a=[0]*N
b=[0]*N
c=[0]*N

for i in range(N):
	a[i],b[i],c[i]=map(int,input().split())

dp=[[0 for j in range(N)] for k in range(3)]

for l in range(N):
	if l==0:
		dp[0][l]=a[l]
		dp[1][l]=b[l]
		dp[2][l]=c[l]
	else:
		dp[0][l]=max(dp[1][l-1],dp[2][l-1])+a[l]
		dp[1][l]=max(dp[0][l-1],dp[2][l-1])+b[l]
		dp[2][l]=max(dp[0][l-1],dp[1][l-1])+c[l]

print(max(dp[0][N-1],dp[1][N-1],dp[2][N-1]))
Buggy code:
n = int(input())
a = []
b = []
c = []
for i in range(n):
    x, y, z = map(int, input().split())
    a.append(x)
    b.append(y)
    c.append(z)

print(a)
print(b)
print(c)
dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

for i in range(1,n):
    print(dp[i],dp[i-1],a[i],b[i],c[i])
    print(dp[i],dp[i-1],a[i],b[i],c[i])
    print(dp[i],dp[i-1],a[i],b[i],c[i])
    print(dp[i],dp[i-1],a[i],b[i],c[i])

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

Fixed code:
n = int(input())
a = []
b = []
c = []
for i in range(n):
    x, y, z = map(int, input().split())
    a.append(x)
    b.append(y)
    c.append(z)
dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

for i in range(1,n):
    dp[i][0] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i])
    dp[i][1] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i])
    dp[i][2] = max(dp[i-1][0]+c[i],dp[i-1][1]+c[i])
print(max(dp[n-1]))
Buggy code:
n=int(input())
abc=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for _ in range(n+1)]
for i in range(n):
  for a in range(3):
    for b in range(3):
      if a!=b:
        dp[i+1][a]=max(dp[i][b]+abc[i][a],dp[i+1][a])
      else:
        dp[i+1][a]=0
print(max(dp[n]))

Fixed code:
n=int(input())
abc=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for _ in range(n+1)]
for i in range(n):
  for a in range(3):
    for b in range(3):
      if a!=b:
        dp[i+1][a]=max(dp[i][b]+abc[i][a],dp[i+1][a])
print(max(dp[n]))
Buggy code:
n=input()
satis=[]

for i in range(n):
	satis.append(map(int,input().split()))

tempA=satis[0]
tempB=satis[1]
tempC=satis[2]
if n > 1:
  for i in range(n-1):
    tempA2=satis[3*i+3]+max([tempB,tempC])
    tempB2=satis[3*i+4]+max([tempA,tempC])
    tempC2=satis[3*i+5]+max([tempA,tempB])
    tempA=tempA2
    tempB=tempB2
    tempC=tempC2
  print(max([tempA,tempB,tempC]))
else:
  print(max([tempA,tempB,tempC]))

Fixed code:
n=int(input())
satis=[]

for i in range(n):
  A=list(map(int,input().split()))
  satis.extend(A)

tempA=satis[0]
tempB=satis[1]
tempC=satis[2]
if n > 1:
  for i in range(n-1):
    tempA2=satis[3*i+3]+max([tempB,tempC])
    tempB2=satis[3*i+4]+max([tempA,tempC])
    tempC2=satis[3*i+5]+max([tempA,tempB])
    tempA=tempA2
    tempB=tempB2
    tempC=tempC2
  print(max([tempA,tempB,tempC]))
else:
  print(max([tempA,tempB,tempC]))
Buggy code:
N=int(input())
inputs=[]
dp=[]
for _ in range(N):
    inputs.append([int(x) for x in input().split()])
    dp.append([0]*3)

for j in range(3):
    dp[0][j]=inputs[0][j]

for i in range(1,N):

    for j in range(3):
        
        for k in range(3):
            if(j!=k):
                dp[i][j]=max(dp[i-1][k],dp[i][j])
        
        dp[i][j]+=inputs[i][j]


print(dp[N-1][N-1])


Fixed code:
N=int(input())
inputs=[]
dp=[]
for _ in range(N):
    inputs.append([int(x) for x in input().split()])
    dp.append([0]*3)

for j in range(3):
    dp[0][j]=inputs[0][j]

for i in range(1,N):

    for j in range(3):
        
        for k in range(3):
            if(j!=k):
                dp[i][j]=max(dp[i-1][k],dp[i][j])
        
        dp[i][j]+=inputs[i][j]



print(max(dp[N-1]))
Buggy code:
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

def chmax(a, b):
    if a > b:
        return a
    else:
        return b

dp = [[ 0 for _ in range(3)]for _ in range(n+10)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            else:
                dp[i][k] = chmax(dp[i+1][k], dp[i][j]+A[i][k])

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


Fixed code:
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

def chmax(a, b):
    if a > b:
        return a
    else:
        return b

dp = [[ 0 for _ in range(3)]for _ in range(n+10)]

for i in range(3):
    dp[0][i] = A[0][i]

for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][k] = chmax(dp[i][k], dp[i-1][j]+A[i][k])

print(max(dp[n-1]))
Buggy code:
# C - Vacation
import numpy as np

N = int(input())
value = np.zeros((N, 3))
for i in range(N):
    value[i, :] = list(map(int, input().split()))
value = value.tolist()

dp = [0]*3

for a, b, c in value:
    dp = [max(dp[1], dp[2])+a, max(dp[0], dp[2])+b, max(dp[0], dp[1])+c]
    
print(max(dp))

Fixed code:
# C - Vacation
import numpy as np

N = int(input())
value = np.zeros((N, 3))
for i in range(N):
    value[i, :] = list(map(int, input().split()))
value = value.tolist()

dp = [0]*3

for a, b, c in value:
    dp = [max(dp[1], dp[2])+a, max(dp[0], dp[2])+b, max(dp[0], dp[1])+c]
    
print(int(max(dp)))
Buggy code:
# -*- coding: utf-8 -*-

import numpy as np

EDPC = "https://atcoder.jp/contests/dp/"
TDPC = "https://atcoder.jp/contests/tdpc/tasks"

############### TESTCASE ###############
test = ""

"""
3
10 40 70
20 50 80
30 60 90
ans 210
"""

"""
1
100 10 1
ans 100
"""
test = \
"""
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
ans 46
8, 8, 5, 8, 8, 4, 7 -> 48
8, 8, 5, 7, 8, 3, 7 -> 46
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
########################################  
n = int(input2())
a = np.array([list(map(int, input2().split())) for i in range(n)])  
########## Non_Numpy_solution ##########

arr = a
dp = [[0, 0, 0] for _ in range(n)]
dp[0] = arr[0]
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0]
    dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + arr[i][1]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i][2]
print (max(dp[-1]))



Fixed code:
# -*- coding: utf-8 -*-

import numpy as np

EDPC = "https://atcoder.jp/contests/dp/"
TDPC = "https://atcoder.jp/contests/tdpc/tasks"

################ DANGER ################
test = ""
#test = \
"""
3
10 40 70
20 50 80
30 60 90
ans 210
"""

"""
1
100 10 1
ans 100
"""

"""
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
ans 46
8, 8, 5, 8, 8, 4, 7 -> 48
8, 8, 5, 7, 8, 3, 7 -> 46
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
########################################  
n = int(input2())
a = np.array([list(map(int, input2().split())) for i in range(n)])  
############ Numpy_solution ############


    
    
    
########## Non_Numpy_solution ##########
arr = a
dp = [[0, 0, 0] for _ in range(n)]
dp[0] = arr[0]
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0]
    dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + arr[i][1]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i][2]
print (max(dp[-1]))
Buggy code:
## tasks https://atcoder.jp/contests/dp/tasks
## TODO

def solution():
    # result array for calculation for optimal cost for every stone
    res = [[-1 for x in range(3)] for y in range(n)]
    res[0] = a[0]
    for i in range(1,n):
        # going through the all days
        for j in range(3):
            # calucaltion for every possible actions, but skipping the same activity
            # picked current activity is j, let us get options from non j and get max of them
            # it will be a cost for j
            # do it for every

            #searching for best previous happines
            bph = -1
            for o in range(3):
                #skipping the same activity
                if o==j:
                    continue
                bph = max(bph, res[i-1][o])
            #print("res = {} a = {}".format(res, a))
            #print("i={} j={}".format(i, j))
            res[i][j] = max(res[i][j], bph + a[i][j])

    return max(res[-1][0],res[-1][1],res[-1][2])


if __name__ == "__main__":
    n = int(input())

    a = [[None for x in range(3)] for y in range(n)]

    for i in range(n):
        row = list(map(int, raw_input().split(" ")))
        for j in range(3):
            a[i][j] = row[j]

    #print("n = {} a = {}".format(n, a))
    if n == 1:
        print max(a[0][0],a[0][1],a[0][2])
    else:
        print(solution())


Fixed code:
## tasks https://atcoder.jp/contests/dp/tasks
## TODO

def solution():
    # result array for calculation for optimal cost for every stone
    res = [[-1 for x in range(3)] for y in range(n)]
    res[0] = a[0]
    for i in range(1,n):
        # going through the all days
        for j in range(3):
            # calucaltion for every possible actions, but skipping the same activity
            # picked current activity is j, let us get options from non j and get max of them
            # it will be a cost for j
            # do it for every

            #searching for best previous happines
            bph = -1
            for o in range(3):
                #skipping the same activity
                if o==j:
                    continue
                bph = max(bph, res[i-1][o])
            #print("res = {} a = {}".format(res, a))
            #print("i={} j={}".format(i, j))
            res[i][j] = max(res[i][j], bph + a[i][j])

    return max(res[-1][0],res[-1][1],res[-1][2])


if __name__ == "__main__":
    n = int(input())

    a = [[None for x in range(3)] for y in range(n)]

    for i in range(n):
        row = list(map(int, input().split(" ")))
        for j in range(3):
            a[i][j] = row[j]

    #print("n = {} a = {}".format(n, a))
    if n == 1:
        print(max(a[0][0],a[0][1],a[0][2]))
    else:
        print(solution())