CodeEff/ECCO huggingface dataset:
# Original solution
from itertools import combinations, product
from functools import reduce
import bisect as bs
from collections import namedtuple

Area = namedtuple('Area', ['xinf', 'xsup', 'yinf', 'ysup'])

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

def insert_xy(line):
    x, y = list(map(int, line.split()))
    X.insert(bs.bisect_left(X,x), x)
    Y.insert(bs.bisect_left(Y,y), y)
    return X, Y

def S_with_K_plots(X, Y, K):
    result = []
    for x, y in product(combinations(X,2), combinations(Y,2)):
        area = Area(xinf=min(x),xsup=max(x),yinf=min(y),ysup=max(y))
        S = (area.xsup-area.xinf)*(area.ysup-area.yinf)
        if count_plots(area) == K:
            result.append(S)
    return result

def count_plots(area):
    is_in_the_area = lambda x: is_in_area(x, area)
    return sum(map(is_in_the_area, plots))

def is_in_area(plot, area):
    between = lambda a, b, c:True if b <= a <= c else False
    x, y = plot
    x1, x2, y1, y2 = area
    if between(x, x1, x2) and between(y, y1, y2):
        return 1
    else:
        return 0

if __name__ == '__main__':
    with open(0) as f:
        N, K = list(map(int, f.readline().split()))
        data = f.readlines()
    plots = list(map(tuple_int, data))
    X, Y = [], []
    for x, y in plots:
        X.append(x); Y.append(y)
    print((min(S_with_K_plots(X, Y, K))))

# Optimized solution
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

if __name__ == '__main__':
    with open(0) as f:
        N, K = list(map(int, f.readline().split()))
        plots = list(map(tuple_int, f.readlines()))
    print((min(S_with_K_plots(plots, K))))
# Original solution
import itertools
from functools import lru_cache

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

XY = [[int(x) for x in input().split()] for _ in range(N)]
XY.sort()
X,Y = list(zip(*XY))

@lru_cache(None)
def cnt(x,y):
  c = 0
  for x1,y1 in XY:
    if x1 > x:
      break
    if y1 <= y:
      c += 1
  return c

min_area = 5*10**18

for x1,x2 in itertools.combinations(X,2):
  for y1,y2 in itertools.combinations(Y,2):
    if y1 > y2:
      y1,y2 = y2,y1
    area = (x2-x1) * (y2-y1)
    if area > min_area:
      continue
    
    c = cnt(x2,y2) - cnt(x2,y1-1) - cnt(x1-1,y2) + cnt(x1-1,y1-1)
    if c < K:
      continue
      
    min_area = area
    
print(min_area)


# Optimized solution
import itertools

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

XY = [[int(x) for x in input().split()] for _ in range(N)]
XY.sort()
X,Y = list(zip(*XY))

min_area = 5*10**18

for left,right in itertools.combinations(list(range(N)),2):
  width = X[right] - X[left]
  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 < min_area:
      min_area = area
    
print(min_area)
# Original solution
import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])

N,K = LI()
XY = [LI() for _ in range(N)]

X = []
Y = []
for x,y in XY:
    if not(x in X):
        X.append(x)
    if not(y in Y):
        Y.append(y)
X.sort()
Y.sort()

ans = []
for xl in range(len(X)-1):
    for xr in range(xl,len(X)):
        for yd in range(len(Y)-1):
            for yu in range(yd,len(Y)):
                ans_tmp = 0
                for x,y in XY:
                    if X[xl]<=x<=X[xr] and Y[yd]<=y<=Y[yu]:
                        ans_tmp += 1
                if ans_tmp >= K:
                    ans.append((X[xr]-X[xl])*(Y[yu]-Y[yd]))
print((min(ans)))



# Optimized solution
import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])

N,K = LI()
XY = [LI() for _ in range(N)]

X = []
Y = []
for x,y in XY:
    if not(x in X):
        X.append(x)
    if not(y in Y):
        Y.append(y)
        
X.sort()
Y.sort()
dic_XoYo = {}
dic_XcYo = {}
dic_XoYc = {}
dic_XcYc = {}
for x1 in X:
  for y1 in Y:
    key = x1*(10**10)+y1
    cnt_XoYo = 0
    cnt_XcYo = 0
    cnt_XoYc = 0
    cnt_XcYc = 0
    for x2,y2 in XY:
      if x2<=x1 and y2<=y1:
        cnt_XcYc += 1
      if x2<x1 and y2<=y1:
        cnt_XoYc += 1
      if x2<=x1 and y2<y1:
        cnt_XcYo += 1
      if x2<x1 and y2<y1:
        cnt_XoYo += 1
    dic_XcYc[key] = cnt_XcYc
    dic_XoYc[key] = cnt_XoYc
    dic_XcYo[key] = cnt_XcYo
    dic_XoYo[key] = cnt_XoYo

