ZhenlongDai/ACPR huggingface dataset:
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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]))

Failing test case input:
7
5 1 61
1 1 0
0 2 -2
20 3 6
1 8 0
0 1 13
2 0 -4

Expected output:
107


Actual output:
[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [71, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [71, 92, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [71, 92, 84], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [71, 92, 84], [92, 0, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [71, 92, 84], [92, 85, 0], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [71, 92, 84], [92, 85, 105], [0, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [71, 92, 84], [92, 85, 105], [107, 0, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [71, 92, 84], [92, 85, 105], [107, 105, 0]]
[[0, 0, 0], [5, 1, 61], [62, 62, 5], [62, 64, 60], [84, 65, 70], [71, 92, 84], [92, 85, 105], [107, 105, 88]]
107


Fixed submission (verdict: Accepted):
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]))
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
DATA = [tuple(map(int,input().split())) for i in range(N)]


for idx,datum in enumerate(DATA):
  if idx == 0:
    prev = datum
  else:
    a,b,c = datum
    prev = prev[0]+max(b,c),prev[1]+max(a,c),prev[2]+max(a,b)
    
print(max(prev))

Failing test case input:
7
5 1 176
0 2 0
-2 2 0
2 8 2
-1 4 1
0 1 10
0 1 -4

Expected output:
196


Actual output:
194


Fixed submission (verdict: Accepted):
N=int(input())
DATA = [tuple(map(int,input().split())) for i in range(N)]


for idx,datum in enumerate(DATA):
  if idx == 0:
    prev = datum
  else:
    a,b,c = datum
    prev = a+max(prev[1],prev[2]),b+max(prev[0],prev[2]),c+max(prev[0],prev[1])

print(max(prev))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):


N = int(input())
act = []
for i in range(N):
	act.append([int(x) for x in input().split()])

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

for i in range(0, 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] + act[i][k])

m = 0
for i in range(3):
	m = max(m, dp[N][i])

print(m)

Failing test case input:
7
3 7 19
11 8 0
4 4 3
15 14 6
4 8 1
3 3 7
2 3 -1

Expected output:
67


Actual output:
63


Fixed submission (verdict: Accepted):


N = int(input())
act = []
for i in range(N):
	act.append([int(x) for x in input().split()])

dp = [[0 for x in range(3)] for y in range(N)]

dp[0][0] = act[0][0]
dp[0][1] = act[0][1]
dp[0][2] = act[0][2]

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][j], dp[i-1][k] + act[i][j])

m = 0
for i in range(3):
	m = max(m, dp[N-1][i])

print(m)

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

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

dp = [[0]*3 for _ in range(N)]
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 i != k: 
                dp[i][k] = max(dp[i-1][j] + A[i][k], dp[i][k])

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

Failing test case input:
7
3 1 90
0 1 0
-2 2 0
2 4 2
-1 12 1
0 1 22
2 1 -3

Expected output:
130


Actual output:
132


Fixed submission (verdict: Accepted):
N = int(input())

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

dp = [[0]*3 for _ in range(N)]
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] = max(dp[i-1][j] + A[i][k], dp[i][k])

print(max(dp[-1]))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = []
for i in range(N):
  a.append(list(map(int,input().split())))
A = [a[0][0]]
B = [a[0][1]]
C = [a[0][2]]
if N == 1:
  print(max(a))
else:
  for i in range(N-1):
    A.append(max(B[i],C[i])+a[i+1][0])
    B.append(max(A[i],C[i])+a[i+1][1])
    C.append(max(A[i],B[i])+a[i+1][2])
  print(max(A[N-1],B[N-1],C[N-1]))

Failing test case input:
1
001 0 -1

Expected output:
1


Actual output:
[1, 0, -1]


Fixed submission (verdict: Accepted):
N = int(input())
a = []
for i in range(N):
  a.append(list(map(int,input().split())))
A = [a[0][0]]
B = [a[0][1]]
C = [a[0][2]]
if N == 1:
  print(max(A[0],B[0],C[0]))
else:
  for i in range(N-1):
    A.append(max(B[i],C[i])+a[i+1][0])
    B.append(max(A[i],C[i])+a[i+1][1])
    C.append(max(A[i],B[i])+a[i+1][2])
  print(max(A[N-1],B[N-1],C[N-1]))

