We have N points in a two-dimensional plane.

The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).

Let us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior.

Here, points on the sides of the rectangle are considered to be in the interior.

Find the minimum possible area of such a rectangle.  

-----Constraints-----
 - 2 \leq K \leq N \leq 50 
 - -10^9 \leq x_i,y_i \leq 10^9 (1 \leq i \leq N) 
 - x_i≠x_j (1 \leq i<j \leq N) 
 - y_i≠y_j (1 \leq i<j \leq N) 
 - All input values are integers. (Added at 21:50 JST)  

-----Input-----
Input is given from Standard Input in the following format:  
N K  
x_1 y_1
:  
x_{N} y_{N}

-----Output-----
Print the minimum possible area of a rectangle that satisfies the condition.  

-----Sample Input-----
4 4
1 4
3 3
6 2
8 1

-----Sample Output-----
21

One rectangle that satisfies the condition with the minimum possible area has the following vertices: (1,1), (8,1), (1,4) and (8,4).

Its area is (8-1) × (4-1) = 21.

Difficulty: interview

Starter code:

Solutions:
n,k=map(int,input().split())
points=[]
for _ in range(n):
    x,y=map(int,input().split())
    points.append((x,y))
points.sort()
ans=float('inf')
for i in range(n-k+1):
    for j in range(i+k-1,n):
        y_sorted=sorted(points[i:j+1],key=lambda x:x[1])
        height_min=float('inf')
        for l in range(j-i-k+2):
            height_min=min(height_min,y_sorted[l+k-1][1]-y_sorted[l][1])
            ans=min(ans,(points[j][0]-points[i][0])*height_min)
print(ans)

# 55:33
import numpy as np

N, K, *XY = list(map(int, open(0).read().split()))

X = XY[::2]
comp_X = {}
decomp_X = {}
for i, x in enumerate(sorted(set(X))):
    comp_X[x] = i
    decomp_X[i] = x

Y = XY[1::2]
comp_Y = {}
decomp_Y = {}
for i, y in enumerate(sorted(set(Y))):
    comp_Y[y] = i
    decomp_Y[i] = y

I = len(comp_X)
J = len(comp_Y)
comp_XY = [(comp_X[x], comp_Y[y]) for x, y in zip(X, Y)]
acc = np.zeros((I + 1, J + 1), np.int32)
for c_x, c_y in comp_XY:
    acc[c_x + 1][c_y + 1] += 1
acc = np.add.accumulate(acc, axis=0)
acc = np.add.accumulate(acc, axis=1)

ans = float("inf")
for i in range(1, I + 1):
    for j in range(1, J + 1):
        cur = acc[i:, j:] + acc[:-i, :-j] - acc[:-i, j:] - acc[i:, :-j]
        for k, row in enumerate(cur):
            for l, val in enumerate(row):
                if val >= K:
                    ans = min(
                        ans,
                        (decomp_X[k + i - 1] - decomp_X[k])
                        * (decomp_Y[l + j - 1] - decomp_Y[l]),
                    )
print(ans)


import sys
input = sys.stdin.readline
INF = 10**20
MOD = 10**9 + 7
from bisect import insort_left

def main():
    n,k = map(int,input().split())
    XY = [tuple(map(int,input().split())) for _ in range(n)]  
    XY.sort(key = lambda x:x[0])
    
    ans = INF
    for l in range(n - k + 1):
        Y = [XY[i][1] for i in range(l,l + k - 1)]
        Y.sort()
        dif = -1
        for r in range(l + k - 1, n):
            dif += 1
            insort_left(Y,XY[r][1])
            w = INF
            for i in range(dif + 1):
                w = min(w, Y[i + k - 1] - Y[i])
            ans = min(ans, w * (XY[r][0] - XY[l][0]))
    
    print(ans)   

def __starting_point():
    main()
__starting_point()

INF = float("inf")

N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

ans = INF
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        for j in range(k - K + 1):
            dy = YY[j + K - 1] - YY[j]
            ans = min(ans, dx * dy)

print(ans)

N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
X, Y = zip(*XY)
r = 10**20
for x0 in range(N - K + 1):
  for x1 in range(K + x0 - 1, N):
    x = X[x1] - X[x0]
    Y_s = sorted(Y[x0:x1 + 1])
    for y0 in range(len(Y_s) - K + 1):
      y = Y_s[y0 + K - 1] - Y_s[y0]
      r = min(r, x * y)
print(r)

INF = float("inf")

N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

ans = INF
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        for j in range(k - K + 1):
            dy = YY[j + K - 1] - YY[j]
            if ans > dx * dy:
                ans = dx * dy

print(ans)

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

xy.sort()

ans = float("inf")
for i in range(n):
    for j in range(i + k - 1, n):
        width = xy[j][0] - xy[i][0]
        y = [e for _, e in xy[i:j+1]]
        y.sort()
        for e1, e2 in zip(y, y[k-1:]):
            height = e2 - e1
            area = width * height
            ans = min(ans, area)

print(ans)


#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,K = map(int, input().split())
L = [tuple(map(int, input().split())) for i in range(N)]
L.sort()

ans = 10**20

for lx in range(N):
    for rx in range(lx+1,N+1):
        L2 = L[lx:rx]
        L2 = sorted(L2, key=lambda x:x[1])
        for ly in range(len(L2)):
            L3 = L2[ly:ly+K]
            if len(L3) >= K:
                ans = min(ans, (L[rx-1][0]-L[lx][0])*(L3[-1][1]-L3[0][1]))

print(ans)

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

#n = int(input())
#n,a = [int(i) for i in readline().split()]
n,k = [int(i) for i in readline().split()]
xy = [[int(i) for i in readline().split()] for i in range(n)]

xy.sort()
#print(xy)
ans = 4*10**18+10
for i in range(n):
    for j in range(i+k-1,n):
        dx = xy[j][0] - xy[i][0]
        y = sorted(xy[k][1] for k in range(i,j+1))
#        print(y,i,j)
        L = len(y)-k+1
        for i in range(L):
            dy = y[i+k-1]-y[i]
            ans = min(ans,dy*dx)
        


print(ans)

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
xy = [LIST() for _ in range(N)]
ans = INF

xy.sort()
for l in range(N-K+1):  #長方形の最も左の点
	for r in range(l+K, N+1):  #長方形の最も右の点
		y = sorted(xy[l:r], key = lambda x: x[1]) #lからrの中でyのとりうる値をソート
		for i in range(r-l-K+1):
			sq = (xy[r-1][0] - xy[l][0])*(y[i+K-1][1] - y[i][1])
			ans = min(ans, sq)
print(ans)

def main():
    n, k, *xy = list(map(int, open(0).read().split()))
    _x_ = sorted(xy[::2])
    ans = 4 * 10 ** 18
    for _x in _x_:
        for x_ in _x_[1:]:
            w = x_ - _x
            c = 0
            _h_ = []
            for x, y in zip(xy[::2], xy[1::2]):
                if _x <= x <= x_:
                    c += 1
                    _h_.append(y)

            if c >= k:
                _h_.sort()
                h = min(_h_[i + k - 1] - _h_[i] for i in range(c - k + 1))
                ans = min(ans, h * w)

    print(ans)


def __starting_point():
    main()

__starting_point()

n,h=map(int,input().split())
p,x,y=[],[],[]
z=float("inf")
for i in range(n):
  a,b=map(int,input().split())
  p.append((a,b))
  x.append(a)
  y.append(b)
x.sort()
y.sort()
for i in range(n-1):
  for j in range(i,n):
    for k in range(n-1):
      lx,rx,dy=x[i],x[j],y[k]
      c=0
      t=[]
      for a,b in p:
        if x[i]<=a<=x[j] and y[k]<=b:c+=1;t.append(b)
      if h<=c:z=min(z,(x[j]-x[i])*(sorted(t)[h-1]-y[k]))
print(z)

N, K = list(map(int, input().split()))
xy = []
for _ in range(N):
    xy.append(tuple(map(int, input().split())))

xy=sorted(xy, key=lambda x:x[0])
#print(xy)

lst=[]
for left in range(0, N-K+1):
    for right in range(left+K-1,N):
        #print(left, right)
        W = xy[right][0] - xy[left][0]
        #print(W)
        temp=sorted(xy[left:right+1], key=lambda x:x[1])
        #print(temp)
        #含まれる点の個数はright-left+1個
        for bottom in range(0, right-left+1 - K+1):
            #print('W', W, 'bottom',bottom)
            H = temp[bottom+K-1][1] - temp[bottom][1]
            #print('H', H)
            lst.append(H * W)
#print('lst',lst)
print((min(lst)))


#!/usr/bin/env python3
from itertools import combinations
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, K: int, x: "List[int]", y: "List[int]"):
    pts = sorted(zip(x, y))
    ys = sorted(y)
    ans = float("inf")
    for y1, y2 in combinations(ys, 2):
        xs = [x for x, y in pts if y1 <= y <= y2]
        if len(xs) >= K:
            ans = min(
                ans,
                (y2 - y1) * min(x2 - x1 for x1, x2 in zip(xs, xs[K - 1:]))
            )
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, K, x, y)


def __starting_point():
    main()

__starting_point()

import sys
from itertools import combinations
read = sys.stdin.read

N, K, *xy = map(int, read().split())
xy = sorted(zip(*[iter(xy)] * 2))
X, Y = zip(*xy)
answer = 10 ** 20

