Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

get = list(map(int, input().split()))

N = get[0]
K = get[1]
Q = get[2]

point = [K]*N

for i in range(Q):
  A = input()
  A = int(A)
  for j in range(N):
    if (A - 1) != j:
      point[j] += -1

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

### FIXED CODE ###

get = list(map(int, input().split()))

N = get[0]
K = get[1]
Q = get[2]

list = [0]*N

for i in range(Q):
  list[int(input()) - 1] += 1 

for i in range(N):
  if K - (Q - list[i]) > 0:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###



def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    Q=I()
    dir=0#0で先頭
    
    for _ in range(Q):
        q=list(input().split())
        if q[0]=="1":
            dir+=1
            dir%=2
        else:
            dir2=dir
            if q[1]=="2":
                dir2+=1
                dir2%=2
            if dir2==0:
                S=q[2]+S
            else:
                S=S+q[2]
            
    ans=list(S)
    
    if dir==1:
        ans=ans[::-1]
        
    print(''.join(map(str, ans)))
        

main()


### FIXED CODE ###



def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
from collections import deque


def main():
    mod=10**9+7
    S=deque(input())
    Q=I()
    dir=0#0で手前につける
    
    for _ in range(Q):
        q=list(input().split())
        if q[0]=="1":
            dir+=1
            dir%=2
        else:
            dir2=dir
            if q[1]=="2":
                dir2+=1
                dir2%=2
            if dir2==0:
                S.appendleft(q[2])
            else:
                S.append(q[2])
            
    ans=list(S)
    
    if dir==1:
        ans=ans[::-1]
        
    print(''.join(map(str, ans)))
        

main()
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]

if a.count(max(a)) >= 2:
    for _ in range(n):
        print(max(a))
else:
    for _ in range(n):
        if a[_] == max(a):
            print(sorted(a)[-2])
        else:
            print(max(a))


### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
a_ = sorted(a)
a_max = a_[-1]
a_second = a_[-2]
 
if a.count(a_max) >= 2:
    for _ in range(n):
        print(a_max)
else:
    for _ in range(n):
        if a[_] == a_max:
            print(a_second)
        else:
            print(a_max)
### BUGGY CODE ###

N, K  = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0

for i in range(1, N):
    H = h[i]
    dp[i] = min( [dp[j] + abs(h[j] - H) for j in range(max(0, i-K),i)])
print(dp[N-1])


### FIXED CODE ###

n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])
### BUGGY CODE ###