Problem: p03162
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for _ in range(n)]
dp[0]=l[0]
for i in  range(1,n):
    dp[i][0]=l[i][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=l[i][1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=l[i][2]+max(dp[i-1][0],dp[i-1][1])
    print(dp)
print(max(dp[-1]))

Failing test case input:
3
-1 5 -4
-1 0 8
21 4 10

Expected output:
34


Actual output:
[[-1, 5, -4], [4, -1, 13], [0, 0, 0]]
[[-1, 5, -4], [4, -1, 13], [34, 17, 14]]
34


Fixed submission (verdict: Accepted):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for _ in range(n)]
dp[0]=l[0]
for i in  range(1,n):
    dp[i][0]=l[i][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=l[i][1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=l[i][2]+max(dp[i-1][0],dp[i-1][1])

print(max(dp[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

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

dp = [[0]*3 for _ in range(N)]
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 i != k: 
                dp[i][j] = max(dp[i-1][k] + A[i][j], dp[i][j])

print(max(dp[-1]))

Failing test case input:
3
-1 47 -1
0 17 5
5 0 3

Expected output:
57


Actual output:
21


Fixed submission (verdict: Accepted):
N = int(input())

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

dp = [[0]*3 for _ in range(N)]
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] = max(dp[i-1][j] + A[i][k], dp[i][k])

print(max(dp[-1]))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a,b,c = 0,0,0
for _ in range(n):
    x, y, z = map(int, input().split())
    a,b,c = max(a,b)+z,max(a,c)+y,max(b,c)+x

print(max(a,b,c))

Failing test case input:
7
3 6 16
22 8 0
4 4 6
15 14 6
4 8 1
3 3 7
2 1 -1

Expected output:
76


Actual output:
63


Fixed submission (verdict: Accepted):
n = int(input())
a,b,c = 0,0,0
for _ in range(n):
    x, y, z = map(int, input().split())
    a,b,c = max(c,b)+x,max(a,c)+y,max(a,b)+z

print(max(a,b,c))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N= int(input())

arr = [list(map(int,input().split())) for _ in range(N)]
dp = [ list([0,0,0]) for i in range(N)]
for i,l in enumerate(arr):
  if i == 0:
    dp[0] = l
    continue
  dp[i] = [max(dp[i-1][1:])+l[1], max(dp[i-1][0],dp[i-1][2])+l[1],max(dp[i-1][:2])+l[2]]
print(max(dp[-1]))


Failing test case input:
7
5 1 66
0 1 1
0 2 -2
5 4 1
0 12 0
0 1 12
2 1 -5

Expected output:
99


Actual output:
98


Fixed submission (verdict: Accepted):
N= int(input())

arr = [list(map(int,input().split())) for _ in range(N)]
dp = [ list([0,0,0]) for i in range(N)]
for i,l in enumerate(arr):
  if i == 0:
    dp[0] = l
    continue
  dp[i] = [max(dp[i-1][1:])+l[0], max(dp[i-1][0],dp[i-1][2])+l[1],max(dp[i-1][:2])+l[2]]
print(max(dp[-1]))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
a=[list(map(int,input().split())) for i in range(n)] 

dp=[]
for i in range(n+1):
    dp.append([0,0,0])

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


print(max(dp[n]))

Failing test case input:
1
010 3 0

Expected output:
10


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
a=[list(map(int,input().split())) for i in range(n)] 

dp=[]
for i in range(n+1):
    dp.append([0,0,0])

for i in range(0,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]+a[i][k])

print(max(dp[n]))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
ABC = [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 j == k:  
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+ABC[i-1][k])

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


Failing test case input:
3
0 94 34
34 50 80
30 35 90

Expected output:
218


Actual output:
264


Fixed submission (verdict: Accepted):
N = int(input())
ABC = [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 j == k:  
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+ABC[i][k])

print(max(dp[N][0], dp[N][1], dp[N][2]))
Problem: p03162
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())

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

dp = []
for i in range(N+1):
    dp.append([])
    for j in range(3):
        dp[i].append(0)

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] + happy[i-1][k])

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

print(res)



Failing test case input:
3
-1 24 37
34 50 80
30 35 90

Expected output:
177


Actual output:
194


Fixed submission (verdict: Accepted):
N = int(input())

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

dp = []
for i in range(N+1):
    dp.append([])
    for j in range(3):
        dp[i].append(0)

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] + happy[i][k])

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

print(res)

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



N = int(input())
dp = [[0, 0, 0] for i in range(N)]
H = []


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

dp[0] = [H[0][0], H[0][1], H[0][2]]

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


Failing test case input:
3
-1 61 -2
0 17 5
7 5 1

Expected output:
73


Actual output:
[[-1, 61, -2], [61, 16, 66], [0, 0, 0]]
[[-1, 61, -2], [61, 16, 66], [73, 71, 62]]
73


Fixed submission (verdict: Accepted):



N = int(input())
dp = [[0, 0, 0] for i in range(N)]
H = []


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

dp[0] = [H[0][0], H[0][1], H[0][2]]

for i in range(1, N):
    
    for k in range(3):
        
        for j in range(3):
            if j == k:
                continue
            else:
                dp[i][j] = max(dp[i][j], (dp[i - 1][k] + H[i][j]))
