Harryxun/stf_run huggingface dataset:
N = int(input())
import numpy as np
a = np.array((26,15))
for i in range(26):
  for j in range(15):
    a[i][j] = 4 * i + 7 * j

if N in a:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = int(input())
import numpy as np
a = np.empty((26,15))
for i in range(26):
  for j in range(15):
    a[i][j] = 4 * i + 7 * j

if N in a:
  print('Yes')
else:
  print('No')
K = int(input())

S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(S[K])

### FIXED CODE ###

K = int(input())

S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(S[K - 1])
# t を前から試してｘ以下か判定する
x = int(input())
for i in range(x):
    if i*(i+1)/2 > x:
        ans =i
        break 
print(ans)

### FIXED CODE ###

from math import ceil
x = int(input())
ans = ceil(((1+8*x)**.5 -1)/2)
print(ans)
N,M=input().split()
l = []
for i in range(0,M):
    l.append(input())
_A,_B=zip(l)

A=_A+_B
B=_B+_A


def gen_get_to(_fr):
    global A
    global B
    global nodes
    global step
    for itr in range(0,len(A)):
        if A[itr]==_fr:
            if not B[itr] in nodes[0:step]:
                yield B[itr]

def move(): #returns whether "move" succeeded or not
    global nodes
    global possible_memo
    global step
    global counter
    global N
    global end_flag
    try:
        _=next(possible_memo[step])
        nodes[step+1]=_
        step+=1
        #print("success move to {}".format(nodes[step]))
        #print("map: {}".format(nodes[0:step+1]))
        #print("I am at {}th node".format(step+1))
        if step==N-1:
            counter+=1
            #print('REACHED GOAL!!!')
        possible_memo[step]=gen_get_to(nodes[step])
    except StopIteration:
        step-=1
        #print("failed to move")
        if not step==-1:
            pass#print("map: {}".format(nodes[0:step+1]))
            #print("I am at {}th node".format(step+1))
        if step==-1:
            #print("I fell from the first node")
            end_flag=True

nodes=[0]*N
possible_memo=[0]*N
counter=0
step=0
nodes[step]=1
possible_memo[step]=gen_get_to(nodes[0])
end_flag=False

while not end_flag:
    move()


print(counter)

### FIXED CODE ###

_N,_M=input().split()
N = int(_N)
M = int(_M)
l = []
for i in range(0,M):
    _p, _q = input().split()
    l.append((int(_p),int(_q)))
_A,_B=zip(*l)

A=_A+_B
B=_B+_A


def gen_get_to(_fr):
    global A
    global B
    global nodes
    global step
    for itr in range(0,len(A)):
        if A[itr]==_fr:
            if not B[itr] in nodes[0:step]:
                yield B[itr]

def move(): #returns whether "move" succeeded or not
    global nodes
    global possible_memo
    global step
    global counter
    global N
    global end_flag
    try:
        _=next(possible_memo[step])
        nodes[step+1]=_
        step+=1
        #print("success move to {}".format(nodes[step]))
        #print("map: {}".format(nodes[0:step+1]))
        #print("I am at {}th node".format(step+1))
        if step==N-1:
            counter+=1
            #print('REACHED GOAL!!!')
        possible_memo[step]=gen_get_to(nodes[step])
    except StopIteration:
        step-=1
        #print("failed to move")
        if not step==-1:
            pass#print("map: {}".format(nodes[0:step+1]))
            #print("I am at {}th node".format(step+1))
        if step==-1:
            #print("I fell from the first node")
            end_flag=True

nodes=[0]*N
possible_memo=[0]*N
counter=0
step=0
nodes[step]=1
possible_memo[step]=gen_get_to(nodes[0])
end_flag=False

while not end_flag:
    move()


print(counter)
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
sum = 0
for i in range(0,N):
  L_1st= L[i]
  for j in range(i+1,N):
    L_2nd = L[j]
    c_min = b-a+1
    c_max = b+a-1
    l = bisect.bisect_left(Ls,c_min,lo = j+1)
    if l!= N:
      r = bisect.bisect_right(Ls,c_max,lo = j+1)
      if r:
        r = r-1
        if r>= l:
          sum += r-l+1
