Buggy python submission (verdict: Runtime Error):
import sys
 
sys.setrecursionlimit(100000)


N, M = map(int, input().split())
memo = [-1]*N
dic = [[] for i in range(N)]
def dfs(dic, memo, v):
    if memo[v] != -1:
        return memo[v]
    plen = 0
    for i in dic[v]:
        plen = max(plen, dfs(dic, memo, i)+1)
    memo[v] = plen
    return plen
for m in range(M):
    x, y = map(int, input().split())
    dic[x-1].append(y-1)
    
ans = 0
for i in range(N):
    ans = max(ans, dfs(dic, memo, i))
print(ans)

Fixed submission:
N = int(input())
h = [i for i in map(int, input().split())]    
memo = [0] * (N+1)
for i in range(N):
    if i == 0:
        pass
    elif i == 1:
        memo[1] = abs(h[1]-h[0])
    else:
        memo[i] = min(memo[i-1]+abs(h[i]-h[i-1]),  memo[i-2]+abs(h[i]-h[i-2]))
print(memo[N-1])

Buggy python submission (verdict: Runtime Error):
import sys
 
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
memo = [-1]*N
dic = [[] for i in range(N)]
def dfs(dic, memo, v):
    if memo[v] != -1:
        return memo[v]
    plen = 0
    for i in dic[v]:
        plen = max(plen, dfs(dic, memo, i)+1)
    memo[v] = plen
    return plen
for m in range(M):
    x, y = map(int, input().split())
    dic[x-1].append(y-1)
ans = 0
for i in range(N):
    ans = max(ans, dfs(dic, memo, i))
print(ans)

Fixed submission:
N = int(input())
h = [i for i in map(int, input().split())]    
memo = [0] * (N+1)
for i in range(N):
    if i == 0:
        pass
    elif i == 1:
        memo[1] = abs(h[1]-h[0])
    else:
        memo[i] = min(memo[i-1]+abs(h[i]-h[i-1]),  memo[i-2]+abs(h[i]-h[i-2]))
print(memo[N-1])

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
def dfs(dic, p, memo):
    if memo[p] != -1:
        return memo[p]
    m = 0
    for d in dic[p]:
        m = max(m, dfs(dic, d, memo)+1)
    memo[p] = m
    return m
dic = [[] for i in range(N)]
for m in range(M):
    x, y = map(int, input().split())
    dic[x-1].append(y-1)
    
inf = -1
memo = [inf]*N
ans = 0
for i in range(N):
    k= dfs(dic, i, memo)
    ans = max(ans,k)
print(ans)

Fixed submission:
N = int(input())
h = [i for i in map(int, input().split())]    
memo = [0] * (N+1)
for i in range(N):
    if i == 0:
        pass
    elif i == 1:
        memo[1] = abs(h[1]-h[0])
    else:
        memo[i] = min(memo[i-1]+abs(h[i]-h[i-1]),  memo[i-2]+abs(h[i]-h[i-2]))
print(memo[N-1])

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [i for i in map(int, input().split())]
memo = [0]*N
for i in range(N):
    mini = 10**10
    for j in range(i-min(i, K), i, 1):
        if memo[j] + abs(h[i]-h[j]) < mini:
            mini = memo[j] + abs(h[i]-h[j])
    if i != 0:
        memo[i] = mini
print(memo[N-1])
N, K = map(int, input().split())
h = [i for i in map(int, input().split())]
memo = [0]*N
for i in range(N):
    mini = 10**10
    for j in range(i-min(i, K), i, 1):
        if memo[j] + abs(h[i]-h[j]) < mini:
            mini = memo[j] + abs(h[i]-h[j])
    if i != 0:
        memo[i] = mini
print(memo[N-1])

Fixed submission:
N = int(input())
h = [i for i in map(int, input().split())]    
memo = [0] * (N+1)
for i in range(N):
    if i == 0:
        pass
    elif i == 1:
        memo[1] = abs(h[1]-h[0])
    else:
        memo[i] = min(memo[i-1]+abs(h[i]-h[i-1]),  memo[i-2]+abs(h[i]-h[i-2]))