print(max(dp[N - 1]))
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
l = []

for _ in range(N):
    a, b, c = map(int, input().split())
    l.append([a,b,c])
dp = [0]*N
choice = [-1] * N
for i in range(3):
    tmp = l[0][i]
    if tmp > dp[0]:
        dp[0] = tmp
        choice[0] = i

for i in range(1, N):
    for j in range(3):
        tmp = l[i][j] + dp[i-1]
        if tmp > dp[i] and choice[i-1] != j:
            dp[i] = tmp
            choice[i] = j
print(dp[N-1])

Failing test case input:
7
5 1 66
0 1 1
0 2 -2
5 4 1
0 12 0
0 1 12
2 1 -5

Expected output:
99


Actual output:
85


Fixed submission (verdict: Accepted):
N = int(input())
l = []

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

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

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] + l[i][k])
ans = 0
for i in range(3):
    ans = max(ans, dp[N][i])
print(ans)

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
u = [[0,0,0]]
for i in range(n):
    u.append(list(map(int,input().split())))

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

print(max(dp[n]))

Failing test case input:
3
-1 61 -2
0 9 10
7 5 1

Expected output:
78


Actual output:
17


Fixed submission (verdict: Accepted):
n = int(input())
u = [[0,0,0]]
for i in range(n):
    u.append(list(map(int,input().split())))

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

print(max(dp[n]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


def dp_happiness(N):
    yesterday_a, yesterday_b, yesterday_c = 0, 0, 0
    for _ in range(N):
        today_a, today_b, today_c = map(int, input().split())
        happiness_a = today_a + max(yesterday_b, yesterday_c)
        happiness_b = today_b + max(yesterday_c, yesterday_a)
        happiness_c = today_c + max(yesterday_a, yesterday_b)
    return max(happiness_a, happiness_b, happiness_c)

N = int(input())
print(dp_happiness(N))

Failing test case input:
3
-1 6 -4
0 4 5
21 2 10

Expected output:
32


Actual output:
21


Fixed submission (verdict: Accepted):




def dp_happiness(N):
    yesterday_a, yesterday_b, yesterday_c = 0, 0, 0
    for _ in range(N):
        a, b, c = map(int, input().split())

        today_a = a + max(yesterday_b, yesterday_c)
        today_b = b + max(yesterday_c, yesterday_a)
        today_c = c + max(yesterday_a, yesterday_b)

        yesterday_a = today_a
        yesterday_b = today_b
        yesterday_c = today_c
    return max(today_a, today_b, today_c)

N = int(input())
print(dp_happiness(N))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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]))

Failing test case input:
7
3 7 19
11 8 0
4 5 3
15 14 6
4 8 1
3 3 7
2 3 -1

Expected output:
68


Actual output:
5


Fixed submission (verdict: Accepted):
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]))

Problem: p03162
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
X = [0]*n
for i in range(n):
    t = list(map(int, input().split()))
    X[i] = t


dp = [[0, 0, 0]]*n
dp[0] = X[0]


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

print(max(dp[-1]))


Failing test case input:
3
-1 24 37
34 50 80
30 35 6

Expected output:
139


Actual output:
175


Fixed submission (verdict: Accepted):
n = int(input())
X = [0]*n
for i in range(n):
    t = list(map(int, input().split()))
    X[i] = t


dp = [[0, 0, 0] for _ in range(n)]
dp[0] = X[0]


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

print(max(dp[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
dp=[[0]*3 for _ in range(n)]
for i in range(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]))

Failing test case input:
1
000 25 2

Expected output:
25


Actual output:
27


Fixed submission (verdict: Accepted):
n=int(input())
dp=[[0]*3 for _ in range(n)]
dp[0]=list(map(int,input().split()))
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[-1]))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
ans = [[0]*3 for _ in range(n)]

ans[0][0] = abc[0][0]
ans[0][1] = abc[0][1]
ans[0][2] = abc[0][2]

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

print(max(ans[-1]))

Failing test case input:
1
001 3 0

Expected output:
3


Actual output:
7


Fixed submission (verdict: Accepted):
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
ans = [[0]*3 for _ in range(n)]

ans[0][0] = abc[0][0]
ans[0][1] = abc[0][1]
ans[0][2] = abc[0][2]

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