for left, right in combinations(range(N), 2):
    width = X[right] - X[left]
    tmp_Y = sorted(Y[left:right + 1])
    h = len(tmp_Y)
    for i in range(h):
        if i + K > h:
            break

        S = width * (tmp_Y[i + K - 1] - tmp_Y[i])
        if S < answer:
            answer = S

print(answer)

import itertools

N, K = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(N)]

X = sorted([x for x, _ in P])
Y = sorted([y for _, y in P])
dict_x = {v: k + 1 for k, v in enumerate(X)}
dict_y = {v: k + 1 for k, v in enumerate(Y)}

table = [[0] * (N + 1) for _ in range(N + 1)]
for x, y in P:
    table[dict_y[y]][dict_x[x]] = 1

for x in range(N + 1):
    for y in range(N):
        table[y + 1][x] += table[y][x]
for y in range(N + 1):
    for x in range(N):
        table[y][x + 1] += table[y][x]

ans = float('inf')
for x1, x2 in itertools.combinations(range(N), 2):
    for y1, y2 in itertools.combinations(range(N), 2):
        if table[y2 + 1][x2 + 1] - table[y2 + 1][x1] - table[y1][x2 + 1] + table[y1][x1] >= K:
            ans = min(ans, (X[x2] - X[x1]) * (Y[y2] - Y[y1]))
print(ans)

N, K = list(map(int, input().split()))
p_list = [[0] * 2 for i in range(N)]
for i in range(N):
    x, y = list(map(int, input().split()))
    p_list[i] = [x, y]

p_list.sort()
ans = float('inf')
for i in range(N - K + 1):
    for j in range(i + K - 1, N):
        x = abs(p_list[j][0] - p_list[i][0])
        y_list = []
        for k in range(i, j + 1):
            y_list.append((p_list[k][1]))
        y_list.sort()
        for k in range(len(y_list) - K + 1):
            ans = min(ans, x * abs(y_list[k + K - 1] - y_list[k]))

print(ans)


n,k=map(int,input().split())
x=[]
y=[]
xy=[]
for _ in range(n):
  xx,yy=map(int,input().split())
  xy.append((xx,yy))
  x.append(xx)
  y.append(yy)
xx=sorted(x)
yy=sorted(y)
ans=10**20
for sxi in range(n-1):
  for syi in range(n-1):
    for tyi in range(1,n):
      sx,sy,ty=xx[sxi],yy[syi],yy[tyi]
      ax=sorted([xxx for xxx,yyy in xy if sx<=xxx and sy<=yyy<=ty])
      if len(ax)<k:continue
      tx=ax[k-1]
      ans=min(ans,(tx-sx)*(ty-sy))
print(ans)

import sys
from bisect import bisect_left
input = sys.stdin.readline

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

x = [p[i][0] for i in range(n)]
x.sort()
y = [p[i][1] for i in range(n)]
y.sort()

coord = [[0] * n for i in range(n)]
for i in range(n):
    x_idx = bisect_left(x, p[i][0])
    y_idx = bisect_left(y, p[i][1])
    coord[x_idx][y_idx] += 1

coord_cs = [[0] * (n+1) for i in range(n+1)]
for i in range(n):
    for j in range(n):
        coord_cs[i+1][j+1] = coord[i][j]
for i in range(n):
    for j in range(n+1):
        coord_cs[i+1][j] += coord_cs[i][j]
for i in range(n+1):
    for j in range(n):
        coord_cs[i][j+1] += coord_cs[i][j]

# print(*coord, sep='\n')
# print(*coord_cs, sep='\n')

ans = (x[-1] - x[0]) * (y[-1] - y[0])
for xi in range(n):
    for xj in range(xi+1, n+1):
        for yi in range(n):
            for yj in range(yi+1, n+1):
                if coord_cs[xj][yj] - coord_cs[xi][yj] - coord_cs[xj][yi] + coord_cs[xi][yi] == k:
                    cand = (x[xj-1] - x[xi]) * (y[yj-1] - y[yi])
                    ans = min(ans, cand)

print(ans)


N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

cand = []
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        cand += [dx * (YY[j + K - 1] - YY[j]) for j in range(k - K + 1)]

print(min(cand))

N, K, *XY = [int(_) for _ in open(0).read().split()]
XY = sorted(zip(XY[::2], XY[1::2]))
ans = float('inf')
for i in range(N):
    for j in range(i + K - 1, N):
        xlen = XY[j][0] - XY[i][0]
        Y = sorted(y for x, y in XY[i:j + 1])
        ylen = min(y2 - y1 for y1, y2 in zip(Y, Y[K - 1:]))
        ans = min(ans, xlen * ylen)
print(ans)


n,k = list(map(int,input().split()))
l = [list(map(int,input().split())) for i in range(n)]
l.sort()
l1 = sorted(l,key=lambda x:x[1])
ans = float("INF")

for i in l:
    for j in l:
        if i[0] >= j[0]:
            continue
        for s in l1:
            count = 0
            for w,h in l1:
                if i[0] <= w <= j[0] and s[1] <= h:
                    count += 1
                if count==k:
                    ans = (min(ans,(j[0]-i[0])*(h-s[1])))
                    break
                
print(ans)


N,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
s = 10**19
B = sorted(A,key=lambda x:x[0])
for i in range(N-K+1):
    for j in range(K,N-i+1):
        xmin = B[i][0]
        xmax = B[i+j-1][0]
        By = sorted(B[i:i+j],key=lambda x:x[1])
        for k in range(len(By)-K+1):
            ymin = By[k][1]
            ymax = By[k+K-1][1]
            s = min(s,(xmax-xmin)*(ymax-ymin))
print(s)

import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(range(N),2):
  width = XY[right][0] - XY[left][0]
  pts = sorted(XY[left:right+1], key = lambda xy: xy[1])
  if len(pts) < K:
    continue
  for D in range(len(pts) - K + 1):
    if D + K - 1 >= len(pts):
      break
    y_max = pts[D+K-1][1]
    y_min = pts[D][1]
    area = (y_max - y_min) * width
    if area < answer:
      answer = area
    
print(answer)

n,h=list(map(int,input().split()))
p,x,y=[],[],[]
z=float("inf")
for i in range(n):
  a,b=list(map(int,input().split()))
  p.append((a,b))
  x.append(a)
  y.append(b)
x.sort()
y.sort()
for i in range(n-1):
  for j in range(i,n):
    for k in range(n-1):
      lx,rx,dy=x[i],x[j],y[k]
      c=0
      t=[]
      for a,b in p:
        if x[i]<=a<=x[j] and y[k]<=b:c+=1;t.append(b)
      if h<=c:z=min(z,(x[j]-x[i])*(sorted(t)[h-1]-y[k]))
print(z)


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


xy.sort()
ans = 2000000000 * (xy[-1][0] - xy[0][0])
for i in range(K-1, N):
  for j in range(N-i):
    xnow = xy[j+i][0] - xy[j][0]
    ylst = [xy[k][1] for k in range(j, j+i+1)]
    ylst.sort()
    ynow = min([ylst[k+K-1]-ylst[k] for k in range(i+2-K)])
    ans = min(ans, xnow*ynow)
    
print(ans)


# solution

import io
import math
import scipy.sparse
import numpy

nim, mike = map(int, input().split())
array = [list(map(int, input().split())) for i in range(nim)]

answer = 10**100
sortx = sorted(array, key = lambda x: x[0])
for a, pt1 in enumerate(sortx[:nim-mike+1]):
    for b, pt2 in enumerate(sortx[a+mike-1:]):
        #print(a,b)
        sorty = sorted(sortx[a:a+mike+b], key = lambda x: x[1])
        sorty_len = len(sorty)
        for c, pt3 in enumerate(sorty[:sorty_len-mike+1]):
            #print(len(sorty), c, k)
            pt4 = sorty[c+mike-1]
            #print(pt1, pt2, pt3, pt4)
            if pt3[1] <= pt1[1] and pt3[1] <= pt2[1] and pt4[1] >= pt1[1] and pt4[1] >= pt2[1]:
                answer = min(answer, (pt2[0] - pt1[0]) * (pt4[1] - pt3[1]))
print(answer)

N, K = (int(x) for x in input().split())
Plot = [tuple(int(x) for x in input().split()) for _ in range(N)]
X = [p[0] for p in Plot]
Y = [p[1] for p in Plot]
X.sort()
Y.sort()
#全2点間で長方形の辺を作り、その内内部点がK個のものだけ面積を比較する。
ans = 10e20
from itertools import combinations
for x1, x2 in combinations(X, 2):
    for y1 in Y:
        y2 = [y for x,y in Plot if x1 <= x <= x2 and y1 <= y]
        if len(y2) < K:
            break
        y2.sort()
        S = (x2-x1)*(y2[K-1]-y1)
        ans = min(ans, S)
print(ans)


n, k = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(n)]
XY.sort(key=lambda x: x[0])
XY = [xy + [x] for x, xy in enumerate(XY)]
XY.sort(key=lambda x: x[1])
XY = [xy + [y] for y, xy in enumerate(XY)]

gr = [[0] * n for _ in range(n)]
for _, _, i, j in XY:
  gr[i][j] = 1
  
