Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
pole_list = sorted([int(item) for item in input().split()])

import numpy as np
pole_list = np.array(pole_list)

cnt = 0

for i in range(num):
    for j in range(i + 1, num):
        cnt += len(np.where(pole_list < pole_list[i] + pole_list[j])[0]) - j - 1
print(cnt)


Fixed submission:
from bisect import bisect_left
 
N = int(input())
Lmat = [int(n) for n in input().split()]
Lmat.sort()
 
sum = 0

for i in range(N):
    for j in range(i + 1, N):
        sum += bisect_left(Lmat, Lmat[i]+Lmat[j]) - (j + 1)
        
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
pole_list = sorted([int(item) for item in input().split()])

import numpy as np
pole_list = np.array(pole_list)

cnt = 0

for i in range(num):
    for j in range(i + 1, num):
        cnt += len(pole_list[pole_list < pole_list[i] + pole_list[j]]) - (j + 1)

print(cnt)

Fixed submission:
from bisect import bisect_left
 
N = int(input())
Lmat = [int(n) for n in input().split()]
Lmat.sort()
 
sum = 0

for i in range(N):
    for j in range(i + 1, N):
        sum += bisect_left(Lmat, Lmat[i]+Lmat[j]) - (j + 1)
        
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
 
N = int(input())
Lmat = [int(n) for n in input().split()]
Lmat.sort()
 
sum = 0

for i in range(N):
    for j in range(N):
        if i < j:
            less_than_c = bisect_left(Lmat, Lmat[i]+Lmat[j])
            more_than_b = bisect_left(Lmat, Lmat[j]+1)

            sum += less_than_c - more_than_b 

print(sum)

Fixed submission:
from bisect import bisect_left
 
N = int(input())
Lmat = [int(n) for n in input().split()]
Lmat.sort()
 
sum = 0

for i in range(N):
    for j in range(i + 1, N):
        sum += bisect_left(Lmat, Lmat[i]+Lmat[j]) - (j + 1)
        
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
pole_list = [int(item) for item in input().split()]

triangle_list = []

for i, a in enumerate(pole_list):
    for k, b in enumerate(pole_list):
        for m, c in enumerate(pole_list):

            if a < b + c and b < c + a and c < a + b and i != k and k != m and m != i:
                triangle = sorted([i, k, m])
                triangle_list.append(str(triangle[0]) + str(triangle[1]) + str(triangle[2]))
# print(set(triangle_list))
print(len(set(triangle_list)))


Fixed submission:
from bisect import bisect_left
 
N = int(input())
Lmat = [int(n) for n in input().split()]
Lmat.sort()
 
sum = 0

for i in range(N):
    for j in range(i + 1, N):
        sum += bisect_left(Lmat, Lmat[i]+Lmat[j]) - (j + 1)
        
print(sum)
Buggy python submission (verdict: Runtime Error):
def resolve():
    '''
    code here
    '''
    line = input()
    K = int(input())


    base_cnt = 0
    prev = line[0]
    
    if len(line) >=2:
        for item in line[1:]:
            if item == prev:
                base_cnt += 1
                prev = -1
            else:
                prev = item
        
        if line[-1] == line[-2]:
            is_tail_double = True

    res = base_cnt * K
    # print(base_cnt, res)

    if line[0] == line[-1]:
        if not is_tail_double:
            res = base_cnt + (base_cnt + 1) * (K-1)

    if len(line) == 1:
        res = K //2
    
    print(res)