print(max(ans[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
l = [list(map(int, input().split())) for _ in range(N)]

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


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

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



Failing test case input:
3
-1 24 37
34 50 80
30 35 6

Expected output:
139


Actual output:
134


Fixed submission (verdict: Accepted):
N = int(input())
l = [list(map(int, input().split())) for _ in range(N)]

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


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

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

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
dp=[[0]*3 for i in range(N)]
for i in range(N):
  a=list(map(int,input().split()))
  for j in range(3):
    for k in range(3):
      if k!=j:
        dp[i][j]=max(dp[i-1][k]+a[j],dp[i][j])
print(max(dp[-1]))

Failing test case input:
1
111 5 -3

Expected output:
111


Actual output:
116


Fixed submission (verdict: Accepted):
N=int(input())
dp=[[0]*3 for i in range(N+1)]
for i in range(N):
  a=list(map(int,input().split()))
  for j in range(3):
    for k in range(3):
      if k!=j:
        dp[i+1][j]=max(dp[i][k]+a[j],dp[i+1][j])
print(max(dp[-1]))
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
abc=[[0,0,0]]*n
dp = [[0]*n for _ in range(3)]

for i in range(n):
  abc[i] = list(map(int,input().split()))
  
for i in range(3):
  dp[i][0] = abc[0][i]

for i in range(n):
  for j in range(3):    
    for k in range(3):
      if j==k:
        pass
      else:
        dp[j][i] = max(dp[j][i], dp[k][i-1]+abc[i][j])
        
print(max([row[-1] for row in dp]))        

Failing test case input:
1
000 2 0

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
abc=[[0,0,0]]*n
dp = [[0]*n for _ in range(3)]

for i in range(n):
  abc[i] = list(map(int,input().split()))
  
for i in range(3):
  dp[i][0] = abc[0][i]

for i in range(1,n):
  for j in range(3):    
    for k in range(3):
      if j==k:
        pass
      else:
        dp[j][i] = max(dp[j][i], dp[k][i-1]+abc[i][j])
        
print(max([row[-1] for row in dp]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
lis = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N+1)]
for k in range(3):
    dp[1][k] = lis[0][k]
for i in range(2, N+1):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + lis[i-2][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + lis[i-2][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + lis[i-2][2]
print(max(dp[N]))

Failing test case input:
3
0 41 -1
1 9 25
11 5 1

Expected output:
77


Actual output:
66


Fixed submission (verdict: Accepted):
N = int(input())
lis = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N+1)]
for k in range(3):
    dp[1][k] = lis[0][k]
for i in range(2, N+1):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + lis[i-1][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + lis[i-1][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + lis[i-1][2]
print(max(dp[N]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):





N = int(input())

dp = [[None] * 3 for _ in range(N)]
dp[0] = list(map(int, input().split()))


for i in range(1, N):
    data = list(map(int, input().split()))
    print(data)

    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + data[0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + data[1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + data[2]


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

Failing test case input:
7
3 1 31
1 8 0
-1 2 2
15 6 6
4 5 0
1 2 7
1 0 -1

Expected output:
69


Actual output:
[1, 8, 0]
[-1, 2, 2]
[15, 6, 6]
[4, 5, 0]
[1, 2, 7]
[1, 0, -1]
69


Fixed submission (verdict: Accepted):





N = int(input())

dp = [[None] * 3 for _ in range(N)]
dp[0] = list(map(int, input().split()))


for i in range(1, N):
    data = list(map(int, input().split()))
    

    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + data[0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + data[1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + data[2]


print(max(dp[N-1]))
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):


N = int(input())
act = []
for i in range(N):
	act.append([int(x) for x in input().split()])

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

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

m = 0
for i in range(3):
	m = max(m, dp[N][i])

print(m)

Failing test case input:
3
1 40 70
20 50 80
30 60 90

Expected output:
210


Actual output:
240


Fixed submission (verdict: Accepted):


N = int(input())
act = []
for i in range(N):
	act.append([int(x) for x in input().split()])

dp = [[0 for x in range(3)] for y in range(N)]

dp[0][0] = act[0][0]
dp[0][1] = act[0][1]
dp[0][2] = act[0][2]

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][j], dp[i-1][k] + act[i][j])

m = 0
for i in range(3):
	m = max(m, dp[N-1][i])

print(m)

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
C=[ list(map(int,input().split(' '))) for i in range(N)]
dp=[]
for i in range(N):
	if i==0:
		dp.append(C[0]) 
	else:
		dp.append([ dp[i-1][j]+max(C[i][(j+1)%3], C[i][(j+2)%3]) for j in range(3) ])

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

Failing test case input:
7
3 1 31
1 8 0
0 2 -1
27 7 6
4 8 0
0 2 7
1 0 -1

Expected output:
81


Actual output:
79


Fixed submission (verdict: Accepted):
N=int(input())
C=[ list(map(int,input().split(' '))) for i in range(N)]
dp=[]
for i in range(N):
	if i==0:
		dp.append(C[0]) 
	else:
		dp.append([ C[i][j]+max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) for j in range(3) ])
print(max(dp[N-1]))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
DP= [0] * N
abc = [0] * N
L = list(map(int,input().split()))
maxa = max(L)
point = L.index(maxa)
DP[0] = maxa
abc[0] = point
for i in range(1,N):
    L = list(map(int,input().split()))
    for j,value in enumerate(L):
        if abc[i-1] != j:
            if DP[i] < DP[i-1] + value:
                DP[i] = DP[i-1] + value
                abc[i] = j
print(DP[-1])

Failing test case input:
7
6 2 176
2 3 -3
0 0 -1
6 9 4
-1 7 2
-4 1 7
0 1 -8

Expected output:
199


Actual output:
191


Fixed submission (verdict: Accepted):
N = int(input())
DP = [[0]*3]*N
abc = [0] * N
for i in range(N):
    L = list(map(int,input().split()))
    abc[i] = L
for i,value in enumerate(abc):
    dp = [0]*3
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[k] = max(dp[k],DP[i-1][j] + value[k])
    DP[i] = dp
print(max(DP[-1]))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
abcList = []
for i in range(n):
    abcList.append(list(map(int, input().split())))



dp = [abcList[0]]


for i in range(1, n):
    dp.append(
        [
            max(dp[-1][1] + abcList[i][0], dp[-1][2] + abcList[i][0]),
            max(dp[-1][0] + abcList[i][1], dp[-1][2] + abcList[i][1]),
            max(dp[-1][1] + abcList[i][2], dp[-1][0] + abcList[i][2]),
        ]
    )

for d in dp:
    print(d)


Failing test case input:
1
010 3 0

Expected output:
10


Actual output:
[10, 3, 0]


Fixed submission (verdict: Accepted):

n = int(input())
abcList = []
for i in range(n):
    abcList.append(list(map(int, input().split())))



dp = [abcList[0]]


for i in range(1, n):
    dp.append(
        [
            abcList[i][0] + max(dp[-1][1], dp[-1][2]),
            abcList[i][1] + max(dp[-1][2], dp[-1][0]),
            abcList[i][2] + max(dp[-1][0], dp[-1][1]),
        ]
    )

print(max(dp[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=list()
for i in range(n):
  li=[int(i) for i in input().split()]
  l.append(li)
dp=[[0,0,0] for i in range(n)]
dp[0][0]=l[0][0]
dp[0][1]=l[0][1]
dp[0][2]=l[0][2]
for i in range(1,n):
  for j in range(3):
    for k in range(3):
      dp[i][j]=max(dp[i-1][k]+l[i][k],dp[i][j])
print(max(dp[-1]))

Failing test case input:
3
-2 20 0
0 10 3
14 -1 1

Expected output:
37


Actual output:
44


Fixed submission (verdict: Accepted):
n=int(input())
l=list()
for i in range(n):
  li=[int(i) for i in input().split()]
  l.append(li)
dp=[[0,0,0] for i in range(n)]
dp[0][0]=l[0][0]
dp[0][1]=l[0][1]
dp[0][2]=l[0][2]
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]+l[i][j],dp[i][j])
print(max(dp[-1]))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]
dp = [[0 for i in range(3)] for j in range(n)]
dp[0] = [max(li[0])]*3


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

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

Failing test case input:
7
3 2 16
1 8 0
4 4 12
15 8 6
4 5 1
2 3 7
1 1 -1

Expected output:
64


Actual output:
57


Fixed submission (verdict: Accepted):
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]
dp = [[0 for i in range(3)] for j 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], li[i][k] + dp[i][j])

print(max(dp[n]))
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

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



dp = [[0] * 3 for _ in range(N)]
dp[0][0] = A[0][0]
dp[0][1] = A[0][1]
dp[0][2] = A[0][2]


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

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

Failing test case input:
1
101 29 1

Expected output:
101


Actual output:
160


Fixed submission (verdict: Accepted):

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



dp = [[0] * 3 for _ in range(N)]
dp[0][0] = A[0][0]
dp[0][1] = A[0][1]
dp[0][2] = A[0][2]


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][j],dp[i-1][k]+A[i][j])

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

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a,b,c=0,0,0
for i in range(n):
    x,y,z=map(int,input().split())
    a,b,c=max(b,c)+x,max(a,c)+y,max(a,b)+z
    print(a,b,c)
print(max(a,b,c))

Failing test case input:
1
001 4 0

Expected output:
4


Actual output:
1 4 0
4


Fixed submission (verdict: Accepted):
n=int(input())
a,b,c=0,0,0
for i in range(n):
    x,y,z=map(int,input().split())
    a,b,c=max(b,c)+x,max(a,c)+y,max(a,b)+z
print(max(a,b,c))

Problem: p03162
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
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]))


