Buggy python submission (verdict: Runtime Error):
import sys
#from functools import lru_cache
sys.setrecursionlimit(100000)

N = int(input())
H = [int(h) for h in input().split()]
INF = 10**5+1
cost = [INF]*N
cost[0] = 0
cost[1] = abs(H[0] - H[1])

#@lru_cache(maxsize=None)
def dp(i):
  if cost[i] != INF:
    return cost[i]
  else:
    cost[i] = min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))
  return cost[i]

print(dp(N-1))

Fixed submission:
import sys
#from functools import lru_cache
sys.setrecursionlimit(100000)

N = int(input())
H = [int(h) for h in input().split()]
INF = 10**5+1
cost = [INF]*N
cost[0] = 0
cost[1] = abs(H[0] - H[1])

#@lru_cache(maxsize=None)
def dp(i):
  if cost[i] != INF:
    return cost[i]
  else:
    cost[i] = min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))
  return cost[i]

for i in range(N-1):
  dp(i)
print(dp(N-1))

Buggy python submission (verdict: Runtime Error):
import sys
#from functools import lru_cache
sys.setrecursionlimit(100000)

N = int(input())
H = [int(h) for h in input().split()]
INF = 10**4+1
cost = [INF]*N
cost[0] = 0
cost[1] = abs(H[0] - H[1])

#@lru_cache(maxsize=None)
def dp(i):
  if cost[i] != INF:
    return cost[i]
  else:
    cost[i] = min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))
  return cost[i]

print(dp(N-1))

Fixed submission:
import sys
#from functools import lru_cache
sys.setrecursionlimit(100000)

N = int(input())
H = [int(h) for h in input().split()]
INF = 10**5+1
cost = [INF]*N
cost[0] = 0
cost[1] = abs(H[0] - H[1])

#@lru_cache(maxsize=None)
def dp(i):
  if cost[i] != INF:
    return cost[i]
  else:
    cost[i] = min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))
  return cost[i]

for i in range(N-1):
  dp(i)
print(dp(N-1))

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

N = int(input())
H = [int(h) for h in input().split()]
cost = [0]*N

@lru_cache(maxsize=None)
def dp(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(H[i-1] - H[i])
  else:
    return min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))
  
print(dp(N-1))

Fixed submission:
import sys
#from functools import lru_cache
sys.setrecursionlimit(100000)

N = int(input())
H = [int(h) for h in input().split()]
INF = 10**5+1
cost = [INF]*N
cost[0] = 0
cost[1] = abs(H[0] - H[1])

#@lru_cache(maxsize=None)
def dp(i):
  if cost[i] != INF:
    return cost[i]
  else:
    cost[i] = min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))
  return cost[i]

for i in range(N-1):
  dp(i)
print(dp(N-1))

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

N = int(input())
H = [int(h) for h in input().split()]
cost = [0]*N

def dp(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(H[i-1] - H[i])
  else:
    return min(
      dp(i-1) + abs(H[i-1] - H[i]), 
      dp(i-2) + abs(H[i-2] - H[i]))
  
print(dp(N-1))

Fixed submission:
import sys
#from functools import lru_cache
sys.setrecursionlimit(100000)

N = int(input())
H = [int(h) for h in input().split()]
INF = 10**5+1
cost = [INF]*N
cost[0] = 0
cost[1] = abs(H[0] - H[1])

#@lru_cache(maxsize=None)
def dp(i):
  if cost[i] != INF:
    return cost[i]
  else:
    cost[i] = min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))
  return cost[i]

for i in range(N-1):
  dp(i)
print(dp(N-1))

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

N = int(input())
H = [int(h) for h in input().split()]
cost = [0]*N

def dp(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(H[i-1] - H[i])
  else:
    return min(
      dp(i-1) + abs(H[i-1] - H[i]), 
      dp(i-2) + abs(H[i-2] - H[i]))
  
print(dp(N-1))

Fixed submission:
import sys
#from functools import lru_cache
sys.setrecursionlimit(100000)

N = int(input())
H = [int(h) for h in input().split()]
INF = 10**5+1
cost = [INF]*N
cost[0] = 0
cost[1] = abs(H[0] - H[1])

#@lru_cache(maxsize=None)
def dp(i):
  if cost[i] != INF:
    return cost[i]
  else:
    cost[i] = min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))
  return cost[i]

for i in range(N-1):
  dp(i)
print(dp(N-1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = [int(h) for h in input().split()]
cost = [0]*N

def dp(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(H[i-1] - H[i])
  else:
    return min(
      dp(i-1) + abs(H[i-1] - H[i]), 
      dp(i-2) + abs(H[i-2] - H[i]))
  
print(dp(N-1))

Fixed submission:
import sys
#from functools import lru_cache
sys.setrecursionlimit(100000)

N = int(input())
H = [int(h) for h in input().split()]
INF = 10**5+1
cost = [INF]*N
cost[0] = 0
cost[1] = abs(H[0] - H[1])

#@lru_cache(maxsize=None)
def dp(i):
  if cost[i] != INF:
    return cost[i]
  else:
    cost[i] = min(
      dp(i-1) + abs(H[i-1] - H[i]),
      dp(i-2) + abs(H[i-2] - H[i]))
  return cost[i]

for i in range(N-1):
  dp(i)
print(dp(N-1))