Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000000)

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

memo = [-1]*N 
def func(n,memo): 
  if n == 0: 
    memo[0] = 0 
    return memo[n] 
  elif n == 1: 
    memo[1] = abs(H[1]-H[0]) 
    return memo[n] 
  else: 
    if memo[n] != -1: 
      return memo[n] 
    else: 
      min_c = min(func(n-1,memo)+abs(H[n]-H[n-1]), func(n-2,memo)+abs(H[n]-H[n-2])) 
      memo[n] = min_c 
    return min_c 
  
print(func(N-1,memo)) 

Fixed submission:
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#足場iにたどり着くための最小コストをリスト化
mincost= []
for i in range(N):
  if i == 0:
    c = 0
  elif i == 1:
    c = abs(H[1]-H[0])
  else:
    c = min(abs(H[i]-H[i-1])+mincost[i-1],abs(H[i]-H[i-2])+mincost[i-2])
  mincost.append(c)

print(mincost[N-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

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

memo = [-1]*N 
def func(n,memo): 
  if n == 0: 
    memo[0] = 0 
    return memo[n] 
  elif n == 1: 
    memo[1] = abs(H[1]-H[0]) 
    return memo[n] 
  else: 
    if memo[n] != -1: 
      return memo[n] 
    else: 
      min_c = min(func(n-1,memo)+abs(H[n]-H[n-1]), func(n-2,memo)+abs(H[n]-H[n-2])) 
      memo[n] = min_c 
    return min_c 
  
print(func(N-1,memo)) 

Fixed submission:
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#足場iにたどり着くための最小コストをリスト化
mincost= []
for i in range(N):
  if i == 0:
    c = 0
  elif i == 1:
    c = abs(H[1]-H[0])
  else:
    c = min(abs(H[i]-H[i-1])+mincost[i-1],abs(H[i]-H[i-2])+mincost[i-2])
  mincost.append(c)

print(mincost[N-1])

Buggy python submission (verdict: Runtime Error):
N =int(input())
H = list(map(int, input().split()))
H.append(0)
#総数Nで、N番目の添字はN-1

#メモ化再帰
#今の場所からゴールまでの最小コストを出す
now = 0
memo = [-1]*N
def func(n,memo):
  if n >= N:
    return 99999999
  if n == N-1:
    memo[N-1] = 0
    return 0
  else:
    if memo[n] != -1:
      return memo[n]
    else:
      min_later = min(func(n+1,memo)+abs(H[n+1]-H[n]), func(n+2,memo)+abs(H[n+2]-H[n]))
      memo[n] = min_later
    return min_later

print(func(now,memo))

Fixed submission:
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#足場iにたどり着くための最小コストをリスト化
mincost= []
for i in range(N):
  if i == 0:
    c = 0
  elif i == 1:
    c = abs(H[1]-H[0])
  else:
    c = min(abs(H[i]-H[i-1])+mincost[i-1],abs(H[i]-H[i-2])+mincost[i-2])
  mincost.append(c)

print(mincost[N-1])

Buggy python submission (verdict: Runtime Error):
N =int(input())
H = list(map(int, input().split()))
memo = [-1]*N
def func(n,memo):
  if n == 0:
    memo[0] = 0
    return memo[n]
  elif n == 1:
    memo[1] = abs(H[1]-H[0])
    return memo[n]
  else:
    if memo[n] != -1:
      return memo[n]
    else:
      min_c = min(func(n-1,memo)+abs(H[n]-H[n-1]), func(n-2,memo)+abs(H[n]-H[n-2]))
      memo[n] = min_c
    return min_c
print(func(N-1,memo))

Fixed submission:
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#足場iにたどり着くための最小コストをリスト化
mincost= []
for i in range(N):
  if i == 0:
    c = 0
  elif i == 1:
    c = abs(H[1]-H[0])
  else:
    c = min(abs(H[i]-H[i-1])+mincost[i-1],abs(H[i]-H[i-2])+mincost[i-2])
  mincost.append(c)

print(mincost[N-1])

Buggy python submission (verdict: Runtime Error):
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#メモ化再帰
memo = [-1]*N
memo[0] = 0
memo[1] = abs(H[1]-H[0])
def func(n,memo):
  if memo[n] != -1:
    return memo[n]
  else:
    min_c = min(func(n-1,memo)+abs(H[n]-H[n-1]),func(n-2,memo)+abs(H[n]-H[n-2]))
    memo[n] = min_c
  return min_c

print(func(N-1,memo))

Fixed submission:
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#足場iにたどり着くための最小コストをリスト化
mincost= []
for i in range(N):
  if i == 0:
    c = 0
  elif i == 1:
    c = abs(H[1]-H[0])
  else:
    c = min(abs(H[i]-H[i-1])+mincost[i-1],abs(H[i]-H[i-2])+mincost[i-2])
  mincost.append(c)

print(mincost[N-1])

Buggy python submission (verdict: Runtime Error):
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#メモ化再帰
memo = [-1]*N
def func(n,memo):
  if n == 0:
    min_c = 0
  elif n == 1:
    min_c = abs(H[n]-H[0])
  else:
    if memo[n] != -1:
      return memo[n]
    else:
      min_c = min(func(n-1,memo)+abs(H[n]-H[n-1]),func(n-2,memo)+abs(H[n]-H[n-2]))
  memo[n] = min_c
  return min_c

print(func(N-1,memo))

Fixed submission:
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#足場iにたどり着くための最小コストをリスト化
mincost= []
for i in range(N):
  if i == 0:
    c = 0
  elif i == 1:
    c = abs(H[1]-H[0])
  else:
    c = min(abs(H[i]-H[i-1])+mincost[i-1],abs(H[i]-H[i-2])+mincost[i-2])
  mincost.append(c)

print(mincost[N-1])

Buggy python submission (verdict: Runtime Error):
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#メモ化再帰
memo = [-1]*N
def func(n,memo):
  if n == 0:
    min_c = 0
  elif n == 1:
    min_c = abs(H[n]-H[0])
  else:
    if memo[n-1] == -1: memo[n-1] = func(n-1,memo)
    if memo[n-2] == -1: memo[n-2] = func(n-2,memo)
    min_c = min(memo[n-1]+abs(H[n]-H[n-1]),memo[n-2]+abs(H[n]-H[n-2]))
  memo[n] = min_c
  return min_c

print(func(N-1,memo))

Fixed submission:
N =int(input())
H = list(map(int, input().split()))
#総数Nで、N番目の添字はN-1
flog = 0

#足場iにたどり着くための最小コストをリスト化
mincost= []
for i in range(N):
  if i == 0:
    c = 0
  elif i == 1:
    c = abs(H[1]-H[0])
  else:
    c = min(abs(H[i]-H[i-1])+mincost[i-1],abs(H[i]-H[i-2])+mincost[i-2])
  mincost.append(c)

print(mincost[N-1])