ans = []
for xl in range(len(X)-1):
  for xr in range(xl,len(X)):
    for yd in range(len(Y)-1):
      for yu in range(yd,len(Y)):
        cnt = dic_XcYc[X[xr]*(10**10)+Y[yu]]
        cnt -= dic_XcYo[X[xr]*(10**10)+Y[yd]]
        cnt -= dic_XoYc[X[xl]*(10**10)+Y[yu]]
        cnt += dic_XoYo[X[xl]*(10**10)+Y[yd]]
        if cnt>=K:
          ans.append((X[xr]-X[xl])*(Y[yu]-Y[yd]))
print((min(ans)))
# Original solution
import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])

N,K = LI()
XY = [LI() for _ in range(N)]

X = []
Y = []
for x,y in XY:
    if not(x in X):
        X.append(x)
    if not(y in Y):
        Y.append(y)
        
X.sort()
Y.sort()
dic_XoYo = {}
dic_XcYo = {}
dic_XoYc = {}
dic_XcYc = {}
for x1 in X:
  for y1 in Y:
    key = x1*(10**10)+y1
    cnt_XoYo = 0
    cnt_XcYo = 0
    cnt_XoYc = 0
    cnt_XcYc = 0
    for x2,y2 in XY:
      if x2<=x1 and y2<=y1:
        cnt_XcYc += 1
      if x2<x1 and y2<=y1:
        cnt_XoYc += 1
      if x2<=x1 and y2<y1:
        cnt_XcYo += 1
      if x2<x1 and y2<y1:
        cnt_XoYo += 1
    dic_XcYc[key] = cnt_XcYc
    dic_XoYc[key] = cnt_XoYc
    dic_XcYo[key] = cnt_XcYo
    dic_XoYo[key] = cnt_XoYo

ans = []
for xl in range(len(X)-1):
  for xr in range(xl,len(X)):
    for yd in range(len(Y)-1):
      for yu in range(yd,len(Y)):
        cnt = dic_XcYc[X[xr]*(10**10)+Y[yu]]
        cnt -= dic_XcYo[X[xr]*(10**10)+Y[yd]]
        cnt -= dic_XoYc[X[xl]*(10**10)+Y[yu]]
        cnt += dic_XoYo[X[xl]*(10**10)+Y[yd]]
        if cnt>=K:
          ans.append((X[xr]-X[xl])*(Y[yu]-Y[yd]))
print((min(ans)))



# Optimized solution
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)
# Original solution
n, k = list(map(int,input().split()))
xs = []
ys = []
points = []
for _ in range(n):
    x, y = list(map(int, input().split()))
    xs.append(x)
    ys.append(y)
    points.append((x, y))

                
min_ = float('inf')
for leftx in xs:
    for rightx in xs:
        if leftx >= rightx:
            continue
        for downy in ys:
            for upy in ys:
                if downy >= upy:
                    continue
                cnt = 0
                for tx, ty in points:
                    if (leftx <= tx <= rightx) and (downy <= ty <= upy):
                        cnt += 1
                
                if cnt >= k:
                    yoko = rightx - leftx
                    tate = upy - downy
                    men = yoko*tate
                    if men < min_:
                        min_ = men
print(min_)
                        

# Optimized solution
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)
# Original solution
n, k = list(map(int, input().split()))
lst = [list(map(int, input().split())) for i in range(n)]

min_area = 10**100
for a in lst:
    for b in lst:
        for c in lst:
            for d in lst:
                count = 0
                for e in lst:
                    if a[0] <= e[0] <= b[0] or a[0] >= e[0] >= b[0]:
                        if c[1] <= e[1] <= d[1] or c[1] >= e[1] >= d[1]:
                            count += 1
                if count >= k:
                    area = abs(a[0] - b[0]) * abs(c[1] - d[1])
                    if area < min_area:
                        min_area = area
print(min_area)

# Optimized solution
n, k = list(map(int, input().split()))
lst = [list(map(int, input().split())) for i in range(n)]

