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

n,k,*h=map(int,open(0).read().split())
dp=[0]*n
for i in range(1,n):
  left=max(i-k,0)
  lst=[dp[j]+abs(h[i]-h[j]) for j in range(left,i)]
  dp[i]=min(lst)
print(dp[-1])  


### FIXED CODE ###

N,K = map(int,input().split())
H = [int(x) for x in input().split()]
 
def main(N,K,H):
    dp = [0]*N
    for i in range(1,N):
        L = [dp[j]+abs(H[i]-H[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)
    print(dp[-1])
main(N,K,H)
#自分のコードがTLEになるので、他の人が書いたコードでAC出来るのか確認。
### BUGGY CODE ###

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

import sys
from collections import Counter, defaultdict

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, Q = MAP()
X = set()
A = defaultdict(list)
for i in range(N):
    s, t, x = MAP()
    # 全ての工事を同じ時系列に持ってくる
    X.add(s-x)
    X.add(t-x)
    A[s-x].append((x, 0))
    A[t-x].append((x, 1))
D = LIST(Q)

Dset = set(D)
S = sorted(X|Dset)
B = {}
C = Counter()
for key in S:
    li = A[key]
    for x, flag in li:
        if flag == 0:
            C[x] += 1
        else:
            C[x] -= 1
        if C[x] == 0:
            del C[x]
    if key in Dset:
        mn = min(C) if len(C) else -1
        B[key] = mn
[print(B[x]) for x in D]


### FIXED CODE ###

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

import sys
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, Q = MAP()
# 3種類の状態変化をイベントとして一括管理する
# 0: 工事終了, 1: 工事開始, 2: 人の出発
events = []
for i in range(N):
    s, t, x = MAP()
    # (開始座標に合わせた状態の工事開始時間, フラグ, 実際の座標)
    events.append((s-x, 1, x))
    # (開始座標に合わせた状態の工事終了時間, フラグ, 実際の座標)
    events.append((t-x, 0, x))
for i in range(Q):
    d = INT()
    # (人の出発時間, フラグ, index)
    events.append((d, 2, i))
# 時系列に沿ってソート、フラグも同時刻な時先に処理して欲しいものから番号を振ってある
events.sort()

# setとheapqを合わせて、時刻に合わせた処理と最小値取得を行う
S = set()
hp = []
ans = [0] * Q
for t, flag, x in events:
    # 工事終了
    if flag == 0:
        S.remove(x)
    # 工事開始
    elif flag == 1:
        S.add(x)
        heappush(hp, x)
    # 人の移動
    elif flag == 2:
        # heapqの先頭要素ついて、setと状態を合わせる
        while len(hp) and hp[0] not in S:
            heappop(hp)
        if len(hp):
            ans[x] = hp[0]
        else:
            ans[x] = -1
[print(a) for a in ans]
### BUGGY CODE ###

K,S = [int(i) for i in input().split()]
count = 0
for z in range(0,K+1):
	for y in range(0,z+1):
		for x in range(0,y+1):
			if x + y + z == S:
				if  x == y and y == z:
					count += 1
				elif (x-y)*(y-z)*(z-x) == 0:
					count += 3
				else:
					count += 6
print(count)

### FIXED CODE ###

K,S = [int(i) for i in input().split()]
count = 0
for z in range(0,K+1):
	for y in range(0,K+1):
			if 0 <= S-y-z <= K:
				count += 1
print(count)
### BUGGY CODE ###

n = int(input())
shin = 0
while n > 0:
    shin += (n % 10)
    n //= 10
if shin % 9 == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = list(input())
shin = 0
for i in n:
    shin += int(i)
if shin % 9 == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

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

if ans > 10 ** 18:
    print("-1")
else:
    print(ans)

### FIXED CODE ###

import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[-1] == 0:
    print(0)
    sys.exit(0)
ans = A[0]
for i in range(1, N):
    ans *= A[i]
    if ans > 10**18:
        print(-1)
        sys.exit(0)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

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

SC=[0,0,0]#1個,2個,3個

for a in A:
    SC[a-1]+=1

one,two,three=SC

DAYSLIST=[[[None for k in range(N+1)] for i in range(N+1)] for j in range(N+1)]

def days(one,two,three):
    if one<0 or two<0 or three<0:
        return 0
    if DAYSLIST[one][two][three]!=None:
        return DAYSLIST[one][two][three]
    k=one+two+three

    if k==0:
        return 0

    DAYSLIST[one][two][three]=(days(one-1,two,three)*one+days(one+1,two-1,three)*two+days(one,two+1,three-1)*three+N)/k
    return DAYSLIST[one][two][three]

print(days(one,two,three))

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

SC=[0,0,0]#1個,2個,3個

for a in A:
    SC[a-1]+=1
one,two,three=SC

DAYSDICT=[[[0.0]*301 for j in range(301)] for k in range(301)]
DAYSDICT[0][0][0]=0
def days(one,two,three):
    ANS=N
    if one>0:
        ANS+=DAYSDICT[one-1][two][three]*one
    if two>0:
        ANS+=DAYSDICT[one+1][two-1][three]*two
    if three>0:
        ANS+=DAYSDICT[one][two+1][three-1]*three
        
    DAYSDICT[one][two][three]=ANS/(one+two+three)


for k in range(three+1):
    for j in range(two+three+1-k):
        for i in range(one+two+three+1-j-k):
            if i==j==k==0:
                continue
            days(i,j,k)

print(DAYSDICT[one][two][three])
### BUGGY CODE ###

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


def lcs(x, y):
    n = len(x)
    m = len(y)
    return rec(x, y, n, m)


@functools.lru_cache(maxsize=None)
def rec(x, y, i, j):
    if i == 0 or j == 0:
        return 0
    elif x[i - 1] == y[j - 1]:
        return rec(x, y, i - 1, j - 1) + 1
    else:
        return max(rec(x, y, i, j - 1), rec(x, y, i - 1, j))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10**7)
    q = int(sys.stdin.readline().strip())
    for i in range(q):
        x = sys.stdin.readline().strip()
        y = sys.stdin.readline().strip()
        print(lcs(x, y))



### FIXED CODE ###

def m():
 e=input
 a=''
 for _ in[0]*int(e()):
  X,z=e(),[]
  for y in e():
   s=i=0
   for k in z:
    t=X.find(y,s)+1
    if t<1:break
    if t<k:z[i]=t
    s=k;i+=1
   else:
    t=X.find(y,s)+1
    if t:z+=[t]
  a+=f'\n{len(z)}'
 print(a[1:])
if'__main__'==__name__:m()
### BUGGY CODE ###

H, W = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(H)]
B = [tuple(map(int, input().split())) for _ in range(H)]

