Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
1 print(10 - int(input()) // 200)

Fixed submission:
print(10 - int(input()) // 200)
Buggy python submission (verdict: Runtime Error):
a, b, t = map(int, input().split())
print(t//a*b)
debug_pri

Fixed submission:
a, b, t = map(int, input().split())
print(t//a*b)
Buggy python submission (verdict: Runtime Error):
a,b,k=list(map(int ,input().split()))
l=[]
count=0
for i in range(1,max(a,b)):
	if(a%i==0 and b%i==0):
		l.append(i)
		
		
	
	else:
		count+=1

l.sort()
l.reverse()
if(len(l)==0):
	
	print(0)
else:
	print(l[k-1])


Fixed submission:
A,B,K=map(int,input().split())
ans=0
n=100
while True:
    if A%n==0 and B%n==0:
        ans+=1
        if ans==K:
            print(n)
            exit()
    n-=1

Buggy python submission (verdict: Runtime Error):
a,b,k=list(map(int ,input().split()))
l=[]
count=0
for i in range(1,max(a,b)):
	if(a%i==0 and b%i==0):
		l.append(i)
		
		
	
	else:
		count+=1

l.sort()
l.reverse()
if(l.empty()):
	
	print(0)
else:
	print(l[k-1])


Fixed submission:
A,B,K=map(int,input().split())
ans=0
n=100
while True:
    if A%n==0 and B%n==0:
        ans+=1
        if ans==K:
            print(n)
            exit()
    n-=1

Buggy python submission (verdict: Runtime Error):
a,b,k=list(map(int ,input().split()))
l=[]
count=0
for i in range(1,max(a,b)):
	if(a%i==0 and b%i==0):
		l.append(i)
		
		
	
	else:
		count+=1

l.sort()
l.reverse()
if(a==b==k):
	print(a)
else:
	print(l[k-1])


Fixed submission:
A,B,K=map(int,input().split())
ans=0
n=100
while True:
    if A%n==0 and B%n==0:
        ans+=1
        if ans==K:
            print(n)
            exit()
    n-=1

Buggy python submission (verdict: Runtime Error):
a,b,k=list(map(int ,input().split()))
l=[]
count=0
for i in range(1,max(a,b)):
	if(a%i==0 and b%i==0):
		l.append(i)
		print(l)
		
	
	else:
		count+=1

l.sort()
l.reverse()
if(a==b==k):
	print(a)
else:
	print(l[k-1])


Fixed submission:
A,B,K=map(int,input().split())
ans=0
n=100
while True:
    if A%n==0 and B%n==0:
        ans+=1
        if ans==K:
            print(n)
            exit()
    n-=1
Buggy python submission (verdict: Runtime Error):
k, s = list(map(int, input().split()))

p = s
factors = {}

while p > 1:
    f = False
    for i in range(2, int(p**0.5)+1):
        if p % i == 0:
            if i in factors:
                factors[i] += 1
            else:
                factors[i] = 1

            p //= i
            f = True
            break

    if not f:
        if p in factors:
            factors[p] += 1
        else:
            factors[p] = 1
        break

if len(factors) == 0:
    print(1)
else:
    primes = list(factors.keys())
    exp = [0] * len(primes)
    upper = s/k
    ans = 1

    while exp[0] <= factors[primes[0]]:
        num = 1
        for i in range(len(primes)):
            num *= pow(primes[i], exp[i])

        if num == upper:
            ans = num
            break
        elif num < upper:
            ans = max(ans, num)

        index = len(primes)-1
        done = False
        while not done:
            exp[index] += 1
            if exp[index] > factors[primes[index]]:
                if index == 0:
                    break
                else:
                    exp[index] = 0
                    index -= 1
            else:
                done = True

    print(ans)


Fixed submission:
n=int(input())

if(n==1):
    print("Hello World")
elif(n==2):
    a=int(input())
    b=int(input())
    print(int(a+b))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=int(input())
b=int(input())
if(n==1):
    print("Hello World")
elif(n==2):
    print(int(a+b))

Fixed submission:
n=int(input())

if(n==1):
    print("Hello World")
elif(n==2):
    a=int(input())
    b=int(input())
    print(int(a+b))
Buggy python submission (verdict: Runtime Error):
s=input()
list_s=list(s)
element='B'
l1=['0','1','B']
for i in range(0,len(list_s)-i):
	if(list_s[i] == element):
		index_element=list_s[i-1]
		if(index_element):
			list_s.remove(index_element)
			list_s.remove(element)
			print(list_s)
		else:
		    list_s.append("s")
		    list_s.remove("s")

	else:
		list_s.append("s")
		list_s.remove("s")
		print(list_s)


Fixed submission:
ans=0
n=int(input())
for i in range(1,n+1):
	ans+=i
	
print(ans)
Buggy python submission (verdict: Runtime Error):
N =int(input())
a =list(map(int,input().split()))

#print(a)
count = 0
D = []
for i in range(N+1):
    if i % 2 == 0:
        D.append(i)

#print(D)   

for j in D:
    if a[j] % 2 != 0:
        count += 1
        

print(count)


Fixed submission:
N = int(input())
a =list(map(int,input().split()))
count = 0

for k in range(N+1):
    if k % 2 == 0:
        continue
    else:
        if a[k-1] % 2 != 0:
            count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator
N =int(input())

B = 1

A = list(map(int,input().split()))
    
#print(A)

result = functools.reduce(operator.mul,A)

#print(B)
C = 10 ** 18
#print(C)
if result > C:
    print(-1)
else:
    print(result)


Fixed submission:
N =int(input())

A = sorted(list(map(int,input().split())))

B = 1
C = 10 ** 18

for i in range(N):
    B = B * A[i]
    if B == 0:
        break
    elif B > C:
        B = -1
        break

print(B)

Buggy python submission (verdict: Time Limit Exceeded):
#169-B

N =int(input())

B = 1

A = list(map(int,input().split()))
    
#print(A)
for j in A:
    B = B * j


#print(B)
C = 10 ** 18
#print(C)
if B > C:
    print(-1)
else:
    print(B)


Fixed submission:
N =int(input())

A = sorted(list(map(int,input().split())))

B = 1
C = 10 ** 18

for i in range(N):
    B = B * A[i]
    if B == 0:
        break
    elif B > C:
        B = -1
        break

print(B)

Buggy python submission (verdict: Runtime Error):
N =int(input())
B = 1
for i in range(N):
    A =list( map(int,input().split()))
    for i in A:
        B = B * i
        #print(B)
    
#print(B)
C = 10 ** 18
#print(C)
if B > C:
    print(-1)
else:
    print(B)


Fixed submission:
N =int(input())

A = sorted(list(map(int,input().split())))

B = 1
C = 10 ** 18

for i in range(N):
    B = B * A[i]
    if B == 0:
        break
    elif B > C:
        B = -1
        break

print(B)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K =map(int,input().split())

d =[]

for i in range(A):
    d.append(1)

for j in range(B):
    d.append(0)

for k in range(C):
    d.append(-1)


d.sort(reverse=True)


KK = 0
for l in range(K):
    N = d[l]
    #print(N)
    KK = KK + N
print(KK)
    


Fixed submission:
A,B,C,K =map(int,input().split())

if A >= K:
    print(K)
    

elif A + B >= K:
    print(A)

elif A + B < K:
    c = -1 * (K-(A+B))
    #print(c)
    #print(A)
    cc = A + c
    print(cc)
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B =map(int,input().split())
D =[]
for i in range(N):
    for j in range(A):
        D.append("A")
    for k in range(B):
        D.append("B")

#print(D)

F =D[0:N]
#print(F)
print(F.count("A"))


Fixed submission:
N,A,B =map(int,input().split())

v = N//(A+B)
z = N %(A+B)

if z < A:
    print(A*v + z)
else:
    print(A*v + A)
Buggy python submission (verdict: Runtime Error):
 = int(input())
a = list(map(int, input().split()))
print(len([i for i, ai in enumerate(a) if i%2 and ai%2]))

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
print(len([i for i, ai in enumerate(a) if i%2==0 and ai%2]))
Buggy python submission (verdict: Runtime Error):
N = input()
 
res = {i+1: 0 for i in range(N)}
 
for i in range(int(sqrt(N))):
  for j in range(int(sqrt(N))):
    for k in range(int(sqrt(N))):
      n = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if n in res:
        res[n] += 1
for r in res.values():
  print(r)

Fixed submission:
N = int(input())
 
res = {i+1: 0 for i in range(N)}
 
for i in range(1, int(N**0.5)):
  for j in range(1, int(N**0.5)):
    for k in range(1, int(N**0.5)):
      n = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if n in res:
        res[n] += 1
for r in res.values():
  print(r)

Buggy python submission (verdict: Runtime Error):
N = input()

res = {i+1: 0 for i in range(N)}

for i in range(int(sqrt(N))):
  for j in range(int(sqrt(N))):
    for k in range(int(sqrt(N))):
      res[i**2 + j**2 + k**2 + i*j + j*k + k*i] += 1
print(res)

Fixed submission:
N = int(input())
 
res = {i+1: 0 for i in range(N)}
 
for i in range(1, int(N**0.5)):
  for j in range(1, int(N**0.5)):
    for k in range(1, int(N**0.5)):
      n = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if n in res:
        res[n] += 1
for r in res.values():
  print(r)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = []
# N, K = 10, 3
# A = [1,5,4,3,8,6,9,7,2,4]
for _ in range(N):
  A.append(int(input()))
dp = [0]*N
nextdp = [1]*(300000)
tmp = 0
while tmp < N:
  dp[tmp] = nextdp[A[tmp]]
  for n in range(0,2*K+1):
    n -= K
    if 300000 > A[tmp]+n >= 0:
      nextdp[A[tmp]+n] = max(nextdp[A[tmp]+n], dp[tmp]+1)
  tmp += 1
print(dp[-1])


Fixed submission:
K = int(input())
print("ACL"*K)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ls = [0]*(N)
n = 1
while n <= N-1:
  k = 1
  tmp = 0
  while k**2 <= n:
    if n % k == 0:
      if k ** 2 == n:
        tmp += 1
      else:
        tmp += 2
    k += 1
  ls[n] = tmp
  n += 1
print(sum(ls))



Fixed submission:
N = int(input())
ans = 0
for n in range(1,N):
  ans += int((N-1)/n)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ls = [0]*(N)
n = 1
while n <= N-1:
  k = 1
  tmp = 0
  while k**2 <= n:
    if n % k == 0:
      if k ** 2 == n:
        tmp += 1
      else:
        tmp += 2
    k += 1
  ls[n] = tmp
  n += 1
print(sum(ls))



Fixed submission:
N = int(input())
ans = 0
for n in range(1,N):
  ans += int((N-1)/n)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
ls = [0]*(N)
n = 1
while n <= N-1:
  k = 1
  tmp = 0
  while k**2 <= n:
    if n % k == 0:
      if k ** 2 = n:
        tmp += 1
      else:
        tmp += 2
  ls[n] = tmp
print(sum(ls))

Fixed submission:
N = int(input())
ans = 0
for n in range(1,N):
  ans += int((N-1)/n)
print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())
if x == 0:
  pirnt("1")
else:
  print("0")

Fixed submission:
x = int(input())
if x == 0:
  print("1")
else:
  print("0")
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int, input())
print(max(a*c,a*d,b*c,b*d))

Fixed submission:
a,b,c,d = map(int, input().split())
print(max(a*c,a*d,b*c,b*d))
Buggy python submission (verdict: Runtime Error):
S = int(input())
mod = 10**9+7
memo = [-1]*(S+1)
def redis(s):
  if memo[s] != -1:
    return memo[s]
  else:
    if s < 3:
      memo[s] = 0
      return 0
    elif s < 6:
      memo[s] = 1
      return 1
    else:
      tmp = 0
      for num in range(s):
        tmp += (redis(num)*redis(s-num))%mod
      memo[s] = tmp
      return tmp%mod
print(redis(S))
    



Fixed submission:
S = int(input())
mod = 10**9+7
memo = [-1]*(S+1)
memo[0] = 1
def redis(s):
  if memo[s] != -1:
    return memo[s]
  else:
    if s < 3:
      memo[s] = 0
      return 0
    elif s < 6:
      memo[s] = 1
      return 1
    else:
      tmp = 0
      for num in range(s-2):
        tmp += redis(num)%mod
      memo[s] = tmp
      return tmp%mod
print(redis(S))

Buggy python submission (verdict: Runtime Error):
S = int(input())
memo = [-1]*(S+1)
redis(s):
  if memo[s] != -1:
    return memo[s]
  else:
    if s < 3:
      memo[s] = 0
      return 0
    elif s < 6:
      memo[s] = 1
      return 1
    else:
      tmp = 0
      for num in range(s):
        tmp += redis(num)*redis(s-num)
      memo[s] = tmp
      return tmp
print(redis(S))
    

Fixed submission:
S = int(input())
mod = 10**9+7
memo = [-1]*(S+1)
memo[0] = 1
def redis(s):
  if memo[s] != -1:
    return memo[s]
  else:
    if s < 3:
      memo[s] = 0
      return 0
    elif s < 6:
      memo[s] = 1
      return 1
    else:
      tmp = 0
      for num in range(s-2):
        tmp += redis(num)%mod
      memo[s] = tmp
      return tmp%mod
print(redis(S))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
i = 1
a = 7
a %= k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**9+7:
    i = -1
    break

print(i)

Fixed submission:
k = int(input())
i = 1
a = 7
a = a % k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**6:
    i = -1
    break

print(i)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
i = 1
a = 7
if k % 2 == 0:
  print("-1")
else:
  while a % k != 0:
    i += 1
    a = 10*a + 7
    if i == 10**9+7:
      i = -1
      break

  print(i)
  


Fixed submission:
k = int(input())
i = 1
a = 7
a = a % k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**6:
    i = -1
    break

print(i)

Buggy python submission (verdict: Runtime Error):
k = int(input())
i = 1
a = 7
if k % 2 == 0:
  print("-1")
  return
while a % k != 0:
  i += 1
  a = 10*a + 7
  if i == 10**9+7:
    i = -1
    break

print(i)
  


Fixed submission:
k = int(input())
i = 1
a = 7
a = a % k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**6:
    i = -1
    break

print(i)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
i = 1
a = 7
while a % k != 0:
  i += 1
  a = 10*a + 7
  if i == 10**9+7:
    i = -1
    break

print(i)
  


Fixed submission:
k = int(input())
i = 1
a = 7
a = a % k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**6:
    i = -1
    break

print(i)
Buggy python submission (verdict: Runtime Error):
import math
A B H M = map(int, input().split())
HP = [A*math.cos(30*H), A*math.sin(30*H)]
MP = [B*math.cos(6*M), B*math.sin(6*H)]

print(math.sqrt((HP[0]-MP[0])**2 + (HP[1]-MP[1])**2))

Fixed submission:
import math
A,B,H,M = map(int, input().split())
H = 60*H + M
pi = (math.pi/180)
HP = [A*math.cos(0.5*H*pi), A*math.sin(0.5*H*pi)]
MP = [B*math.cos(6*M*pi), B*math.sin(6*M*pi)]

print(math.sqrt((HP[0]-MP[0])**2 + (HP[1]-MP[1])**2))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj_max = [0]*N
ans = 0
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  adj_max[tmp1] = max(adj_max[tmp1], H[tmp2])
  adj_max[tmp2] = max(adj_max[tmp2], H[tmp1])
for num in range(N):
  if H[num] > adj_max[num]:
    ans += 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj_max = [0]*N
ans = 0
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  adj_max[tmp1-1] = max(adj_max[tmp1-1], H[tmp2-1])
  adj_max[tmp2-1] = max(adj_max[tmp2-1], H[tmp1-1])
for num in range(N):
  if H[num] > adj_max[num]:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)

H = int(input())
ls = [-1]*(H+1)
ls[0] = 0
ls[1] = 1
def battle(h):
  if ls[h] != -1:
    return ls[h]
  else:
    tmp = 2*battle(h//2)
    ls[h] = tmp+1
    return ls[h]
print(battle(H))



Fixed submission:
H = int(input())

def battle(h):
  if h == 1:
    return 1
  else:
    return 2*battle(h//2)+1
print(battle(H))

Buggy python submission (verdict: Runtime Error):
H = int(input())
ls = [-1]*(H+1)
ls[0] = 0
ls[1] = 1
def battle(h):
  if ls[h] != -1:
    return ls[h]
  else:
    tmp = 2*battle(h//2)
    ls[h] = tmp+1
    return ls[h]
print(battle(H))



Fixed submission:
H = int(input())

def battle(h):
  if h == 1:
    return 1
  else:
    return 2*battle(h//2)+1
print(battle(H))

Buggy python submission (verdict: Runtime Error):
H = int(input())
ls = [-1]*(H+1)
ls[0] = 0
ls[1] = 1
def battle(h):
  if ls[h] != -1:
    return ls[h]
  else:
    tmp = 2*battle(h//2)
    ls[h] = tmp
    return ls[h]
print(battle(H))

Fixed submission:
H = int(input())

def battle(h):
  if h == 1:
    return 1
  else:
    return 2*battle(h//2)+1
print(battle(H))
Buggy python submission (verdict: Runtime Error):
S = input()
DAY = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
for num in range(7):
  if DAY[num] = S:
    print(7-num)

Fixed submission:
S = input()
DAY = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
for num in range(7):
  if DAY[num] == S:
    print(7-num)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse = True)

def binary(mini,maxi,a,b): #a>b
  if maxi == mini + 1:
    if L[maxi] > a - b:
      return maxi
    elif L[mini] > a - b:
      return mini
    else:
      return False
  elif maxi == mini:
    if L[maxi] > a - b:
      return maxi
    else:
      return False
  else:
    mid = (mini+maxi)//2
    if L[mid] > a - b:
      return binary(mid,maxi,a,b)
    else:
      return binary(mini,mid,a,b)
      
for a in range(0, N-2):
  for b in range(a+1, N-1):
    tmp = binary(b+1, N-1, L[a], L[b])
    if tmp:
      ans += tmp - b
print(ans)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse = True)

def binary(mini,maxi,a,b): #a>b
  if maxi == mini + 1:
    if L[maxi] > a - b:
      return maxi
    elif L[mini] > a - b:
      return mini
    else:
      return False
  elif maxi == mini:
    if L[maxi] > a - b:
      return maxi
    else:
      return False
  else:
    mid = (mini+maxi)//2
    if L[mid] > a - b:
      return binary(mid,maxi,a,b)
    else:
      return binary(mini,mid,a,b)
ans = 0
for a in range(0, N-2):
  for b in range(a+1, N-1):
    tmp = binary(b+1, N-1, L[a], L[b])
    if tmp:
      ans += tmp - b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
def tri(a, b, c):
  if a < b + c and b < a + c and c < a + b:
    return True
  else:
    return False
ans = 0
for a in range(0,N-2):
  for b in range(a+1,N-1):
    for c in range(b+1,N):
      if tri(L[a],L[b],L[c]):
        ans += 1
        
print(ans)



Fixed submission:
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse = True)

def binary(mini,maxi,a,b): #a>b
  if maxi == mini + 1:
    if L[maxi] > a - b:
      return maxi
    elif L[mini] > a - b:
      return mini
    else:
      return False
  elif maxi == mini:
    if L[maxi] > a - b:
      return maxi
    else:
      return False
  else:
    mid = (mini+maxi)//2
    if L[mid] > a - b:
      return binary(mid,maxi,a,b)
    else:
      return binary(mini,mid,a,b)
ans = 0
for a in range(0, N-2):
  for b in range(a+1, N-1):
    tmp = binary(b+1, N-1, L[a], L[b])
    if tmp:
      ans += tmp - b
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N, D = map(int, input().split())
a = []
ans = 0
for _ in range(N):
  tmp = list(map(int, input().split()))
  a.append(tmp)
for n in range(N):
  for m in range(n+1,N):
 	dis = 0
    for d in range(D):
      dis += (a[n][d]-a[m][d])**2
    if math.sqrt(dis) == int(math.sqrt(dis)):
      ans += 1
print(ans)

Fixed submission:
import math
N, D = map(int, input().split())
a = []
ans = 0
for _ in range(N):
  tmp = list(map(int, input().split()))
  a.append(tmp)
for n in range(N):
  for m in range(n+1,N):
    dis = 0
    for d in range(D):
      dis += (a[n][d]-a[m][d])**2
    if math.sqrt(dis) == int(math.sqrt(dis)):
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
height = list(map(int, input().split()))

minimum_jump = [-1]*N
minimum_jump[0] = 0
minimum_jump[1] = abs(height[0] - height[1])

def frog_jump(n): #n is index of stone
  if minimum_jump[n] != -1:
    return minimum_jump[n]
  else:
    if minimum_jump[n-1] != -1:
      temp1 = minimum_jump[n-1]
    else:
      temp1 = frog_jump(n-1)
    if minimum_jump[n-2] != -1:
      temp2 = minimum_jump[n-2]
    else:
      temp2 = frog_jump(n-2)
    minimum_jump[n] = min(temp1+abs(height[n] - height[n-1]), temp2+abs(height[n] - height[n-2]))
    return minimum_jump[n]
  
print(frog_jump(N-1))

Fixed submission:
import sys
sys.setrecursionlimit(1001000)

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

minimum_jump = [-1]*N
minimum_jump[0] = 0
minimum_jump[1] = abs(height[0] - height[1])

def frog_jump(n): #n is index of stone
  if minimum_jump[n] != -1:
    return minimum_jump[n]
  else:
    if minimum_jump[n-1] != -1:
      temp1 = minimum_jump[n-1]
    else:
      temp1 = frog_jump(n-1)
    if minimum_jump[n-2] != -1:
      temp2 = minimum_jump[n-2]
    else:
      temp2 = frog_jump(n-2)
    minimum_jump[n] = min(temp1+abs(height[n] - height[n-1]), temp2+abs(height[n] - height[n-2]))
    return minimum_jump[n]
  
print(frog_jump(N-1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
height = map(int, input().split())

minimum_jump = [-1]*N
minimum_jump[0] = 0
minimum_jump[1] = abs(height[0] - height[1])

def frog_jump(n): #n is index of stone
  if minimum_jump[n] != -1:
    return minimum_jump[n]
  else:
	if minimum_jump[n-1] != -1:
      temp1 = minimum_jump[n-1]
    else:
      temp1 = frog_jump(n-1)
    if minimum_jump[n-2] != -1:
      temp2 = minimum_jump[n-2]
    else:
      temp2 = frog_jump(n-2)
    minimum_jump[n] = min(temp1+(height[n] - height[n-1]), temp2+(height[n] - height[n-2]))
    return minimum_jump[n]
     
  

Fixed submission:
import sys
sys.setrecursionlimit(1001000)

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

minimum_jump = [-1]*N
minimum_jump[0] = 0
minimum_jump[1] = abs(height[0] - height[1])

def frog_jump(n): #n is index of stone
  if minimum_jump[n] != -1:
    return minimum_jump[n]
  else:
    if minimum_jump[n-1] != -1:
      temp1 = minimum_jump[n-1]
    else:
      temp1 = frog_jump(n-1)
    if minimum_jump[n-2] != -1:
      temp2 = minimum_jump[n-2]
    else:
      temp2 = frog_jump(n-2)
    minimum_jump[n] = min(temp1+abs(height[n] - height[n-1]), temp2+abs(height[n] - height[n-2]))
    return minimum_jump[n]
  
print(frog_jump(N-1))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
height = list(map(int,input().split()))
min_jump = [0,abs(height[0]-height[1])]

for num in range(2,N): #num is index of stone
  jump = 10**9
  if num < K:
    for n in range(num): # n is number of passed stones
      jump = min(jump, min_jump[num-n-1] + abs(height[num-n-1] - height[num]))
    min_jump.append(jump)
  else:
    for n in range(K): # n is number of passed stones
      jump = min(jump, min_jump[num-n-1] + abs(height[num-n-1] - height[num]))
    min_jump.append(jump)
print(min_jump[N-1])

Fixed submission:
N, K = map(int, input().split())
height = list(map(int,input().split()))
min_jump = [0,abs(height[0]-height[1])]

for num in range(2,N): #num is index of stone
  jump = 10**9
  if num < K:
    for n in range(num): # n is number of passed stones
      jump = min(jump, min_jump[num-n-1] + abs(height[num-n-1] - height[num]))
    min_jump.append(jump)
  else:
    for n in range(K): # n is number of passed stones
      jump = min(jump, min_jump[num-n-1] + abs(height[num-n-1] - height[num]))
    min_jump.append(jump)
print(min_jump[N-1])

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
height = list(map(int,input().split()))
min_jump = [0,abs(height[0]-height[1])]

for num in range(2,N): #num is index of stone
  jump = 10**9
  if num < K:
    for n in range(num): # n is number of passed stones
      jump = min(jump, min_jump[num-n-1] + abs(height[num-n-1] - height[num]))
    min_jump[num] = jump
  else:
    for n in range(K): # n is number of passed stones
      jump = min(jump, min_jump[num-n-1] + abs(height[num-n-1] - height[num]))
    min_jump.append(jump)
print(min_jump[N-1])

Fixed submission:
N, K = map(int, input().split())
height = list(map(int,input().split()))
min_jump = [0,abs(height[0]-height[1])]

for num in range(2,N): #num is index of stone
  jump = 10**9
  if num < K:
    for n in range(num): # n is number of passed stones
      jump = min(jump, min_jump[num-n-1] + abs(height[num-n-1] - height[num]))
    min_jump.append(jump)
  else:
    for n in range(K): # n is number of passed stones
      jump = min(jump, min_jump[num-n-1] + abs(height[num-n-1] - height[num]))
    min_jump.append(jump)
print(min_jump[N-1])