Failing test case input:
7
9 1 66
-1 1 2
-1 2 0
2 4 1
0 12 1
0 1 22
2 1 -3

Expected output:
105


Actual output:
108


Fixed submission (verdict: Accepted):
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]))
Problem: p03162
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
a,b,c=map(int,input().split())
dp=[[0]*3 for i in range(n)]
dp[0][0],dp[0][1],dp[0][2]=a,b,c

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

Failing test case input:
3
-1 35 53
34 50 149
30 8 5

Expected output:
214


Actual output:
53


Fixed submission (verdict: Accepted):
n=int(input())
a,b,c=map(int,input().split())
dp=[[0]*3 for i in range(n)]
dp[0][0],dp[0][1],dp[0][2]=a,b,c

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

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0] 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][j], dp[i][j] + abc[i][k])

print(max(dp[N]))


Failing test case input:
7
3 7 14
11 9 0
4 5 3
15 13 6
4 8 1
3 3 7
2 3 -1

Expected output:
63


Actual output:
43


Fixed submission (verdict: Accepted):
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0] 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] + abc[i][k])

print(max(dp[N]))

Problem: p03162
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


n = int(input())

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

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

dp[0] = li[0]

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


Failing test case input:
7
5 1 176
0 2 0
-2 2 -1
2 8 2
-1 3 1
0 1 4
0 1 -5

