Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache
import sys
sys.setrecursionlimit(20000000)
INF = float('inf')

N = int(input())
h = list(map(int, input().split()))
n = len(h)-1

@lru_cache(maxsize=None)
def rec(i):
    if i==0:
        return 0
    res = INF
    res = min(res, rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        res = min(res, rec(i-2)+abs(h[i]-h[i-2]))
    return res
print(rec(n))

Fixed submission:
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

# ans
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
import sys
sys.setrecursionlimit(5000)
INF = float('inf')

N = int(input())
h = list(map(int, input().split()))
n = len(h)-1

@lru_cache(maxsize=None)
def rec(i):
    if i==0:
        return 0
    res = INF
    res = min(res, rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        res = min(res, rec(i-2)+abs(h[i]-h[i-2]))
    return res
print(rec(n))

Fixed submission:
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

# ans
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np

class Tropical():
    def __init__(self, values):
        self.values = values

    def __add__(self, x):
        return min(self.values, x.values)

    def __mul__(self, x):
        return self.values + x.values

    def Tropical_sum(self):
        return min(self.values)

# INF
INF = float('inf')
Infty = Tropical(INF)

# Tropical Product
def Tropical_Product(A, B):
    return [[(lambda x: Tropical(x).Tropical_sum())(list(map(lambda x: Tropical(x[0]) * Tropical(x[1]), zip(A[i], [[B[j][i] for j in range(len(B))] for i in range(len(B))][j])))) for j in range(len(A))] for i in range(len(B))]

def Tropical_Pow(A, num):
    tmp = A
    B = A
    for _ in range(num-1):
        B = Tropical_Product(B,tmp)
    return B

N = int(input())
h = list(map(int, input().split()))

Z = np.zeros((N,N))
Z = Z.full((N,N),INF)
for i in range(N+1):
    for j in range(i+1,i+3):
        #print(i,j)
        if j <= N:
            print(i,j)
            if abs(i-j)==1 and i+1 < N:
                Z[i][j] = abs(h[i]-h[i+1])
            elif abs(i-j)==2 and i+2 < N:
                Z[i][j] = abs(h[i]-h[i+2])

for i in range(N):
    tmp = Tropical_Pow(Z,i)
    if tmp[0][-1] != INF:
        print(int(tmp[0][-1]))
        exit()

Fixed submission:
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

# ans
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np

class Tropical():
    def __init__(self, values):
        self.values = values

    def __add__(self, x):
        return min(self.values, x.values)

    def __mul__(self, x):
        return self.values + x.values

    def Tropical_sum(self):
        return min(self.values)

# INF
INF = float('inf')
Infty = Tropical(INF)

# Tropical Product
def Tropical_Product(A, B):
    return [[(lambda x: Tropical(x).Tropical_sum())(list(map(lambda x: Tropical(x[0]) * Tropical(x[1]), zip(A[i], [[B[j][i] for j in range(len(B))] for i in range(len(B))][j])))) for j in range(len(A))] for i in range(len(B))]

def Tropical_Pow(A, num):
    tmp = A
    B = A
    for _ in range(num-1):
        B = Tropical_Product(B,tmp)
    return B

N = int(input())
h = list(map(int, input().split()))

Z = np.full((N,N),INF)
for i in range(N+1):
    for j in range(i+1,i+3):
        #print(i,j)
        if j <= N:
            #print(i,j)
            if abs(i-j)==1 and i+1 < N:
                Z[i][j] = abs(h[i]-h[i+1])
            elif abs(i-j)==2 and i+2 < N:
                Z[i][j] = abs(h[i]-h[i+2])

for i in range(N):
    tmp = Tropical_Pow(Z,i)
    if tmp[0][-1] != INF:
        print(int(tmp[0][-1]))
        exit()

Fixed submission:
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

# ans
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np

class Tropical():
    def __init__(self, values):
        self.values = values

    def __add__(self, x):
        return min(self.values, x.values)

    def __mul__(self, x):
        return self.values + x.values

    def Tropical_sum(self):
        return min(self.values)

# INF
INF = float('inf')
Infty = Tropical(INF)

# Tropical Product
def Tropical_Product(A, B):
    return [[(lambda x: Tropical(x).Tropical_sum())(list(map(lambda x: Tropical(x[0]) * Tropical(x[1]), zip(A[i], [[B[j][i] for j in range(len(B))] for i in range(len(B))][j])))) for j in range(len(A))] for i in range(len(B))]

def Tropical_Pow(A, num):
    tmp = A
    B = A
    for _ in range(num-1):
        B = Tropical_Product(B,tmp)
    return B

N = int(input())
h = list(map(int, input().split()))

Z = np.full((N,N),INF)
for i in range(N):
    for j in range(i+1,i+3):
        if j <= N:
            if abs(i-j)==1 and i+1 < N:
                Z[i][j] = abs(h[i]-h[i+1])//10
            elif abs(i-j)==2 and i+2 < N:
                Z[i][j] = abs(h[i]-h[i+2])//10

print(Z)

for i in range(N):
    tmp = Tropical_Pow(Z,i)
    if tmp[0][-1] != INF:
        print(int(tmp[0][-1])*10)
        exit()

Fixed submission:
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

# ans
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np

class Tropical():
    def __init__(self, values):
        self.values = values

    def __add__(self, x):
        return min(self.values, x.values)

    def __mul__(self, x):
        return self.values + x.values

    def Tropical_sum(self):
        return min(self.values)

# INF
INF = float('inf')
Infty = Tropical(INF)

# Tropical Product
def Tropical_Product(A, B):
    return [[(lambda x: Tropical(x).Tropical_sum())(list(map(lambda x: Tropical(x[0]) * Tropical(x[1]), zip(A[i], [[B[j][i] for j in range(len(B))] for i in range(len(B))][j])))) for j in range(len(A))] for i in range(len(B))]

def Tropical_Pow(A, num):
    tmp = A
    B = A
    for _ in range(num-1):
        B = Tropical_Product(B,tmp)
    return B

N = int(input())
h = list(map(int, input().split()))

Z = np.full((N,N),INF)
for i in range(N):
    for j in range(i+1,i+3):
        #print(i,j)
        if j <= N:
            #print(i,j)
            if abs(i-j)==1 and i+1 < N:
                Z[i][j] = abs(h[i]-h[i+1])
            elif abs(i-j)==2 and i+2 < N:
                Z[i][j] = abs(h[i]-h[i+2])

for i in range(N):
    tmp = Tropical_Pow(Z,i)
    if tmp[0][-1] != INF:
        print(int(tmp[0][-1]))
        exit()

Fixed submission:
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

# ans
print(dp[N-1])