rui = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n):
  for j in range(n):
    rui[i + 1][j + 1] = rui[i + 1][j] + rui[i][j + 1] - rui[i][j] + gr[i][j]
    
# XYの2点,3点,4点を総当たり
ans = 10 ** 21
for i in range(n - 1):
  for j in range(i + 1, n):
    x = [XY[m][0] for m in [i, j]]
    y = [XY[m][1] for m in [i, j]]
    ii = [XY[m][2] for m in [i, j]]
    jj = [XY[m][3] for m in [i, j]]
    innerPoints = rui[max(ii) + 1][max(jj) + 1] \
                + rui[min(ii)][min(jj)] \
                - rui[min(ii)][max(jj) + 1] \
                - rui[max(ii) + 1][min(jj)]
    if innerPoints >= k:
      area = (max(x) - min(x)) * (max(y) - min(y)) 
      if area < ans:
        ans = area

if n > 2:
  for i in range(n - 2):
    for j in range(i + 1, n - 1):
      for l in range(j + 1, n):
        x = [XY[m][0] for m in [i, j, l]]
        y = [XY[m][1] for m in [i, j, l]]
        ii = [XY[m][2] for m in [i, j, l]]
        jj = [XY[m][3] for m in [i, j, l]]
        innerPoints = rui[max(ii) + 1][max(jj) + 1] \
                    + rui[min(ii)][min(jj)] \
                    - rui[min(ii)][max(jj) + 1] \
                    - rui[max(ii) + 1][min(jj)]
        if innerPoints >= k:
          area = (max(x) - min(x)) * (max(y) - min(y)) 
          if area < ans:
            ans = area

if n > 3:
  for i in range(n - 3):
    for j in range(i + 1, n - 2):
      for l in range(j + 1, n - 1):
        for o in range(l + 1, n):
          x = [XY[m][0] for m in [i, j, o, l]]
          y = [XY[m][1] for m in [i, j, o, l]]
          ii = [XY[m][2] for m in [i, j, o, l]]
          jj = [XY[m][3] for m in [i, j, o, l]]
          innerPoints = rui[max(ii) + 1][max(jj) + 1] \
                      + rui[min(ii)][min(jj)] \
                      - rui[min(ii)][max(jj) + 1] \
                      - rui[max(ii) + 1][min(jj)]
          if innerPoints >= k:
            area = (max(x) - min(x)) * (max(y) - min(y)) 
            if area < ans:
              ans = area

print(ans)

n,k=map(int,input().split())
XY=[[0]*2 for i in range(n)]
X=[0]*n
Y=[0]*n
Z=[i for i in range(1,n+1)]
for i in range(n):
  X[i],Y[i]=map(int,input().split())
  XY[i]=[X[i],Y[i]]
X.sort()
Y.sort()
XX=dict(zip(X,Z))
YY=dict(zip(Y,Z))
XXX=dict(zip(Z,X))
YYY=dict(zip(Z,Y))
A=[[0]*n for i in range(n)]
for i in range(n):
  A[XX[XY[i][0]]-1][YY[XY[i][1]]-1]+=1
C=[[0]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,n+1):
    C[i][j]=C[i-1][j]+C[i][j-1]-C[i-1][j-1]+A[i-1][j-1]
ans=10**20
for i in range(1,n):
  for j in range(i+1,n+1):
    for s in range(1,n):
      for t in range(s+1,n+1):
        if C[j][t]-C[j][s-1]-C[i-1][t]+C[i-1][s-1]<k:
          continue
        a=(XXX[j]-XXX[i])*(YYY[t]-YYY[s])
        if a<ans:
          ans=a
print(ans)

def main():
    N, K = list(map(int, input().split()))
    XY = [tuple(map(int, input().split())) for _ in range(N)]
    XY.sort()
    XY = tuple(XY)

    def count(x_min, x_max, y_min, y_max, i, j):
        OK = 0
        # NG = 0
        for m, n in XY[i:j + 1]:
            if y_min <= n <= y_max:
                OK += 1
        if OK >= K:
            return True
        return False

    ans = 10 ** 20
    for i, val_i in enumerate(XY[:N - 1]):
        a = val_i[0]
        for j in range(i + K - 1, N):
            b = XY[j][0]
            e = b - a
            # print (e, i, j)
            for k, c in XY:
                # c = k[1]
                for l, d in XY:
                    # d = l[1]
                    if c < d:
                        if  e * (d - c) < ans and count(a, b, c, d, i, j):
                            # print ('A')
                            ans = e * (d - c)
                            # ans = min(ans, e * (d - c))
    print (ans)
    return

def __starting_point():
    main()

__starting_point()

n, k = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]
INF = 10 ** 19

xy.sort()

ans = INF
for i in range(n):
	for j in range(i + k - 1, n):
		width = xy[j][0] - xy[i][0]

		y = [xy[idx][1] for idx in range(i, j + 1)]
		y.sort()

		for e1, e2 in zip(y, y[k-1:]):
			height = e2 - e1
			area = width * height
			ans = min(ans, area)

print(ans)


N,K = map(int,input().split())
ary = [list(map(int,input().split())) for _ in range(N)]
a = sorted(ary)
ans = float("Inf")
for i in range(N-K+1):
    for j in range(i,N-K+1):
        lx = a[i][0]; rx = a[K+j-1][0]
        b = a[i:K+j]
        c = sorted(b,key=lambda x:(x[1]))
        for k in range(len(c)-K+1):
            by = c[k][1]; uy = c[k+K-1][1]
            ans = min(ans,(rx - lx) * (uy - by))
print(ans)

n, k = list(map(int,input().split()))
ps = [tuple(map(int,input().split())) for i in range(n)]

sx = sorted(ps,key = lambda x: x[0]) # x座標でソート
nx = list(enumerate(sx)) # 頂点番号を付加
ans = 5e18

for f, (x1,y1) in nx[:n-k+1]: # 左辺の頂点
    for e, (x2,y2) in nx[f+k-1:]: # 右辺の頂点
        dx = x2 - x1 # 横
        sy = sorted(y for x,y in sx[f:e+1]) # 含まれる頂点をy座標でソート
        for y3,y4 in zip(sy,sy[k-1:]): # y3=下辺の頂点，y4=上辺の頂点
            if y3 <= y1 and y4 >= y2: # 左右辺の頂点を含むこと
                ans = min(ans, dx * (y4 - y3))

print(ans)


import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, K = list(map(int, input().split()))
    xy = [list(map(int, input().split())) for i in range(N)]
    # 座標圧縮
    xs = []
    ys = []
    xy = sorted(xy, key=lambda x: x[0])
    for i in range(N):
        xs.append(xy[i][0])
        xy[i][0] = i+1
    xy = sorted(xy, key=lambda x: x[1])
    for i in range(N):
        ys.append(xy[i][1])
        xy[i][1] = i+1
    # 2次元累積和
    sum_ = np.zeros((N+1, N+1), dtype=int)
    for i in range(N):
        x, y = xy[i]
        sum_[y][x] = 1
    for i in range(1, N+1):
        sum_[i] += sum_[i-1]
    for i in range(1, N+1):
        sum_[:,i] += sum_[:,i-1]
    # 全探索
    ans = int(1e20)
    for l in range(1, N+1):
        no_three = True
        for r in range(N, l, -1):
            no_two = True
            for d in range(1, N+1):
                no_one = True
                for u in range(d+1, N+1):
                    tmp = sum_[u][r] - sum_[d-1][r] - sum_[u][l-1] + sum_[d-1][l-1]
                    if tmp >= K:
                        tmp = (xs[r-1] - xs[l-1]) * (ys[u-1] - ys[d-1])
                        ans = min(ans, tmp)
                        no_one = False
                        break
                if no_one:
                    break
                else:
                    no_two = False
            if no_two:
                break
            else:
                no_three = False
        if no_three:
            break
                

    print(ans)

def __starting_point():
    main()

__starting_point()

n,K=map(int,input().split())
xy=[]
x=[]
y=[]
for _ in range(n):
	X,Y=map(int,input().split())
	x.append(X+10**9)
	y.append(Y+10**9)
	xy.append((X+10**9,Y+10**9))
x.sort();y.sort();xy.sort()
num=[[0]*(n+1)for _ in range(n+1)]
for xx in xy:
	for i in range(n):
		if x[i]==xx[0]:
			break
	for j in range(n):
		if y[j]==xx[1]:
			break
	num[i+1][j+1]+=1
for i in range(n):
	for j in range(n):
		num[i+1][j+1]+=num[i+1][j]
for i in range(n):
	for j in range(n):
		num[i+1][j+1]+=num[i][j+1]
ans=10**20
for i in range(n):
	for j in range(n):
		for k in range(i+1,n+1):
			for l in range(j+1,n+1):
				if num[k][l]-num[i][l]-num[k][j]+num[i][j]>=K:
					r=(y[l-1]-y[j])*(x[k-1]-x[i])
					ans=min(ans,r)
print(ans)

"""
座標圧縮
2D累積和
全探索
勝利
"""
n, k = map(int,input().split())
xs = set()
ys = set()
ps = []
# 座圧
for _ in range(n):
    x,y = map(int,input().split())
    ps.append((x,y))
    xs.add(x)
    ys.add(y)