if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    Sを先頭　真ん中　お尻の三分割する
    連結した場合を考えると以下の場合分け
    先頭　お尻　真ん中×K　（先頭₊お尻）×（K-1）
    同じ文字が続いたらn//2個の文字変更が必要
    以上で解けるはず

    '''
    S = input()
    K = int(input())

    S_head = ''
    head = S[0]
    for s in S:
        if s == head:
            S_head += s
        else:
            break
    
    S_tail = ''
    tail = S[-1]
    for s in S[::-1]:
        if s == tail:
            S_tail += s
        else:
            break
    S_tail = S_tail[::-1]

    S_body = S[len(S_head):-1 * len(S_tail)]
    
    def double_counter(S):
        cnt = 0
        if len(S) >= 2:
            prev = S[0]
            for item in S[1:]:
                if item == prev:
                    cnt += 1
                    prev = -1
                else:
                    prev = item

        return cnt
    
    if len(S) >= 2 and len(S) != len(S_head):
        res = len(S_head)//2\
            + len(S_tail)//2\
            + double_counter(S_body) * K\
            + double_counter(S_tail+S_head) * (K-1)
    elif len(S) == 1:
        res = K // 2
    elif len(S) == len(S_head):
        res = (K * len(S)) // 2

    print(res)

if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Runtime Error):
a, b = [int(item) for item in input().split()]

if b > a:
    c = a
    a = b
    b = c


# 最大公約数を求める
def gcd(a, b):
    while b > 1:
        a, b = b, a%b
    return a

# 公約数でかつ素数の_listを求める
prime_devisor_list = [1, 2]

import math

def is_prime(num):
    if num in [1, 2]:
        return True
    else:
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                return False
        return True

for i in range(3, gcd(a, b)+1):
    if a % i == 0 and b % i == 0:
        # i can be ans
        # check pirme

        if is_prime(i):
            prime_devisor_list.append(i)

# 数をこたえる
len(prime_devisor_list)


Fixed submission:
num = int(input())
odd_num = num // 2 + num % 2
print(odd_num / num)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(item) for item in input().split()]
price_list = sorted([int(item) for item in input().split()])

ticket_list = []
total_price_list = []
total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0

    while total_ticket < ticket_num:
        price_list[-1] = int(price_list[-1]/2)
        price_list.sort()
        total_ticket += 1

    return price_list

res = discount(price_list, M)
print(sum(res))

Fixed submission:
import heapq as hp
N, M = [int(item) for item in input().split()]
price_list = sorted([-1 * int(item) for item in input().split()])

total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0
    hp.heapify(price_list)

    while total_ticket < ticket_num:
        temp = hp.heappop(price_list)
        hp.heappush(price_list, -1* (-1*temp//2))
        total_ticket += 1

    return price_list

res = discount(price_list, M)
print(-1 * sum(res))

Buggy python submission (verdict: Runtime Error):
N, M = [int(item) for item in input().split()]
price_list = sorted([int(item) for item in input().split()])

ticket_list = []
total_price_list = []
total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0

    while total_ticket < ticket_num:
        price_list[-1] = int(price_list[-1]/2)
        temp = price_list[-2]
        price_list[-2] = price_list[-1]
        price_list[-1] =temp
        total_ticket += 1

    return price_list

res = discount(price_list, M)
print(sum(res))

Fixed submission:
import heapq as hp
N, M = [int(item) for item in input().split()]
price_list = sorted([-1 * int(item) for item in input().split()])

total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0
    hp.heapify(price_list)

    while total_ticket < ticket_num:
        temp = hp.heappop(price_list)
        hp.heappush(price_list, -1* (-1*temp//2))
        total_ticket += 1

    return price_list

res = discount(price_list, M)
print(-1 * sum(res))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(item) for item in input().split()]
price_list = [int(item) for item in input().split()]

ticket_list = []
total_price_list = []
total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0

    while total_ticket < ticket_num:
        temp_num = int(sorted(price_list)[-1]/2)
        price_list.sort()
        price_list[-1] = temp_num 
        total_ticket += 1

    return price_list



# total_price  += int(price_list[n] / (2 ** m))
# break
res = discount(price_list, M)
# print(res)
print(sum(res))

Fixed submission:
import heapq as hp
N, M = [int(item) for item in input().split()]
price_list = sorted([-1 * int(item) for item in input().split()])

total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0
    hp.heapify(price_list)

    while total_ticket < ticket_num:
        temp = hp.heappop(price_list)
        hp.heappush(price_list, -1* (-1*temp//2))
        total_ticket += 1

    return price_list

res = discount(price_list, M)
print(-1 * sum(res))
Buggy python submission (verdict: Runtime Error):
N, K = [int(item) for item in input().split()]
S = [item for item in input()]

def compress(arr):
    """圧縮して消えた人はhappy"""
    cnt_h = 0
    new_arr = []
    comp_arr = ['L']

    #最初は先頭をLにする　この回転はノーカン
    if arr[0] == 'R':
        for item in arr:
            if item == 'L':
                new_arr.append('R')
            else:
                new_arr.append('L')

            prev_item = item
    else:
        new_arr = arr
    # 圧縮操作と圧縮されたかずを数える

    for i in range(1, N):
        if new_arr[i - 1] == new_arr[i]:
            cnt_h += 1
        else:
            comp_arr.append(new_arr[i])

    return [comp_arr, cnt_h] 


def execute(arr, cnt_h, K):
    # 境界を全て反転するために必要な操作回数
    max_rotation = len(arr)//2
    # 全てLになるか反転回数がKに到達するかで終了
    if max_rotation <= K:
        cnt += len(arr) - 1
    else:
        cnt_h += 2*K

    return cnt_h

arr, cnt_h = compress(S)
print(execute(arr, cnt_h, K))


Fixed submission:
print(int(input())**3)
Buggy python submission (verdict: Runtime Error):

N, K = [int(item) for item in input().split()]
S = [item for item in input()]

def compress(arr):
    """圧縮して消えた人はhappy"""
    cnt_h = 0
    new_arr = []
    comp_arr = ['L']

    #最初は先頭をLにする　この回転はノーカン
    if arr[0] == 'R':
        for item in arr:
            if item == 'L':
                new_arr.append('R')
            else:
                new_arr.append('L')

            prev_item = item
    else:
        new_arr = arr
    # 圧縮操作と圧縮されたかずを数える

    for i in range(1, N):
        if new_arr[i - 1] == new_arr[i]:
            cnt_h += 1
        else:
            comp_arr.append(new_arr[i])

    return [comp_arr, cnt_h] 


def execute(arr, cnt_h, K):
    # 境界を全て反転するために必要な操作回数
    max_rotation = len(arr)//2
    # 全てLになるか反転回数がKに到達するかで終了
    if max_rotation <= K:
        cnt += len(arr) - 1
    else:
            cnt_h += 2*K

    return cnt_h

arr, cnt_h = compress(S)
print(execute(arr, cnt_h, K))

Fixed submission:
N, K = [int(item) for item in input().split()]
S = [item for item in input()]

def compress(arr):
    """圧縮して消えた人はhappy"""
    cnt_h = 0
    new_arr = []
    comp_arr = ['L']

    #最初は先頭をLにする　この回転はノーカン
    if arr[0] == 'R':
        for item in arr:
            if item == 'L':
                new_arr.append('R')
            else:
                new_arr.append('L')

            prev_item = item
    else:
        new_arr = arr
    # 圧縮操作と圧縮されたかずを数える

    for i in range(1, N):
        if new_arr[i - 1] == new_arr[i]:
            cnt_h += 1
        else:
            comp_arr.append(new_arr[i])

    return [comp_arr, cnt_h] 


def execute(arr, cnt_h, K):
    # 境界を全て反転するために必要な操作回数
    max_rotation = len(arr)//2
    # 全てLになるか反転回数がKに到達するかで終了
    if max_rotation <= K:
        if arr[-1] == 'R':
            cnt_h += max_rotation*2 -1
        elif arr[-1] == 'L':
            cnt_h += max_rotation*2
    else:
        if arr[2*K] == 'R':
            cnt_h += 2*K - 1
        elif arr[2*K] == 'L':
            cnt_h += 2*K

    return cnt_h

arr, cnt_h = compress(S)
print(execute(arr, cnt_h, K))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

res = 0
for i in range(1, N):
  res += i
        
print(res)

Fixed submission:
N = int(input())

print((N-1)*N //2 )

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

res = 0
for i in range(1, N +1):
    if i < N:
        res += i

print(res)

Fixed submission:
N = int(input())

print((N-1)*N //2 )

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
res = 0
for i in range(1, N +1):
    if i < N:
        res += i % (i + 1)

print(res)

Fixed submission:
N = int(input())

print((N-1)*N //2 )

Buggy python submission (verdict: Runtime Error):
N = int(input())

num_list = range(1, N + 1)

def mod_sum(num_list, div_list):
    res = 0
    for i in range(N):
        res += num_list[i] % div_list[i]

    return res


div_list = list(num_list[1:])
div_list.append(num_list[0])

print(mod_sum(num_list, div_list))

Fixed submission:
N = int(input())

print((N-1)*N //2 )
Buggy python submission (verdict: Runtime Error):
def resolve():
    '''
    code here
    '''
    S = input()

    memo = 1
    new_list = []
    
    prev = S[0]
    cnt = 0

    for i in range(len(S)-1):
        if S[i+1] == prev:
            memo += 1
        else:
            new_list.append(memo)
            memo = 1
        prev = S[i+1]
    else:
        new_list.append(memo)

    # print(new_list)

    res = []
    for i in range(len(new_list)//2):

        a = new_list[i*2]
        b = new_list[i*2 +1]
        cond = (10_000_000_000*10 - (a+b))%(a+b)

        if (a+b)%2 ==1:
            if cond % 2 == 1:
                res += [0 for _ in range(new_list[i*2])]
                res[-1] = new_list[i*2+1]
                res += [new_list[i*2]]
                res += [0 for _ in range(new_list[i*2+1]-1)]
            else:
                res += [0 for _ in range(new_list[i*2])]
                res[-1] = new_list[i*2]
                res += [new_list[i*2+1]]
                res += [0 for _ in range(new_list[i*2+1]-1)]
        else:
            res += [0 for _ in range(new_list[i*2])]
            res[-1] = (a + b) // 2
            res += [(a + b ) // 2]
            res += [0 for _ in range(new_list[i*2+1]-1)]
    print(*res)




if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''
    S = input()

    memo = 1
    new_list = []
    
    prev = S[0]
    cnt = 0

    for i in range(len(S)-1):
        if S[i+1] == prev:
            memo += 1
        else:
            new_list.append(memo)
            memo = 1
        prev = S[i+1]
    else:
        new_list.append(memo)

    # print(new_list)

    res = []
    for i in range(len(new_list)//2):

        a = new_list[i*2]
        b = new_list[i*2 +1]

        if (a+b)%2 == 1:
            res += [0 for _ in range(new_list[i*2])]
            res[-1] = (a+1)//2 + b//2
            res += [a//2 + (b+1)//2]
            res += [0 for _ in range(new_list[i*2+1]-1)]
        else:
            res += [0 for _ in range(new_list[i*2])]
            res[-1] = (a + b) // 2
            res += [(a + b ) // 2]
            res += [0 for _ in range(new_list[i*2+1]-1)]
    print(*res)




if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    '''
    code here
    '''
    import bisect
    N, M = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]
    queries = [[int(item) for item in input().split()] for _ in range(M)]

    A_list.sort()

    for i in range(M):
        b, c = queries[i]
        # print(b,c)
        index_c = bisect.bisect_left(A_list, c)
        # print(index_c)

        if index_c >= b:
            big_A = A_list[index_c:]

            A_list = A_list[b:index_c] + [c]*b + big_A
        else:
            A_list = [c]*index_c + A_list[index_c:]

    # print(A_list)
    print(sum(A_list))




if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''
    import bisect
    import collections
    N, M = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]
    queries = [[int(item) for item in input().split()] for _ in range(M)]
    queries = sorted(queries, key=lambda x:x[1], reverse=True)
    A_list.sort()

    cnt_b = 0
    D = collections.deque()
    for i in range(M):
        b, c = queries[i]
        cnt_b += b
        for _ in range(b):
            D.append(c)
        if cnt_b >= N:
            break
    D_len = len(D)
    res = 0
    for i in range(N):
        if i < D_len:
            res += max(D[i], A_list[i])
        else:
            res += A_list[i]

    # print(A_list)
    print(res)




if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    '''
    code here
    '''

    R, G, B, N = [int(item) for item in input().split()]

    cnt = 0

    for i in range(N+1):
        for j in range(N+1):
            _b = N - (i * R + j * G)
            
            if _b % B == 0 and _b >= 0:
                cnt += 1

    print(cnt)

if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''

    R, G, B, N = [int(item) for item in input().split()]

    cnt = 0

    for i in range(N+1):
        for j in range(N+1-i):
            _b = N - (i * R + j * G)
            
            if _b % B == 0 and _b >= 0:
                cnt += 1

    print(cnt)

if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    '''
    code here
    '''
    import collections
    H, W = [int(item) for item in input().split()]
    grid = [[item for item in input()] for _ in range(H)]

    fp = [[-1 for _ in range(W)] for _ in range(H)]

    que = collections.deque()
    next_y_x = [[0, 1], [1, 0], [-1, 0], [0, -1]]
    

    for i in range(H):
        for j in range(W):
            if grid[i][j] == '#':
                que.append([i, j, 0])
                fp[i][j] = 0




    while que:
        temp = que.popleft()

        for dy, dx in next_y_x:
            ny = temp[0] + dy
            nx = temp[1] + dx

            if 0 <= ny <= H-1 and 0 <= nx <= W-1:
                if fp[ny][nx] == -1:
                    que.append([ny, nx, temp[2]+1])
                    fp[ny][nx] = temp[2] + 1

    temp_max_list = []
    for line in fp:
        temp_max_list.append(max(line))

    print(max(temp_max_list))



if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''
    import collections
    H, W = [int(item) for item in input().split()]
    grid = [[item for item in input()] for _ in range(H)]

    fp = [[-1 for _ in range(W)] for _ in range(H)]

    que = collections.deque()
    next_y_x = [[0, 1], [1, 0], [-1, 0], [0, -1]]
    

    for i in range(H):
        for j in range(W):
            if grid[i][j] == '#':
                que.append([i, j, 0])
                fp[i][j] = 0




    while que:
        temp = que.popleft()

        for dy, dx in next_y_x:
            ny = temp[0] + dy
            nx = temp[1] + dx

            if 0 <= ny <= H-1 and 0 <= nx <= W-1:
                if fp[ny][nx] == -1:
                    que.append([ny, nx, temp[2]+1])
                    fp[ny][nx] = temp[2] + 1

    temp_max_list = []
    for line in fp:
        temp_max_list.append(max(line))

    print(max(temp_max_list))



if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Runtime Error):
import collections

N =int(input())

As = [int(item) for item in input().split()]

cnt = 0

Bs = collections.deque()

min1 = 1000000000000

for i in As:

	if As < 0:
      cnt +=1

	Bs.append(abs(i))

	mim1=min(min1, abs(i))

	

if cnt % 2 =0:

	print(sum(list(Bs)))

else:

	print(sum(list(Bs))-min1*2)

Fixed submission:
import collections
N =int(input())
As = [int(item) for item in input().split()]

cnt = 0
Bs = collections.deque()
min1 = 1000000000000

for i in As:
	if i < 0:
		cnt +=1
	Bs.append(abs(i))
	min1=min(min1, abs(i))
	
if cnt % 2 ==0:
	print(sum(list(Bs)))
else:
	print(sum(list(Bs))-min1*2)

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

N =int(input())

As = [int(item) for item in input().split()]

cnt = 0

Bs = collections.deque()

min1 = 1000000000000

for i in As:

	if As < 0:		cnt +=1

	Bs.append(abs(i))

	mim1=min(min1, abd(i))

	

if cnt % 2 =0:

	print(sum(list(Bs)))

else:

	print(sum(list(Bs))-min1*2)
    

Fixed submission:
import collections
N =int(input())
As = [int(item) for item in input().split()]

cnt = 0
Bs = collections.deque()
min1 = 1000000000000

for i in As:
	if i < 0:
		cnt +=1
	Bs.append(abs(i))
	min1=min(min1, abs(i))
	
if cnt % 2 ==0:
	print(sum(list(Bs)))
else:
	print(sum(list(Bs))-min1*2)
Buggy python submission (verdict: Runtime Error):
def resolve():
    '''
    code here
    '''
    import sys
    N = int(input())
    S = sys.stdin.readlines().strip()

    set_S = set([item for item in S])
    res = 1

    for s in set_S:
        cnt = 1
        for letter in S:
            if s == letter:
                cnt += 1
        res *= cnt

    print(res-1)

if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''
    import sys
    N = int(input())
    S = sys.stdin.readline().strip()
    mod = pow(10, 9) + 7
    set_S = set([item for item in S])
    res = 1

    for s in set_S:
        cnt = 1
        for letter in S:
            if s == letter:
                cnt += 1
        res *= cnt
        res %= mod

    mod = pow(10, 9) + 7
    print(res-1)

if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    '''
    code here
    '''
    import collections
    N, M = [int(item) for item in input().split()]
    Xs = [int(item) for item in input().split()]
    if N < M-1:
        Xs.sort()
        ds = [Xs[i] - Xs[i-1] for i in range(1, M)]
        ds.sort()
        # print(ds)
        print(sum(ds[:-1*(N-1)]))
    elif M - N == 1:
        Xs.sort()
        ds = [Xs[i] - Xs[i-1] for i in range(1, M)]
        ds.sort()
        # print(ds)
        print(sum(ds[0]))
        
    else:
        print(0)


if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''
    import collections
    N, M = [int(item) for item in input().split()]
    Xs = [int(item) for item in input().split()]
    if N < M:
        Xs.sort()
        ds = [Xs[i] - Xs[i-1] for i in range(1, M)]
        ds.sort()
        # print(ds)
        print(sum(ds[:M-N]))

    else:
        print(0)


if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Runtime Error):
N, K = [int(item) for item in input().split()]
h =[0] + [int(item) for item in input().split()]

dp = [0 for _ in range(N+1)]

for i in range(N+1):
    for k in range(1, K+1):
        if i - k >= 1:
            if dp[i] != 0:
                dp[i] = min(dp[i-k] + abs(h[i] - h[i-k]), dp[i])
            else:
                dp[i] = dp[i-k] + abs(h[i] - h[i-k])
print(dp[N])

Fixed submission:
N = int(input())
hight_list = [int(item) for item in input().split()]


dp = [0 for i in range(N+1)]

dp[1] = abs(hight_list[1] - hight_list[0])

for i in range(2, N):
    jump1 = abs(hight_list[i] - hight_list[i-1])
    jump2 = abs(hight_list[i] - hight_list[i-2])

    dp[i] = min(dp[i-1] + jump1, dp[i-2] + jump2)


print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N=int(input())
step=[int(i) for i in input().split()]

dp=[0 for _ in range(N+2)]

for i in range(N):
  cost_sum = dp[i][0]
  a=abs(step[i+1]-step[i])
  b=abs(step[i+2]-step[i])
  if a < b:
      dp[i+1] = [cost_sum + a, step[i+1]]
  else:
      dp[i+2] = [cost_sum + b, step[i+2]

print(dp(N))

Fixed submission:
N = int(input())
hight_list = [int(item) for item in input().split()]


dp = [0 for i in range(N+1)]

dp[1] = abs(hight_list[1] - hight_list[0])

for i in range(2, N):
    jump1 = abs(hight_list[i] - hight_list[i-1])
    jump2 = abs(hight_list[i] - hight_list[i-2])

    dp[i] = min(dp[i-1] + jump1, dp[i-2] + jump2)


print(dp[N-1])