print(sum)


### FIXED CODE ###

A,B = map(int,input().split())
if (A-2*B)<0:
  print(0)
else:
  print(A-2*B)
a,b=map(int,input().split())
if (a=="H" and b=="H") and (a=="H" and b=="H"):
    print("H")
else:
    print("D")

### FIXED CODE ###

a,b=map(str,input().split())
if (a=="H" and b=="H") or (a=="D" and b=="D"):
    print("H")
else:
    print("D")
n = int(input())
A = list(map(int, input().split()))
cnt = 0
w = A[0]
for i in range(n - 1):
    nw = w + A[i + 1]
    if w > 0:
        if nw >= 0:
            cnt += nw + 1
            chg = -(nw  + 1)
    elif w < 0:
        if nw <= 0:
            cnt += 1 - nw
            chg = 1 - nw
    w = nw + chg
    chg = 0
    
print(cnt)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = [a_ for a_ in a]
 
ans = 10**14
for a0 in [-1,a[0],1]:
    if a0 == 0:
        continue
    ans_ = abs(a[0]-a0)
    b[0] = a0
    sign = b[0] > 0
    for i in range(1,n):
        b[i] = a[i]+b[i-1]
        if sign:
            if b[i] >= 0:
                ans_ += b[i]+1
                b[i] = -1
        else:
            if b[i] <= 0:
                ans_ += 1-b[i]
                b[i] = 1
        sign = not sign
    ans = min(ans, ans_)