answer = 10**100
sortx = sorted(lst, key = lambda x: x[0])
for a, pt1 in enumerate(sortx[:n-k+1]):
    for b, pt2 in enumerate(sortx[a+k-1:]):
        #print(a,b)
        sorty = sorted(sortx[a:a+k+b], key = lambda x: x[1])
        sorty_len = len(sorty)
        for c, pt3 in enumerate(sorty[:sorty_len-k+1]):
            #print(len(sorty), c, k)
            pt4 = sorty[c+k-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)
# Original solution
# 全縦線と全横線を全探索するとO(N^5)
# 50 ** 5 = 312500000
# 縦線の選び方は50 C 2だから2分の1になるのを考慮しても、78125000
# いや無理だろ……と思ったら公式がこの解法だった。衝撃。
# 二次元累積和を使うと各回の計算がO(1)になるので、O(N^4)となる。

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


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

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

print(ans)


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

# まず O(N^5)解法を作ってみよう。通るのかこれ?
# Python 3.8.2 ではTLE、PyPyではAC(1.2秒)

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

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

print(ans)
# Original solution
n,k = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(n)]
ans = float('inf')
for i in range(len(xy)):
    for j in range(i+1,len(xy)):
        x1 = min(xy[i][0],xy[j][0])
        x2 = max(xy[i][0],xy[j][0])
        for m in range(len(xy)):
            for l in range(m+1,len(xy)):
                y1 = min(xy[m][1],xy[l][1])
                y2 = max(xy[m][1],xy[l][1])
                points = 0
                for c in range(len(xy)):
                    x,y = xy[c]
                    if x1<=x<=x2 and y1<=y<=y2:
                        points+=1
                if points>=k:
                    ans = min(ans,(x2-x1)*(y2-y1))

print(ans)

# Optimized solution
n,k = list(map(int,input().split()))
x_y = [list(map(int,input().split())) for _ in range(n)]
x_y = sorted(x_y,key=lambda x:(x[0],x[1]))
ans = float('inf')
for i in range(n-1):
    for j in range(i+1,n):
        if j-i+1<k:
            continue
        dis_x = x_y[j][0]-x_y[i][0]
        y_x = x_y[i:j+1]
        y_x = sorted(y_x,key=lambda x:x[1])
        for l in range(len(y_x)-1):
            for m in range(l+1,len(y_x)):
                if m-l+1<k:
                    continue
                dis_y = y_x[m][1]-y_x[l][1]
                ans = min(ans,dis_x*dis_y)
print(ans)
# Original solution
#!/usr/bin/env python3
#ABC75 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,K = LI()
xy = []
X = []
Y = []
for _ in range(n):
    x,y = LI()
    xy.append([x,y])
    X.append(x)
    Y.append(y)
X.sort(reverse = True)
Y.sort(reverse = True)
ans = inf
for i in range(n):
    uy = Y[i]
    for j in range(i+1,n):
        dy = Y[j]
        for k in range(n):
            rx = X[k]
            for l in range(k+1,n):
                lx = X[l]
                cnt = 0
                for m in range(n):
                    x,y = xy[m]
                    if lx <= x <= rx and dy <= y <= uy:
                        cnt += 1
                if cnt >= K:
                    S = (uy - dy)*(rx - lx)
                    ans = min(ans,S)
print(ans)


# Optimized solution
#!/usr/bin/env python3
#ABC75 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,K = LI()
xy = []
X = []
Y = []
for _ in range(n):
    x,y = LI()
    xy.append([x,y])
    X.append(x)
    Y.append(y)
X.sort(reverse = True)
Y.sort(reverse = True)
ans = inf
for i in range(n):
    uy = Y[i]
    for j in range(i+1,n):
        dy = Y[j]
        for k in range(n):
            rx = X[k]
            for l in range(k+1,n):
                lx = X[l]
                cnt = 0
                for x,y in xy:
                    if lx <= x <= rx and dy <= y <= uy:
                        cnt += 1
                if cnt >= K:
                    S = (uy - dy)*(rx - lx)
                    ans = min(ans,S)
print(ans)
# Original solution
#!/usr/bin/env python3
#ABC75 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,K = LI()
xy = [LI() for _ in range(n)]
ans = inf
for _ , uy in xy:
    for _ , dy in xy:
        if uy < dy:
            continue
        for rx , _ in xy:
            for lx , _ in xy:
                if rx < lx:
                    continue
                cnt = 0
                for x,y in xy:
                    if lx <= x <= rx and dy <= y <= uy:
                        cnt += 1
                if cnt >= K:
                    S = (uy - dy)*(rx - lx)
                    ans = min(ans,S)
