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

#import heapq

def dice(p):
    sum = 0
    for i in range(1,p+1):
        sum += i/p
    return sum

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

m = 0
l = []
for i in range(n-k+1):
    t = sum(p[i:i+k])
    if(m <= t):
        l = p[i:i+k]
        m = t
#print(l)
#l = heapq.nlargest(k, p)
#print(l)


dist = {}
res = 0
for i in l:
    if i in dist:
        ans = dist[i]
    else:
        dist[i] = dice(i)
    res += dice(i)

print(res)











### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
num_li = [0]*n
for i in range(n):
    num_li[i] = (p[i]+1)/2

num = sum(num_li[:k])
ans = num
for j in range(n-k):
    num = num - num_li[j] + num_li[j+k]
    ans = max(num,ans)

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

import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	A = np.array(LI())
	A.sort()
	count = 0
	a_max = A[-1]
	dp = [1]*a_max
	for a in A:
		point = dp[a-1]
		if point == 1:
			dp[a-1] = 2
			count += 1
			i = 2
			while a*i <= a_max:
				dp[a*i-1] = 0
				i += 1
		elif point == 2:
			count -= 1
			dp[a-1] = 0
	print(count)






if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	A = np.array(LI())
	A.sort()
	count = 0
	a_max = A[-1]
	dp = [1]*a_max
	for a in A:
		point = dp[a-1]
		if point == 1:
			dp[a-1] = 2
			count += 1
			for ai in range(a*2,a_max+1,a):
				dp[ai-1] = 0
		elif point == 2:
			count -= 1
			dp[a-1] = 0
	print(count)






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

N,A,B=map(int, raw_input().split()) 
H=[ input() for i in range(N) ] 

def func(n , T):
	sa=A-B
	k=0
	for x in T:
		x-=n*B
		if x>0:
			if x%sa==0:
				k+=x/sa
			else:
				k+=(x/sa+1)
		
			if n<k:
				return False
	else:
			return True

l=0
r=10**9
while l!=r:
	m=(r+l)/2
	if func(m,H):
		r=m
	else:
		l=m+1

print l


### FIXED CODE ###

N,A,B= map(int,raw_input().split())
h=[input() for _ in range(N)]

high=max(h)
low=1

def enough(T):
	cnt=0
	for i in h:
		i-=T*B
		if i>0:
			if i%(A-B)==0:
				cnt+=i/(A-B)
			else:
				cnt+=i/(A-B)+1
	if cnt<=T:
		return True
	else:
		return False

ans=0
while low<=high:
	c= (low + high) / 2
	if enough(c):
		high=c-1
		ans=c
	else:
		low=c+1


print ans
### BUGGY CODE ###

import re
N,Q = map(int,input().split())
S = input()
pattern = re.compile(r'AC')
for i in range(Q):
    l,r = map(int,input().split())
    print(len(pattern.findall(S[l-1:r])))

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
lst = [0] * (N+1)
before = ''
count = 0
for i in range(len(S)-1):
    if S[i:i+2] == 'AC':
        count += 1
    lst[i+2] = count
for i in range(Q):
    l,r = map(int,input().split())
    print(lst[r]-lst[l])
### BUGGY CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


if __name__ == '__main__':
    S = int(input())
    prime_numbers = factorization(S)

    prime_numbers_list = []

    for e in prime_numbers:
        number, count = e
        for i in range(count):
            prime_numbers_list.append(number)


    # bit全探索
    pattern = len(prime_numbers_list)
    for i in range(2**pattern):
        width = 1
        height = 1
        index = 0
        for j in range(pattern):
            if ((i >> j) & 1) == 1:
                width *= prime_numbers_list[index]
            else:
                height *= prime_numbers_list[index]
            index += 1
        if (width <= 10**9) and (height <= 10**9):
            break

    x1 = 0
    y1 = 0
    x2 = width
    y2 = 0
    x3 = 0
    y3 = height

    print(str(x1) + ' ' + str(y1) + ' ' + str(x2) + ' ' + str(y2) + ' ' + str(x3) + ' ' + str(y3))

### FIXED CODE ###

if __name__ == '__main__':
    S = int(input())

    x0 = 0
    x1 = 10**9
    x2 = 1
    y0 = 0
    y2 = (S + x1 - 1)//x1
    y1 = x1 * y2 - S

    print(str(x0) + ' ' + str(y0) + ' ' + str(x1) + ' ' + str(y1) + ' ' + str(x2) + ' ' + str(y2))