xdic = {x:i for i,x in enumerate(sorted(list(xs)))}
ydic = {y:i for i,y in enumerate(sorted(list(ys)))}
rxdic = {i:x for i,x in enumerate(sorted(list(xs)))}
rydic = {i:y for i,y in enumerate(sorted(list(ys)))}

# 2D累積和
h = len(xdic)
w = len(ydic)
A = [[0 for i in range(w+1)] for j in range(h+1)]
Acum = [[0 for i in range(w+1)] for j in range(h+1)]

for x,y in ps:
    h = xdic[x]
    w = ydic[y]
    A[h][w] += 1

for i in range(len(xdic)):
    for j in range(len(ydic)):
        Acum[i+1][j+1] = Acum[i][j+1] + Acum[i+1][j] - Acum[i][j] + A[i][j]
      
# 探索
ans = 1 << 100
h = len(xdic)
w = len(ydic)
for i1 in range(h+1):
    for i2 in range(i1+1,h+1):
        for j1 in range(w+1):
            for j2 in range(j1+1,w+1):
                num = Acum[i2][j2]-Acum[i1][j2]-Acum[i2][j1]+Acum[i1][j1]
                # print((i1,i2),(j1,j2),num)
                if num == k:
                    x1 = rxdic[i1]
                    x2 = rxdic[i2-1]
                    y1 = rydic[j1]
                    y2 = rydic[j2-1]
                    S = (x2-x1)*(y2-y1)
                    ans = min(ans, S)
print(ans)

def abc075_d():
    n, k = map(int, input().split())
    P = []
    xarr = []
    yarr = []
    for _ in range(n):
        x, y = (int(x) for x in input().split())
        P.append((x, y))
        xarr.append(x)
        yarr.append(y)
    xarr.sort()
    yarr.sort()

    ans = 5*10**18
    for s, xi in enumerate(xarr):
        for xj in xarr[s+1:]:
            cand = [(x, y) for x, y in P if xi <= x and x <= xj]
            for t, yi in enumerate(yarr):
                for yj in yarr[t+1:]:
                    cnt = len([y for x, y in cand if yi <= y and y <= yj])
                    if cnt >= k:
                        area = (xj - xi) * (yj - yi)
                        ans = min(ans, area)
    print(ans)

def __starting_point():
    abc075_d()
__starting_point()

from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,k=MI()
    xx=set()
    yy=set()
    xy=[]
    for _ in range(n):
        x,y=MI()
        xy.append((x,y))
        xx.add(x)
        yy.add(y)
    xy.sort()
    xx=list(sorted(xx))
    yy = list(sorted(yy))
    xn=len(xx)
    yn=len(yy)
    ans=10**20
    for t in range(yn):
        y2=yy[t]
        for b in range(t):
            y1=yy[b]
            r=-1
            s=0
            i=j=0
            for l,x1 in enumerate(xx):
                while i<n and xy[i][0]<x1:
                    if y1 <= xy[i][1] <= y2: s -= 1
                    i += 1
                while s<k and r+1<xn:
                    r+=1
                    x2=xx[r]
                    while j<n and xy[j][0]<=x2:
                        if y1<=xy[j][1]<=y2:s+=1
                        j+=1
                if s>=k:
                    cur=(x2-x1)*(y2-y1)
                    if cur<ans:ans=cur
    print(ans)

main()

from itertools import accumulate
from operator import add

N, K = list(map(int, input().split()))
xs, ys = [], []
for _ in range(N):
    x, y = list(map(int, input().split()))
    xs.append(x)
    ys.append(y)

iXs = list(range(N))
iXs.sort(key=lambda iX: xs[iX])
odrXs = [0]*(N)
for odrX, iX in enumerate(iXs):
    odrXs[iX] = odrX
iYs = list(range(N))
iYs.sort(key=lambda iY: ys[iY])
odrYs = [0]*(N)
for odrY, iY in enumerate(iYs):
    odrYs[iY] = odrY

Ass = [[0]*(N) for _ in range(N)]
for odrX, odrY in zip(odrXs, odrYs):
    Ass[odrX][odrY] = 1

def getAccAss(Ass):
    accAss = [[0] * (len(Ass[0])+1)] + [accumulate([0] + As) for As in Ass]
    for x in range(1, len(accAss)):
        accAss[x] = list(map(add, accAss[x], accAss[x-1]))
    return accAss
def getRangeSum2D(accAss, xFr, xTo, yFr, yTo):
    return accAss[xTo+1][yTo+1] - accAss[xTo+1][yFr] - accAss[xFr][yTo+1] + accAss[xFr][yFr]

accAss = getAccAss(Ass)

ans = 10**20
for xFr in range(N-1):
    for xTo in range(xFr+1, N):
        for yFr in range(N-1):
            for yTo in range(yFr+1, N):
                num = getRangeSum2D(accAss, xFr, xTo, yFr, yTo)
                if num >= K:
                    area = (xs[iXs[xTo]]-xs[iXs[xFr]]) * (ys[iYs[yTo]]-ys[iYs[yFr]])
                    ans = min(ans, area)

print(ans)


import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for i, j in itertools.combinations(list(range(N)), 2):
    xleft = XY[i][0]
    xright = XY[j][0]
    candidate = sorted(XY[i:j+1], key=lambda xy: xy[1])
    if len(candidate) < K:
        continue
    for s in range(len(candidate) - K + 1):
        yup = candidate[s+K-1][1]
        ylow = candidate[s][1]
        area = (xright - xleft) * (yup - ylow)
        if area < answer:
            answer = area

print(answer)
# 31


from itertools import combinations, product
import bisect as bs

def tuple_int(iterable):
    return tuple(map(int, iterable.split()))

def S_with_K_plots(plots, K):
    result = []
    X, Y = sorted([x for x,y in plots]), sorted([y for x,y in plots])
    for xinf, xsup in combinations(X,2):
        for yinf in Y:
            ysup = [y for x,y in plots if xinf<=x<=xsup and y >= yinf]
            if len(ysup) < K: continue
            ysup.sort()
            result.append((xsup-xinf)*(ysup[K-1]-yinf))
    return result

def __starting_point():
    with open(0) as f:
        N, K = map(int, f.readline().split())
        plots = list(map(tuple_int, f.readlines()))
    print(min(S_with_K_plots(plots, K)))
__starting_point()

N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
X, Y = zip(*XY)
r = float('inf')
for x0 in range(N - K + 1):
  for x1 in range(K + x0 - 1, N):
    x = X[x1] - X[x0]
    Y_s = sorted(Y[x0:x1 + 1])
    for y0 in range(len(Y_s) - K + 1):
      y = Y_s[y0 + K - 1] - Y_s[y0]
      r = min(r, x * y)
print(r)

#!/usr/bin/env python3
import sys
from itertools import combinations

def _solve(y1, y2, sorted_points, K):
    y1, y2 = tuple(sorted([y1, y2]))
    x = tuple(x for x, y in sorted_points if y1 <= y <= y2)
    if len(x) < K:
        return float('inf')
    return min((y2 - y1) * (x2 - x1) for x1, x2 in zip(x, x[K-1:]))

def solve(N: int, K: int, x: "List[int]", y: "List[int]"):
    sorted_points = tuple(sorted(zip(x, y)))
    return min(_solve(y1, y2, sorted_points, K) for y1, y2 in combinations(y, 2))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print((solve(N, K, x, y)))

def __starting_point():
    main()

__starting_point()

import numpy as np

N, K, *XY = list(map(int, open(0).read().split()))

X = XY[::2]
comp_X = {}
decomp_X = {}
for i, x in enumerate(sorted(set(X))):
    comp_X[x] = i
    decomp_X[i] = x

Y = XY[1::2]
comp_Y = {}
decomp_Y = {}
for i, y in enumerate(sorted(set(Y))):
    comp_Y[y] = i
    decomp_Y[i] = y

I = len(comp_X)
J = len(comp_Y)
comp_XY = [(comp_X[x], comp_Y[y]) for x, y in zip(X, Y)]
acc = np.zeros((I + 1, J + 1), np.int32)
for c_x, c_y in comp_XY:
    acc[c_x + 1][c_y + 1] += 1
acc = np.add.accumulate(acc, axis=0)
acc = np.add.accumulate(acc, axis=1)

ans = float("inf")
for i in range(1, I + 1):
    for j in range(1, J + 1):
        cur = acc[i:, j:] + acc[:-i, :-j] - acc[:-i, j:] - acc[i:, :-j]
        for k, row in enumerate(cur):
            for l, val in enumerate(row):
                if val >= K:
                    ans = min(
                        ans,
                        (decomp_X[k + i - 1] - decomp_X[k])
                        * (decomp_Y[l + j - 1] - decomp_Y[l]),
                    )
print(ans)


