Buggy python submission (verdict: Runtime Error):
(n, W) = map(int,input().split())
pre = [0] * (W+1)
cur = [0] * (W+1)
#a = [[0] * (W+1) for i in range(n)]
for i in range(0, n):
  (w, v) = map(int,input().split())
  for j in range(w, W + 1):
    cur[j] = max(pre[j], pre[j-w] + v)
  pre = list(cur)
print(cur[W])

Fixed submission:
def printArray(arr):
  for i in range(0, len(arr)):
    print(arr[i])
    
def minimumCost(n, hights):  
  if (n < 2):
    print("0")
  else:
    memo = []
    memo.append(0)
    memo.append(abs(hights[0] - hights[1]))
    for i in range(2, n):
      memo.append(min(
        (abs(hights[i] - hights[i - 1]) + memo [i - 1]), 
        (abs(hights[i] - hights[i - 2]) + memo [i - 2])
      ))
    print(memo[n-1])
    
n = int(input())
hights = list(map(int,input().split()))
minimumCost(n, hights)

Buggy python submission (verdict: Runtime Error):
import numpy as np
 
(n, k) = map(int,input().split())
hights = list(map(int,input().split()))
memo = [-1] * n
memo[0]

print(' '.join([str(elem) for elem in memo]))




Fixed submission:
def printArray(arr):
  for i in range(0, len(arr)):
    print(arr[i])
    
def minimumCost(n, hights):  
  if (n < 2):
    print("0")
  else:
    memo = []
    memo.append(0)
    memo.append(abs(hights[0] - hights[1]))
    for i in range(2, n):
      memo.append(min(
        (abs(hights[i] - hights[i - 1]) + memo [i - 1]), 
        (abs(hights[i] - hights[i - 2]) + memo [i - 2])
      ))
    print(memo[n-1])
    
n = int(input())
hights = list(map(int,input().split()))
minimumCost(n, hights)

Buggy python submission (verdict: Runtime Error):
import numpy as np
 
(n, k) = map(int,input().split())
hights = list(map(int,input().split()))
memo.append(0)
for i in range(1, n):
  memo.append(np.iinfo(np.int64).max)
  for j in range(max(i - k, 0), i):
    memo[i] = min(memo[i], (abs(hights[i] - hights[j]) + memo [j]))
print(memo[n-1])


Fixed submission:
def printArray(arr):
  for i in range(0, len(arr)):
    print(arr[i])
    
def minimumCost(n, hights):  
  if (n < 2):
    print("0")
  else:
    memo = []
    memo.append(0)
    memo.append(abs(hights[0] - hights[1]))
    for i in range(2, n):
      memo.append(min(
        (abs(hights[i] - hights[i - 1]) + memo [i - 1]), 
        (abs(hights[i] - hights[i - 2]) + memo [i - 2])
      ))
    print(memo[n-1])
    
n = int(input())
hights = list(map(int,input().split()))
minimumCost(n, hights)

Buggy python submission (verdict: Runtime Error):
def printArray(arr):
  for i in range(0, len(arr)):
    print(arr[i])
    
def minimumCost(n, k, hights):  
  if (n < 2):
    print("0")
  else:
    memo = []
    memo.append(0)
    memo.append(abs(hights[0] - hights[1]))
    for i in range(2, n):
      memo.append(abs(hights[i] - hights[i - 1]) + memo [i - 1])
      for j in range(2, k + 1):
        if (i - j) >= 0:
        	memo[i] = min(memo[i],
                      (abs(hights[i] - hights[i - j]) + memo [i - j]))
    print(memo[n-1])
    
(n, k) = map(int,input().split())
hights = list(map(int,input().split()))
minimumCost(n, k, hights)

Fixed submission:
def printArray(arr):
  for i in range(0, len(arr)):
    print(arr[i])
    
def minimumCost(n, hights):  
  if (n < 2):
    print("0")
  else:
    memo = []
    memo.append(0)
    memo.append(abs(hights[0] - hights[1]))
    for i in range(2, n):
      memo.append(min(
        (abs(hights[i] - hights[i - 1]) + memo [i - 1]), 
        (abs(hights[i] - hights[i - 2]) + memo [i - 2])
      ))
    print(memo[n-1])
    
n = int(input())
hights = list(map(int,input().split()))
minimumCost(n, hights)

Buggy python submission (verdict: Runtime Error):
def minimumCost(n, hights):
  if (n < 2):
    print "0"
  else:
    memo = []
    memo[0] = 0
    memo[1] = abs(hights[0] - hights[1])
    for i in range(2, n):
      memo[i] = min((hights[i] - hights[i - 1] + memo [i - 1]), (hights[i] - hights[i - 2] + memo [i - 2]))
    print memo[n-1]

Fixed submission:
def printArray(arr):
  for i in range(0, len(arr)):
    print(arr[i])
    
def minimumCost(n, hights):  
  if (n < 2):
    print("0")
  else:
    memo = []
    memo.append(0)
    memo.append(abs(hights[0] - hights[1]))
    for i in range(2, n):
      memo.append(min(
        (abs(hights[i] - hights[i - 1]) + memo [i - 1]), 
        (abs(hights[i] - hights[i - 2]) + memo [i - 2])
      ))
    print(memo[n-1])
    
n = int(input())
hights = list(map(int,input().split()))
minimumCost(n, hights)

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
arr = map(int,raw_input().split())
dp = [float("inf")]*(n)
 
for i in range(n):
  for j in (i+1,i+2)
    if j < n:
      dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]))
print dp[n-1]

Fixed submission:
n = int(raw_input())
arr = map(int,raw_input().split())
dp = [float("inf")]*(n)
dp[0]=0
for i in range(n):
    for j in [i+1,i+2]:
        if j < n: 
            dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]))
print dp[n-1]

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
arr = map(int,raw_input().split())
dp = [float("inf")]*(n)
 
for i in range(n):
  for j in range(i+1,i+3):
    if j < n:
      dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[h]))
print dp[n-1]

Fixed submission:
n = int(raw_input())
arr = map(int,raw_input().split())
dp = [float("inf")]*(n)
dp[0]=0
for i in range(n):
    for j in [i+1,i+2]:
        if j < n: 
            dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]))
print dp[n-1]

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
arr = map(int,raw_input().split())
dp = [float("inf")]*(n)

for i in range(n):
  for j in range(i,i+2):
    if j < n:
      dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[h]))
print dp[n-1]

Fixed submission:
n = int(raw_input())
arr = map(int,raw_input().split())
dp = [float("inf")]*(n)
dp[0]=0
for i in range(n):
    for j in [i+1,i+2]:
        if j < n: 
            dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]))
print dp[n-1]