D = [[abs(A[h][w] - B[h][w]) for w in range(W)] for h in range(H)]
table = [[set() for __ in range(W)] for _ in range(H)]
table[0][0] = {D[0][0]}

for h in range(H):
    for w in range(W):
        Dhw = D[h][w]
        table[h][w] |= {x + Dhw for x in table[h - 1][w]} | {abs(x - Dhw) for x in table[h - 1][w]} | \
                       {x + Dhw for x in table[h][w - 1]} | {abs(x - Dhw) for x in table[h][w - 1]}

print(min(table[H - 1][W - 1]))


### FIXED CODE ###

import numpy as np
import itertools

H, W = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(H)]
B = [tuple(map(int, input().split())) for _ in range(H)]

D = [[abs(A[h][w] - B[h][w]) for w in range(W)] for h in range(H)]
max_num = 80 * (H + W)
table = np.zeros((H, W, max_num), dtype='bool')
table[0][0][D[0][0]] = True

it = itertools.product(range(H), range(W))
next(it)  # h=w=0 捨てる
for h, w in it:
    d = D[h][w]
    table[h][w][d:] += table[h - 1][w][:max_num - d] + table[h][w - 1][:max_num - d]
    table[h][w][:max_num - d] += table[h - 1][w][d:] + table[h][w - 1][d:]
    table[h][w][d:0:-1] += table[h - 1][w][:d] + table[h][w - 1][:d]

print(np.amin(*np.where(table[H - 1][W - 1])))
### BUGGY CODE ###

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

