Buggy python submission (verdict: Runtime Error):
import sys
from math import sqrt, floor, factorial, gcd
from collections import deque, Counter, defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

sys.setrecursionlimit(10**3)

def a():
	n = int(inp()); arr = read()
	dic = {0 : 0, 1 : abs(arr[0]-arr[1])}
	def func(arr, n):
		# print(arr[n], n)
		if n in dic:
			return(dic[n])
		min_path = min(abs(arr[n]-arr[n-1])+func(arr,n-1), abs(arr[n]-arr[n-2])+func(arr,n-2))
		dic[n] = min_path
		return(min_path) 


	print(func(arr, n-1))
	# print(dic)




if __name__ == "__main__":
	a()


Fixed submission:
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dp = [0 for i in range(n)]
	dp[0] = 0
	dp[1] = abs(arr[1]-arr[0])
	for i in range(2, n):
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
	print(dp[n-1])




if __name__ == "__main__":
	a()

Buggy python submission (verdict: Runtime Error):
import sys
from math import sqrt, floor, factorial, gcd
from collections import deque, Counter, defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

sys.setrecursionlimit(10**6)

def a():
	n = int(inp()); arr = read()
	dic = {0 : 0, 1 : abs(arr[0]-arr[1])}
	def func(arr, n):
		# print(arr[n], n)
		if n in dic:
			return(dic[n])
		min_path = min(abs(arr[n]-arr[n-1])+func(arr,n-1), abs(arr[n]-arr[n-2])+func(arr,n-2))
		dic[n] = min_path
		return(min_path) 


	print(func(arr, n-1))
	# print(dic)




if __name__ == "__main__":
	a()

Fixed submission:
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dp = [0 for i in range(n)]
	dp[0] = 0
	dp[1] = abs(arr[1]-arr[0])
	for i in range(2, n):
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
	print(dp[n-1])




if __name__ == "__main__":
	a()

Buggy python submission (verdict: Runtime Error):
import sys
from math import sqrt, floor, factorial, gcd
from collections import deque, Counter, defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# def is_prime(n):
# 	for i in range(2, int(sqrt(n))+1):
# 		if n%i == 0:
# 			return(False)
# 	return(True)

# def func(n, arr):
# 	dic = {}
# 	if is_prime(n):
# 		return(arr[-1]+min(func(n, arr)))
# def factorize(n):
# 	output = []
# 	for i in range(2, int(sqrt(n))+1):
# 		if n%i == 0:
# 			c = 0
# 			while n%i == 0:
# 				n //= i
# 				c += 1
# 			output.append((i, c))
# 	if n > 1:
# 		output.append((n, 1))
# 	return(output)
sys.setrecursionlimit(10**6)

def a():
	n = int(inp()); arr = read()
	dic = {0 : 0, 1 : abs(arr[0]-arr[1])}
	def func(arr, n):
		# print(arr[n], n)
		if n in dic:
			return(dic[n])
		min_path = min(abs(arr[n]-arr[n-1])+func(arr,n-1), abs(arr[n]-arr[n-2])+func(arr,n-2))
		dic[n] = min_path
		return(min_path) 


	print(func(arr, n-1))
	# print(dic)




if __name__ == "__main__":
	a()

Fixed submission:
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dp = [0 for i in range(n)]
	dp[0] = 0
	dp[1] = abs(arr[1]-arr[0])
	for i in range(2, n):
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
	print(dp[n-1])




if __name__ == "__main__":
	a()

Buggy python submission (verdict: Runtime Error):
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dic = {0 : 0, 1 : abs(arr[0]-arr[1])}
	def func(arr, n):
		if n in dic:
			return(dic[n])
		min_path = min(abs(arr[n]-arr[n-1])+func(arr,n-1), abs(arr[n]-arr[n-2])+func(arr,n-2))
		dic[n] = min_path
		return(min_path) 


	print(func(arr, n-1))
	# print(dic)




if __name__ == "__main__":
	a()

Fixed submission:
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dp = [0 for i in range(n)]
	dp[0] = 0
	dp[1] = abs(arr[1]-arr[0])
	for i in range(2, n):
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
	print(dp[n-1])




if __name__ == "__main__":
	a()

Buggy python submission (verdict: Runtime Error):
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dic = {}
	def func(arr, n):
		if n == 1:
			dic[n] = abs(arr[n]-arr[n-1])
			return(abs(arr[n]-arr[n-1]))
		if n== 0:
			return(0)
		if n in dic:
			return(dic[n])
		min_path = min(abs(arr[n]-arr[n-1])+func(arr,n-1), abs(arr[n]-arr[n-2])+func(arr,n-2))
		dic[n] = min_path
		return(min_path) 


	print(func(arr, n-1))
	print(dic)




if __name__ == "__main__":
	a()

Fixed submission:
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dp = [0 for i in range(n)]
	dp[0] = 0
	dp[1] = abs(arr[1]-arr[0])
	for i in range(2, n):
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
	print(dp[n-1])




if __name__ == "__main__":
	a()

Buggy python submission (verdict: Runtime Error):
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dic = {}
	def func(arr, n):
		if n == 1:
			dic[n] = abs(arr[n]-arr[n-1])
			return(abs(arr[n]-arr[n-1]))
		if n== 0:
			return(0)
		if n in dic:
			return(dic[n])
		min_path = min(abs(arr[n]-arr[n-1])+func(arr,n-1), abs(arr[n]-arr[n-2])+func(arr,n-2))
		dic[n] = min_path
		return(min_path) 
	print(func(arr, n-1))




if __name__ == "__main__":
	a()

Fixed submission:
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dp = [0 for i in range(n)]
	dp[0] = 0
	dp[1] = abs(arr[1]-arr[0])
	for i in range(2, n):
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
	print(dp[n-1])




if __name__ == "__main__":
	a()

Buggy python submission (verdict: Runtime Error):
import sys
#from math import sqrt, floor, factorial, gcd
#from collections import deque, Counter, defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def is_prime(n):
	for i in range(2, int(sqrt(n))+1):
		if n%i == 0:
			return(False)
	return(True)

def func(n, arr):
	dic = {}
	if is_prime(n):
		return(arr[-1]+min(func(n, arr)))
def factorize(n):
	output = []
	for i in range(2, int(sqrt(n))+1):
		if n%i == 0:
			c = 0
			while n%i == 0:
				n //= i
				c += 1
			output.append((i, c))
	if n > 1:
		output.append((n, 1))
	return(output)


def func(arr, n):
	if n == 1:
		return(abs(arr[n]-arr[n-1]))
	if n== 0:
		return(0)
	return(min(abs(arr[n]-arr[n-1])+func(arr,n-1), abs(arr[n]-arr[n-2])+func(arr,n-2))) 

def a():
	n = int(inp()); arr = read()
	dic = {}
	def func(arr, n):
		if n == 1:
			return(abs(arr[n]-arr[n-1]))
		if n== 0:
			return(0)
		if n in dic:
			return(dic[n])
		min_path = min(abs(arr[n]-arr[n-1])+func(arr,n-1), abs(arr[n]-arr[n-2])+func(arr,n-2))
		dic[n] = min_path
		return(min_path) 


	print(func(arr, n-1))




if __name__ == "__main__":
	a()

Fixed submission:
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dp = [0 for i in range(n)]
	dp[0] = 0
	dp[1] = abs(arr[1]-arr[0])
	for i in range(2, n):
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
	print(dp[n-1])




if __name__ == "__main__":
	a()