import math
n = int(input())
ans = [int(i) for i in range(n+1)]
ans[1] = 0
i = 2
sosu = []
while i <= int(math.sqrt(n)):
    if ans[i] != 0:
        j = i
        sosu.append(i)
        for j in range(j,(n//j)+1):
            ans[i*j] = 0
    i += 1
f = []
tmp = n
for i in range(len(sosu)):
    if tmp%sosu[i]==0:
        cnt = 0
        while tmp%sosu[i]==0:
            cnt += 1
            tmp = tmp//sosu[i]
        f.append([sosu[i],cnt])
if tmp != 1:
    f.append([tmp,1])
count = 0
for i in range(len(f)):
    j = 1
    while j <= f[i][1]:
        n = n//(f[i][0]*j)
        f[i][1] -= j
        count += 1
        j += 1
#print(f)
print(count)


### FIXED CODE ###

import collections

#https://note.nkmk.me/python-prime-factorization/
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def f(n):
    for i in range(1,20):
        if n<(i*(i+1))//2:
            return i-1

n = int(input())
c = collections.Counter(prime_factorize(n))
ans = 0
for i in c.keys():
    ans += f(c[i])
print(ans)
### BUGGY CODE ###

import itertools
N = int(input())
S = [int(_) for _ in input()]
s = list(itertools.combinations(S, 3))
print(len(set(s)))

### FIXED CODE ###

N = int(input())
S = input()
ans = 0
# 000 - 999 まで全探索
for i in range(1000):
    t = str(i).zfill(3)

    # 1桁目が存在するか
    if t[0] in S:
        t1 = S.index(t[0])
        # 2桁目を1桁目のidx + 1から探す
        if t[1] in S[t1 + 1:]:
            # 1桁目のidx + 2桁目のidx + 1 桁目から3文字目を探す
            t2 = t1 + S[t1 + 1:].index(t[1]) + 1
            if t[2] in S[t2 + 1:]:
                ans += 1

print(ans)
### BUGGY CODE ###

n, m, k = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
import numpy as np
from itertools import accumulate
AS = np.array([0] + list(accumulate(A)))
BS = np.array([0] + list(accumulate(B)))

ans = 0
for i in range(n+1):
    if AS[i] > k:
        break
    for j in range(m+1):
        if AS[i] + BS[j] > k:
            break
        ans = max(ans, i+j)
        
print(ans)



### FIXED CODE ###

n, m, k = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
from itertools import accumulate
AS = [0] + list(accumulate(A))
BS = [0] + list(accumulate(B))

ans = 0
j = m
for i in range(n+1):
    if AS[i] > k:
        break

    while AS[i] + BS[j] > k:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)
### BUGGY CODE ###

# 全縦線と全横線を全探索するとO(N^5)
# 50 ** 5 = 312500000
# 縦線の選び方は50 C 2だから2分の1になるのを考慮しても、78125000
# いや無理だろ……と思ったら公式がこの解法だった。衝撃。
# 二次元累積和を使うと各回の計算がO(1)になるので、O(N^4)となる。

# まず O(N^5)解法を作ってみよう。通るのかこれ?


n, k = list(map(int, input().split()))
coords = [list(map(int, input().split())) for _ in range(n)]

ans = (3 * 10 ** 9) ** 2
for ix1, x1 in enumerate(coords):
    for ix2, x2 in enumerate(coords[ix1+1:]):
        for iy1, y1 in enumerate(coords):
            for iy2, y2 in enumerate(coords[iy1+1:]):
                point_in_rect = 0
                for c in coords:
                    # ソートしてない。
                    if (c[0] - x1[0]) * (c[0] - x2[0]) <= 0 and (c[1] - y1[1]) * (c[1] - y2[1]) <= 0:
                        point_in_rect += 1
                if point_in_rect >= k:
                    ans = min(ans, abs((x1[0] - x2[0]) * (y1[1] - y2[1])))

print(ans)


### FIXED CODE ###

# 全縦線と全横線を全探索するとO(N^5)
# 50 ** 5 = 312500000
# 縦線の選び方は50 C 2だから2分の1になるのを考慮しても、78125000
# いや無理だろ……と思ったら公式がこの解法だった。衝撃。
# 二次元累積和を使うと各回の計算がO(1)になるので、O(N^4)となる。

# まず O(N^5)解法を作ってみよう。通るのかこれ?


n, k = list(map(int, input().split()))
coords = [list(map(int, input().split())) for _ in range(n)]

ans = (3 * 10 ** 9) ** 2
for ix1, x1 in enumerate(coords):
    for ix2, x2 in enumerate(coords[ix1+1:]):
        for iy1, y1 in enumerate(coords):
            for iy2, y2 in enumerate(coords[iy1+1:]):
                point_in_rect = 0
                for c in coords:
                    # ソートしてない。
                    if (c[0] - x1[0]) * (c[0] - x2[0]) <= 0 and (c[1] - y1[1]) * (c[1] - y2[1]) <= 0:
                        point_in_rect += 1
                if point_in_rect >= k:
                    ans = min(ans, abs((x1[0] - x2[0]) * (y1[1] - y2[1])))

print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
sum = 0
for i in range(N):
    for j in range(i):
        if(S[i] == S[j]):
            continue
        for k in range(j):
            if(k - j == j - i):
                continue
            if(S[j] == S[k]):
                continue
            elif(S[i] == S[k]):
                continue
            sum += 1
            
print(sum)

### FIXED CODE ###

N = int(input())
S = input()


R = []
B = []
G = []
p = 0
for i in S:
    if(i == "R"):
        R.append(p)
    elif(i == "B"):
        B.append(p)
    elif(i == "G"):
        G.append(p)
    p += 1
R = set(R)
B = set(B)
G = set(G)
sum = len(R) * len(B) * len(G)
for r in R:
    for b in B:
        up = max(r, b)
        dw = min(r, b)
        d = up-dw
        if up + d in G:
            sum -= 1
        if dw - d in G:
            sum -= 1
        if (r+b)/2 in G:
            sum -= 1

print(sum)
### BUGGY CODE ###

import math
N,M = list(map(int,input().split()))
a = [-1]
for i in range(M):
    a.append(int(input()))
a.append(N+1)
b = []
c = []
fac_N =[1]
for i in range(M+1):
    b.append(a[i+1]-a[i]-2)
for i in range(1,max(b)+1):
    fac_N.append(fac_N[-1]*i)


for i in range(len(b)):
    counter= 0
    for num2 in range(b[i]//2+1):
        counter += fac_N[num2+(b[i]-2*num2)]//fac_N[num2]//fac_N[b[i]-2*num2]
    c.append(counter)
ans = 1
for i in range(len(c)):
    ans *= c[i]
print(ans%1000000007)


### FIXED CODE ###

n,m = map(int,input().split())
a = [ int(input()) for _ in range(m)]
M=10**9+7
lis = [1] + [0]*n

for i in a:
  lis[i]=-1
lis[1] += 1
for i in range(n-1):
  if lis[i+2]<0:
    lis[i+2]= 0
  else:
    lis[i+2] = (lis[i+1] + lis[i])%M
print(lis[n])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict,deque

N=input()
AL=defaultdict(lambda: set())
IN=defaultdict(lambda: 0)


for i in range(N):
	A=map(int, sys.stdin.readline().split())
	for j in range(N-2):
		x=i+1
		x_next=i+1
		y_now=A[j]
		y_next=A[j+1]
		#print x,y_now,x_next,y_next
		if x>y_now: x,y_now=y_now,x
		if x_next>y_next: x_next,y_next=y_next,x_next
		IN[(x_next,y_next)]+=1
		AL[(x,y_now)].add((x_next,y_next))

q=deque()

for i in range(1,N+1):
	for j in range(i+1,N+1):
		if IN[(i,j)]==0:
			q.append((i,j))

DAY=defaultdict(lambda: 1)	#距離

ans=-1
while q:
	fro=q.pop()
	for to in AL[fro]:
		alt=DAY[fro]+1
		if DAY[to]<alt:
			ans=max(ans,alt)
			DAY[to]=alt
			q.append((to[0],to[1]))

print ans

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
from collections import defaultdict,deque

N=input()
A=[[]]+[ map(int, sys.stdin.readline().split()) for _ in range(N) ]
C=defaultdict(lambda: 0)

Now=[ 0 for _ in range(N+1)]
game=set()
next_game=set()

for i in range(1,N+1):
	a=i
	b=A[i][0]
	if a>b: a,b=b,a
	game.add((a,b))

day=0

while game:
	next_game=set()
	Visit=defaultdict(lambda: None) 

	for x,y in game:
		now_x=Now[x]
		now_y=Now[y]

		xopp=A[x][now_x]
		yopp=A[y][now_y]

		if (x,y)==(yopp,xopp) and Visit[x] is None and Visit[y] is None:
			Visit[x]=1
			Visit[y]=1
			if now_x<N-2:
				now_x+=1
				Now[x]=now_x
				x_nextopp=A[x][now_x]
				if x_nextopp<x: x,x_nextopp=x_nextopp,x
				next_game.add((x,x_nextopp))

			if now_y<N-2:
				now_y+=1
				Now[y]=now_y
				y_nextopp=A[y][now_y]
				if y_nextopp<y: y,y_nextopp=y_nextopp,y
				next_game.add((y,y_nextopp))

	game=next_game
	day+=1


for i in range(1,N+1):
	if Now[i] != N-2:
		print -1
		quit()
else:
	print day
### BUGGY CODE ###

import math
import bisect
import heapq
from collections import deque

n,k = map(int, input().split())

h = list(map(int, input().split()))

d = [float('inf')] * n
d[0] = 0
d[1] = abs(h[0] - h[1])

p = [100000] * k

for i in range(2,n):

    for j in range(0, min(k,i)):
        # print(i-j)
        p[j] = d[i-j-1] + abs(h[i-j-1]-h[i])

    d[i] = min(p)

print(d[n-1])


### FIXED CODE ###

# import math
# import bisect
# import heapq
# from collections import deque

def main():
    n, k = map(int, input().split())

    h = list(map(int, input().split()))
    inf = 10**7
    d = [inf] * n
    d[0] = 0

    for j in range(1, n):
        p = [d[i] + abs(h[j] - h[i]) for i in range(max(0, j - k), j)]

        d[j] = min(p)

    print(d[-1])

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))