print(ans)


# Optimized solution
#!/usr/bin/env python3
#ABC75 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,K = LI()
xy = []
for _ in range(n):
    x,y = LI()
    xy.append((x,y))
ans = inf
for _ , uy in xy:
    for _ , dy in xy:
        if uy < dy:
            continue
        for rx , _ in xy:
            for lx , _ in xy:
                if rx < lx:
                    continue
                cnt = 0
                for x,y in xy:
                    if lx <= x <= rx and dy <= y <= uy:
                        cnt += 1
                if cnt >= K:
                    ans = min(ans,(rx - lx)*(uy - dy))
print(ans)
# Original solution
import sys
input = sys.stdin.readline

N, K=list(map(int,input().strip().split(' ')))
x=[]
y=[]
p=[]
for i in range(N):
    xt,yt=list(map(int,input().strip().split(' ')))
    x.append(xt)
    y.append(yt)
    p.append([xt,yt])
ans=10**20
x.sort()
y.sort()
p.sort(key=lambda xt:xt[0])

for i in range(N):
    for j in range(i+1,N):
        xmin=x[i]
        xmax=x[j]
        for k in range(N):
            for l in range(k+1,N):
                ymin=y[k]
                ymax=y[l]
                A=(xmax-xmin)*(ymax-ymin)
                ct=0
                for m in range(N):
                    if xmin<=p[m][0] and p[m][0]<=xmax and ymin<=p[m][1] and p[m][1]<=ymax:
                        ct+=1
                if ct==K:
                    ans=min(ans,A)
                    break
print(ans)


# Optimized solution
import sys
input = sys.stdin.readline

N, K=list(map(int,input().strip().split(' ')))
x=[]
y=[]
point=[]
for i in range(N):
    xt,yt=list(map(int,input().strip().split(' ')))
    x.append(xt)
    y.append(yt)
    point.append([xt,yt])
ans=10**20
x.sort()
y.sort()
point.sort(key=lambda x:x[1])


for i in range(N):
    for j in range(i+1,N):
        xmin=x[i]
        xmax=x[j]
        for k in range(N):
            ymin=y[k]
#            ymax=y[l]
#            
            ct=0
            for p in point:
                if xmin<=p[0] and p[0]<=xmax and ymin<=p[1]:
                    ct+=1
                if ct==K:
                    A=(xmax-xmin)*(p[1]-ymin)
                    ans=min(ans,A)
                    break
print(ans)
# Original solution
n, k = list(map(int, input().split()))
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))
s = []
x = [xy[i][0] for i in range(n)]
y = [xy[i][1] for i in range(n)]
x.sort()
y.sort()
for i in range(n):
    for j in range(n):
        for l in range(i + 1, n):
            x1 = x[i]
            y1 = y[j]
            x2 = x[l]
            y2 = j - 1
            count = 0
            while count < k:
                y2 += 1
                if y2 >= n:
                    break
                for m in range(n):
                    if y[y2] == y1:
                        if x1 <= xy[m][0] <= x2 and xy[m][1] == y1:
                            count += 1
                    elif x1 <= xy[m][0] <= x2 and y[y2 - 1] < xy[m][1] <= y[y2]:
                        count += 1
            else:
                s.append((x2 - x1) * (y[y2] - y1))
print((min(s)))

# Optimized solution
n, k = list(map(int, input().split()))
xy = []
X = []
Y = []
for i in range(n):
    x, y = list(map(int, input().split()))
    X.append(x)
    Y.append(y)
    xy.append([x, y])
X.sort()
Y.sort()
ans = float("inf")
for i in range(n):
    for j in range(i + 1, n):
        for l in range(n):
            for m in range(l + 1, n):
                count = 0
                for o in range(n):
                    if X[i] <= xy[o][0] <= X[j] and Y[l] <= xy[o][1] <= Y[m]:
                        count += 1
                if count >= k:
                    ans = min(ans, (X[j] - X[i]) * (Y[m] - Y[l]))
print(ans)
# Original solution
N,K=list(map(int,input().split()))

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

xy_prod_list=[]
for x in xlist:
  for y in ylist:
    xy_prod_list.append((x,y))
xy_prod_list.sort()
#print(xy_prod_list)    

answer=float("inf")
for i in range(len(xy_prod_list)):
  x1,y1=xy_prod_list[i]
  for j in range(i+1,len(xy_prod_list)):
    x2,y2=xy_prod_list[j]    
    
    num_inbox=0
    for x,y in xylist:
      if min(x1,x2)<=x<=max(x1,x2) and min(y1,y2)<=y<=max(y1,y2):
        num_inbox+=1
    
    if num_inbox>=K:
      answer=min(answer,abs(x2-x1)*abs(y2-y1))
    