### BUGGY CODE ###

#!/usr/bin/env python3

def solve(x):
    if x >= 2000:
        return True
    def dp(x):
        if x == 0:
            return True
        elif x < 0:
            return False
        for i in range(100,106):
            if dp(x-i):
                return True
        
        return False

    return dp(x)



def main():
    X = int(input())
    print(int(solve(X)))
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def solve(x):
    if x >= 2000:
        return True
    memo = [True] + [False]*x

    def dp(k):
        if k == 0:
            return True
        for i in range(100,106):
            if k-i >= 0 and memo[k-i]:
                return True
        
        return False
    
    for i in range(x):
        memo[i+1] = dp(i+1)
    return memo[x]



def main():
    X = int(input())
    print(int(solve(X)))
    return

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

# Binary Indexed Tree (Fenwick Tree)
class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    i += 1
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i)

N, Q = map(int, input().split())
c = list(map(int, input().split()))
q = []
for k in range(Q):
  l, r = map(int, input().split())
  l -= 1
  r -= 1
  q.append([l, r, k])


q.sort(key = lambda x: x[1])
ans = [0 for k in range(Q)]


good = BIT(N)
lastapp = [-1 for _ in range(N)]
end = -1
for k in range(Q):
  l = q[k][0]
  r = q[k][1]
  a = q[k][2]
  for j in range(r, end, -1):
    if lastapp[c[j]-1] == -1:
      lastapp[c[j]-1] = j
      good.add(j, 1)
    elif lastapp[c[j]-1] < j:
      good.add(lastapp[c[j]-1], -1)
      good.add(j, 1)
      lastapp[c[j]-1] = j
  ans[a] = good.get(l, r+1)
  end = r
  
for k in range(Q):
  print(ans[k])

### FIXED CODE ###

# Binary Indexed Tree (Fenwick Tree)
class BIT:
    # 1-index
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, Q = map(int, input().split())
c = list(map(int, input().split()))
q = []
for k in range(Q):
  l, r = map(int, input().split())
  l -= 1
  r -= 1
  q.append([l, r, k])


q.sort(key = lambda x: x[1])
ans = [0 for k in range(Q)]


good = BIT(N)
lastapp = [-1 for _ in range(N)]
end = -1
for k in range(Q):
  l = q[k][0]
  r = q[k][1]
  a = q[k][2]
  for j in range(r, end, -1):
    if lastapp[c[j]-1] == -1:
      lastapp[c[j]-1] = j
      good.add(j+1, 1)
    elif lastapp[c[j]-1] < j:
      good.add(lastapp[c[j]-1]+1, -1)
      good.add(j+1, 1)
      lastapp[c[j]-1] = j
  ans[a] = good.sum(r+1) - good.sum(l)
  end = r
  
for k in range(Q):
  print(ans[k])
### BUGGY CODE ###

N,K = map(int,input().split())
s=input()
if '0' not in s:
    print(len(s))
else:
    s2 = []
    count = 1
    for i in range(1,len(s)):
        if s[i-1] == s[i]:
            count += 1
        if s[i-1] != s[i]:
            s2.append(count)
            count = 1
    s2.append(count)
    if s[0] != '1':
        s2.insert(0,0)
    if s[-1] != '1':
        s2.append(0)
    ans2 = 0
    K2 = 2*K+1
    for i in range(0,max(1,(len(s2) - K2)//2 +2)):
        ans2 = max(ans2,sum(s2[2*i:2*i+K2]))
    print(ans2)

### FIXED CODE ###

N,K = map(int,input().split())
s=input()
if '0' not in s:
    print(len(s))
else:
    s2 = [0]
    count = 0
    for i in range(len(s)-1):
        count += 1
        if s[i] != s[i+1]:
            s2.append(count)
    s2.append(count+1)
    if s[0] == '0':
        s2.insert(0,0)
    ans = 0
    for i in range(0,len(s2)-1,2):
        ans = max(ans,s2[min(len(s2)-1,i+2*K+1)] - s2[i])
    print(ans)
### BUGGY CODE ###

import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


H, W = list(map(int, sys.stdin.buffer.readline().split()))
A = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(H)]
B = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(H)]

grid = [[0] * W for _ in range(H)]
for h, w in itertools.product(range(H), range(W)):
    grid[h][w] = A[h][w] - B[h][w]

