Buggy python submission (verdict: Runtime Error):
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

Fixed submission:
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

Buggy python submission (verdict: Runtime Error):
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
def jump(a,now):
  if dp[a] != 0:
    return dp[a]
  if a == num:
    res = 0
  elif a+2 > num:
    res = jump(a+1,height[a])+abs(now-height[a])
  else:
    res = min(jump(a+1,height[a])+abs(now-height[a]),jump(a+2,height[a+1])+abs(now-height[a+1]))
  dp[a] = res
  return res
print(jump(1,height[0]))

Fixed submission:
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

Buggy python submission (verdict: Runtime Error):
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [{} for n in range(10 ** 5 * 2)]
def jump(a,now):
  if now in dp[a]:
    return dp[a][now]
  if a == num:
    res = 0
  elif a+2 > num:
    res = jump(a+1,height[a])+abs(now-height[a])
  else:
    res = min(jump(a+1,height[a])+abs(now-height[a]),jump(a+2,height[a+1])+abs(now-height[a+1]))
  dp[a][now] = res
  return res
print(jump(1,height[0]))

Fixed submission:
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

Buggy python submission (verdict: Runtime Error):
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [{} for n in range(1000000)]
def jump(a,now):
  if now in dp[a]:
    return dp[a][now]
  if a == num:
    res = 0
  elif a+2 > num:
    res = jump(a+1,height[a])+abs(now-height[a])
  else:
    res = min(jump(a+1,height[a])+abs(now-height[a]),jump(a+2,height[a+1])+abs(now-height[a+1]))
  dp[a][now] = res
  return res
print(jump(1,height[0]))

Fixed submission:
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

Buggy python submission (verdict: Runtime Error):
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [{} for n in range(10000)]
def jump(a,now):
  if now in dp[a]:
    return dp[a][now]
  if a == num:
    res = 0
  elif a+2 > num:
    res = jump(a+1,height[a])+abs(now-height[a])
  else:
    res = min(jump(a+1,height[a])+abs(now-height[a]),jump(a+2,height[a+1])+abs(now-height[a+1]))
  dp[a][now] = res
  return res
print(jump(1,height[0]))

Fixed submission:
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

Buggy python submission (verdict: Runtime Error):
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [{}]
def jump(a,cost,now):
  if cost in dp[a]:
    return dp[a][cost]
  elif a == num:
    res = 0
  else:
    res = min(jump(a+1,cost+abs(now-height[a+1],height[a+1]),jump(a+2,cost+abs(now-height[a+2],height[a+2])
print(jump(1,0,height[0])    

Fixed submission:
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

Buggy python submission (verdict: Runtime Error):
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [{} for n in range(10000)]
def jump(a,cost,now):
  print(cost)
  if cost in dp[a]:
    return dp[a][cost]
  elif a-1 == num:
	res = 0
  elif a+2 < num:
    res = min(jump(a+1,cost+abs(now-height[a+1]),height[a+1]),jump(a+2,cost+abs(now-height[a+2]),height[a+2]))
  else:
    res = jump(a+1,cost+abs(now-height[a+1]),height[a+1])
  dp[a][cost] = res
  return res
print(jump(1,0,height[0]))

Fixed submission:
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

Buggy python submission (verdict: Runtime Error):
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [{}]
def jump(a,cost,now):
  if cost in dp[a]:
    return dp[a][cost]
  elif a == num:
    res = 0
  else:
    res = min(jump(a+1,cost+abs(now-height[a+1],height[a+1]),jump(a+2,cost+abs(now-height[a+2],height[a+2])
print(jump(1,0,height[0])    
                                                                  

Fixed submission:
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

Buggy python submission (verdict: Runtime Error):
from sys import stdin,stdout


n = int(stdin.readline())
dp = [0 for i in range(n)]
a  = list(map(int,stdin.readline().split()))
dp[1] = abs(a[1] - a[0])
if(n>1):
  for i in range(2,n):
  	dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]) + dp[i-2] + abs(a[i]-a[i-2]))
print(dp[-1])


Fixed submission:
from sys import stdin,stdout


n = int(stdin.readline())
dp = [0 for i in range(n)]
a  = list(map(int,stdin.readline().split()))
dp[1] = abs(a[1] - a[0])
if(n>1):
  for i in range(2,n):
  	dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]) , dp[i-2] + abs(a[i]-a[i-2]))
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
def main():
    inf = float('inf')
    n,k=map(int,input().split())
    h = list(map(int,input().split()))
    dp=[0] + [inf] *(n-1)#初期化
    for i in range(1,n):
        for j in range(1,k+1):#iからj離れた場所から来る場合と比較
            if i >=j:
                dp[i] = min(dp[i],abs(h[i-j]-h[i])+dp[i-j])
            else:break
    print(dp[n-1])
if __name__ == '__main__':
    main()

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
s1, s2 = abs(h[1]-h[0]), 0
if n==2:
    print(s1)
else:
    score = [0] + [s1] + [0] * (n - 2)
    for i in range(2,n):
        s1= abs(h[i-1]-h[i])+score[i-1]
        s2= abs(h[i-2]-h[i])+score[i-2]
        score[i] = min(s1,s2)
    print(score[n-1])

Buggy python submission (verdict: Runtime Error):
def main():
    inf = float('inf')
    n,k=map(int,input().split())
    h = list(map(int,input().split()))
    dp=[0] + [inf] *(n-1)#初期化
    for i in range(1,n):
        for j in range(1,k+1):#iからj離れた場所から来る場合と比較
            if i >=j:
                dp[i] = min(dp[i],abs(h[i-j]-h[i])+dp[i-j])
            else:break
    print(dp[n-1])
if __name__ == '__main__':
    main()

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
s1, s2 = abs(h[1]-h[0]), 0
if n==2:
    print(s1)
else:
    score = [0] + [s1] + [0] * (n - 2)
    for i in range(2,n):
        s1= abs(h[i-1]-h[i])+score[i-1]
        s2= abs(h[i-2]-h[i])+score[i-2]
        score[i] = min(s1,s2)
    print(score[n-1])

Buggy python submission (verdict: Runtime Error):
inf = float('inf')
n,k=map(int,input().split())
h = list(map(int,input().split()))
dp=[0] + [inf] *(n-1)#初期化
for i in range(1,n):
    for j in range(1,k+1):#iからj離れた場所から来る場合と比較
        if i >=j:
            dp[i] = min(dp[i],abs(h[i-j]-h[i])+dp[i-j])
        else:break
print(dp[n-1])

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
s1, s2 = abs(h[1]-h[0]), 0
if n==2:
    print(s1)
else:
    score = [0] + [s1] + [0] * (n - 2)
    for i in range(2,n):
        s1= abs(h[i-1]-h[i])+score[i-1]
        s2= abs(h[i-2]-h[i])+score[i-2]
        score[i] = min(s1,s2)
    print(score[n-1])