Expected output:
189


Actual output:
193


Fixed submission (verdict: Accepted):

n = int(input())

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

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

dp[0] = li[0]

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

  
print(max(dp[-1]))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[]
for i in range(n):
  a_=list(map(int,input().split()))
  a.append(a_)
  
dp=[[0]*3 for i in range(n)]
dp[0]=a[0]
for i in range(1,n):
  for k in range(3):
    
    for j in range(3):
      
      if k!=j:
        dp[i][k]=max(dp[i][k], dp[i-1][j] + a[i-1][k])

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

Failing test case input:
7
3 7 19
11 8 0
4 4 3
15 14 6
4 8 1
3 3 7
2 3 -1

Expected output:
67


Actual output:
71


Fixed submission (verdict: Accepted):
n=int(input())
a=[]
for i in range(n):
  a_=list(map(int,input().split()))
  a.append(a_)
  
dp=[[0]*3 for i in range(n)]
dp[0]=a[0]
for i in range(1,n):
  for k in range(3):
    
    for j in range(3):
      
      if k!=j:
        dp[i][k]=max(dp[i][k], dp[i-1][j] + a[i][k])

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

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdin


def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()

n=ii()
a, b, c=mi()
for _ in range(n-1):
    x, y, z=mi()
    a+=max(y, z)
    b+=max(x, z)
    c+=max(y, z)
print(max(a, b, c))

Failing test case input:
3
-1 35 53
34 50 149
30 35 5

Expected output:
219


Actual output:
237


Fixed submission (verdict: Accepted):
from sys import stdin


def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()

n=ii()
x, y, z=mi()
for _ in range(n-1):
    a, b, c=mi()
    a+=max(y, z)
    b+=max(x, z)
    c+=max(y, x)
    x, y, z=a, b, c
print(max(x, y, z))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdin


def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()

n=ii()
a, b, c=mi()
for _ in range(n-1):
    x, y, z=mi()
    a+=max(y, z)
    b+=max(x, z)
    c+=max(y, x)
print(max(a, b, c))

Failing test case input:
7
3 6 16
22 8 0
4 4 6
15 14 6
4 8 1
3 3 7
2 1 -1

Expected output:
76


Actual output:
70


Fixed submission (verdict: Accepted):
from sys import stdin


def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()

n=ii()
x, y, z=mi()
for _ in range(n-1):
    a, b, c=mi()
    a+=max(y, z)
    b+=max(x, z)
    c+=max(y, x)
    x, y, z=a, b, c
print(max(x, y, z))
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdin

def main():
    n = int(input())
    ary = [list(map(int, stdin.readline().split())) for _ in range(n)]
    dp = [[]] * n

    def max_act(abc,yesterday=None):
        if yesterday:
            del abc[yesterday]
        v = max(abc)
        i = abc.index(v)
        return [i,v]

    dp[0] = max_act(ary[0])

    for i in range(1,n):
        dp[i] = max_act(ary[i],dp[i-1][0])
    print(sum([i[1] for i in dp]))

if __name__ == '__main__':
    main()

Failing test case input:
3
0 94 34
34 50 80
30 35 90

Expected output:
218


Actual output:
264


Fixed submission (verdict: Accepted):
from sys import stdin

def main():
    n = int(input())
    ary = [list(map(int, stdin.readline().split())) for _ in range(n)]
    dp = [[0 for _ in range(3)] for _ in range(n)]
    for k in range(n):
        for i in range(3):
            if k == 0:
                dp[k][i] = ary[k][i]
            else:
                dp[k][i] = ary[k][i] + max([dp[k-1][j] for j in range(3) if j != i])
    print(max(dp[n-1]))