LIMIT = 80 * 40 * 40
# 符号をどっちにするか選べる
dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0] = {grid[0][0], -grid[0][0]}
for h, w in itertools.product(range(H), range(W)):
    g = grid[h][w]
    if h - 1 >= 0:
        for c in dp[h - 1][w]:
            if -LIMIT <= c + g <= LIMIT:
                dp[h][w].add(c + g)
            if -LIMIT <= c - g <= LIMIT:
                dp[h][w].add(c - g)
    if w - 1 >= 0:
        for c in dp[h][w - 1]:
            if -LIMIT <= c + g <= LIMIT:
                dp[h][w].add(c + g)
            if -LIMIT <= c - g <= LIMIT:
                dp[h][w].add(c - g)

ans = INF
for s in dp[-1][-1]:
    ans = min(ans, abs(s))

print(ans)


### FIXED CODE ###

import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


H, W = list(map(int, sys.stdin.buffer.readline().split()))
A = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(H)]
B = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(H)]

grid = [[0] * W for _ in range(H)]
for h, w in itertools.product(range(H), range(W)):
    grid[h][w] = A[h][w] - B[h][w]

# 符号をどっちにするか選べる
dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0] = {grid[0][0] % 800, -(grid[0][0]) % 800}
for h, w in itertools.product(range(H), range(W)):
    g = grid[h][w]
    s = dp[h][w]
    if h - 1 >= 0:
        for c in dp[h - 1][w]:
            s.add((c + g) % 800)
            s.add((c - g) % 800)
    if w - 1 >= 0:
        for c in dp[h][w - 1]:
            s.add((c + g) % 800)
            s.add((c - g) % 800)
# print(grid)
# print(dp)
ans = INF
for s in dp[-1][-1]:
    ans = min(ans, s)
    ans = min(ans, (-s) % 800)
print(ans)
### BUGGY CODE ###

#template
def inputlist(): return [int(k) for k in input().split()]
#template
mod = 10**9+7
S = list(input())
n = len(S)
#桁dp
dp = [[0]*(13) for _ in range(n+1)]
if S[0] == '?':
    for i in range(10):
        dp[1][i] = 1
if S[0] != '?':
    dp[1][int(S[0])] = 1
for i in range(1,n):
    i+=1
    if S[i-1] == '?':
        for m in range(13):
            for j in range(10):
                dp[i][(10*m+j)%13] += dp[i-1][m]
                dp[i][(10*m+j)%13] %= mod
        continue
    if S[i-1] != '?':
        for m in range(13):
            dp[i][(10*m+int(S[i-1]))%13] += dp[i-1][m]
            dp[i][(10*m+int(S[i-1]))%13] %= mod
dp[n][5] %= mod
print(dp[n][5])

### FIXED CODE ###

#template
def inputlist(): return [int(k) for k in input().split()]
#template
mod = 10**9+7
S = list(input())
n = len(S)
#桁dp
dp = [[0]*(13) for _ in range(n+1)]
if S[0] == '?':
    for i in range(10):
        dp[1][i] = 1
if S[0] != '?':
    dp[1][int(S[0])] = 1
for i in range(1,n):
    i+=1
    if S[i-1] == '?':
        for m in range(13):
            for j in range(10):
                dp[i][(10*m+j)%13] += dp[i-1][m]
                dp[i][(10*m+j)%13] %= mod
        continue
    if S[i-1] != '?':
        for m in range(13):
            dp[i][(10*m+int(S[i-1]))%13] += dp[i-1][m]
            dp[i][(10*m+int(S[i-1]))%13] %= mod
dp[n][5] %= mod
print(dp[n][5])
### BUGGY CODE ###

S=input()
dp=[[0 for _ in range(13)] for _ in range(len(S))]
MOD=10**9+7
if S[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(S[0])]+=1
for i in range(1, len(S)):
  cur_nums=[i for i in range(10)] if S[i]=='?' else [int(S[i])]
  for cur in cur_nums:
    for rem in range(13):
      dp[i][(10*rem+cur)%13]=(dp[i][(10*rem+cur)%13]+dp[i-1][rem])%MOD
print(dp[-1][5])

### FIXED CODE ###

S=input()
dp=[[0 for _ in range(13)] for _ in range(len(S))]
MOD=10**9+7
if S[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(S[0])]+=1
for i in range(1, len(S)):
  cur_nums=[i for i in range(10)] if S[i]=='?' else [int(S[i])]
  for cur in cur_nums:
    for rem in range(13):
      dp[i][(10*rem+cur)%13]=(dp[i][(10*rem+cur)%13]+dp[i-1][rem])%MOD
