Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys


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


def main():

    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)


if __name__ == '__main__':
    N = int(input())
    A = [int(x) for x in input().split()]
    main(N, A)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys


input = sys.stdin.readline


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)]

or 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 submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- 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)]

or 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 submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- 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 submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline

def main(N, DATA):
    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])

    return res


if __name__ == '__main__':
    N = int(input())
    DATA = [map(int, input().split()) for i in range(N)]
    r = main(N, DATA)
    print(r)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys


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


def main(N, DATA):
    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])

    return res


if __name__ == '__main__':
    N = int(input())
    DATA = [map(int, input().split()) for i in range(N)]
    r = main(N, DATA)
    print(r)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys


input = sys.stdin.readline


def main(N, DATA):
    dp = [[0 for _ in range(N)] for _ in range(N + 1)]

    for i in range(N):
        for j in range(N):
            for k in range(N):
                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(N):
        res = max(res, dp[N][v])

    return res


if __name__ == '__main__':
    N = int(input())
    DATA = [list(map(int, input().split())) for i in range(N)]
    r = main(N, DATA)
    print(r)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys


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


def main(N, DATA):
    dp = [[0 for _ in range(N)] for _ in range(N + 1)]

    for i in range(N):
        for j in range(N):
            for k in range(N):
                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(N):
        res = max(res, dp[N][v])

    return res


if __name__ == '__main__':
    N = int(input())
    DATA = [map(int, input().split()) for i in range(N)]

    
    r = main(N, DATA)
    print(r)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys


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


def main(N, DATA):
    dp = [[0 for _ in range(N)] for _ in range(N + 1)]

    for i in range(N):
        for j in range(N):
            for k in range(N):
                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(N):
        res = max(res, dp[N][v])
    print(res)


if __name__ == '__main__':
    N = int(input())
    DATA = [map(int, input().split()) for i in range(N)]

    main(N, DATA)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys


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


def main(N, DATA):
    dp = [[0 for _ in range(N)] for _ in range(N + 1)]

    for i in range(N):
        for j in range(N):
            for k in range(N):
                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(N):
        res = max(res, dp[N][v])
    print(res)


if __name__ == '__main__':
    N = int(input())
    DATA = [map(int, input().split()) for i in range(N)]

    main(N, DATA)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys


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


def main(N, DATA):
    dp = [[0 for _ in range(N)] 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(N):
        res = max(res, dp[N][v])
    print(res)


if __name__ == '__main__':
    N = int(input())
    DATA = [input().split() for _ in range(N)]
    main(N, DATA)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys


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


def main(N, DATA):
    dp = [[0 for _ in range(N)] 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(N):
        res = max(res, dp[N][v])
    print(res)


if __name__ == '__main__':
    N = int(input())
    DATA = [input().split() for _ in range(N)]
    main(N, DATA)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys


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


def main(N, DATA):
    dp = [[0 for _ in range(N)] for _ in range(N + 1)]

    for i in range(N):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue

                # ここと      ここを比較  ↓比較対象はこれ、j+ k
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + DATA[i][k])

    res = 0

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


if __name__ == '__main__':
    N = int(input())
    DATA = [input().split() for _ in range(N)]
    # N = 3
    # DATA = [
    #     [10, 40, 70],
    #     [20, 50, 80],
    #     [30, 60, 90]
    # ]
    main(N, DATA)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys


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


def main(N, DATA):
    dp = [[0 for _ in range(N)] for _ in range(N)]

    for i in range(N):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue

                # ここと      ここを比較  ↓比較対象はこれ、j+ k
                dp[i][k] = max(dp[i][k], dp[i][j] + DATA[i][k])

    res = 0

    for v in range(N):
        res = max(res, dp[N - 1][v])
    print(res)


if __name__ == '__main__':
    N = int(input())
    DATA = [input().split() for _ in range(N)]
    # N = 3
    # DATA = [
    #     [10, 40, 70],
    #     [20, 50, 80],
    #     [30, 60, 90]
    # ]
    main(N, DATA)


Fixed submission:
import sys

input = sys.stdin.readline

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

dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)