dp = [[0] * (n + 1) for _ in range(n + 1)]

for i in range(n)[::-1]:
    for j in range(n + 1):
        if i >= j:
            continue
        dp[i][j] = max(a[j - 1] - dp[i][j - 1], a[i] - dp[i + 1][j])

print(dp[0][n])


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

dp = [[0] * (n+1) for _ in range(n+1)]

for i in range(n)[::-1]:
    for j in range(n + 1):
        if i >= j:
            continue
        minus = (n - i + j) % 2 * (-2) + 1
        dp[i][j] = max(a[j - 1]-dp[i][j - 1], a[i]-dp[i + 1][j])

print(dp[0][n])
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()

## S中で、'AC'であるインデックスを求める
index = [0] * N
i = 0
while i < len(S)-1:
    if S[i]=='A' and S[i+1]=='C':
        index[i] = 1
        i += 2
    else:
        i += 1

#print('\n')
#print(index)

for i in range(Q):
    l, r = map(int, input().split())
    l = l-1
    r = r-1
    print( sum(index[l : r]) )


### FIXED CODE ###

# coding: utf-8

N, Q = map(int, input().split())
S = input()

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

for i in range(Q):
    l, r = map(int, input().split())
    print( num[r-1] - num[l-1] )
### BUGGY CODE ###