def jud(n,a,b):
    distance_dic_before_a = []
    distance_dic_before_b = []
    distance_dic_before_a.append(a)
    distance_dic_before_b.append(b)

    turn_count = 1
    while True:
        distance_dic_after_a = []
        for a_dir in distance_dic_before_a:
            a_dir_plus = a_dir + 1
            a_dir_minus = a_dir - 1
            if a_dir_plus > n:
                a_dir_plus = n
            if a_dir_minus == 0:
                a_dir_minus = 1
            distance_dic_after_a.append(a_dir_plus)
            distance_dic_after_a.append(a_dir_minus)
        distance_dic_before_a = distance_dic_after_a

        distance_dic_after_b = []
        for a_dir in distance_dic_before_b:
            a_dir_plus = a_dir + 1
            a_dir_minus = a_dir - 1
            if a_dir_plus > n:
                a_dir_plus = n
            if a_dir_minus == 0:
                a_dir_minus = 1
            distance_dic_after_b.append(a_dir_plus)
            distance_dic_after_b.append(a_dir_minus)
        distance_dic_before_b = distance_dic_after_b

        set_a = set(distance_dic_after_a)
        set_b = set(distance_dic_after_b)
        result_set = set_a & set_b
        if len(result_set) > 0:
            return turn_count

        turn_count +=1

print(jud(n, a, b))

### FIXED CODE ###

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

def jud(n,a,b):
    distance_dic_before_a = []
    distance_dic_before_b = []
    distance_dic_before_a.append(a)
    distance_dic_before_b.append(b)

    turn_count = 1
    while True:
        distance_dic_after_a = []
        for a_dir in distance_dic_before_a:
            a_dir_plus = a_dir + 1
            a_dir_minus = a_dir - 1
            if a_dir_plus > n:
                a_dir_plus = n
            if a_dir_minus == 0:
                a_dir_minus = 1
            distance_dic_after_a.append(a_dir_plus)
            distance_dic_after_a.append(a_dir_minus)
        distance_dic_before_a = distance_dic_after_a

        distance_dic_after_b = []
        for a_dir in distance_dic_before_b:
            a_dir_plus = a_dir + 1
            a_dir_minus = a_dir - 1
            if a_dir_plus > n:
                a_dir_plus = n
            if a_dir_minus == 0:
                a_dir_minus = 1
            distance_dic_after_b.append(a_dir_plus)
            distance_dic_after_b.append(a_dir_minus)
        distance_dic_before_b = distance_dic_after_b

        set_a = set(distance_dic_after_a)
        set_b = set(distance_dic_after_b)
        print(set_a, set_b)
        result_set = set_a & set_b
        if len(result_set) > 0:
            return turn_count

        turn_count +=1

def jud_2(n,a,b):
    if abs(a-b) % 2 == 0:
        return abs(a-b) // 2
 
    x = n - a
    y = b - 1
 
    if x > y:
        choice_1 = a-1+1 + (y-a) // 2
        if choice_1 > y:
            return y
        else:
            return choice_1
    else:
        choice_2 = n-b+1 + (x-(n-b+1)) // 2
        if choice_2 > x:
            return x
        else:
            return choice_2
# print(jud(n, a, b))
print(jud_2(n,a,b))
### BUGGY CODE ###

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

ans = 0

for n in range(1, N+1):
  for bit in range(1 << N):
    s = []

    for index, i in enumerate(li):
      if bit & (1 << index):
        s.append(i)

    if len(s) == n:
      if sum(s) / len(s) == A:
        ans += 1

print(ans)

### FIXED CODE ###

N, A = map(int, input().split())
X = list(map(int, input().split()))
dp = [[[0] * 3001 for i in range(51)] for j in range(51)]

dp[0][0][0] = 1

for i in range(N):
  for j in range(N):
    for k in range(0, 2501):
      dp[i+1][j][k] += dp[i][j][k]
      dp[i+1][j+1][k+X[i]] += dp[i][j][k]

ans = 0
for n in range(1, N+1):
  ans += dp[N][n][n*A]

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

n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in a:
    ans.append(i)
    ans=ans[::-1]