print(dp[-1][5])
### BUGGY CODE ###

import math as mt
N = int(input())
A = [int(x) for x in input().split()]
a = 1
for i in range(N):
    a *= A[i]
if a > 1000000000000000000:
    print(-1)
else:
    print(a)
    

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
a = 1
if 0 in A:
    a = 0
else:
    for i in range(N):
        a *= A[i]

        if a > 1000000000000000000:
            a = -1
            break
print(a)
### BUGGY CODE ###

inf = 1001001001
n = int(input())
lis = list(map(int, input().split()))
lis.sort()
ans = 0
for i in range(n-1):
    a = lis[i]
    for j in range(i + 1, n):
        b = lis[j]
        nl = [0] + lis[j+1:] + [inf]
        l = 0
        r = len(nl) -1
        while r > l+1:
            mid = (l+r) // 2
            if nl[mid] < a + b:
                l = mid
            else:
                r = mid
        ans += l
print(ans)

### FIXED CODE ###

inf = 1001001001
n = int(input())
lis = list(map(int, input().split()))
lis.sort()
lis.append(inf)
ans = 0
for i in range(n-2):
    a = lis[i]
    for j in range(i + 1, n-1):
        b = lis[j]
        l = j
        r = n
        while r > l+1:
            mid = (l+r) // 2
            if lis[mid] < a + b:
                l = mid
            else:
                r = mid
        ans += l - j
print(ans)
### BUGGY CODE ###

import bisect
import functools
import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

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


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        ret = fn(*args, **kwargs)
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        print(ret)
        return ret

    return wrapper


@debug
def calc_bit(k):
    """
    答えの下から k ビット目を返す
    :param int k:
    :return:
    """
    # 答えの k ビット目が偶数なら 0、奇数なら 1

    # これ以上の桁は不要
    mod = 1 << (k + 1)
    amod = [a % mod for a in A]
    bmod = [b % mod for b in B]
    bmod.sort()
    ret = 0
    for a in amod:
        # bmod + a のうち k ビット目が 1 となる数
        # => (1 << k) 以上 (2 << k) 未満または (3 << k) 以上 (4 << k) 未満
        ret += bisect.bisect_left(bmod, (2 << k) - a) - bisect.bisect_left(bmod, (1 << k) - a)
        ret += bisect.bisect_left(bmod, (3 << k) - a) - bisect.bisect_left(bmod, (4 << k) - a)

    return ret % 2


ans = 0
for i in range(32):
    ans += calc_bit(i) * (2 ** i)
print(ans)


### FIXED CODE ###

import bisect
import functools
import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

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


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        ret = fn(*args, **kwargs)
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        print(ret)
        return ret

    return wrapper


@debug
def calc_bit(k):
    """
    答えの下から k ビット目を返す
    :param int k:
    :return:
    """
    # 答えの k ビット目が偶数なら 0、奇数なら 1

    # これ以上の桁は不要
    mod = 1 << (k + 1)
    amod = [a & (mod - 1) for a in A]
    bmod = [b & (mod - 1) for b in B]
    amod.sort()
    bmod.sort()
    ret = 0

    # bmod + amod のうち k ビット目が 1 となる数
    # => (1 << k) 以上 (2 << k) 未満または (3 << k) 以上 (4 << k) 未満
    # しゃくとる
    b01 = bisect.bisect_left(bmod, (1 << k) - amod[0])
    b10 = bisect.bisect_left(bmod, (2 << k) - amod[0])
    b11 = bisect.bisect_left(bmod, (3 << k) - amod[0])
    for a in range(len(amod)):
        while b01 - 1 >= 0 and bmod[b01 - 1] >= (1 << k) - amod[a]:
            b01 -= 1
        while b10 - 1 >= 0 and bmod[b10 - 1] >= (2 << k) - amod[a]:
            b10 -= 1
        while b11 - 1 >= 0 and bmod[b11 - 1] >= (3 << k) - amod[a]:
            b11 -= 1
        # (1 << k) 以上 (2 << k) 未満
        ret += b10 - b01
        # (3 << k) 以上 (4 << k) 未満
        ret += len(bmod) - b11

    return ret % 2


ans = 0
for i in range(30):
    ans += calc_bit(i) * (2 ** i)
print(ans)
### BUGGY CODE ###

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

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