h, w = map(int, input().split())
t = [input() for _ in range(h)]
U = [[0] * (w + 2) for _ in range(h + 2)]
D = [[0] * (w + 2) for _ in range(h + 2)]
L = [[0] * (w + 2) for _ in range(h + 2)]
R = [[0] * (w + 2) for _ in range(h + 2)]
ans = 0
Ui1=U[0]
for i in range(1, 1 + h):
    Ui=U[i]
    Li=L[i]
    ti1=t[i-1]
    for j in range(1, 1 + w):
        if ti1[j - 1] == "#":
            Ui[j] = 0
            Li[j] = 0
        else:
            Ui[j] = Ui1[j] + 1
            Li[j] = Li[j - 1] + 1
    Ui1=Ui
    Di1=D[-1]
for i in range(h, 0, -1):
    Ui=U[i]
    Li=L[i]
    Di=D[i]
    Ri=R[i]
    ti1=t[i-1]
    for j in range(w, 0, -1):
        if ti1[j - 1] == "#":
            Di[j] = 0
            Ri[j] = 0
        else:
            Di[j] = Di1[j] + 1
            Ri[j] = Ri[j + 1] + 1
            tmp = Ui[j] + Di[j] + Li[j] + Ri[j]
            if tmp > ans:
                ans = tmp
    Di1=Di
print(ans - 3)


### FIXED CODE ###

def f(h, w):
    t = [input() for _ in range(h)]
    U = [[0] * (w + 2) for _ in range(h + 2)]
    D = [[0] * (w + 2) for _ in range(h + 2)]
    L = [[0] * (w + 2) for _ in range(h + 2)]
    R = [[0] * (w + 2) for _ in range(h + 2)]
    ans = 0
    Ui1 = U[0]
    for i in range(1, 1 + h):
        Ui = U[i]
        Li = L[i]
        ti1 = t[i - 1]
        for j, tk in enumerate(ti1):
            j += 1
            if tk == "#":
                Ui[j] = 0
                Li[j] = 0
            else:
                Ui[j] = Ui1[j] + 1
                Li[j] = Li[j - 1] + 1
        Ui1 = Ui
        Di1 = D[-1]
    for i in range(h, 0, -1):
        Ui = U[i]
        Li = L[i]
        Di = D[i]
        Ri = R[i]
        ti1 = t[i - 1]
        for j in range(w, 0, -1):
            if ti1[j - 1] == "#":
                Di[j] = 0
                Ri[j] = 0
            else:
                Di[j] = Di1[j] + 1
                Ri[j] = Ri[j + 1] + 1
                tmp = Ui[j] + Di[j] + Li[j] + Ri[j]
                if tmp > ans:
                    ans = tmp
        Di1 = Di
    print(ans - 3)

h, w = map(int, input().split())
f(h, w)
### BUGGY CODE ###

import re
S = input()
N = len(S)
r = re.compile(r"01|10")
T = ""
while S != T:
    T = S
    S = r.sub("", S)
print(N - len(S))
r.sub("", S)


### FIXED CODE ###

S = input()
s = abs(S.count("0") - S.count("1"))
print(len(S) - s)
### BUGGY CODE ###