print(*ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a1=[]
for i in range(n-1,-1,-2):
    a1.append(a[i])
a2=[]
for i in range(n-2,-1,-2):
    a2.append(a[i])
a2.reverse()
a1+=a2
print(*a1)
### BUGGY CODE ###

def main():
    from collections import deque
    import sys

    n,m =map(int,input().split())
    abl=[[] for i in range(n)]
    for i in range(m):
        a,b = map(int,input().split())
        abl[a-1].append(b)
        abl[b-1].append(a)

    an=[0]*(n-1)
    tg = deque([1])
    while len(tg):
        itg = tg.popleft()
        for j in abl[itg-1]:
            if an[j-2]==0 and j!=1:
                an[j-2]=itg
                tg.append(j)
            if all(an):
                print('Yes')
                for j in an:
                    print(j)
                sys.exit()

    if all(an):
        print('Yes')
        for j in an:
            print(j)
    else:
        print('No')

main()

### FIXED CODE ###

def main():
    from collections import deque
 
    n,m =map(int,input().split())
    abl=[[] for i in range(n+1)]
    for i in range(m):
        a,b = map(int,input().split())
        abl[a].append(b)
        abl[b].append(a)
 
    an=[0]*(n+1)
    an[0]=1
    tg = deque([1])
    while len(tg):
        itg = tg.popleft()
        for j in abl[itg]:
            if an[j]==0:
                an[j]=itg
                tg.append(j)

    if all(an):
        print('Yes')
        for j in an[2:]:
            print(j)
    else:
        print('No')
 
main()
### BUGGY CODE ###

from scipy.sparse import*
g=[]
n=int(raw_input())
for _ in xrange(n-1):
	a,b=map(int,raw_input().split())
	g.append((a-1,b-1,1))
z=[-1]*n
for _ in xrange(int(raw_input())):
	a,b=map(int,raw_input().split())
	g.append((n,a-1,b))
	z[a-1]=b
a,b,c=zip(*g)
a=map(int,csgraph.dijkstra(csr_matrix((c,(a,b)),[n+1]*2),0,n))
for i in xrange(n):
	if z[i]>=0 and z[i]!=a[i]:
		print('No')
		exit()
for e in g:
	if e[0]<e[1] and abs(a[e[0]]-a[e[1]])!=1:
		print('No')
		exit()
print('Yes')
print("\n".join(map(str,a[:n])))

### FIXED CODE ###

#!/usr/bin/python
def shortestPath(g,s,dist,prev):
	n = len(g)-1
	Q=[]
	heapq.heappush(Q,(0,-2,s))
	while Q:
		e = heapq.heappop(Q)
		if prev[e[2]]!=-1: continue
		prev[e[2]] = e[1]
		for f in g[e[2]]:
			if dist[f[2]] > e[0] + f[0]:
				dist[f[2]] = e[0] + f[0]
				heapq.heappush(Q,(e[0]+f[0],f[1],f[2]))

import sys,heapq
#if sys.version_info[0]>=3:raw_input=input

n=int(raw_input())
g=[[] for _ in range(n+1)]
for _ in xrange(n-1):
	a,b=map(int,raw_input().split())
	g[a-1]+=[(1,a-1,b-1)]
	g[b-1]+=[(1,b-1,a-1)]
z=[-1]*n
for _ in xrange(int(raw_input())):
	a,b=map(int,raw_input().split())
	g[n]+=[(b,n,a-1)]
	z[a-1]=b
a=[1e9]*n+[0]
shortestPath(g,n,a,[-1]*(n+1))
for i in xrange(n):
	if z[i]>=0 and z[i]!=a[i]:
		print('No')
		sys.exit()
for _ in g:
	for e in _:
		if e[1]<e[2] and abs(a[e[1]]-a[e[2]])!=1:
			print('No')
			sys.exit()
print('Yes')
print("\n".join(map(str,a[:n])))
### BUGGY CODE ###

N, M = [int(x) for x in input().split()]
path = []
for i in range(M):
  t1, t2 = [int(x) for x in input().split()]
  path.append((t1, t2))
l = [1]
ans = [1] + [0] * (N-1)
while True:
  t = l.pop(0)
  for i in reversed(range(len(path))):
    if t in path[i]:
      if path[i][0] == t:
        if ans[path[i][1]-1] == 0:
          ans[path[i][1]-1] = t
          l.append(path[i][1])
      else:
        if ans[path[i][0]-1] == 0:
          ans[path[i][0]-1] = t
          l.append(path[i][0])
      path.pop(i)
  if path == []:
    break
print('Yes')
for i in range(1,N):
  print(ans[i])

### FIXED CODE ###

N, M = [int(x) for x in input().split()]
path = []
for i in range(N):
  path.append([])
for i in range(M):
  t1, t2 = [int(x) for x in input().split()]
  path[t1-1].append((t1,t2))
  path[t2-1].append((t2,t1))
l = [1]
ans = [1] + [0] * (N-1)
while len(l) > 0:
  t = l.pop(0)
  for i in range(len(path[t-1])):
    if ans[path[t-1][i][1]-1] == 0:
      ans[path[t-1][i][1]-1] = t
      l.append(path[t-1][i][1])
print('Yes')
for i in range(1, N):
  print(ans[i])
### BUGGY CODE ###

N , M = map(int,input().split())
Height = [h_i for h_i in map(int,input().split())]
Roots = []
for j in range(M):
    root = [c_i for c_i in map(int,input().split())]
    #if root[0] > root[1]:
    #    root.reverse()
    Roots +=[root]
#print(Height,"\n",Roots)

connections=[]
for i in range(1,N+1):
    site = []
    for root in Roots:
        if root[0]==i:
            site+=[root[1]]
        elif root[1]==i:
            site+=[root[0]]
    connections+=[site]
#print(connections)

counter = 0
for i in range(N):
    counter2 = 0
    for site in connections[i]:
        if Height[i] <= Height[site-1]:
            counter2 += 1
    if counter2 == 0:
        counter+=1
#        print(i+1,counter2)
print(counter)

### FIXED CODE ###

N , M = map(int,input().split())
Height = [h_i for h_i in map(int,input().split())]
Roots = []
counter = [0 for i in range(N)]
for j in range(M):
    root = [c_i -1 for c_i in map(int,input().split())]
    #print(root)
    if Height[root[0]]<Height[root[1]]:
        counter[root[0]] += 1
    elif Height[root[0]]==Height[root[1]]:
        counter[root[0]] += 1
        counter[root[1]] += 1
    else:
        counter[root[1]] += 1

counter2 = 0
for i in range(N):
    if counter[i]==0:
        counter2+=1
print(counter2)
### BUGGY CODE ###

MOD = int(1e9 + 7)
M = 13

s = input()
dp = [0 for x in range(M)]
dp[0] = 1
ndp = [0 for x in range(M)]

for i in range(len(s)):
    for j in range(M):
        for k in range(10):
            if s[i] == "?" or s[i] == str(k):
                ndp[(j*10 +k) % M] += dp[j]
                ndp[(j*10 +k) % M] %= MOD
    dp = ndp
    ndp = [0 for x in range(M)]

print(dp[5])


### FIXED CODE ###

MOD = int(1e9 + 7)
N = int(1e5)
M = 13

s = input()
dp = [[0 for x in range(M)] for x in range(N+10)]
dp[0][0] = 1

for i in range(len(s)):
    for j in range(M):
        for k in range(10):
            if s[i] == "?" or s[i] == str(k):
                dp[i+1][(j*10 +k) % M] += dp[i][j]
                dp[i+1][(j*10 +k) % M] %= MOD


print(dp[len(s)][5])
### BUGGY CODE ###

n = int(input())
S = input()

T = S[0]
for i in range(1, len(S)):
    if S[i-1] != S[i]:
        T += S[i]
print(len(T))

### FIXED CODE ###

n = int(input())
S = input()

count = 1
for i in range(1, len(S)):
    if S[i-1] != S[i]:
        count += 1
print(count)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(i) for i in input().split()] for _ in range(N-1)]
PX = [[int(j) for j in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    
counters = [0] * (N+1)
for p,x in PX:
    counters[p] += x
    
def dfs(v,parent,add):
    counters[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,counters[v])

dfs(1,0,0)

ans = ' '.join(map(str,counters[1:]))
print(ans)

### FIXED CODE ###

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

N,Q = map(int,input().split())
AB = [[int(i) for i in input().split()] for _ in range(N-1)]
PX = [[int(j) for j in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    
counters = [0] * (N+1)
for p,x in PX:
    counters[p] += x
    
def dfs(v,parent,add):
    counters[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,counters[v])

dfs(1,0,0)

ans = ' '.join(map(str,counters[1:]))
print(ans)
### BUGGY CODE ###

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

P = []
for i in range(N):
	x, y = map(int, input().split())
	P.append([x, y])

answer = 2**69
for i in range(N):
	for j in range(N):
		for k in range(N):
			for l in range(N):
				xmin = min(P[i][0], P[j][0], P[k][0], P[l][0]);
				xmax = max(P[i][0], P[j][0], P[k][0], P[l][0]);
				ymin = min(P[i][1], P[j][1], P[k][1], P[l][1]);
				ymax = max(P[i][1], P[j][1], P[k][1], P[l][1]);
				cnt = 0
				for x in range(N):
					if xmin <= P[x][0] and P[x][0] <= xmax and ymin <= P[x][1] and P[x][1] <= ymax:
						cnt += 1
				if cnt >= K:
					answer = min(answer, (xmax-xmin)*(ymax-ymin))
print(int(answer))


### FIXED CODE ###

import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
 
N,K = LI()
p = []
for i in range(N):
    a,b = LI()
    p.append((a,b))
sx = sorted(p)
ans = 10**50
for x,y in sx:
    for x2,y2 in sx:
        if x2 <= x:
            continue
        points = sx.index((x2,y2)) - sx.index((x,y)) + 1
        if points < K:
            continue
        sy = sorted(sx[sx.index((x,y)):sx.index((x2,y2))+1],key=lambda sx: sx[1])
        for j in range(len(sy)-K+1):
            if sy[j][1] <= y and y2 <= sy[j+K-1][1]:
                ans = min(ans, (x2 - x) * (sy[j+K-1][1]-sy[j][1])) 
print(ans)
### BUGGY CODE ###

l,r = map(int,input().split())

mod = 2019
ans = 10000
a = [i%mod for i in range(l,r+1)]


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)

print(ans)


### FIXED CODE ###

import sys
l,r = map(int,input().split())

mod = 2019
ans = 10000
a = []
for i in range(l,r+1):
  a.append(i%2019)
  if len(a) == 2020*2:
    break


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

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

import numpy as np
import bisect
import copy
N, Q = map(int, input().split())
events = []
for i in range(N):
    s,t,x = map(int, input().split())
    events.append([s-x, 1, x])
    events.append([t-x, -1, x])
events.sort()
events=np.array(events)
sets = set()
prev = 0
for _ in range(Q):
    d = int(input())
    index = bisect.bisect_right(events[:,0], d)
    for i in range(prev, index):
        t, pm, x = events[i]
        if pm == 1:
            sets.add(x)
        if pm == -1:
            sets.remove(x)
    prev=copy.copy(index)
    if len(sets)==0:
        print(-1)
    else:
        print(min(sets))

### FIXED CODE ###

from bisect import bisect_left
N, Q = map(int, input().split())
consts = []
for _ in range(N):
    s,t,x = map(int, input().split())
    consts.append((x,s,t))
consts.sort()
D=[int(input()) for _ in range(Q)]
ans=[-1]*Q
jump=[-1]*Q
for x,s,t in consts:
    left=bisect_left(D,s-x)
    right=bisect_left(D,t-x)
    while left<right:
        if jump[left]==-1:
            ans[left]=x
            jump[left]=right
            left += 1
        else:
            left=jump[left]
print(*ans, sep='\n')
### BUGGY CODE ###

N = int(input())
A = [input() for i in range(N)]
M = 1046527
T = [0 for i in range(M)]

def convert_str_to_int(s):
    if s == "A":
        return 1
    elif s == "C":
        return 2
    elif s == "G":
        return 3
    elif s == "T":
        return 4
    else:
        return 0

def get_key(value: str) -> int:
    converted_value = ""
    for s in value:
        i = convert_str_to_int(s)
        converted_value += str(i)
    return int(converted_value)

def h1(key: int) -> int:
    return key % M

def h2(key: int) -> int:
    move_value = 1 + (key % (M-1))
    return move_value

def h(key:int, i:int) -> int:
    hash_value = (h1(key) + i+h2(key)) % M
    return hash_value

def find(key: int) -> bool:
    i = 0
    while True:
        j = h(key, i)
        if T[j] == key:
            return True
        elif T[j] == 0 or i >= M:
            return False
        else:
            i += 1


def insert(key: int) -> None:
    i = 0
    while True:
        j = h(key, i)
        if T[j] == 0:
            T[j] = key
            return
        else:
            i += 1


for row in A:
    order, value = row.split()
    key = get_key(value)
    if order[0] == "i":
        insert(key)
    else:
        if find(key):
            print("yes")
        else:
            print("no")


### FIXED CODE ###

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

D = {}
for row in A:
    order, key = row.split()
    if order[0] == "i":
        D[key] = 1
    else:
        if key in D.keys():
            print("yes")
        else:
            print("no")