if __name__ == '__main__':
    main()

Problem: p03162
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
dp=[]
for i in range(n):
  l=list(map(int,input().split()))
  dp.append(l)
for i in range(1,n):
  for j in range(3):
  	dp[i][(j%3)]+=max(dp[i][(j+1)%3],dp[i][(j+2)%3]) 
print(max(dp[n-1]))
  

Failing test case input:
3
-1 5 -4
-1 0 8
21 4 10

Expected output:
34


Actual output:
45


Fixed submission (verdict: Accepted):
n=int(input())
dp=[]
for i in range(n):
  l=list(map(int,input().split()))
  dp.append(l)
for i in range(1,n):
  for j in range(3):
  	dp[i][(j%3)]+=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]) 
print(max(dp[n-1]))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
T = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N)]
for i in range(N):
  if i == 0:
    dp[i] = T[i]
  for j in [0,1,2]:
    dp[i][j] = max([dp[i-1][j1]+T[i][j] for j1 in [0,1,2] if j1 != j])
print(max(dp[-1]))

Failing test case input:
1
000 16 1

Expected output:
16


Actual output:
33


Fixed submission (verdict: Accepted):
N = int(input())
T = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for i in range(N)]
dp[0] = T[0]
for i in range(1,N):
  for j in [0,1,2]:
    dp[i][j] = max([dp[i-1][j1]+T[i][j] for j1 in [0,1,2] if j1 != j])
print(max(dp[N-1]))
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())

max_a = [0] * N
max_b = [0] * N
max_c = [0] * N

for i in range(0, N):
    a, b, c = map(int, input().split())
    max_a[i] = max(max_b[i - 1] + a, max_c[i-1] + a)
    max_b[i] = max(max_a[i - 1] + b, max_c[i - 1] + b)
    max_c[i] = max(max_a[i - 1] + c, max_b[i - 1] + c)

print(max(max_a[-1], max_b[-1], max_c[-1]))

Failing test case input:
1
101 29 1

Expected output:
101


Actual output:
131


Fixed submission (verdict: Accepted):
N = int(input())

max_a = [0] * N
max_b = [0] * N
max_c = [0] * N
if N>1:
    for i in range(0, N):
        a, b, c = map(int, input().split())
        max_a[i] = max(max_b[i - 1] + a, max_c[i-1] + a)
        max_b[i] = max(max_a[i - 1] + b, max_c[i - 1] + b)
        max_c[i] = max(max_a[i - 1] + c, max_b[i - 1] + c)

    print(max(max_a[-1], max_b[-1], max_c[-1]))
else:
    a, b, c = map(int, input().split())

    print(max(a, b, c))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
L = []

for i in range(N):
  l = list(map(int,input().split()))
  L.append(l)
  
dp = [[0,0,0] for i in range(N)]
dp[0] = [L[0][0],L[0][1],L[0][2]]

for i in range(1,N):
  for j in range(3):
    dp[i][j] = max(dp[i - 1][(j + 1) % 3],dp[i - 1][(j + 2) % 3]) + L[i - 1][j]
    
print(max(dp[N - 1]))

Failing test case input:
7
3 7 19
11 8 0
4 4 3
15 14 6
4 8 1
3 3 7
2 1 -1

Expected output:
66


Actual output:
71


Fixed submission (verdict: Accepted):
N = int(input())
L = []

for i in range(N):
  l = list(map(int,input().split()))
  L.append(l)
  
dp = [[0,0,0] for i in range(N)]
dp[0] = [L[0][0],L[0][1],L[0][2]]

for i in range(1,N):
  for j in range(3):
    dp[i][j] = max(dp[i - 1][(j + 1) % 3],dp[i - 1][(j + 2) % 3]) + L[i][j]
    