import collections, itertools, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    xy = [LI() for _ in range(N)]

    # x, y全ての重複あり組み合わせに対して含まれる点の個数を算出する

    x_coord = [i[0] for i in xy]
    x_coord.sort()
    x_val_num = {x_coord[i]: i for i in range(N)}
    y_coord = [i[1] for i in xy]
    y_coord.sort()
    y_val_num = {y_coord[i]: i for i in range(N)}

    # 2次元累積和
    xy_cnt = [[0] * N for _ in range(N)]
    for x, y in xy:
        xy_cnt[y_val_num[y]][x_val_num[x]] = 1
    # for i in xy_cnt:
    #     print(i)
    xy_acm = [[0] * (N + 1) for _ in range(N + 1)]
    for i in range(N):
        for j in range(N):
            xy_acm[i+1][j+1] = xy_cnt[i][j] + xy_acm[i+1][j] + xy_acm[i][j+1] - xy_acm[i][j]
    # for i in xy_acm:
    #     print(i)

    ans = INF
    for yl, yu in itertools.combinations(list(range(N + 1)), 2):
        for xl, xu in itertools.combinations(list(range(N + 1)), 2):
            cnt = xy_acm[yu][xu] - xy_acm[yu][xl] - xy_acm[yl][xu] + xy_acm[yl][xl]
            # print(cnt, yl, yu, xl, xu)
            if cnt >= K:
                ans = min((x_coord[xu-1] - x_coord[xl]) * (y_coord[yu-1] - y_coord[yl]), ans)

    print(ans)

def __starting_point():
    resolve()

__starting_point()

from bisect import bisect_left
import sys
input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    XY = [list(map(int, input().split())) for _ in range(N)]

    Xs = []
    Ys = []
    for x, y in XY:
        Xs.append(x)
        Ys.append(y)
    Xs.sort()
    Ys.sort()
    points = [[0 for _ in range(N)] for _ in range(N)]

    for x, y in XY:
        ix = bisect_left(Xs, x)
        iy = bisect_left(Ys, y)
        points[ix][iy] += 1

    sumpoints = [[0 for _ in range(N+1)] for _ in range(N+1)]

    for ix in range(1, N+1):
        s = 0
        for iy in range(1, N+1):
            if ix == 1:
                sumpoints[ix][iy] = points[ix-1][iy-1]
            if points[ix-1][iy-1] == 1:
                s = 1
            sumpoints[ix][iy] = sumpoints[ix-1][iy] + s

    ans = int(8E18)
    for lx in range(N-1):
        for rx in range(lx+1, N):
            for ly in range(N-1):
                for ry in range(ly+1, N):
                    if sumpoints[rx+1][ry+1] - sumpoints[rx+1][ly] - sumpoints[lx][ry+1] + sumpoints[lx][ly] >= K:
                        s = (Xs[rx]-Xs[lx])*(Ys[ry]-Ys[ly])
                        ans = min(ans, s)
    print(ans)

def __starting_point():
    main()
__starting_point()

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

xy.sort()
ans = 10**20

for i in range(n):
    for j in range(i,n):
        xy_tmp = xy[i:j+1]
        if len(xy_tmp) >= k:
            l1 = xy_tmp[0][0]
            r1 = xy_tmp[-1][0]
            xy_tmp.sort(key = lambda x: x[1])
            for jj in range(len(xy_tmp) - k + 1):
                ans = min(ans, (r1-l1) * (xy_tmp[k+jj-1][1] - xy_tmp[jj][1]))

print(ans)


N, K = list(map(int, input().split()))
pts = []
ys = []
for _ in range(N):
    x, y = list(map(int, input().split()))
    pts.append((x, y))
    ys.append(y)

pts.sort()
ys.sort()

ans = 10**20
for i, y1 in enumerate(ys):
    for y2 in ys[i+1:]:
        for j, (x1, _) in enumerate(pts):
            num = 0
            for x, y in pts[j:]:
                if y1 <= y <= y2:
                    num += 1
                if num >= K:
                    area = (x-x1) * (y2-y1)
                    ans = min(ans, area)
                    break

print(ans)


N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

ans = 1e20
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        ans = min(ans, min(dx * (YY[j + K - 1] - YY[j]) for j in range(k - K + 1)))

print(ans)

def da_generate(h,w,a):
    da = [[0]*w for j in range(h)]
    da[0][0] = a[0][0]
    for i in range(1,w):
        da[0][i] = da[0][i-1]+a[0][i]
    for i in range(1,h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            da[i][j] = da[i-1][j]+cnt_w
    return da

def da_calc(da,p,q,x,y):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y]-da[x][q-1]
    if q == 0:
        return da[x][y]-da[p-1][y]
    return da[x][y]-da[p-1][y]-da[x][q-1]+da[p-1][q-1]

n , k = map(int,input().split())
mototen = []
atuten = []
zax = []
zay = []
for i in range(n):
    x , y = map(int,input().split())
    mototen.append((x,y))
    zax.append(x)
    zay.append(y)
zax.sort()
zay.sort()

a = [[0 for i in range(len(zay))] for j in range(len(zax))]

for x , y in mototen:
    atx = zax.index(x)
    aty = zay.index(y)
    a[atx][aty] += 1
b = da_generate(len(zax),len(zay),a)
ans = float("inf")
for p in range(len(zax)-1):
    for q in range(len(zay)-1):
        for x in range(p+1,len(zax)):
            for y in range(q+1,len(zax)):
                kar = da_calc(b,p,q,x,y)
                if kar >= k:
                    men = (zax[x]-zax[p])*(zay[y]-zay[q])
                    ans = min(ans,men)
print(ans)

N,K = list(map(int,input().split()))
p = sorted([list(map(int,input().split())) for _ in range(N)])
x, y = list(zip(*p))
inf = float('inf')
ans = inf

for i in range(N-K+1):
    for j in range(K+i-1, N):
        Ys = sorted(y[i:j+1])
        for k in range(len(Ys)-K+1):
            ans = min(ans, (x[j]-x[i])*(Ys[k+K-1]-Ys[k]))
print(ans)


n,k,*L=map(int,open(0).read().split())
X=[];Y=[]
for x,y in sorted((x,y) for x,y in zip(*[iter(L)]*2)):
	X.append(x)
	Y.append(y)
ans=float("inf")
for i in range(n-k+1):
	for j in range(i+k-1,n):
		w=X[j]-X[i]
		l=sorted(Y[i:j+1])
		h=min(My-my for my,My in zip(l,l[k-1:]))
		ans=min(ans,w*h)
print(ans)

def solve():
  n, k = map(int, input().split())
  p = [tuple(map(int, input().split())) for i in range(n)]
  p.sort()
  ans = 4000000000000000000
  for i in range(k, n + 1):
      for j in range(n - i + 1):
          x = p[i + j - 1][0] - p[j][0]
          s = [p[a][1] for a in range(j, i + j)]
          s.sort()
          y = 4000000000
          for a in range(i - k + 1):
            y = min(y, s[a + k - 1] - s[a])
          ans = min(ans, x * y)
  print(ans)
solve()

import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
sys.setrecursionlimit(10**6)

n,k = na()
xy = []

for i in range(n):
    x,y = na()
    xy.append((x,y))

xy.sort()
ans = 10000000000000000000000000000

for i in range(n):
    for j in range(i+1, n):
        x = xy[j][0] - xy[i][0]
        yy = sorted(xy[i:j+1], key=lambda x:x[1])
        for u in range(len(yy)-k+1):
            y = yy[u+k-1][1] - yy[u][1]
            ans = min(ans, y*x)
            
print(ans)


N, K = list(map(int, input().split()))
P = sorted([tuple(map(int, input().split())) for _ in range(N)])

ans = 1e30
for lx in range(N):
    for rx in range(lx+K, N+1):
        Q = sorted(P[lx:rx], key=lambda x:x[1])
        for ly in range(len(Q)):
            R = Q[ly:ly+K]
            if len(R)>=K: ans = min(ans, (P[rx-1][0]-P[lx][0])*(R[-1][1]-R[0][1]))
print(ans)

n,k=map(int,input().split())
li=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:(x[1],x[0]))
ans=float("INF")
#print(li)
for i in range(n):
    for j in range(i+1,n):
        ux,lx=max(li[i][0],li[j][0]),min(li[i][0],li[j][0])
        l,r=0,0
        cnt=int(lx<=li[r][0]<=ux)
#        print("!",ux,lx,"!",end="")
        while True:
#            print("cnt:",cnt,end="")
            while r<n-1 and cnt<k:
                r+=1
                cnt+=int(lx<=li[r][0]<=ux)
            if cnt<k or not(0<=r<=n-1) or not(0<=l<=n-1) or r<=l :break
            if ans>(ux-lx)*(li[r][1]-li[l][1]):
                ans=(ux-lx)*(li[r][1]-li[l][1])
#                print(i,j,l,r,cnt,ans)
            cnt-=int(lx<=li[l][0]<=ux)
            l+=1
print(ans)

# coding: utf-8

# 11:50-
# 50min: give up
# 15:15-15:58 done


