Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
# N = 4
# ARR = [10, 30, 40, 20]

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

def calculate(n, arr):
    result = aaa(0)
    print(result)


def aaa(currentPosition, cost=0):
    endPosition = N - 1
    if currentPosition == endPosition:
        return cost
    if currentPosition == (endPosition - 1):
        return aaa(endPosition, cost + abs(ARR[endPosition] - ARR[currentPosition]))

    a1 = abs(ARR[currentPosition + 1] - ARR[currentPosition])
    a2 = abs(ARR[currentPosition + 2] - ARR[currentPosition])

    s1 = aaa(currentPosition + 1, cost + a1)
    s2 = aaa(currentPosition + 2, cost + a2)
    return min(s1, s2)

calculate(N, ARR)


Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
# N = 4
# ARR = [10, 30, 40, 20]

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

def calculate(n, arr):
    result = aaa(0)
    print(result)


def aaa(currentPosition, cost=0):
    endPosition = N - 1
    if currentPosition == endPosition:
        return cost
    if currentPosition == (endPosition - 1):
        return aaa(endPosition, cost + abs(ARR[endPosition] - ARR[currentPosition]))

    a1 = abs(ARR[currentPosition + 1] - ARR[currentPosition])
    a2 = abs(ARR[currentPosition + 2] - ARR[currentPosition])

    s1 = aaa(currentPosition + 1, cost + a1)
    s2 = aaa(currentPosition + 2, cost + a2)
    return min(s1, s2)

calculate(N, ARR)


Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
# N = 4
# ARR = [10, 30, 40, 20]

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

def calculate(n, arr):
    result = aaa(0, n - 1)
    print(result)


def aaa(currentPosition, endPosition, cost=0):
    if currentPosition == endPosition:
        return cost
    if currentPosition == (endPosition - 1):
        return aaa(endPosition, endPosition, cost + abs(ARR[endPosition] - ARR[currentPosition]))

    a1 = abs(ARR[currentPosition + 1] - ARR[currentPosition])
    a2 = abs(ARR[currentPosition + 2] - ARR[currentPosition])

    s1 = aaa(currentPosition + 1, endPosition, cost + a1)
    s2 = aaa(currentPosition + 2, endPosition, cost + a2)
    return min(s1, s2)

calculate(N, ARR)


Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
# N = 4
# ARR = [10, 30, 40, 20]

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

def calculate(n, arr):
    result = aaa(0, n - 1, arr)
    print(result)


def aaa(currentPosition, endPosition, arr, cost=0):
    if currentPosition == endPosition:
        return cost
    if currentPosition == (endPosition - 1):
        return aaa(endPosition, endPosition, arr, cost + abs(arr[endPosition] - arr[currentPosition]))

    a1 = abs(arr[currentPosition + 1] - arr[currentPosition])
    a2 = abs(arr[currentPosition + 2] - arr[currentPosition])

    s1 = aaa(currentPosition + 1, endPosition, arr, cost + a1)
    s2 = aaa(currentPosition + 2, endPosition, arr, cost + a2)
    return min(s1, s2)





calculate(N, ARR)


Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
# N = 4
# ARR = [10, 30, 40, 20]

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

def calculate(n, arr):
    result = aaa(0, n - 1, arr)
    print(result)


def aaa(currentPosition, endPosition, arr, cost=0):
    if currentPosition == endPosition:
        return cost
    if currentPosition == (endPosition - 1):
        return aaa(endPosition, endPosition, arr, cost + abs(arr[endPosition] - arr[currentPosition]))

    a1 = abs(arr[currentPosition + 1] - arr[currentPosition])
    a2 = abs(arr[currentPosition + 2] - arr[currentPosition])

    s1 = aaa(currentPosition + 1, endPosition, arr, cost + a1)
    s2 = aaa(currentPosition + 2, endPosition, arr, cost + a2)
    return min(s1, s2)





calculate(N, ARR)


Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])

Buggy python submission (verdict: Runtime Error):
# N = 4
# ARR = [10, 30, 40, 20]

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

def calculate(n, arr):
    result = aaa(0, n - 1, arr)
    print(result)


def aaa(currentPosition, endPosition, arr, cost=0):
    if currentPosition == endPosition:
        return cost
    if currentPosition == (endPosition - 1):
        return aaa(endPosition, endPosition, arr, cost + abs(arr[endPosition] - arr[currentPosition]))

    a1 = abs(arr[currentPosition + 1] - arr[currentPosition])
    a2 = abs(arr[currentPosition + 2] - arr[currentPosition])

    s1 = aaa(currentPosition + 1, endPosition, arr, cost + a1)
    s2 = aaa(currentPosition + 2, endPosition, arr, cost + a2)
    return min(s1, s2)





calculate(N, ARR)


Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
sys.setrecursionlimit(100000000)

# N = 4
# HRR = [10, 30, 40, 20]
# # N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []


def calculate(pos, cost):
    if pos == N-1:
        result.append(int(cost))
        return

    if pos + 1 <= N - 1:
        calculate(pos + 1, cost + math.fabs(HRR[pos + 1] - HRR[pos]))

    if pos + 2 <= N - 1:
        calculate(pos + 2,cost + math.fabs(HRR[pos + 2] - HRR[pos]))


calculate(0, 0)
print(min(result))

Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
sys.setrecursionlimit(100000000)

# N = 4
# HRR = [10, 30, 40, 20]
# # N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []


def calculate(pos, n, hrr, cost):
    if pos == n-1:
        result.append(int(cost))
        return

    if pos + 1 <= n - 1:
        calculate(pos + 1, n, hrr, cost + math.fabs(hrr[pos + 1] - hrr[pos]))

    if pos + 2 <= n - 1:
        calculate(pos + 2, n, hrr, cost + math.fabs(hrr[pos + 2] - hrr[pos]))


calculate(0, N, HRR, 0)
print(min(result))

Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])

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

# N = 4
# HRR = [10, 30, 40, 20]
# # N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []


def calculate(pos, n, hrr, cost):
    if pos > n - 1:
        return
    if pos == n-1:
        result.append(int(cost))
        return

    if pos + 1 <= n - 1:
        calculate(pos + 1, n, hrr, cost + math.fabs(hrr[pos + 1] - hrr[pos]))

    if pos + 2 <= n - 1:
        calculate(pos + 2, n, hrr, cost + math.fabs(hrr[pos + 2] - hrr[pos]))


calculate(0, N, HRR, 0)
print(min(result))

Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])

Buggy python submission (verdict: Runtime Error):
import math

# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []


def calculate(pos, n, hrr, cost):
    if pos == n-1:
        result.append(int(cost))

    if pos + 1 <= n-1:
        calculate(pos + 1, n, hrr, cost + math.fabs(hrr[pos + 1] - hrr[pos]))

    if pos + 2 <= n-1:
        calculate(pos + 2, n, hrr, cost + math.fabs(hrr[pos + 2] - hrr[pos]))


calculate(0, N, HRR, 0)
print(min(result))

Fixed submission:
# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])