Buggy python submission (verdict: Time Limit Exceeded):
def swap(a, b):
    tmp = a
    a = b
    b = tmp

    return a, b

def main():
    N = int(input())
    field = list(map(int, input().split()))

    dpList = [0] * N
    presentedDpList = [0] * N

    for i in range(N):
        dpList, presentedDpList = swap(dpList, presentedDpList)

        for j in range(i, N):
            if j == 0:
                dpList[j] = 0
            elif j == 1:
                dpList[j] = presentedDpList[j - 1] + abs(field[j] - field[j - 1])
            else:
                dpList[j] = min([presentedDpList[j - 1] + abs(field[j] - field[j - 1]), presentedDpList[j - 2] + abs(field[j] - field[j - 2])])

    print(dpList[-1])

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    field = list(map(int, input().split()))

    dpList = [0] * N
    dpList[1] = abs(field[0] - field[1])

    for i in range(2, N):
        dpList[i] = min([dpList[i - 1] + abs(field[i] - field[i - 1]), dpList[i - 2] + abs(field[i] - field[i - 2])])
        
    print(dpList[-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def swap(a, b):
    tmp = a
    a = b
    b = tmp

    return a, b

def main():
    N = int(input())
    field = list(map(int, input().split()))

    dpList = [0] * N
    presentedDpList = [0] * N

    for i in range(N):
        dpList, presentedDpList = swap(dpList, presentedDpList)

        for j in range(i, N):
            if j == 0:
                dpList[j] = 0
            elif j == 1:
                dpList[j] = presentedDpList[j - 1] + abs(field[j] - field[j - 1])
            else:
                dpList[j] = min([presentedDpList[j - 1] + abs(field[j] - field[j - 1]), \
                                 presentedDpList[j - 2] + abs(field[j] - field[j - 2])])

    print(dpList[-1])

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    field = list(map(int, input().split()))

    dpList = [0] * N
    dpList[1] = abs(field[0] - field[1])

    for i in range(2, N):
        dpList[i] = min([dpList[i - 1] + abs(field[i] - field[i - 1]), dpList[i - 2] + abs(field[i] - field[i - 2])])
        
    print(dpList[-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def swap(a, b):
    tmp = a
    a = b
    b = tmp

    return a, b

def main():
    N = int(input())
    field = list(map(int, input().split()))

    dpList = [0] * N
    presentedDpList = [0] * N

    for i in range(N):
        dpList, presentedDpList = swap(dpList, presentedDpList)

        for j in range(N):
            if j == 0:
                dpList[j] = 0
            elif j == 1:
                dpList[j] = presentedDpList[j - 1] + abs(field[j] - field[j - 1])
            else:
                dpList[j] = min([presentedDpList[j - 1] + abs(field[j] - field[j - 1]), \
                                 presentedDpList[j - 2] + abs(field[j] - field[j - 2])])

    print(dpList[-1])

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    field = list(map(int, input().split()))

    dpList = [0] * N
    dpList[1] = abs(field[0] - field[1])

    for i in range(2, N):
        dpList[i] = min([dpList[i - 1] + abs(field[i] - field[i - 1]), dpList[i - 2] + abs(field[i] - field[i - 2])])
        
    print(dpList[-1])

if __name__ == "__main__":
    main()