print(ans)
H, N = map(int, input().split())
a = list(map(int, input().split())
sum = sum(a)
if sum >= H:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

H, N = map(int, input().split())
a = list(map(int, input().split()))
sum = sum(a)
if sum >= H:
  print("Yes")
else:
  print("No")
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[]
for i in range(M):
    AB.append(list(map(int,input().split())))

J=[0]*N
for i in range(M):
    if H[AB[i][0]-1]<H[AB[i][1]-1]:
        J[AB[i][0]]+=1
    else:
        J[AB[i][1]]+=1
c=0
for i in J:
    if i == 0:
        c+=1

print(c)


### FIXED CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[]
for i in range(M):
    AB.append(list(map(int,input().split())))

J=[0]*N
for i in range(M):
    if H[AB[i][0]-1]<H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
    elif H[AB[i][0]-1]==H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
        J[AB[i][1]-1]+=1    
    else:
        J[AB[i][1]-1]+=1
c=0
for i in J:
    if i == 0:
        c+=1

print(c)
import sys

first = 0
second = 0
third = 0
i = 0

for i in range(1,10):
    line = sys.argv[i]
    if first < int(line):
        third = second
        second = first
        first = int(line)
    elif second < int(line):
        third = second
        second = int(line)
    elif third < int(line):
        third = int(line)

print(first)
print(second)
print(third)

### FIXED CODE ###

# -*- coding:utf-8 -*-

first = 0
second = 0
third = 0
i = 0

for i in range(0,10):
    line = int(input())
    
    if first < int(line):
        third = second
        second = first
        first = int(line)
    elif second < int(line):
        third = second
        second = int(line)
    elif third < int(line):
        third = int(line)
print(first)
print(second)
print(third)
s = raw_input()
k = float(raw_input())


s_l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

def s_i(st):
    for i in range(26):
        if st == s_l[i]:
            break
    return i + 1

j = 0
while k > 0:
    a = s_i(s[j])
    if s[j] == 'a' and j < len(s)-1:
        pass
    elif 27 - a <= k:
        k = k - (27 - a)
        s = s[:j] + 'a' + s[j+1:]
    elif j == len(s) - 1:
        t = (a+k)%26 - 1
        if t >= 0:
            s = s[:j] + s_l[t]
        else:
            s = s[:j] + s_l[t + 26]
        break
    else:
        pass
    j += 1

print s


### FIXED CODE ###

s = raw_input()
k = int(raw_input())


s_l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

def s_i(st):
    for i in range(26):
        if st == s_l[i]:
            return i + 1
            break

j = 0
while k > 0 and j <= len(s)-1:
    a = s_i(s[j])
    if s[j] == 'a' and j < len(s)-1:
        pass
    elif 27 - a <= k and j < len(s)-1:
        k = k - (27 - a)
        s = s[:j] + 'a' + s[j+1:]
    elif j == len(s) - 1:
        t = (a+k)%26 - 1
        if t >= 0:
            s = s[:j] + s_l[t]
        else:
            s = s[:j] + s_l[t + 26]
        break
    else:
        pass
    j += 1

print s
#!user/bin/env python
# coding:utf-8

n = int(input())
info = []

for i in range(n):
    ai = int(input())
    bi = int(input())
    info.append([ai, bi])

info = sorted(info, key=lambda inf: inf[1])

imp = info[0][0] + info[0][1]
print(imp)

### FIXED CODE ###

#!user/bin/env python
# coding:utf-8

n = int(input())
info = []

for i in range(n):
    # ai = int(input())
    # bi = int(input())
    abi = input()
    ai, bi = int(abi.split(' ')[0]), int(abi.split(' ')[1])
    
    info.append([ai, bi])

info = sorted(info, key=lambda inf: inf[1])

imp = info[0][0] + info[0][1]
print(imp)
number = int(input())
  
if 7 in number:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

number = input()
  
if '7' in number:
	print("Yes")
else:
	print("No")
ef gcd(a,b):
    if a <= b:
        a,b = b,a
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

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

L_gcd = [A[0]]
R_gcd = [A[-1]]

for i in range(1,N):
    L_gcd.append(gcd(L_gcd[i-1],A[i]))
    R_gcd.insert(0,gcd(A[N-i-1],R_gcd[0]))

ans = max(L_gcd[-1],R_gcd[0])

for i in range(N-2):
    if max(L_gcd[i],R_gcd[i+2])<=ans:
        break
    if gcd(L_gcd[i],R_gcd[i+2])>ans:
        ans = gcd(L_gcd[i],R_gcd[i+2])
print(ans)

### FIXED CODE ###

def gcd(a,b):
    if a <= b:
        a,b = b,a
    if b == 0:
        return a
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

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

L_gcd = [0]*(N+1)
R_gcd = [0]*(N+1)

for i in range(N):
    L_gcd[i+1] = gcd(L_gcd[i],A[i])
    R_gcd[N-i-1] = gcd(R_gcd[N-i],A[N-i-1])

ans = 0
for i in range(N):
    if gcd(L_gcd[i],R_gcd[i+1])>ans:
        ans = gcd(L_gcd[i],R_gcd[i+1])
    
print(ans)
import sys
read = sys.stdin.buffer.read
readlines = sys.stdin.buffer.readlines
input = sys.stdin.buffer.readline

OFS = 100005
N = int(input())
G = [[] for _ in [0]*OFS*2]
for line in readlines():
    x, y = map(int, line.split())
    y += OFS
    G[x].append(y)
    G[y].append(x)

visited = [0]*OFS*2


def dfs(v, x=0, y=0):
    if v < OFS:
        x += 1
    else:
        y += 1

    for u in G[v]:
        if visited[u]:
            continue
        visited[u] = 1
        x, y = dfs(u, x, y)

    return x, y


ans = 0
for i in range(OFS):
    if visited[i]:
        continue
    visited[i] = 1
    x, y = dfs(i)
    ans += x*y

print(ans - N)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readlines = sys.stdin.buffer.readlines
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)


def main():
    OFS = 100005
    N = int(input())
    G = [[] for _ in [0]*OFS*2]
    for line in readlines():
        x, y = map(int, line.split())
        y += OFS
        G[x].append(y)
        G[y].append(x)

    def dfs(v):
        if v < OFS:
            counter[0] += 1
        else:
            counter[1] += 1

        for u in G[v]:
            if visited[u]:
                continue
            visited[u] = 1
            dfs(u)

    visited = [0]*OFS*2
    ans = 0
    for i in range(OFS):
        if visited[i]:
            continue
        counter = [0]*2
        visited[i] = 1
        dfs(i)
        ans += counter[0] * counter[1]

    print(ans - N)


if __name__ == '__main__':
    main()