from heapq import*;(N,M),*t=[map(int,s.split())for s in open(0)];q=[0]*99*M;v=[[]for _ in q]
for a,b in t:v[a-1]+=b,
print(sum(exec("for j in i:heappush(q,-j)")or-heappop(q)for i in v[:M]))

### FIXED CODE ###

from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
q = [0] * 10**5
v = [[] for _ in q]
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)
### BUGGY CODE ###

N = int(input())
S = input()

def solve(SS):
	n = len(SS)
	Z = [0] * n
	i, j = 1, 0
	while i < n:
		while (i + j < n) and (j < i) and (SS[j] == SS[i + j]):
			j += 1
		Z[i] = j
		if j == 0:
			i += 1
			continue
		else:
			k = 1
			while (i + k < n) and (k + Z[k] < j):
				Z[i + k] = Z[k]
				k += 1
			i += k
			j -= k

	return max(Z)

ans = 0
for i in range(N):
	ans = max(ans, solve(S[i:]))

print(ans)

### FIXED CODE ###

N = int(input())
S = input()

def solve(SS):
	n = len(SS)
	Z = [0] * n
	Z[0] = n
	i, j = 1, 0
	while i < n:
		while (i + j < n) and (SS[j] == SS[i + j]):
			j += 1
		Z[i] = j
		if j == 0:
			i += 1
			continue
		else:
			k = 1
			while (i + k < n) and (k + Z[k] < j):
				Z[i + k] = Z[k]
				k += 1
			i += k
			j -= k

	out = 0
	for i in range(n):
		tmp = min(Z[i], i)
		out = max(out, tmp)
	return out

ans = 0
for i in range(N):
	ans = max(ans, solve(S[i:]))

print(ans)
### BUGGY CODE ###

N = int(input())

P = list(map(int,input().split()))

result = 0
for i in range(N):
    flag = True
    for j in range(i,-1,-1):
        if P[i] > P[j]:
            flag = False
    if flag:
        result += 1

print(result)

### FIXED CODE ###

N = int(input())

P = list(map(int,input().split()))

result = 0
current_min = 10**6
for i in range(N):
    current_min = min(current_min, P[i])
    if P[i] <= current_min:
        result += 1

print(result)
### BUGGY CODE ###

S = [0 for i in range(300000)]
S2 = []
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S2.append(str(da))
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1
while 1:
    n = int(input())
    if n == 1:break
    res = [str(n) + ':']
    res += [x for x in S2 if int(x) <= n and n % int(x) == 0]
    print(' '.join(res))

### FIXED CODE ###

S = [0 for i in range(300000)]
S2 = []
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S2.append(da)
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1
while 1:
    n = int(input())
    if n == 1:break
    print(str(n) + ':',' '.join([str(x) for x in S2 if n % x == 0 and x <= n]))
### BUGGY CODE ###

n=int(input())
s=sorted(list(map(int, input().split())))
ans=0
count=0
for i in range(n-2):  
  l,r=i+1,i+2
  sums=s[i]+s[l]
  while r<n:
    if s[r]<sums:
      count+=1
      if r==n-1:
        ans+=count
        count=0
        sums=sums-s[l]+s[l+1]
        l+=1
        r=l
      r+=1
    elif l==r:
      r+=1
    else:
      ans+=count
      count=0
      sums=sums-s[l]+s[l+1]
      l+=1
      r=l+1
print(ans)

### FIXED CODE ###

n=int(input())
l=sorted(list(map(int,input().split())))
from bisect import bisect_left as b
a=0
for i in range(n-1):
  for j in range(i+1,n):
    a+=b(l,l[i]+l[j])-j-1
print(a)
### BUGGY CODE ###

N=int(input());AB=[list(map(int,input().split())) for _ in range(1,N)]
nd=[0 for _ in range(N)]
table = [[] for _ in range(N)]
for a,b in AB:
  table[a-1].append(b)
  nd[a-1]+=1
  nd[b-1]+=1

K=max(nd)
co=[0 for _ in range(N)]
for x,li in enumerate(table):
  c=[i for i in range(1,K+1) if i != co[x]]
  for b,y in zip(li,c):
    co[b-1]=y

print(K)
for _,b in AB:
  print(co[b-1])


### FIXED CODE ###

import sys

input = sys.stdin.readline
N=int(input());AB=[tuple(map(int,input().split())) for _ in range(1,N)]