print(answer)

# Optimized solution
N,K=list(map(int,input().split()))

xlist,ylist,xylist=[],[],[]
xyset=set()
xydic={}
yxdic={}
for i in range(N):
  x,y=list(map(int,input().split()))
  xlist.append(x)
  ylist.append(y)
  xylist.append((x,y))
  xyset.add((x,y))
  xydic[x]=y
  yxdic[y]=x

xy_prod_list=[]
for x in xlist:
  for y in ylist:
    xy_prod_list.append((x,y))
xy_prod_list.sort()
#print(xy_prod_list)    

num_ld_dic={}
for xx,yy in xy_prod_list:
  num_ld=0
  for x,y in xylist:
    if x<=xx and y<=yy:
      num_ld+=1
  num_ld_dic[(xx,yy)]=num_ld
#print(num_ld_dic)

answer=float("inf")
for i in range(len(xy_prod_list)):
  x1,y1=xy_prod_list[i]
  for j in range(len(xy_prod_list)):
    x2,y2=xy_prod_list[j]
    if x1>=x2 or y1>=y2:
      continue
    
    area=(x2-x1)*(y2-y1)
    if area>answer:
      continue
      
    num_point=num_ld_dic[(x2,y2)]-num_ld_dic[(x1,y2)]-num_ld_dic[(x2,y1)]+num_ld_dic[(x1,y1)]
    if (x1,y1) in xyset:  
      num_point+=1
    else:
      xx=yxdic[y1]
      if x1<=xx<=x2:
        num_point+=1
      yy=xydic[x1]
      if y1<=yy<=y2:
        num_point+=1
      
    if num_point>=K:
      #print((x1,y1),(x2,y2),num_point)
      answer=min(answer,area)
    
print(answer)
# Original solution
N,K = list(map(int,input().split()))
XY = list(list(map(int,input().split()))for i in range(N))

ans = float('inf')

for lx, _ in XY:
    for rx, _ in XY:
        if lx > rx:
            continue
        for _, dy in XY:
            for _, uy in XY:
                if dy > uy:
                    continue
                count = 0
                for x,y in XY:
                    if lx <= x <= rx and dy <= y <= uy:
                        count += 1
                if count >= K:
                    ans = min(ans,(rx-lx)*(uy-dy))
print(ans)

# Optimized solution
N,K = list(map(int,input().split()))
XY = []

for i in range(N):
    x,y = list(map(int,input().split()))
    XY.append((x,y))


ans = float('inf')

for lx, _ in XY:
    for rx, _ in XY:
        if lx > rx:
            continue
        for _, dy in XY:
            for _, uy in XY:
                if dy > uy:
                    continue
                count = 0
                for x,y in XY:
                    if lx <= x <= rx and dy <= y <= uy:
                        count += 1
                if count >= K:
                    ans = min(ans,(rx-lx)*(uy-dy))
print(ans)
# Original solution
from itertools import product, combinations
n, k = list(map(int, input().split()))
dots = [list(map(int, input().split())) for _ in range(n)]

ans = float("inf")
for a, b in combinations(dots, 2):
	for c, d in combinations(dots, 2):
		upper = max(a[1], b[1], c[1], d[1])
		lower = min(a[1], b[1], c[1], d[1])
		left = min(a[0], b[0], c[0], d[0])
		right = max(a[0], b[0], c[0], d[0])

		area = (upper - lower) * (right - left)
		num = 0
		for dot in dots:
			if left <= dot[0] <= right and lower <= dot[1] <= upper:
				num += 1
		if num >= k and 0 < area < ans:
			ans = area

print(ans)

# Optimized solution
from itertools import combinations
n, k = list(map(int, input().split()))
dots = sorted([list(map(int, input().split())) for _ in range(n)])

ans = float("inf")
for x1, x2 in combinations(list(range(n)), 2):
	wid = dots[x2][0] - dots[x1][0]
	dots_cand = sorted(dots[x1: x2 + 1], key=lambda x: x[1])
	for y1, y2 in combinations(list(range(x2 + 1 - x1)), 2):
		if y2 - y1 + 1 >= k:
			area = (dots_cand[y2][1] - dots_cand[y1][1]) * wid
			if area < ans:
				ans = area

print(ans)