N, K = map(int,input().split())
x = N%K
print(min(x,k-x))

### FIXED CODE ###

N, K = map(int,input().split())

if N > K:
    x = N%K
else:
    x = K-N

while  N > x :
    N = x

    if N > K:
        x = N-K

    else:
        x = K-N

print(N)
H,W=input().split(" ")
print(str(math.ceil(H / W)))

### FIXED CODE ###

import math
s = list(map(int, input().split()))
print(str(math.ceil(s[0] / s[1])))
x, y = map(int, input().split())
count = 1
while x <= y:
    x *= 2
    count += 1
print(count-1

### FIXED CODE ###

x, y = map(int, input().split())
count = 1
while x <= y:
    x *= 2
    count += 1
print(count-1)
def compute(n1, n2):
    threshold = n1*n2-1
    count = 0
    if n1 == 1:
        index1 = 2
    else:
        index1 = 1
    index2 = threshold
    list1, list2 = [], []
    while index1 < index2:
        index2 = int(threshold/index1)
        while index2 in list2 or index2 == n2:
            index2 -= 1
        count+=1
        index1 += 1
        if index1 == n1:
            index1+=1
            
    while not (index2 == 1 or (n2 == 1 and index2==2)):
        index1 = int(threshold)/index2
        while index1 in list1 or index1 == n1:
            index1 += 1
        count+=1
        index2 -=1
        if index2 == n2:
            index2 -=1
    print(count)
    return

N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)

for i in grid:
    compute(i[0],i[1])

### FIXED CODE ###

import math

N = int(input().strip())
grid = []
for i in range(N):
	array = list(map(int, input().strip().split(' ')))
	grid.append(array)

for i in grid:
	i.sort()
	a,b = [i[0],i[1]]
	if(a == b or a+1 == b):
		print(2*a-2)
	else:
		c = int(math.sqrt(a*b))
		if c**2 == a*b:
			c-=1
		if(c*(c+1)>=a*b):
			print(2*c-2)
		else:
			print(2*c-1)
from collections import Counter
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()

N, Q = tuple(li())
S = ns()
ops = []
for i in range(Q):
    ops.append(tuple(ls()))

head, tail = 0, N-1
while(ops):
    cur = ops.pop()
    if cur[1] == 'L':
        if S[head] == cur[0]:
            head += 1
    elif cur[1] == 'R':
        if S[tail] == cur[0]:
            tail -= 1
alive = tail - head + 1
print("tail:{}, head:{}".format(tail, head))
print(max(alive, 0))


### FIXED CODE ###

from collections import Counter
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()

N, Q = tuple(li())
S = ns()
ops = []
for i in range(Q):
    ops.append(tuple(ls()))

head, tail = 0, N-1
while(ops):
    cur = ops.pop()
    if cur[1] == 'L' and head <N:
        if S[head] == cur[0]:
            head += 1
        if tail <= N-2 and S[tail + 1] == cur[0]:
            tail = min(tail + 1, N-1)
    elif cur[1] == 'R' and tail >= 0:
        if S[tail] == cur[0]:
            tail -= 1
        if head >= 1 and S[head - 1] == cur[0]:
            head = max(0, head-1)