dp = [[0] * N for _ in range(N)]
#print(dp)
dp[0] = Z[0]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + Z[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + Z[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + Z[i][2]
    #print(dp)

print(max(dp[-1]))


### FIXED CODE ###

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

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

dp = [[0] * 3 for _ in range(N)]
#print(dp)
dp[0] = Z[0]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + Z[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + Z[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + Z[i][2]
    #print(dp)

print(max(dp[-1]))
### BUGGY CODE ###

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

dp = [float("inf")]*len(h)
dp[0] = 0

for i in range(len(h)):
    for j in range(1,K+1):
        if i - j >= 0:
            dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]), dp[i])


print(dp[N-1])


### FIXED CODE ###

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

dp = [float("inf")]*len(h)
dp[0] = 0

for i in range(len(h)):
    for j in range(1,min(i+1,K+1)):
        dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]), dp[i])
        
print(dp[N-1])
### BUGGY CODE ###

import sys
import os
import bisect
from operator import itemgetter

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [ 0  for _ in range(M)]
for i in range(M):
    b,c = map(int,input().split())
    B[i] = [b,c]
B = sorted(B,key=itemgetter(1),reverse=True)
for i in range(M):
    id = bisect.bisect_left(A,B[i][1])
    if id > 0:
        for j in range(min(B[i][0],id+1)):
            if A[0] < B[i][1]:
                A.append(B[i][1])
                del A[0]
    else:
        break
print(sum(A))


### FIXED CODE ###

import sys
import os
import bisect
from operator import itemgetter

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [ 0  for _ in range(M)]
for i in range(M):
    b,c = map(int,input().split())
    B[i] = [b,c]
B = sorted(B,key=itemgetter(1),reverse=True)
ans = 0
for i in range(M):
    id = bisect.bisect_left(A,B[i][1])
    if id > 0:
        for j in range(min(B[i][0],id+1)):
            if len(A) > 0 and A[0] < B[i][1]:
                ans += B[i][1]
                del A[0]
    else:
        break
print(sum(A)+ans)
### BUGGY CODE ###

H,W=map(int, input().split())

A=[]
for i in range(H):
  A.append(list(input()))
q=[]
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      q.append((i, j))

cnt=0
while q:
  r=[]
  for i, j in q:
    if i > 0 and A[i-1][j] == '.':
      A[i-1][j] = '#'
      r.append((i-1, j))
    if i < H-1 and A[i+1][j] == '.':
      A[i+1][j] = '#'
      r.append((i+1, j))
    if j > 0 and A[i][j-1] == '.':
      A[i][j-1] = '#'
      q=r.append((i, j-1))
    if j < W-1 and A[i][j+1] == '.':
      A[i][j+1] = '#'
      r.append((i, j+1))
  q=r
  cnt = cnt + 1
print(cnt-1)

### FIXED CODE ###

def f(h, w):
    dt = [[-1, 0], [0, -1], [0, 1], [1, 0]]
    t = [[True] * (w + 2)]
    for _ in range(h):
        t += [[True] + [(c == "#") for c in input()] + [True]]
    t += [[True] * (w + 2)]
    kuro = []
    for i, ti in enumerate(t[1:-1]):
        for j, tij in enumerate(ti[1:-1]):
            if tij:
                kuro+=[(i + 1, j + 1)]
    cnt = -1
    while kuro:
        cnt += 1
        nxt = []
        for i, j in kuro:
            ti=t[i]
            if not ti[j+1]:
                ti[j + 1]=True
                nxt += [(i, j+1)]
            if not ti[j-1]:
                ti[j - 1]=True
                nxt += [(i, j-1)]
            if not t[i - 1][j]:
                t[i - 1][j]=True
                nxt += [(i - 1, j)]
            if not t[i + 1][j]:
                t[i + 1][j]=True
                nxt += [(i + 1, j)]
        kuro = nxt
    print(cnt)
 
 
h, w = map(int, input().split())
f(h, w)
### BUGGY CODE ###

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

base = 1

for ai in A[:K]:
  base *= ai

score = [base]

for i in range(K, N):
  s = score[-1] // A[i-K] * A[i]
  score.append(s)
  print('Yes' if score[-1] > score[-2] else 'No')

### FIXED CODE ###

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

for i in range(N - K):
  score_2 = A[i+K]
  score_1 = A[i]
  print('Yes' if score_1 < score_2 else 'No')