co=[0 for _ in range(N)]
prev=0
color=1
for a,b in sorted(AB):
  if prev!=a:
    color=1
  if co[a-1]==color:
    color+=1
  co[b-1]=color
  prev=a
  color+=1

print(max(co))
for _,b in AB:
  print(co[b-1])
### BUGGY CODE ###

N, K= map(int, input().split())
h = list(map(int, input().split()))
import numpy as np
dp = np.zeros((N+1, K+1), dtype=int)
for i in range(1, N):
    for k in range(1, K+1):
        if i >= k:
            dp[i+1][k] = abs(h[i] - h[i - k]) + min(dp[i + 1 - k][1:K + 1])
        else:
            w = i
            dp[i+1][k] = dp[i+1][k-1]
print(min(dp[N][1:K+1]))




### FIXED CODE ###

N, K= map(int, input().split())
h = list(map(int, input().split()))
dp = [0]*(N+1)
for i in range(1, N):
    dp[i+1] = min(
        [
            abs(h[i]-h[i-k]) + dp[i+1-k]
            for k in range(1, min(K, i)+1)
        ]
    )
print(dp[N])
### BUGGY CODE ###

k = int(input())

def mygcd(x,y):
    a = min(x,y)  # 最小値
    b = max(x,y)  # 最大値
    r = 2  # 余り
    while r != 0:
        r = b % a
        b = a
        a = r
    return b

ans = 0
for i in range(k):
    for j in range(k):
        for l in range(k):
            ans += mygcd(mygcd(i+1,j+1),l+1)

print(ans)

### FIXED CODE ###

K   = int(input())
Sum = 0
def mygcd(x,y):
    a = min(x,y)  # 最小値
    b = max(x,y)  # 最大値
    r = 2  # 余り
    while r != 0:
        r = b % a
        b = a
        a = r
    return b

for A in range(1,K+1):
    for B in range(1,K+1):
        AB = mygcd(A,B)
        if AB==1:
            Sum = Sum+K
        else:
            for C in range(1,K+1):
                Sum = Sum+mygcd(AB,C)
print(Sum)
### BUGGY CODE ###

input_first = input()
input_second= input().split()
N = int(input_first)
in_list = [int(i) for i in input_second]


flag = 0
for i in range(N):
    if flag !=0:
        break
    for j in range(i+1,N):
        # print("i",in_list[i],"j",in_list[j])

        if in_list[i]==in_list[j]:
            print("NO")
            flag =1
            break

        
if flag ==0:
    print("YES")


### FIXED CODE ###


# input_first= 5
# input_second=[2,6,1,4,5] 
input_first = input()
input_second= input().split()
N = int(input_first)
in_list = [int(i) for i in input_second]


check_dic = {}
flag  =0
for i in in_list:
    if i in check_dic.keys():
        # print(i)
        print("NO")
        flag = 1
        break
    else:
        check_dic[i] = True
    

# print(check_dic)
if flag ==0:
    print("YES")
### BUGGY CODE ###

n = int(input())
s =[]
for i in range(n):
  str = input()
  if not str in s: 
    s.append(str)
print(len(s))


### FIXED CODE ###

n = int(input())
s =[]
for i in range(n):
    s.append(input())
print(len(set(s)))
### BUGGY CODE ###

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


n, m, l = map(int, input().split())
d = [[10**12 for i in range(n)] for i in range(n)]
for i in range(m):
    ai, bi, ci = map(int, input().split())
    d[ai-1][bi-1] = ci
    d[bi-1][ai-1] = ci
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０

d = warshall_floyd(d)
for i in range(n):
    for j in range(n):
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = 10**12

d = warshall_floyd(d)

q = int(input())
for i in range(q):
    si, ti = map(int, input().split())
    if d[si-1][ti-1] >= 10**12:
        print(-1)
    else:
        print(d[si-1][ti-1]-1)

### FIXED CODE ###

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


n, m, l = map(int, input().split())
d = [[10**12 for i in range(n)] for i in range(n)]
for i in range(m):
    ai, bi, ci = map(int, input().split())
    d[ai-1][bi-1] = ci
    d[bi-1][ai-1] = ci
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０

d = warshall_floyd(d)
for i in range(n):
    for j in range(n):
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = 10**12

d = warshall_floyd(d)

q = int(input())
for i in range(q):
    si, ti = map(int, input().split())
    if d[si-1][ti-1] >= 10**12:
        print(-1)
    else:
        print(d[si-1][ti-1]-1)