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


def jump(k, h, res):
  if not k:
    return 0

  if res[k] == -1:
    res[k] = jump(k-1, h, res) + abs(h[k] - h[k-1])
    if k >= 2:
      res[k] = min(res[k], jump(k-2, h, res) + abs(h[k] - h[k-2]))

  return res[k]


def main(N, H):
  if len(H) != N:
      print 0
      return
  res = [-1] * N

  print jump(N-1, H, res)


if __name__ == '__main__':
  H, N = None, None
  for i, line_ in enumerate(sys.stdin):
    line = line_.strip()
    if line:
        if not i:
            N = int(line.strip())
        H_ = line.strip().split()
        H = [int(num) for num in H_]
  if N is not None and H is not None:
    main(N, H)

Fixed submission:
import sys


def jump(n, h, res):
  res[0] = 0
  res[1] = abs(h[0] - h[1])
  for i in range(2, len(res)):
      res[i] = min(res[i-1] + abs(h[i] - h[i-1]), res[i-2] + abs(h[i] - h[i-2]))

  return res[n]


def main(N, H):
  res = [0] * N

  print jump(N-1, H, res)


if __name__ == '__main__':
  H, N = None, None
  for i, line_ in enumerate(sys.stdin):
    line = line_.strip()
    if line:
        if not i:
            N = int(line.strip())
        H_ = line.strip().split()
        H = [int(num) for num in H_]
  if N is not None and H is not None:
    main(N, H)

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


def jump(k, h, res):
  if not k:
    return 0

  if res[k] == -1:
    res[k] = jump(k-1, h, res) + abs(h[k] - h[k-1])
    if k >= 2:
      res[k] = min(res[k], jump(k-2, h, res) + abs(h[k] - h[k-2]))

  return res[k]


def main(N, H):
  res = [-1] * N

  print jump(N-1, H, res)


if __name__ == '__main__':
  H, N = None, None
  for i, line_ in enumerate(sys.stdin):
    line = line_.strip()
    if line:
        if not i:
            N = int(line.strip())
        H_ = line.strip().split()
        H = [int(num) for num in H_]
  if N and H:
    main(N, H)

Fixed submission:
import sys


def jump(n, h, res):
  res[0] = 0
  res[1] = abs(h[0] - h[1])
  for i in range(2, len(res)):
      res[i] = min(res[i-1] + abs(h[i] - h[i-1]), res[i-2] + abs(h[i] - h[i-2]))

  return res[n]


def main(N, H):
  res = [0] * N

  print jump(N-1, H, res)


if __name__ == '__main__':
  H, N = None, None
  for i, line_ in enumerate(sys.stdin):
    line = line_.strip()
    if line:
        if not i:
            N = int(line.strip())
        H_ = line.strip().split()
        H = [int(num) for num in H_]
  if N is not None and H is not None:
    main(N, H)

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


def jump(k, h, res):
  if not k:
    return 0

  if res[k] == -1:
    res[k] = jump(k-1, h, res) + abs(h[k] - h[k-1])
    if k >= 2:
      res[k] = min(res[k], jump(k-2, h, res) + abs(h[k] - h[k-2]))

  return res[k]


def main(N, H):
  res = [-1] * N

  print jump(N-1, H, res)


if __name__ == '__main__':
  for i, line_ in enumerate(sys.stdin):
    line = line_.strip()
    if line:
        if not i:
            N = int(line.strip())
        H_ = line.strip().split()
        H = [int(num) for num in H_]

  main(N, H)

Fixed submission:
import sys


def jump(n, h, res):
  res[0] = 0
  res[1] = abs(h[0] - h[1])
  for i in range(2, len(res)):
      res[i] = min(res[i-1] + abs(h[i] - h[i-1]), res[i-2] + abs(h[i] - h[i-2]))

  return res[n]


def main(N, H):
  res = [0] * N

  print jump(N-1, H, res)


if __name__ == '__main__':
  H, N = None, None
  for i, line_ in enumerate(sys.stdin):
    line = line_.strip()
    if line:
        if not i:
            N = int(line.strip())
        H_ = line.strip().split()
        H = [int(num) for num in H_]
  if N is not None and H is not None:
    main(N, H)

Buggy python submission (verdict: Runtime Error):
def helper(k, h, res):
    if k == 0:
        return 0
    if res[k] == -1:
        res[k] = helper(k-1, h, res)+abs(h[k]-h[k-1])
        if k >= 2:
            res[k] = min(helper(k, h, res), res[k-2]+abs(h[k]-h[k-2]))
    return res[k]

def main():
    n = int(input())
    h= list(map(int, input().split(" ")))
    res = [-1]*n
    print(helper(n-1, h, res))

if __name__ == "__main__":
    main()

Fixed submission:
def helper(h, n):
    res = [0]*n
    res[0] = 0
    res[1] = abs(h[1]-h[0])
    for i in range(2, n):
        res[i] = min(res[i-1]+abs(h[i]-h[i-1]), res[i-2]+abs(h[i]-h[i-2]))
    return res[-1]

def main():
    n = int(input())
    h = list(map(int, input().split(" ")))
    print(helper(h, n))

if __name__ == "__main__":
    main()