Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

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

    import math
    dp = [math.inf]*N

    dp[0] = 0
    step1, step2 = math.inf, math.inf

    for i in range(1, N):
        step1 = abs(H[i-1]-H[i]) + dp[i-1]
        if i >= 2:
            step2 = abs(H[i-2]-H[i]) + dp[i-2]
        step = min(step1, step2)

        dp[i] = min(dp[i], step)
    print(dp[-1])


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

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

    inf = float("inf")
    dp = [inf]*N

    dp[0] = 0
    step1, step2 = inf, inf

    for i in range(1, N):
        step1 = abs(H[i-1]-H[i]) + dp[i-1]
        if i >= 2:
            step2 = abs(H[i-2]-H[i]) + dp[i-2]
        step = min(step1, step2)

        dp[i] = min(dp[i], step)
    print(dp[-1])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

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

    from scipy.sparse import csgraph, csr_matrix

    start = [i for i in range(N-1)] + [i for i in range(N-2)]
    end = [i+1 for i in range(N-1)] + [i+2 for i in range(N-2)]
    cost = [abs(h1-h2) for h1, h2 in zip(H[0:-1], H[1:])] + \
        [abs(h1-h2) for h1, h2 in zip(H[0:-2], H[2:])]
    csr = csr_matrix((cost, (start, end)), shape=(N, N))
    d = csgraph.shortest_path(csr, method='D')

    print(int(d[0][N-1]))


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

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

    inf = float("inf")
    dp = [inf]*N

    dp[0] = 0
    step1, step2 = inf, inf

    for i in range(1, N):
        step1 = abs(H[i-1]-H[i]) + dp[i-1]
        if i >= 2:
            step2 = abs(H[i-2]-H[i]) + dp[i-2]
        step = min(step1, step2)

        dp[i] = min(dp[i], step)
    print(dp[-1])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

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

    from scipy.sparse import csgraph, csr_matrix

    start = [i for i in range(N-1)] + [i for i in range(N-2)]
    end = [i+1 for i in range(N-1)] + [i+2 for i in range(N-2)]
    cost = [abs(h1-h2) for h1, h2 in zip(H[0:-1], H[1:])] + \
        [abs(h1-h2) for h1, h2 in zip(H[0:-2], H[2:])]
    csr = csr_matrix((cost, (start, end)), shape=(N, N))
    d = csgraph.shortest_path(csr, indices=0)

    print(int(d[N-1]))


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

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

    inf = float("inf")
    dp = [inf]*N

    dp[0] = 0
    step1, step2 = inf, inf

    for i in range(1, N):
        step1 = abs(H[i-1]-H[i]) + dp[i-1]
        if i >= 2:
            step2 = abs(H[i-2]-H[i]) + dp[i-2]
        step = min(step1, step2)

        dp[i] = min(dp[i], step)
    print(dp[-1])


if __name__ == "__main__":
    main()