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

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N,K=LI()
AB=[LI() for i in range(N)]

counts={}
l=[]
for ab in AB:
	if not counts.get(ab[0]):
		counts[ab[0]]=ab[1]
	else:
		counts[ab[0]]+=ab[1]
	if ab[0] not in l:
		l.append(ab[0])

l.sort()
c=0
for item in l:
	c+=counts.get(item)
	if c>=K:
		print(item)
		exit()


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N,K=LI()
A=[]
B=[]
AB=[]
for i in range(N):
	a,b=LI()
	A.append(a)
	B.append(b)
	AB.append([a,b])
A=list(set(A))
A.sort()
counts={}
for a in A:
	counts[a]=0

for ab in AB:
	counts[ab[0]]+=ab[1]
if K<N/2:
	c=0
	for item in A:
		c+=counts.get(item)
		if c>=K:
			print(item)
			exit()
else:
	c=sum(B)
	for item in reversed(A):
		c-=counts.get(item)
		if c<K:
			print(item)
			exit()
### BUGGY CODE ###

def dijkstra(s, n, cost):
    d = [float("inf")] * (n+1)
    used = [False] * (n+1)
    d[s] = 0

    while True:
        v = -1
        for i in range(1, n+1):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True
        for j in range(1, n+1):
            d[j] = min(d[j], d[v] + cost[v][j])
    return d


n = int(input())
inf = float("inf")
cost = [[inf]*(n+1) for _ in range(n+1)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    cost[a][b] = c
    cost[b][a] = c
q, k = map(int, input().split())
ans = dijkstra(k, n, cost)
for _ in range(q):
    x, y = map(int, input().split())
    print(ans[x] + ans[y])

### FIXED CODE ###

n = int(input())
inf = float("inf")
tree = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    tree[a].append([b, c])
    tree[b].append([a, c])
q, k = map(int, input().split())

depth = [inf] * (n+1)
visited = [False] * (n+1)
depth[k] = 0
stack = [k]
while stack:
    now = stack.pop()
    visited[now] = True
    for i, v in tree[now]:
        if visited[i]:
            pass
        else:
            stack.append(i)
            depth[i] = min(depth[i], depth[now] + v)
for _ in range(q):
    x, y = map(int, input().split())
    ans = depth[x] + depth[y]
    print(ans)
### BUGGY CODE ###

N = int(input())

l = [
  [len([n for n in range(1, N+1) if (str(n)[0]==str(i) and str(n)[-1]==str(j))])
     for j in range(1, 10)]
  for i in range(1, 10)
]

ans = 0
for i in range(9):
  for j in range(9):
    ans += l[i][j]*l[j][i]

print(ans)

### FIXED CODE ###

N = int(input())

l = [
  [len([n for n in range(1, N+1) if (str(n)[0]==str(i) and str(n)[-1]==str(j))])
     for j in range(1, 10)]
  for i in range(1, 10)
]

ans = 0
for i in range(9):
  for j in range(9):
    ans += l[i][j]*l[j][i]

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

import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    N=int(input())

    # divisors=sieve(N)
    #
    # # print(divisors)
    # sum=0
    # for i,n in enumerate(divisors):
    #     sum+=i*n

    # print(5*(2+5-1)//2)
    print(sieve(N))

def sieve(n):
    # is_prime = [i for i in range(n+1)]
    sum=n*(2+n-1)//2

    for i in range(2, n+1):
        # print(is_prime)
        sum += i
        j = 2 * i
        while j <= n:
            sum += j
            j += i

    return sum


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    N=int(input())

    # divisors=sieve(N)
    #
    # # print(divisors)
    # sum=0
    # for i,n in enumerate(divisors):
    #     sum+=i*n

    # print(5*(2+5-1)//2)
    print(sieve(N))

def sieve(n):
    # is_prime = [i for i in range(n+1)]
    sum=n*(2+n-1)//2
    # sum=0

    for i in range(2, n+1):
        # print(is_prime)
        d=n//i
        # print(d)
        sum+=d*((d+1)*i)//2
        # sum += i
        # j = 2 * i
        # while j <= n:
        #     sum += j
        #     j += i

    return sum


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

if __name__ == '__main__':
    N = int(input())
    a = input()
    a = a.split(' ')
    a = list(map(int, a))

    a.sort()

    min = a[0]
    max = a[-1]

    i = min
    j = 0
    k = 0
    num = 0
    max_num = 0

    while i <= max + 1:
        if i - 1 <= a[j] and a[j] <= i + 1:
            num += 1
        elif i + 1 < a[j]:
            if max_num < num:
                max_num = num
            num = 0
            # j = k
            i += 1
            j = 0
            continue
        j += 1
        if j == len(a):
            if max_num < num:
                max_num = num
            num = 0;
            # j = k
            i += 1
            j = 0
            continue
            
    print(max_num)

### FIXED CODE ###

if __name__ == '__main__':
    N = int(input())
    a = input()
    a = a.split(' ')
    a = list(map(int, a))

    min_a = min(a)
    max_a = max(a)

    num = []

    for i in range(max_a+1):
        num.append(0)

    for i in a:
        if i-2 >= 0:
            num[i-2] += 1
        if i-1 >= 0:
            num[i-1] += 1
        num[i] += 1

    c = max(num)
    print(c)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
raw_input()
n = map(int,raw_input().split())
raw_input()
res = 0
for i in map(int,raw_input().split()):
    if i in n :
        res += 1
print res

### FIXED CODE ###

raw_input()
s1 = set(raw_input().split())
raw_input()
s2 = set(raw_input().split())
print (len(s1&s2))
### BUGGY CODE ###

from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)
from collections import deque
import heapq
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    S = [int(a) for a in input().split()]
    S = sorted(S,key=lambda x:x)
    # debug(S,'S')
    live = [S[-1]]
    S.pop()
    # iはステップ
    for i in range(N):
        # 各スライムに生んでもらう
        livenext = [l for l in live]
        for l in live:
            borned = False
            for j in range(len(S)-1, -1, -1):
                if l > S[j]:
                    livenext.append(S[j])
                    S.remove(S[j])
                    borned = True
                    break
            if not borned:
                print("No")
                exit()
        live = livenext
    if len(S) == 0:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import exit, stderr, stdin