print(max(dp[N - 1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = []
for _ in range(N):
    H.append(list(map(int, input().split())))
dp = [[0, 0, 0] for _ in range(N)]
dp[0] = H[0]
for i,h in enumerate(H[1:], start=1):
    for k in range(3):
        dp[i][k] = h[k]+max(map(lambda x: x if dp[i-1].index(x)!=k else 0, dp[i-1]))
print(max(dp[-1]))

Failing test case input:
7
5 1 176
0 2 0
-2 2 0
2 8 2
-1 3 1
0 1 4
0 1 -5

Expected output:
190


Actual output:
188


Fixed submission (verdict: Accepted):
N = int(input())
H = []
for _ in range(N):
    H.append(list(map(int, input().split())))
dp = [[0, 0, 0] for _ in range(N)]
dp[0] = H[0]
for i,h in enumerate(H[1:], start=1):
    dp[i][0] = h[0]+max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = h[1]+max(dp[i-1][0], dp[i-1][2])
    dp[i][2] = h[2]+max(dp[i-1][0], dp[i-1][1])
print(max(dp[-1]))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline  

N = int(input())
a,b,c = map(int,input().split())
dp = [[a,b,c]]
for i in range(N-1):
    a,b,c = map(int,input().split())
    A = max(dp[i][1]+a,dp[i][2]+a)
    B = max(dp[i][2]+b,dp[i][0]+b)
    C = max(dp[i][0]+b,dp[i][1]+c)
    dp.append([A,B,C])
print(max(dp[-1]))


Failing test case input:
7
5 1 176
0 2 0
-2 2 0
2 8 2
-1 4 1
0 1 10
0 1 -4

Expected output:
196


Actual output:
199


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline  

N = int(input())
a,b,c = map(int,input().split())
dp = [[a,b,c]]
for i in range(N-1):
    a,b,c = map(int,input().split())
    A = max(dp[i][1]+a,dp[i][2]+a)
    B = max(dp[i][2]+b,dp[i][0]+b)
    C = max(dp[i][0]+c,dp[i][1]+c)
    dp.append([A,B,C])
print(max(dp[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=[]
for i in range(n):
  a,b,c=map(int,input().split())
  l.append([a,b,c])

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

Failing test case input:
7
3 7 14
11 9 0
4 5 3
15 13 6
4 8 1
3 3 7
2 3 -1

Expected output:
63


Actual output:
[3, 7, 14]
63


Fixed submission (verdict: Accepted):
n=int(input())
l=[]
for i in range(n):
  a,b,c=map(int,input().split())
  l.append([a,b,c])

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

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

what_to_do = []
for i in range(N):
    input2 = input().split()
    tmp1,tmp2,tmp3 = list(map(int,input2))
    what_to_do.append([tmp1,tmp2,tmp3])
    
print(what_to_do)

dp = []
for _ in range(N+1):
    dp.append([0,0,0])

print(dp)

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

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

Failing test case input:
3
-1 61 -2
0 17 5
7 5 1

Expected output:
73


Actual output:
[[-1, 61, -2], [0, 17, 5], [7, 5, 1]]
[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [0, 61, 0], [61, 17, 66], [73, 71, 62]]
73


Fixed submission (verdict: Accepted):
N = int(input())

what_to_do = []
for i in range(N):
    input2 = input().split()
    tmp1,tmp2,tmp3 = list(map(int,input2))
    what_to_do.append([tmp1,tmp2,tmp3])

dp = []
for _ in range(N+1):
    dp.append([0,0,0])

for i in range(N):
    for k in range(3):
        for j in range(3):
            if k != j:
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + what_to_do[i][k])
                
            
print(max(dp[-1]))
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())

a = [[0] * 3 for i in range(n+1)]
dp = [[0] * 3 for i in range(n+1)]

for i in range(n):
  a[i] = list(map(int,input().strip().split()))

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

Failing test case input:
3
1 40 34
20 50 80
30 35 90

Expected output:
174


Actual output:
210


Fixed submission (verdict: Accepted):
n = int(input())

a = [[0] * 3 for i in range(n+1)]
dp = [[0] * 3 for i in range(n+1)]

for i in range(n):
  a[i] = list(map(int,input().strip().split()))

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

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

N = int(input())

dp = [[0]*3  for i in range(N)]

dp[0][0], dp[0][1], dp[0][2] = map(int, sys.stdin.readline().split())

tmp = [0, 0, 0]

for i in range(1, N):
    tmp[0], tmp[1], tmp[2] = map(int, sys.stdin.readline().split())
    for j in range(3):
        dp[i][j] = max(dp[i-1][(j+1)%3]+tmp[(j+2)%3], dp[i-1][(j+2)%3]+tmp[(j+2)%3])

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

Failing test case input:
7
5 1 66
0 1 1
0 2 -2
5 4 1
0 12 0
0 1 12
2 1 -5

Expected output:
99


Actual output:
100


Fixed submission (verdict: Accepted):
import sys

N = int(input())

dp = [[0]*3  for i in range(N)]

dp[0][0], dp[0][1], dp[0][2] = map(int, sys.stdin.readline().split())

tmp = [0, 0, 0]

for i in range(1, N):
    tmp[0], tmp[1], tmp[2] = map(int, sys.stdin.readline().split())
    for j in range(3):
        dp[i][j] = max(dp[i-1][(j+1)%3]+tmp[j], dp[i-1][(j+2)%3]+tmp[j])

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

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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))


Failing test case input:
3
-1 35 9
15 50 48
19 8 5

Expected output:
102


Actual output:
[102, 91, 64]
102


Fixed submission (verdict: Accepted):
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))