def main():
    N, K = list(map(int, input().split()))
    x, y = [None] * N, [None] * N
    for i in range(N):
        x[i], y[i] = list(map(int, input().split()))
    
    points = [[i, x[i], y[i]] for i in range(N)]
    points_ysort = sorted(points, key=lambda p: p[2], reverse=True)
    points_ysort_rev = list(reversed(points_ysort))
    points_xsort = sorted(points, key=lambda p: p[1], reverse=False)
    points_xsort_rev = list(reversed(points_xsort))
    
    min_area = 4 * (10**18)
    outsides_top = []
    
    t = 0
    while t <= N-K:
        # n_inside = N - t

        top_i, top_x, top_y = points_ysort[t]

        outsides_bottom = []
        b = 0
        while b < N:
            # n_inside -= b

            bottom_i, bottom_x, bottom_y = points_ysort_rev[b]

            if bottom_i == top_i:
                break

            # outsides_left = []
            n_outsides_left = 0
            l = 0
            while l < N:
                left_i, left_x, left_y = points_xsort[l]

                if left_x > top_x:
                    break

                if left_i in outsides_top or left_i in outsides_bottom:
                    l += 1
                    continue
                
                # outsides_right = []
                n_outsides_right = 0
                r = 0
                while r < N:
                    if N - t - b - n_outsides_left - n_outsides_right < K:
                        break

                    right_i, right_x, right_y = points_xsort_rev[r]

                    if right_i == left_i:
                        break
                    
                    if right_x < top_x:
                        break
                    
                    if right_i in outsides_top or right_i in outsides_bottom:
                        r += 1
                        continue

                    area = (top_y - bottom_y) * (right_x - left_x)
                    if area < min_area:
                        min_area = area
                    
                    # outsides_right.append(right_i)
                    n_outsides_right += 1
                    r += 1
                
                # outsides_left.append(left_i)
                n_outsides_left += 1
                l += 1
            
            outsides_bottom.append(bottom_i)
            b += 1
        
        outsides_top.append(top_i)
        t += 1

    return min_area


print((main()))


from itertools import combinations


N, K, *XY = list(map(int, open(0).read().split()))
X = sorted(XY[::2])
Y = sorted(XY[1::2])

ans = 10 ** 20
for x1, x2 in combinations(X, 2):
    for y1 in Y[:-1]:
        y2s = sorted(y for x, y in zip(*[iter(XY)] * 2) if x1 <= x <= x2 and y1 <= y)
        if len(y2s) < K:
            continue
        ans = min(ans, (x2 - x1) * (y2s[K - 1] - y1))
print(ans)



import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
xy = [LIST() for _ in range(N)]
ans = INF
xy.sort()
for l in range(N-K+1):  # 長方形に含まれる最も左の点
    for r in range(l+K, N+1):  # 長方形に含まれる最も右の点
        y = sorted(xy[l:r], key = lambda x: x[1])  # lからrの中でのyのとりうる値をソート
        for i in range(r-l-K+1):
            sq = (xy[r-1][0] - xy[l][0]) * (y[i+K-1][1] - y[i][1])  # 下からKこ選んだときの面積
            ans = min(ans, sq)
print(ans)


import sys

inf = float('inf')

n, k, *xy = map(int, sys.stdin.read().split())
xy = list(zip(*[iter(xy)] * 2))

def main():
    xy.sort(key=lambda x: x[0])
    x = []
    y = []
    for i in range(n):
        x.append(xy[i][0])
        y.append(xy[i][1])
    
    area = inf
    for l in range(n-k+1):
        for r in range(l+k-1, n):
            dx = x[r] - x[l]
            seq_y = sorted(y[l:r+1])
            m = r - l + 1
            for d in range(m-k+1):
                for u in range(d+k-1, m):
                    dy = seq_y[u] - seq_y[d]
                    area = min(area, dx * dy)

    return area

def __starting_point():
    ans = main()
    print(ans)
__starting_point()

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

XY.sort(key=lambda x: x[0])

ans = float("INF")
for i in range(N):
    for j in range(i+K-1, N):
        W = XY[j][0] - XY[i][0]
        Y = [XY[x][1] for x in range(i, j+1)]
        Y.sort()
        for l, k in zip(Y, Y[K-1:]):
                H = k - l
                ans = min(ans, W*H)

print(ans)

#075_D
n, k = map(int, input().split())
xy = [tuple(map(int, input().split())) for _ in range(n)]
ans = 10 ** 50
xy.sort()
for l in range(0, n):
    for r in range(l+k-1, n):
        y = [xy[i][1] for i in range(l, r+1)]
        y.sort()
        h = 10 ** 50
        for i in range(len(y)-k+1):
            h = min(h, y[i+k-1] - y[i])
        ans = min(ans, h * (xy[r][0] - xy[l][0]))
print(ans)

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

ans = float("Inf")
for i in range(n-k+1):
    for j in range(k,n-i+1):
        xmin = ary[i][0]
        xmax = ary[i+j-1][0]
        ary_y = sorted(ary[i:i+j], key=lambda x: (x[1]))
        for l in range(len(ary_y)-k+1):
            ymin = ary_y[l][1]
            ymax = ary_y[l+k-1][1]
            ans = min(ans,(xmax - xmin) * (ymax - ymin))
print(ans)

from itertools import combinations
def main():
    N, K = list(map(int, input().split()))
    P = [list(map(int, input().split())) for _ in range(N)]
    ans = 1<<62
    for t in combinations(P, min(4, K)):
        xs, ys = list(zip(*t))
        xmin = min(xs)
        xmax = max(xs)
        ymin = min(ys)
        ymax = max(ys)
        area = (xmax-xmin) * (ymax-ymin)
        if ans < area:
            continue
        k = 0
        for x, y in P:
            if xmin <= x <= xmax and ymin <= y <= ymax:
                k += 1
        if k >= K:
            ans = area
    print(ans)

main()


N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

cand = []
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        cand.append(min(dx * (YY[j + K - 1] - YY[j]) for j in range(k - K + 1)))

print(min(cand))

import sys
from bisect import bisect_left
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *XY = list(map(int, read().split()))

    X = set()
    Y = set()
    for i, (x, y) in enumerate(zip(*[iter(XY)] * 2)):
        X.add(x - 1)
        Y.add(y - 1)

    X = sorted(X)
    Y = sorted(Y)

    P, Q = len(X), len(Y)

    G = [[0] * Q for _ in range(P)]
    for x, y in zip(*[iter(XY)] * 2):
        G[bisect_left(X, x - 1)][bisect_left(Y, y - 1)] = 1

    csum = [[0] * (Q + 1) for _ in range(P + 1)]
    for i in range(P):
        for j in range(Q):
            csum[i + 1][j + 1] = csum[i + 1][j] + csum[i][j + 1] - csum[i][j] + G[i][j]

    ans = -1
    for x1 in range(P):
        for x2 in range(x1, P + 1):
            for y1 in range(Q):
                for y2 in range(y1, Q + 1):
                    if csum[x2][y2] - csum[x1][y2] - csum[x2][y1] + csum[x1][y1] >= K:
                        if ans > (X[x2 - 1] - X[x1]) * (Y[y2 - 1] - Y[y1]) or ans == -1:
                            ans = (X[x2 - 1] - X[x1]) * (Y[y2 - 1] - Y[y1])

    print(ans)
    return


def __starting_point():
    main()

__starting_point()

from itertools import accumulate
n, k = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(n)]
X, Y = zip(*XY)
def compress(arr):
    *XS, = set(arr)
    XS.sort()
    return {e: i+1 for i, e in enumerate(XS)}
Xlabel = compress(X)
Ylabel = compress(Y)
rX = {j:i for i,j in Xlabel.items()}
rY = {j:i for i,j in Ylabel.items()}
lX = len(Xlabel)
lY = len(Ylabel)
F = [[0]*(lX+1) for _ in range(lY+1)]
for x, y in XY:
  F[Ylabel[y]][Xlabel[x]] = 1
for i in range(lY):
  F[i+1] = list(accumulate(F[i+1]))
F = list(zip(*F))
for j in range(lY):
  F[j+1] = list(accumulate(F[j+1]))
F = list(zip(*F))
ans = float("inf")
for y1 in range(lY):
  for y2 in range(y1+1, lY+1):
    for x1 in range(lX):
      for x2 in range(x1+1, lX+1):
        count = F[y2][x2] - F[y1][x2] - F[y2][x1] + F[y1][x1]
        if count >= k:
          temp = (rX[x2]-rX[x1+1]) * (rY[y2]-rY[y1+1])
          ans = min(ans, temp)
print(ans)

N, K = list(map(int, input().split()))
XY = []
X = []
Y = []
for _ in range(N):
    x, y = list(map(int, input().split()))
    XY.append((x, y))
    X.append(x)
    Y.append(y)
X.sort()
Y.sort()
ix = {v: i for i, v in enumerate(X)}
iy = {v: i for i, v in enumerate(Y)}
m = [[0] * (len(X) + 1) for _ in range(len(Y) + 1)]
for x, y in XY:
    m[iy[y] + 1][ix[x] + 1] += 1
for y in range(len(Y) + 1):
    for x in range(len(X)):
        m[y][x + 1] += m[y][x]
for x in range(len(X) + 1):
    for y in range(len(Y)):
        m[y + 1][x] += m[y][x]
ans = float("inf")
for x0 in range(len(X) - 1):
    for x1 in range(x0 + 1, len(X)):
        for y0 in range(len(Y) - 1):
            for y1 in range(y0 + 1, len(Y)):
                n = m[y1 + 1][x1 + 1] - m[y0][x1 + 1] - \
                    m[y1 + 1][x0] + m[y0][x0]
                if n >= K:
                    s = (X[x1] - X[x0]) * (Y[y1] - Y[y0])
                    ans = min(ans, s)
print(ans)


import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
xy = [LIST() for _ in range(N)]
ans = INF
xy.sort()
for l in range(N-K+1):  # 長方形に含まれる最も左の点
    for r in range(l+K, N+1):  # 長方形に含まれる最も右の点
        y = sorted(xy[l:r], key = lambda x: x[1])  # lからrの中でのyのとりうる値をソート
        for i in range(r-l-K+1):
            sq = (xy[r-1][0] - xy[l][0]) * (y[i+K-1][1] - y[i][1])  # 下からKこ選んだときの面積
            ans = min(ans, sq)