alive = tail - head + 1
# print("tail:{}, head:{}".format(tail, head))
print(max(alive, 0))
print(' '.join(input().split(','))

### FIXED CODE ###

print(input().replace(',', ' '))
# -*- coding: utf-8 -*-
    import math
     
    ###
    # main
    if(__name__ == '__main__'):
        # input
        r = int(input())
     
        pi = 3.141592
        ans = pi * r * 2.0
        print(ans)
     
    # else:
        # do nothing

### FIXED CODE ###

# -*- coding: utf-8 -*-
import math

###
# main
if(__name__ == '__main__'):
    # input
    r = int(input())

    pi = 3.141592
    ans = pi * r * 2.0
    print(ans)

# else:
    # do nothing
import math
r=int().input()
c = r * r *math.pi
cf = r *2 *math.pi
print("{0:.5f} {1:.5f}".format(c,cf))
 

### FIXED CODE ###

import math
r = float(input())
s=r**2*math.pi
l=2*r*math.pi
print('{:.6f} {:.6f}'.format(s,l))
def circle_in_rectangle(radius, pos, height, width):
    """ 
    radius: float
    pos: tuple, (x, y)
    height: float, height of rectangle
    width: float, width of rectangle

    returns True if circle is in rectangle, otherwise False
    """
    (x, y) = pos 
    if x < radius or x > width - radius:
        return False

    if y < radius or y > height - radius:
        return False

    return True

if __name__ == '__main__':
    (w, h, x, y, r) = input().split(' ')

    if circle_in_rectangle(r, (x, y), h, w): 
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

def circle_in_rectangle(radius, pos, height, width):
    """
    radius: int
    pos: tuple, (x, y)
    height: int, height of rectangle
    width: int, width of rectangle

    returns True if circle is in rectangle, otherwise False

    >>> circle_in_rectangle(1, (1, 1), 4, 5)
    True
    >>> circle_in_rectangle(1, (2, 4), 4, 5)
    False
    """
    (x, y) = pos
    if x < radius or x > width - radius:
        return False

    if y < radius or y > height - radius:
        return False

    return True

if __name__ == '__main__':
    #import doctest
    #doctest.testmod()

    (w, h, x, y, r) = input().split(' ')

    if circle_in_rectangle(int(r), (int(x), int(y)), int(h), int(w)):
        print('Yes')
    else:
        print('No')
from math import log2
N, K = map(int, input().split())
a = list(map(int, input().split()))
x = 0
if K == 0:
    x = 0
else:
    for i in range(int(log2(K))+1)[::-1]:
        cnt_1 = 0
        for _a in a:
            if _a & 2**i == 2**i:
                cnt_1 += 1
        if cnt_1 <= len(a)/2 and (x + 2**i) <= K:
            x += 2**i
            
ans = 0
for _a in a:
    ans += x ^ _a
print(ans)

### FIXED CODE ###

import math
N, K = map(int, input().split())
a = list(map(int, input().split()))
x = 0
if K == 0:
    x = 0
else:
    for i in range(41)[::-1]:
        cnt_1 = 0
        for _a in a:
            if _a & 2**i == 2**i:
                cnt_1 += 1
        if cnt_1 <= len(a)/2 and (x + 2**i) <= K:
            x += 2**i

ans = 0
for _a in a:
    ans += x ^ _a
print(ans)
r = 10 ** 9 + 7
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
a = sorted(set(a))

if 1 in a:
    dp[1] = 0
    del a[0]
else:
    dp[1] = 1

if 2 in a:
    dp[2] = 0
    del a[0]
else:
    dp[2] = dp[1] + 1

if N == 1 or N == 2:
    print(dp[N])
    exit()

for i in range(1,N-1):
    if a == [] :
        dp[i+2] = (dp[i] + dp[i+1]) % r
    elif i+2 == a[0]:
        dp[i+2] = 0
        del a[0]
    else:
        dp[i+2] = (dp[i] + dp[i+1]) % r

print(dp[N])

### FIXED CODE ###

r = 10 ** 9 + 7
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
a = sorted(set(a))

if 1 in a:
    dp[1] = 0
    del a[0]
else:
    dp[1] = 1

if N == 1:
    print(dp[1])
    exit()

if 2 in a:
    dp[2] = 0
    del a[0]
else:
    dp[2] = dp[1] + 1

if N == 2:
    print(dp[2])
    exit()

for i in range(1,N-1):
    if a == [] :
        dp[i+2] = (dp[i] + dp[i+1]) % r
    elif i+2 == a[0]:
        dp[i+2] = 0
        del a[0]
    else:
        dp[i+2] = (dp[i] + dp[i+1]) % r

print(dp[N])
N, K, Q = map(int, input().split())
A = [0] * Q
for i in range(Q):
    A[i] = int(input())

import numpy as np
initial_point = np.array([K] * N)

for i in range(Q):
    initial_point -= 1
    initial_point[(A[i]-1)] += 1

for i in range(N):
    if initial_point[i] > 0 :
        print("Yes")
    else:
        print("No") 

### FIXED CODE ###

N, K, Q = map(int, input().split())
A = [0] * Q
for i in range(Q):
    A[i] = int(input())

initial_point = [(K-Q)]*N

for i in range(Q):
    initial_point[(A[i]-1)] += 1

for i in range(N):
    if initial_point[i] > 0 :
        print("Yes")
    else:
        print("No")
a,b = input.split()
print('H') if a == b else print('D')

### FIXED CODE ###

a,b = input().split()
print('H') if a == b else print('D')
a,b=map(int,input().split())
c=int(input())
for i in range(2):
  a-=max(c)
if a<=0:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

a,b=map(int,input().split())
c=list(map(int,input().split()))
for i in range(b):
  a-=c[i]
if a<=0:
  print('Yes')
else:
  print('No')
def dfs(i,f):
    if i == n-1:
        return sum(list(map(int,input().split("+"))))
    return dfs(i+1,f+s[i+1]) + dfs[i+1,f + "+" + s[i+1]]

s = input()
n = len(s)
print(dfs(0,s[0]))

### FIXED CODE ###

s = input()
l = len(s)

ans = 0
for i in range(2 ** (l -1)):
    ans_sub = 0
    subst = s[0]
    for j in range(l-1):
        if(i>>j)&1:
            ans_sub += int(subst)
            subst = s[j+1]
        else:
            subst += s[j+1]
        if j ==l-2:
            ans_sub += int(subst)
    ans += ans_sub
if l == 1:
    print(int(s))
else:
    print(ans)
def zero_index(i: str) -> int:
  return int(i) - 1

n, k = map(int, input().split())
transition = map(zero_index, input().split())
places = [0]
next_place = transition[0]
while next_place not in places:
  places.append(next_place)
  next_place = transition[next_place]
start = places.index(next_place)
period = len(places) - start
if k < start:
  t = k
else:
  t = (k - start) % priod + start
print(place[t] + 1)

### FIXED CODE ###

def zero_index(i: str) -> int:
  return int(i) - 1

n, k = map(int, input().split())
transition = list(map(zero_index, input().split()))
places = [0]
next_place = transition[0]
virgin = [True] * n
virgin[0] = False
while virgin[next_place]:
  virgin[next_place] = False
  places.append(next_place)
  next_place = transition[next_place]
start = places.index(next_place)
period = len(places) - start
if k < start:
  t = k
else:
  t = (k - start) % period + start
print(places[t] + 1)
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

import numpy as np

N, K = map(int, readline().split())
H = np.array(readline().split(), dtype=np.int64)

dp = [INF] * N
dp[0] = 0

# 配るDP
for i in range(N):
    for j in range(1, K+1):
        if i+j < N:
            dp[i+j] = min(dp[i+j], dp[i]+abs(H[i] - H[i+j]))
    
ans = dp[-1]
print(ans)

### FIXED CODE ###

import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, K = map(int, readline().split())
H = list(map(int, readline().split()))

dp = [INF] * N
dp[0] = 0

# 配るDP
for i in range(N):
    for j in range(1, K+1):
        if i+j < N:
            dp[i+j] = min(dp[i+j], dp[i]+abs(H[i] - H[i+j]))
    
ans = dp[-1]
print(ans)
import math
N = int(input())
for i in N+1:
    if math.floor(i*1.08) = N
    print(i)
    exit()
    
print(":(")
    


### FIXED CODE ###

import math
N = int(input())

for i in range(N+1):
    if math.floor(1.08 * i) == N:
        print(i)
        exit()

print(":(")
N, M = map(int, input().split())
l, r = 1, N
for _ in range(M):
    L, R = map(int, input().split())
    l = max(l, L)
    r = min(r, R)
print((max(0, r-l+1))

### FIXED CODE ###

N, M = map(int, input().split())
l, r = 1, N
for _ in range(M):
    L, R = map(int, input().split())
    l = max(l, L)
    r = min(r, R)
print(max(0, r-l+1))
N=int(input())
A=[]
for n in range(N):
	A+=[int(input())]
B=A.copy()
B.sort()
if N!=2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in A:
		if i==C:
			print(D)
		else:
			print(C)

else:
	print(A[1])
	print(A[0])

### FIXED CODE ###

import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])