input = stdin.readline
from collections import defaultdict
from sys import stderr
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return
def main():
    N = int(input())
    S = [int(a) for a in input().split()]
    S = sorted(S)
    exist = [S.pop()]
    debug(S)
    debug(exist)
    for i in range(N):
        next_exist = []
        next_s = []
        for p in exist[::-1]:
            while S:
                x = S.pop()
                if x < p:
                    next_exist.append(x)
                    break
                else:
                    next_s.append(x)
        exist += next_exist
        exist.sort()
        S += next_s[::-1]

    if len(exist) == 2**N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

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

import itertools
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7

def xor(x, y):
    X = bin(max(x, y))[2:]
    Y = bin(min(x, y))[2:]
    w = str(int(X)+int(Y))
    ans = 0
    for i in reversed(range(len(w))):
        if w[i] == "1":
            ans += 2**(len(w)-1-i)
    return ans % mod


Ans = 0
for i in itertools.combinations(a, 2):
        Ans = Ans + xor(i[0], i[1])
print(Ans % mod)


### FIXED CODE ###

def powmod(x, y, mod):
    if y == 0:
        return 1
    return (((powmod(x, y >> 1, mod) ** 2) % mod) * x ** (y & 1)) % mod


n = int(input())
a = tuple(map(int, input().split()))
mod = 10**9 + 7
cnt = [0] * 60
for i in range(n):
    r = a[i]
    for j in range(60):
        if r & 1:
            cnt[j] += 1
        r >>= 1

ans = 0
for i in range(60):
    ans += powmod(2, i, mod) * cnt[i] * (n-cnt[i])
    ans %= mod
print(ans)
### BUGGY CODE ###

ss, ts = input(), input()

lenS, lenT = len(ss), len(ts)

dp = [[0]*(lenT+1) for _ in range(lenS+1)]
dp[0][0] = 0
for iS, s in enumerate(ss, 1):
    for jT, t in enumerate(ts, 1):
        if s == t:
            dp[iS][jT] = dp[iS-1][jT-1] + 1
        else:
            dp[iS][jT] = max(dp[iS-1][jT], dp[iS][jT-1])