print(ans)


n,k = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
ax = sorted(a)
ans = 10**19
for i in range(n-1):
    for j in range(i+1,n):
        a_use = ax[i:j+1]
        xnum = len(a_use)
        sx = a_use[-1][0]-a_use[0][0]
        a_use.sort(key = lambda x:x[1])
        if xnum<k:
            continue
        for y1 in range(xnum-k+1):
            y2 = y1+k-1
            s = sx*(a_use[y2][1]-a_use[y1][1])
            ans = min(ans,s)
print(ans)

N,K,*xy = map(int, open(0).read().split())
_x_ = sorted(xy[::2])
ans = 4 * 10 ** 18
for _x in _x_:
  for x_ in _x_[1:]:
    w = x_ - _x
    c = 0
    _h_ = []
    for x, y in zip(xy[::2], xy[1::2]):
      if _x <= x <= x_:
        c += 1
        _h_.append(y)
      if c >= K:
        _h_.sort()
        h = min(_h_[i + K - 1] - _h_[i] for i in range(c - K + 1))
        ans = min(ans, h * w)

print(ans)

import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().rstrip().split()])


# ===CODE===

def main():
    n, k = ns()
    pos = []
    for _ in range(n):
        x, y = ns()
        pos.append((x, y))

    ans = INF
    for tmp in itertools.combinations_with_replacement(pos, 4):
        xl = max(tmp, key=lambda t: t[0])[0]
        xs = min(tmp, key=lambda t: t[0])[0]
        yl = max(tmp, key=lambda t: t[1])[1]
        ys = min(tmp, key=lambda t: t[1])[1]

        cnt = 0
        for xi, yi in pos:
            if xs <= xi <= xl and ys <= yi <= yl:
                cnt += 1
        if cnt >= k:
            ans = min(ans, (xl - xs) * (yl - ys))

    print(ans)

def __starting_point():
    main()

__starting_point()

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    inf=10**20
    n,k=map(int,readline().split())
    co=[list(map(int,readline().split())) for _ in range(n)]
    
    co.sort()
    
    x_range=[]
    for i in range(n-1):
        for j in range(i+1,n):
            x_range.append((co[i][0],co[j][0]))

    co.sort(key=lambda x:x[1])
    ans=inf
    for x in x_range:
        x_min=x[0]
        x_max=x[1]
        y_min=0
        y_max=0
        for under in range(n):
            cnt=0
            for i in range(under,n):
                if x_min<=co[i][0]<=x_max:
                    if cnt==0:
                        y_min=co[i][1]
                        cnt+=1
                    else:
                        y_max=co[i][1]
                        cnt+=1
                if cnt==k:
                    break
            if cnt==k:
                ans=min(ans,(x_max-x_min)*(y_max-y_min))

    print(ans)

def __starting_point():
    main()
__starting_point()

import collections, itertools, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    xy = [LI() for _ in range(N)]

    # 全ての長方形候補に対して、2次元累積和を使って内部の点の個数を算出する
    x_coord = [i[0] for i in xy]
    x_coord.sort()
    x_val_num = {x_coord[i]: i for i in range(N)}
    y_coord = [i[1] for i in xy]
    y_coord.sort()
    y_val_num = {y_coord[i]: i for i in range(N)}

    # 2次元累積和の計算
    xy_cnt = [[0] * N for _ in range(N)]
    for x, y in xy:
        xy_cnt[y_val_num[y]][x_val_num[x]] = 1
    # for i in xy_cnt:
    #     print(i)
    xy_acm = [[0] * (N + 1) for _ in range(N + 1)]
    for i in range(N):
        for j in range(N):
            xy_acm[i+1][j+1] = xy_cnt[i][j] + xy_acm[i+1][j] + xy_acm[i][j+1] - xy_acm[i][j]
    # for i in xy_acm:
    #     print(i)

    ans = INF
    for yl, yu in itertools.combinations(list(range(N + 1)), 2):
        for xl, xu in itertools.combinations(list(range(N + 1)), 2):
            cnt = xy_acm[yu][xu] - xy_acm[yu][xl] - xy_acm[yl][xu] + xy_acm[yl][xl]
            # print(cnt, yl, yu, xl, xu)
            if cnt >= K:
                ans = min((x_coord[xu-1] - x_coord[xl]) * (y_coord[yu-1] - y_coord[yl]), ans)

    print(ans)

def __starting_point():
    resolve()

__starting_point()

N,K = map(int,input().split())
xy = []
for i in range(N):
  xy.append(tuple(map(int,input().split())))
xy=sorted(xy,key=lambda x : x[0])
lst=[]
for left in  range(0,N-K+1):
  for  right in range(left+K-1,N):
    W = xy[right][0] - xy[left][0]
    temp = sorted(xy[left:right+1], key =  lambda x :x[1])
    for bottom in range(0,right-left+1-K+1):
      H = temp[bottom+K-1][1]-temp[bottom][1]
      lst.append(H*W)
print(min(lst))

N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
r = 10**20
for xi0 in range(N - K + 1):
  for xi1 in range(K + xi0 - 1, N):
    x = XY[xi1][0] - XY[xi0][0]
    XY_ys = sorted(XY[xi0:xi1 + 1], key=lambda a: a[1])
    for yi0 in range(len(XY_ys) - K + 1):
      y = XY_ys[yi0 + K - 1][1] - XY_ys[yi0][1]
      r = min(r, x * y)
print(r)

N,K = map(int,input().split())
A = sorted([list(map(int,input().split()))for n in range(N)])
ans = float("inf")

for i in range(N-K+1):
  for j in range(i+K-1,N):
    P = A[j][0]-A[i][0]
    C = sorted([a[1] for a in A[i:j+1]])
    for k in range(j-i-K+2):
      Q = C[k+K-1]-C[k]
      ans = min(ans,P*Q)

print(ans)

import sys
I = lambda:[int(x) for x in sys.stdin.readline().split()]
N,K = I()
Z = [I() for _ in range(N)]
Z.sort()

INF = 10**20
ans = INF

for i in range(N):
    for j in range(i+K-1,N):
        l = sorted(t[1] for t in Z[i:j+1])
        ans_tmp = [(Z[j][0]-Z[i][0])*(v-u) for u,v in zip(l,l[K-1:])]
        ans = min(ans,*ans_tmp)
print(ans)


# coding: utf-8
# Your code here!
N,K=list(map(int,input().split()))

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

point.sort(key=lambda x: x[0])

shin=10**200
able=N-K
for i in range(able+1):
    temp_high=point[:N-i]
    for j in range(able+1-i):
        temp_low=temp_high[j:]
        for k in range(able+1-i-j):
            temp_left=temp_low[:]
            temp_left.sort(key=lambda x: x[1])
            temp_left=temp_left[k:len(temp_left)-(able+1-i-j)+k+1]
            #print(i,j,k)
            #print(temp_left)
            if temp_left:
                ans=temp_left[:]
            elif temp_low:
                ans=temp_low[:]
            else:
                ans=temp_high[:]
            x=[]
            y=[]
            for item in ans:
                x.append(item[0])
                y.append(item[1])
            #print(x)
            #print(y)
            num=((max(x)-min(x))*(max(y)-min(y)))
            shin=min(shin,num)

print(shin)




import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(range(N),2):
  width = XY[right][0] - XY[left][0]
  pts = sorted(XY[left:right+1], key = lambda xy: xy[1])
  for D in range(len(pts)):
    if D + K - 1 >= len(pts):
      break
    y_max = pts[D+K-1][1]
    y_min = pts[D][1]
    area = (y_max - y_min) * width
    if area < answer:
      answer = area
    
print(answer)