print(memo[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = [i for i in map(int, input().split())]    
def jump(point):
    if point <= 0:
        return 0
    if memo[point] != inf:
        return memo[point]
    if point ==1:
        memo[1] = abs(h[0]-h[1])
        return abs(h[0]-h[1])
    memo[point] = min(jump(point-1)+abs(h[point-1]-h[point]), jump(point-2)+abs(h[point-2]-h[point]))
    return min(jump(point-1)+abs(h[point-1]-h[point]), jump(point-2)+abs(h[point-2]-h[point]))
    
inf = 10**10
memo = [inf]*(N+1)
print(jump(N-1))

Fixed submission:
N = int(input())
h = [i for i in map(int, input().split())]    
memo = [0] * (N+1)
for i in range(N):
    if i == 0:
        pass
    elif i == 1:
        memo[1] = abs(h[1]-h[0])
    else:
        memo[i] = min(memo[i-1]+abs(h[i]-h[i-1]),  memo[i-2]+abs(h[i]-h[i-2]))
print(memo[N-1])

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

def jump(point):
    if point <= 0:
        return 0
    if memo[point] != inf:
        return memo[point]
    memo[point] = min(jump(point-1)+abs(h[point-1]-h[point]), jump(point-2)+abs(h[point-2]-h[point]))
    return min(jump(point-1)+abs(h[point-1]-h[point]), jump(point-2)+abs(h[point-2]-h[point]))

inf = 10**10
memo = [inf]*(N+1)

print(jump(N-1))

Fixed submission:
N = int(input())
h = [i for i in map(int, input().split())]    
memo = [0] * (N+1)
for i in range(N):
    if i == 0:
        pass
    elif i == 1:
        memo[1] = abs(h[1]-h[0])
    else:
        memo[i] = min(memo[i-1]+abs(h[i]-h[i-1]),  memo[i-2]+abs(h[i]-h[i-2]))
print(memo[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = [i for i in map(int, input().split())]    
def jump(point):
    if point <= 0:
        return 0
    if memo[point] != inf:
        return memo[point]
    memo[point] = min(jump(point-1)+abs(h[point-1]-h[point]), jump(point-2)+abs(h[point-2]-h[point]))
    return min(jump(point-1)+abs(h[point-1]-h[point]), jump(point-2)+abs(h[point-2]-h[point]))
    
inf = 10**10
memo = [inf]*(N+2)

print(jump(N-2))

Fixed submission:
N = int(input())
h = [i for i in map(int, input().split())]    
memo = [0] * (N+1)
for i in range(N):
    if i == 0:
        pass
    elif i == 1:
        memo[1] = abs(h[1]-h[0])
    else:
        memo[i] = min(memo[i-1]+abs(h[i]-h[i-1]),  memo[i-2]+abs(h[i]-h[i-2]))
print(memo[N-1])

Buggy python submission (verdict: Runtime Error):
def jump(point):
    if point <= 0:
        return 0
    if memo[point] != inf:
        return memo[point]
    memo[point] = min(jump(point-1)+abs(h[point-1]-h[point]), jump(point-2)+abs(h[point-2]-h[point]))
    return min(jump(point-1)+abs(h[point-1]-h[point]), jump(point-2)+abs(h[point-2]-h[point]))
    
inf = 10**10
memo = [inf]*(N+2)

print(jump(N-2))

Fixed submission:
N = int(input())
h = [i for i in map(int, input().split())]    
memo = [0] * (N+1)
for i in range(N):
    if i == 0:
        pass
    elif i == 1:
        memo[1] = abs(h[1]-h[0])
    else:
        memo[i] = min(memo[i-1]+abs(h[i]-h[i-1]),  memo[i-2]+abs(h[i]-h[i-2]))
print(memo[N-1])