ans = ''
iS, jT = lenS, lenT
while iS*jT:
    if ss[iS-1] == ts[jT-1]:
        ans += ss[iS-1]
        iS, jT = iS-1, jT-1
    elif dp[iS-1][jT] >= dp[iS][jT-1]:
        iS -= 1
    else:
        jT -= 1

print(ans[::-1])


### FIXED CODE ###

ss, ts = input(), input()

lenS, lenT = len(ss), len(ts)

dp = [[0]*(lenT+1) for _ in range(lenS+1)]
dp[0][0] = 0
for iS, s in enumerate(ss, 1):
    for jT, t in enumerate(ts, 1):
        if s == t:
            dp[iS][jT] = dp[iS-1][jT-1] + 1
        else:
            dp[iS][jT] = max(dp[iS-1][jT], dp[iS][jT-1])

ans = ''
iS, jT = lenS, lenT
while iS*jT:
    if ss[iS-1] == ts[jT-1]:
        ans += ss[iS-1]
        iS, jT = iS-1, jT-1
    elif dp[iS-1][jT] >= dp[iS][jT-1]:
        iS -= 1
    else:
        jT -= 1

print(ans[::-1])
### BUGGY CODE ###

def solve():
    k, s = map(int, input().split())
    c = 0
    for x in range(k + 1):
        for y in range(k + 1):
            for z in range(k + 1):
                if x + y + z == s:
                    c += 1
    return c


if __name__ == "__main__":
    print(solve())


### FIXED CODE ###

def solve():
    k, s = map(int, input().split())
    c = 0
    for x in range(k + 1):
        for y in range(k + 1):
            if 0 <= s - (x + y) <= k:
                c += 1
    return c


if __name__ == "__main__":
    print(solve())
### BUGGY CODE ###

from bisect import bisect, bisect_left
N = int(input())
A = sorted(list(map(int, input().split())))
ans = 0
i = 0
while i < N:
  j = 0
  isOK = True
  while A[j]*2 <= A[i] and isOK:
    if A[i]%A[j] == 0:
      isOK = False
      break
    j += 1
  if bisect(A, A[i])-bisect_left(A, A[i]) == 1 and isOK:
    ans += 1
  i += 1
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
M = max(A)
memo = [0]*(M+1)
i = 0
while i < N:
  a = A[i]
  memo[a] += 1
  x = a+a
  while x <= M:
    memo[x] += 2
    x += a
  i += 1
print(sum([1 if m == 1 else 0 for m in memo]))
### BUGGY CODE ###

#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, = read_h()
    arr = sorted(read_h(), reverse=True)
    #  print(arr)

    cnts = {}
    for a in arr:
        cnts[a] = cnts.get(a, 0) + 1
    #  print(cnts)

    rem = sum(cnts.values())
    for i in range(n - 1):
        a = arr[i]
        if cnts[a] <= 0:
            continue

        cnts[a] -= 1
        rem -= 1
        if rem == 0:
            break

        tmp_rem = rem
        for j in range(i + 1, n):
            b = arr[j]
            if cnts[b] <= 0:
                continue

            xor = a ^ b
            if xor not in cnts or cnts[xor] <= 0:
                continue

            cnts[b] -= 1
            cnts[xor] -= 1
            rem -= 2
            #  print(a, b, xor)
            #  print('remain:', cnts)
            break

        if tmp_rem == rem:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, = read_h()
    arr = read_h()
    #  print(arr)

    s = 0
    for a in arr:
        s ^= a

    if s == 0:
        print('Yes')
    else:
        print('No')


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

import sys
import numpy as np


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    List = np.unique(A)
    count = np.bincount(A)
    # print(count)

    dic = {}
    Ans = 0
    for l in List:
        n = count[l]
        num = n * (n - 1) // 2
        Ans += num
        dic[l] = num
    B = np.empty(N, dtype=np.int)
    for l in List:
        n = count[l] - 1
        num = n * (n - 1) // 2
        B = np.where(A == l, int(Ans - dic[l] + num), B)
    print(*B, sep="\n")


main()


### FIXED CODE ###