from collections import defaultdict
def main():
  n,k=list(map(int,input().split()))
  xy=[list(map(int,input().split())) for _ in range(n)]
  x=[p[0] for p in xy]
  y=[p[1] for p in xy]
  x.sort()
  y.sort()
  
  s1=[[0]*n for _ in range(n)]
  s2=[[0]*n for _ in range(n)]
  s3=[[0]*n for _ in range(n)]
  s4=[[0]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
        for p in xy:
            if p[0]<=x[i] and p[1]<=y[j]:
              s1[i][j]+=1
              s2[i][j]+=(p[0]<x[i])
              s3[i][j]+=(p[1]<y[j])
              s4[i][j]+=(p[0]<x[i])*(p[1]<y[j])
  ans=float('inf')
  for s in range(n):
    for t in range(s+1,n):
      for u in range(n):
        for v in range(u+1,n):
          if s1[t][v]-s3[t][u]-s2[s][v]+s4[s][u]>=k:
            ans=min(ans,(x[t]-x[s])*(y[v]-y[u]))
  print(ans)

def __starting_point():
  main()

__starting_point()

n,K = map(int,input().split())
d = [[int(i) for i in input().split()] for _ in range(n)]
x = sorted(d,key=lambda x:x[0])
y = sorted(d,key=lambda x:x[1])
ans = float("inf")

for i in range(n):
    for j in range(i+1,n):
        for k in range(n):
            cnt = 0
            for l in range(k,n):
                if x[i][0] <= y[l][0] <= x[j][0]: cnt += 1
                if cnt == K:
                    dx = x[j][0]-x[i][0]
                    dy = y[l][1]-y[k][1]
                    ans = min(ans, dx*dy)
                    break
print(ans)

N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

cand = []
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        cand += [min(dx * (YY[j + K - 1] - YY[j]) for j in range(k - K + 1))]

print(min(cand))

from itertools import combinations

n,k = map(int,input().split())
xy = [list(map(int,input().split())) + [i] for i in range(n)]
x_order = sorted(xy)
y_order = sorted(xy,key = lambda x:x[1])

pos = [[None]*2 for _ in range(n)]

for i,(x,y,j) in enumerate(x_order):
    pos[j][0] = i
for i,(x,y,j) in enumerate(y_order):
    pos[j][1] = i

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

for x,y in pos:
    count[y+1][x+1] += 1

for i in range(n+1):
    for j in range(1,n+1):
        count[i][j] += count[i][j-1]

for i in range(n+1):
    for j in range(1,n+1):
        count[j][i] += count[j-1][i]

ans = float('inf')
for x1,x2 in combinations(range(1,n+1),2):
    for y1,y2 in combinations(range(1,n+1),2):
        if count[y2][x2] - count[y2][x1-1] - count[y1-1][x2] + count[y1-1][x1-1] >=k:
            S = (x_order[x2-1][0] - x_order[x1-1][0]) * (y_order[y2-1][1] - y_order[y1-1][1])
            ans = min(ans, S)
print(ans)

n,k = map(int,input().split())
points = []
for _ in range(n):
  x,y = map(int,input().split())
  points.append((x,y))

points.sort()
ans = float('inf')

for i in range(n-k+1):
  for j in range(i+k-1,n):
    y_sorted = sorted(points[i:j+1], key = lambda x:x[1])
    height_min = float('inf')
    for l in range(j-i-k+2):
      height_min = min(height_min,y_sorted[l+k-1][1] - y_sorted[l][1])
    ans = min(ans, (points[j][0]-points[i][0])*height_min)
print(ans)

import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(range(N),2):
  width = XY[right][0] - XY[left][0]
  pts = sorted(XY[left:right+1], key = lambda xy: xy[1])
  if len(pts) < K:
    continue
  for D in range(len(pts) - K + 1):
    y_max = pts[D+K-1][1]
    y_min = pts[D][1]
    area = (y_max - y_min) * width
    if area < answer:
      answer = area
    
print(answer)

N,K=list(map(int,input().split()))
point=[tuple(map(int,input().split())) for i in range(N)]
point.sort(key=lambda x:x[0])
ans=float('inf')
for i in range(1+N-K):
    for j in range(i+K,N+1):
        x=point[j-1][0]-point[i][0]
        now=point[i:j]
        now.sort(key=lambda x:x[1])
        for k in range(j-i-K+1):
            ans=min(x*(now[k+K-1][1]-now[k][1]),ans)
print(ans)


def main():
    N,K = map(int,input().split())
    XY = [list(map(int,input().split())) for _ in [0]*N]
    
    iX = sorted(x for x,y in XY)
    iY = sorted(y for x,y in XY)
    X = {x:i for i,x in enumerate(iX)}
    Y = {y:i for i,y in enumerate(iY)}

    c = [[0]*(N+1) for i in [0]*(N+1)]
    for x,y in XY:
        c[Y[y]+1][X[x]+1] = 1

    for i in range(N):
        ci1 = c[i+1]
        for j in range(N):
            ci1[j+1] += ci1[j]
    for i in range(N):
        ci1 = c[i+1]
        ci = c[i]
        for j in range(N):
            ci1[j+1] += ci[j+1]

    ans = 10**20
    for u in range(N):
        for d in range(u+K-1,N):
            l = 0
            r = 1
            dY = iY[d]-iY[u]
            cd = c[d+1]
            cu = c[u]
            while r<N:
                if cd[r+1]+cu[l]-cu[r+1]-cd[l] >=K:
                    ans = min(ans, (iX[r] - iX[l])*dY)
                    l+=1
                else:r+=1

    print(ans)
main()

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

XY.sort(key=lambda x: x[0])

ans = float("INF")
for i in range(N):
    for j in range(i+K-1, N):
        W = XY[j][0] - XY[i][0]
        Y = [XY[x][1] for x in range(i, j+1)]
        Y.sort()
        for k in range(len(Y)-K+1):
            H = Y[k+K-1] - Y[k]
            ans = min(ans, W*H)

print(ans)

import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(list(range(N)),2):
  xleft = XY[left][0]
  xright = XY[right][0]
  pts = sorted(XY[left:right+1], key = lambda xy: xy[1])
  if len(pts) < K:
    continue
  for D in range(len(pts) - K + 1):
    y_max = pts[D+K-1][1]
    y_min = pts[D][1]
    area = (y_max - y_min) * (xright - xleft)
    if area < answer:
      answer = area
    
print(answer)


import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n, k = MI()
    xy = []
    xx = []
    yy = []
    for _ in range(n):
        x, y = MI()
        xy.append([x, y])
        xx.append(x)
        yy.append(y)
    xx.sort()
    yy.sort()
    #print(xx)
    #print(yy)
    xtoi = {x: i for i, x in enumerate(xx)}
    ytoj = {y: j for j, y in enumerate(yy)}
    cs2d = [[0] * (n + 1) for _ in range(n + 1)]
    for x, y in xy:
        i, j = xtoi[x], ytoj[y]
        cs2d[i + 1][j + 1] = 1
    #p2D(cs2d)
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            cs2d[i][j] += cs2d[i][j - 1]
    for j in range(1, n + 1):
        for i in range(1, n + 1):
            cs2d[i][j] += cs2d[i-1][j]
    #p2D(cs2d)
    ans = 10 ** 20
    for ri in range(n):
        r = xx[ri]
        for li in range(ri):
            l = xx[li]
            for ti in range(n):
                t = yy[ti]
                for bi in range(ti):
                    b = yy[bi]
                    cnt = cs2d[ri+1][ti+1]-cs2d[ri+1][bi]-cs2d[li][ti+1]+cs2d[li][bi]
                    if cnt >= k:
                        s = (r - l) * (t - b)
                        if s < ans: ans = s
    print(ans)

main()


def main():
    N, K = list(map(int, input().split(' ')))
    points = [list(map(int, input().split(' '))) for _ in range(N)]
    points.sort(key=lambda p: p[1])
    ans = 10**19
    for b in range(N):
        bottom = points[b][1]
        for t in range(b + K - 1, N):
            top = points[t][1]
            target_points = points[b:(t+1)].copy()
            target_points.sort(key=lambda p: p[0])
            M = len(target_points)
            for left in range(M):
                right = left + K - 1
                if right >= M:
                    break
                width = target_points[right][0] - target_points[left][0]
                ans = min([ans, width * (top - bottom)])
    print(ans)


def __starting_point():
    main()
__starting_point()

n,k= map(int,input().split())
grid=[]
gridx=set()
gridy=set()
for i in range(n):
    x,y= map(int,input().split())
    grid.append((x,y))
    gridx.add(x)
    gridy.add(y)
gridxl = sorted(gridx)
xlen = len(gridxl)
gridyl = sorted(gridy)
ylen = len(gridyl)
atable = [[0 for _ in range(ylen+1)] for _ in range(xlen+1)]
for i in range(n):
    (px,py) = grid[i]
    xid = gridxl.index(px)
    yid = gridyl.index(py)
    atable[yid+1][xid+1]=1
for i in range(1,ylen+1):
    for j in range(1,xlen+1):atable[i][j]+=atable[i][j-1]
for j in range(1,xlen+1):
    for i in range(1,ylen+1):atable[i][j]+=atable[i-1][j]
gmin = 99999999999999999999
for x1 in range(1,xlen):
    for x2 in range(x1,xlen+1):
        for y1 in range(1,ylen):
            for y2 in range(y1,ylen+1):
                a = atable[y2][x2]
                b = atable[y1-1][x2]
                c = atable[y2][x1-1]
                d = atable[y1-1][x1-1]
                rui = a - b - c + d
                if rui>=k:
                    r = (gridxl[x2-1]-gridxl[x1-1])*(gridyl[y2-1]-gridyl[y1-1])
                    if gmin>r:
                        gmin = min(gmin,r)                  
print(gmin)

N, K = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(N)]
x_sort = sorted(XY, key=lambda x: x[0])


def check(l, r, b, t):
    cnt = 0
    for x, y in XY:
        if r >= x and x >= l and t >= y and b >= y:
            cnt += 1
    return cnt >= K


ans = 10**20

for i in range(N - K + 1):
    xl = x_sort[i][0]
    for j in range(i + K - 1, N):
        dx = x_sort[j][0] - xl

        points = sorted(x_sort[i: j+1], key=lambda x: x[1])

        rest = j - i + 1
        for p in range(rest - K + 1):
            yd = points[p][1]
            for q in range(p + K - 1, rest):
                dy = points[q][1] - yd
                ans = min(ans, dx*dy)

print(ans)


N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
X, Y = zip(*XY)
r = 10**20
for x0 in range(N - K + 1):
  for x1 in range(K + x0 - 1, N):
    Ys = sorted(Y[x0:x1 + 1])
    for y0 in range(len(Ys) - K + 1):
      r = min(r, (X[x1] - X[x0]) * (Ys[y0 + K - 1] - Ys[y0]))
print(r)