import sys
import numpy as np


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    count = np.bincount(A)
    # print(count)
    total = (count * (count - 1)).sum() // 2
    answer = (total - (count - 1))[A]
    print("\n".join(answer.astype(str)))


main()
### BUGGY CODE ###

import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
  dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])


### FIXED CODE ###

import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])
### BUGGY CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    h, w = list(map(int, readline().split()))
    a = [list(map(int, readline().split())) for _ in range(h)]
    b = [list(map(int, readline().split())) for _ in range(h)]

    diff = [[abs(an - bn) for an, bn in zip(arow, brow)] for arow, brow in zip(a, b)]

    dp = [[set() for _ in range(w)] for _ in range(h)]

    dp[0][0].add(diff[0][0])

    from collections import deque
    que = deque()
    que.append((0, 0))

    seen = [[False] * w for _ in range(h)]

    while que:
        row, col = que.popleft()

        if row + 1 < h:
            if not seen[row + 1][col]:
                seen[row + 1][col] = True
                que.append((row + 1, col))

            for num in dp[row][col]:
                dp[row + 1][col].add(num + diff[row + 1][col])
                dp[row + 1][col].add(abs(num - diff[row + 1][col]))

        if col + 1 < w:
            if not seen[row][col + 1]:
                seen[row][col + 1] = True
                que.append((row, col + 1))

            for num in dp[row][col]:
                dp[row][col + 1].add(num + diff[row][col + 1])
                dp[row][col + 1].add(abs(num - diff[row][col + 1]))

    cand = list(dp[h - 1][w - 1])

    print(min(cand))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    h, w = list(map(int, readline().split()))
    a = [list(map(int, readline().split())) for _ in range(h)]
    b = [list(map(int, readline().split())) for _ in range(h)]

    diff = [[abs(an - bn) for an, bn in zip(arow, brow)] for arow, brow in zip(a, b)]

    dp = [[1 << (80 * 160 + 1) for _ in range(w)] for _ in range(h)]
    dp[0][0] |= 1 << diff[0][0]

    from itertools import product

    for row, col in product(range(h), range(w)):
        diff_cur = diff[row][col]
        prevset = 0

        if row - 1 >= 0:
            prevset |= dp[row - 1][col]
        if col - 1 >= 0:
            prevset |= dp[row][col - 1]

        dp[row][col] |= (prevset << diff_cur)
        dp[row][col] |= (prevset >> diff_cur)
        temp = 0
        for i in range(diff_cur):
            if prevset >> i & 1:
                temp += (1 << diff_cur - i)
        dp[row][col] |= temp

    for i in range(12801):
        if dp[h - 1][w - 1] >> i & 1:
            print(i)
            sys.exit()


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

import heapq

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
used = [[False] * N for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(N):
        via = i
        for k in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            if k == i or k == j:
                continue
            if A[i][j] == A[i][k] + A[k][j]:
                via = k
        if i >= j:
            continue
        if not (used[i][via] and used[via][i]):
            used[i][via] = True
            used[via][i] = True
            ans += A[i][via]
        if not (used[via][j] and used[j][via]):
            used[via][j] = True
            used[j][via] = True
            ans += A[via][j]
print(ans)


### FIXED CODE ###

import heapq

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

ans = 0
for i in range(N):
    for j in range(N):
        via_k = float('inf')
        for k in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            if k == i or k == j:
                continue
            via_k = min(via_k, A[i][k] + A[k][j])
        if i <= j:
            continue
        if A[i][j] < via_k:
            ans += A[i][j]
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
MOD = 10**9 + 7

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = [int(item) - 1 for item in input().split()]
    edge[a].append(b)
    edge[b].append(a)

childs = [[] for _ in range(n)]
def dfs(p, v):
    val = 1
    for nv in edge[v]:
        if nv == p:
            continue
        ret = dfs(v, nv)
        val += ret
        childs[v].append(ret)
    if val != n:
        childs[v].append(n - val)
    return val

dfs(-1, 0)
total_pattern = pow(2, n, MOD)
total_pattern_inv = pow(total_pattern, MOD-2, MOD)
inv2 = pow(2, MOD-2, MOD)
pow2_table = [1]
for i in range(2 * 10**5):
    pow2_table.append(pow2_table[-1] * 2 % MOD)
ans = 0
for line in childs:
    pattern_ok = 0
    if len(line) == 1:
        continue
    for item in line:
        pattern_ok += pow2_table[item] - 1
    pattern_ok += 1
    ans += (total_pattern * inv2 - pattern_ok) * total_pattern_inv
    ans %= MOD
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
MOD = 10**9 + 7

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = [int(item) - 1 for item in input().split()]
    edge[a].append(b)
    edge[b].append(a)

childs = [[] for _ in range(n)]
def dfs(p, v):
    val = 1
    for nv in edge[v]:
        if nv == p:
            continue
        ret = dfs(v, nv)
        val += ret
        childs[v].append(ret)
    if val != n:
        childs[v].append(n - val)
    return val

dfs(-1, 0)
total_pattern = pow(2, n, MOD)
total_pattern_inv = pow(total_pattern, MOD-2, MOD)
inv2 = pow(2, MOD-2, MOD)
pow2_table = [1]
for i in range(2 * 10**5):
    pow2_table.append(pow2_table[-1] * 2 % MOD)
ans = 0
for line in childs:
    pattern_ok = 0
    if len(line) == 1:
        continue
    for item in line:
        pattern_ok += pow2_table[item] - 1
    pattern_ok += 1
    ans += (total_pattern * inv2 - pattern_ok) * total_pattern_inv
    ans %= MOD
print(ans)
### BUGGY CODE ###

import math
import sys
input = sys.stdin.readline
number, jump =input().rstrip().split()
number = int(number)
jump = int(jump)
scaffolding = input().rstrip().split()
scaffolding = list(map(int, scaffolding))
res = [math.inf for i in range(number)]
res[0] =0 
test = [math.inf for k in range(jump)]
test[0] = 0

for i in range(number):
    for j in range(1,jump+1):
        if i-j < 0:break
        cost = abs(scaffolding[i]-scaffolding[i-j])
        test[j-1] = res[i-j] + cost
    
    res[i] = min(test)
    

print(res[number-1])




### FIXED CODE ###

import math
import sys
input = sys.stdin.readline
number, jump =input().rstrip().split()
number = int(number)
jump = int(jump)
scaffolding = input().rstrip().split()
scaffolding = list(map(int, scaffolding))
res = [0 for i in range(number)]
res[1] = abs(scaffolding[1]-scaffolding[0])
#test = [math.inf for k in range(jump)]
#test[0] = 0

for i in range(2, number):
    h=max(0,i-jump)
    res[i]=min(res[k]+abs(scaffolding[i]-scaffolding[k]) for k in range(h,i))   
    #res[i] = min(test)
    

print(res[number-1])
### BUGGY CODE ###

N = int(input())

A = [int(input()) for i in range(N)]

for i in range(N):
    new_A = A.copy()
    del new_A[i]
    print(sorted(new_A)[-1])

### FIXED CODE ###

N = int(input())

l = [int(input()) for i in range(N)]

new_l = sorted(l)

fmax = new_l[N-1]
fmax2 = new_l[N-2]
smax = fmax

for j in reversed(range(N)):
    if not new_l[j] == fmax:
        smax = new_l[j]
        break

if fmax == fmax2:
    for k in range(N):
        print(fmax)
else:
    for m in range(N):
        if l[m] == fmax:
            print(smax)
        else:
            print(fmax)
### BUGGY CODE ###

import os, sys, atexit
from io import BytesIO, StringIO
 
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER
 
@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
n, k = map(int, input().split())
l = list(map(int, input().split()))
ans = [0] * (n - k + 1)
x = 0
for i in range(1, n):
    l[i] *= l[i - 1]
for i in range(k - 1, n):
    if i == k - 1:
        ans[x] = l[i]
        x -= -1
    else:
        ans[x] = l[i] // l[i - k]
        x -= -1
for i in range(1, len(ans)):
    if ans[i] > ans[i - 1]: print('Yes')
    else: print('No')

### FIXED CODE ###

n, k = map(int, input().split())
l = list(map(int, input().split()))
for i in range(k, n):
    if l[i] > l[i - k]: print('Yes')
    else: print('No')