CodeEff/ECCO huggingface dataset:
# Original solution
N,K = list(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):
    for j in range(N):
        c[i+1][j+1] += c[i+1][j]
for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i][j+1]

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

print(ans)

# Optimized solution
N,K = list(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):
    for j in range(N):
        c[i+1][j+1] += c[i+1][j]
for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i][j+1]

ans = 10**20
for l in range(N):
    for u in range(N):
        for r in range(l+1,N):
            for d in range(u+1,N):
                if c[d+1][r+1]+c[u][l]-c[u][r+1]-c[d+1][l] >=K:
                    ans = min(ans,
                             (iX[r]-iX[l])*(iY[d]-iY[u]))
                    break

print(ans)
# Original solution
N,K = list(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):
    for j in range(N):
        c[i+1][j+1] += c[i+1][j]
for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i][j+1]

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

print(ans)

# Optimized solution
N,K = list(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):
    for j in range(N):
        c[i+1][j+1] += c[i+1][j]
for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i][j+1]

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

print(ans)
# Original solution
N,K = list(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)

# Optimized solution
def main():
    N,K = list(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()
# Original solution
def main():
    N,K = list(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 = K-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()

# Optimized solution
def main():
    N,K = list(map(int,input().split()))
    XY = [list(map(int,input().split())) for _ in [0]*N]
    
    iX = [x for x,y in XY]
    iY = [y for x,y in XY]
    iX.sort()
    iY.sort()
    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 = K-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()
# Original solution
N,K=list(map(int,input().split()))
nodes=[]
for i in range(N):
  x,y=list(map(int,input().split()))
  nodes.append((x,y))
import math
ans=math.inf
count=0
for i in range(N):
  for j in range(N):
    for k in range(N):
      for l in range(N):
        count=0
        for m in range(N):
          if nodes[i][0]<=nodes[m][0]<=nodes[j][0] and nodes[k][1]<=nodes[m][1]<=nodes[l][1]:
            count+=1
        if count>=K:
          ans=min(ans,(nodes[j][0]-nodes[i][0])*(nodes[l][1]-nodes[k][1]))
print(ans)

# Optimized solution
N,K=list(map(int,input().split()))
nodes=[]
for i in range(N):
  x,y=list(map(int,input().split()))
  nodes.append((x,y))
nodes.sort()
import math
ans=math.inf
count=0
for i in range(N):
  for j in range(i+1,N):
    for k in range(N):
      for l in range(i+1,N):
        count=0
        for m in range(N):
          small=min(nodes[k][1],nodes[l][1])
          big=max(nodes[k][1],nodes[l][1])
          if nodes[i][0]<=nodes[m][0]<=nodes[j][0] and small<=nodes[m][1]<=big:
            count+=1
        if count>=K:
          ans=min(ans,(nodes[j][0]-nodes[i][0])*(big-small))
print(ans)
# Original solution
N, K = list(map(int, input().split()))
x = []
for i in range(N):
    x.append(list(map(int, input().split())))
ans = []
for i in range(N):
    for j in range(N):
        for l in range(N):
            for m in range(N):
                count = 0
                x1 = min(x[i][0], x[j][0])
                x2 = max(x[i][0], x[j][0])
                y1 = min(x[l][1], x[m][1])
                y2 = max(x[l][1], x[m][1])

                for k in range(N):
                    if x1 <= x[k][0] and x[k][0] <= x2 and y1 <= x[k][1] and x[k][1] <= y2:
                        count += 1
                if count >= K:
                    ans.append((x2 - x1) * (y2 - y1))
print((min(ans)))


# Optimized solution
N, K = list(map(int, input().split()))
x = []
for i in range(N):
    x.append(list(map(int, input().split())))
ans = []
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
                x1 = min(x[i][0], x[j][0])
                x2 = max(x[i][0], x[j][0])
                y1 = min(x[l][1], x[m][1])
                y2 = max(x[l][1], x[m][1])

                for k in range(N):
                    if x1 <= x[k][0] and x[k][0] <= x2 and y1 <= x[k][1] and x[k][1] <= y2:
                        count += 1
                if count >= K:
                    ans.append((x2 - x1) * (y2 - y1))
print((min(ans)))
# Original solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n,k=list(map(int,input().split()))
    X=[0]*n
    Y=[0]*n
    for i in range(n):
        X[i],Y[i]=list(map(int,input().split()))
    ans=INF
    for a in range(n):
        for b in range(n):
            for c in range(a+1,n):
                for d in range(b+1):
                    x0,x1=sorted([X[a],X[c]])
                    y0,y1=sorted([Y[b],Y[d]])
                    if k<=sum((x0<=X[i]<=x1 and y0<=Y[i]<=y1) for i in range(n)):
                        ans=min(ans,(x1-x0)*(y1-y0))
    print(ans)
resolve()

# Optimized solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n,k=list(map(int,input().split()))
    X=[0]*n
    Y=[0]*n
    for i in range(n):
        X[i],Y[i]=list(map(int,input().split()))
    ans=INF
    for a in range(n):
        for b in range(n):
            for c in range(a+1,n):
                for d in range(b+1):
                    x0,x1=sorted([X[a],X[c]])
                    y0,y1=sorted([Y[b],Y[d]])
                    count=0
                    for i in range(n):
                        if x0<=X[i]<=x1 and y0<=Y[i]<=y1:
                            count+=1
                    if count>=k:
                        ans=min(ans,(x1-x0)*(y1-y0))
    print(ans)
resolve()
# Original solution
N, K = list(map(int, input().split()))
S = []
T = []
A = []
for i in range(N):
    x, y = list(map(int, input().split()))
    S.append(x)
    T.append(y)
    A.append([x, y])

ans = float("inf")
for i in S:
    for j in S:
        for k in T:
            for l in T:
                c = 0
                for x, y in A:
                    if i <= x <= j:
                        if k <= y <= l:
                            c += 1
                if c >= K:
                    ans = min(ans, (j - i)*(l - k))
print(ans)

# Optimized solution
N, K = list(map(int, input().split()))
S = []
T = []
A = []
for i in range(N):
    x, y = list(map(int, input().split()))
    S.append(x)
    T.append(y)
    A.append([x, y])

S.sort()
T.sort()
ans = float("inf")
for i in range(N):
    for j in range(i+1, N):
        for k in range(N):
            for l in range(k+1, N):
                c = 0
                for x, y in A:
                    if S[i] <= x <= S[j]:
                        if T[k] <= y <= T[l]:
                            c += 1
                if c >= K:
                    ans = min(ans, (S[j] - S[i])*(T[l] - T[k]))
print(ans)
# Original solution
from itertools import combinations
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)


# Optimized solution
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()
# Original solution
N, K = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(N)]
X, Y = list(zip(*XY))
X_s = sorted(X)
Y_s = sorted(Y)

r = 10**20
for xi0 in range(N):
  for xi1 in range(xi0, N):
    for yi0 in range(N):
      for yi1 in range(yi0, N):
        x0 = X_s[xi0]
        x1 = X_s[xi1]
        y0 = Y_s[yi0]
        y1 = Y_s[yi1]
        c = 0
        for x, y in XY:
          if x0 <= x <=x1 and y0 <= y <= y1:
            c += 1
        if c >= K:
          r = min(r, (x1 - x0) * (y1 - y0))
print(r)

# Optimized solution
N, K = list(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)
# Original solution
import sys
input = sys.stdin.readline


def main():
    n, k = list(map(int, input().split()))
    X, Y = [], []
    for _ in range(n):
        x, y = list(map(int, input().split()))
        X.append(x)
        Y.append(y)
    x_min, x_max = min(X), max(X)
    y_min, y_max = min(Y), max(Y)
    res = abs(x_max - x_min) * abs(y_max - y_min)

    for x1 in range(n):
        for x2 in range(n):
            for y1 in range(n):
                for y2 in range(n):
                    lx, rx = X[x1], X[x2]
                    by, uy = Y[y1], Y[y2]
                    cnt = 0
                    for i in range(n):
                        if lx <= X[i] <= rx and by <= Y[i] <= uy:
                            cnt += 1
                    if cnt >= k:
                        res = min(res, abs(rx - lx) * abs(uy - by))
    print(res)


if __name__ == '__main__':
    main()


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


def main():
    n, k = list(map(int, input().split()))
    X, Y = [], []
    for _ in range(n):
        x, y = list(map(int, input().split()))
        X.append(x)
        Y.append(y)
    X_s = sorted(X)
    Y_s = sorted(Y)
    f_inf = float("inf")
    res = f_inf

    for x1 in range(n):
        for x2 in range(x1 + 1, n):
            for y1 in range(n):
                for y2 in range(y1 + 1, n):
                    lx, rx = X_s[x1], X_s[x2]
                    by, uy = Y_s[y1], Y_s[y2]
                    cnt = 0
                    for i in range(n):
                        if lx <= X[i] <= rx and by <= Y[i] <= uy:
                            cnt += 1
                    if cnt >= k:
                        res = min(res, abs(rx - lx) * abs(uy - by))
    print(res)


if __name__ == '__main__':
    main()
# Original solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = list(map(int, input().split()))
    X, Y = [], []
    for _ in range(n):
        x, y = list(map(int, input().split()))
        X.append(x)
        Y.append(y)
    X_s = sorted(X)
    Y_s = sorted(Y)

    res = f_inf
    for x1 in range(n):
        for x2 in range(x1 + 1, n):
            for y1 in range(n):
                for y2 in range(y1 + 1, n):
                    lx, rx = X_s[x1], X_s[x2]
                    by, uy = Y_s[y1], Y_s[y2]
                    cnt = 0
                    for i in range(n):
                        if lx <= X[i] <= rx and by <= Y[i] <= uy:
                            cnt += 1
                    if cnt >= k:
                        res = min(res, (rx - lx) * (uy - by))
    print(res)


if __name__ == '__main__':
    resolve()


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = list(map(int, input().split()))
    X, Y = [], []
    XY = []
    for _ in range(n):
        x, y = list(map(int, input().split()))
        X.append(x)
        Y.append(y)
        XY.append([x, y])
    X.sort()
    Y.sort()

    res = f_inf
    for x1 in range(n):
        left = X[x1]
        for x2 in range(x1 + 1, n):
            right = X[x2]
            for y1 in range(n):
                bottom = Y[y1]
                for y2 in range(y1 + 1, n):
                    up = Y[y2]
                    cnt = 0
                    for x, y in XY:
                        if left <= x <= right and bottom <= y <= up:
                            cnt += 1
                        if cnt >= k:
                            area = (right - left) * (up - bottom)
                            res = min(res, area)
                            break
    print(res)


if __name__ == '__main__':
    resolve()
# Original solution
from itertools import combinations

N, K = list(map(int, input().split()))
coord = [tuple(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for points in combinations(coord, K):
    x_coords, y_coords = [x for x, _ in points], [y for _, y in points]
    x_min, x_max, y_min, y_max = min(x_coords), max(x_coords), min(y_coords), max(y_coords)
    cand = (x_max - x_min)*(y_max - y_min)
    inside = 0
    for p in coord:
        inside += 1 if p[0] in range(x_min, x_max+1) and p[1] in range(y_min, y_max+1) else 0
        if inside == K:
            break
    else:
        continue
    ans = min(ans, cand)
print(ans)

# Optimized solution
from itertools import combinations

N, K = list(map(int, input().split()))
coord = sorted([tuple(map(int, input().split())) for _ in range(N)])
ans = float('inf')
for left, right in combinations(list(range(N)), 2):
    n_points = right - left + 1
    if n_points < K: continue
    width = coord[right][0] - coord[left][0]
    y_coords = sorted([y for _, y in coord[left: right+1]])
    for i in range(n_points - K + 1):
        height = y_coords[i+K-1] - y_coords[i]
        ans = min(ans, width*height)
print(ans)
# Original solution
#n,kが小さい
#xi,yi全て試す

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

p = []
x = []
y = []
for i in range(n):
    xi,yi = list(map(int, input().split( )))
    p.append((xi,yi))
    x.append(xi)
    y.append(yi)

y = list(set(y))
x = list(set(x))
x.sort()
y.sort()
lx = len(x)
ly = len(y)
ans = 10**20
for ix in range(lx):
    for jx in range(i):
        for iy in range(ly):
            for jy in range(iy):
                cnt = 0
                for xk,yk in p:
                    if x[ix]>= xk and xk>=x[jx] and y[iy]>=yk and yk>=y[jy]:
                        cnt += 1
                if cnt >= k:
                    ans = min(ans, (x[ix]-x[jx])*(y[iy]-y[jy]))
print(ans)
                    



# Optimized solution
#n,kが小さい
#xi,yi全て試す

#for ループ変更
import itertools
n,k = list(map(int, input().split( )))

p = []
x = []
y = []
for i in range(n):
    xi,yi = list(map(int, input().split( )))
    p.append((xi,yi))
    x.append(xi)
    y.append(yi)

y = list(set(y))
x = list(set(x))
x.sort()
y.sort()
lx = len(x)
ly = len(y)
ans = 10**20
for xi,xj in itertools.combinations(x,2):
    for yi,yj in itertools.combinations(y,2):
        cnt = 0
        for xk,yk in p:
            if xi <= xk and xk<=xj and yi <=yk and yk<=yj:
                        cnt += 1
        if cnt >= k:
            ans = min(ans, (xj-xi)*(yj-yi))
print(ans)
# Original solution
N, K = list(map(int, input().split()))

X = []
Y = []
P = []
for i in range(N):
	coor = tuple(map(int, input().split()))
	P.append(coor)
	X.append(coor[0])
	Y.append(coor[1])
	
X.sort()
Y.sort()

answer = (X[-1] - X[0])*(Y[-1] - Y[0])

for xmin in range(N):
	for xmax in range(xmin+1, N):
			for ymin in range(N):
				for ymax in range(ymin+1, N):
						cnt = 0
						for i in range(N):
							if X[xmin] <= P[i][0] and P[i][0] <= X[xmax] and Y[ymin] <= P[i][1] and P[i][1] <= Y[ymax]:
								cnt += 1
						if cnt >= K:
							answer = min(answer, (X[xmax]-X[xmin])*(Y[ymax]-Y[ymin]))
print((int(answer)))


# Optimized solution
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
 
N,K = LI()
p = []
for i in range(N):
    a,b = LI()
    p.append((a,b))
sx = sorted(p)
ans = 10**50
for x,y in sx:
    for x2,y2 in sx:
        if x2 <= x:
            continue
        points = sx.index((x2,y2)) - sx.index((x,y)) + 1
        if points < K:
            continue
        sy = sorted(sx[sx.index((x,y)):sx.index((x2,y2))+1],key=lambda sx: sx[1])
        for j in range(len(sy)-K+1):
            if sy[j][1] <= y and y2 <= sy[j+K-1][1]:
                ans = min(ans, (x2 - x) * (sy[j+K-1][1]-sy[j][1])) 
print(ans)
# Original solution
"""
座標圧縮
2D累積和
全探索
勝利
"""
n, k = list(map(int,input().split()))
xs = set()
ys = set()
ps = []
# 座圧
for _ in range(n):
    x,y = list(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)

# Optimized solution
n,k = list(map(int, input().split()))
xs = []
ys = []
ps = []
for i in range(n):
    x,y = list(map(int, input().split()))
    xs.append(x)
    ys.append(y)
    ps.append((x,y))
# 座圧
xs = sorted(list(set(xs)))
ys = sorted(list(set(ys)))
xdic = {x:i for i, x in enumerate(xs)}
ydic = {y:i for i, y in enumerate(ys)}
xrdic = {i:x for i, x in enumerate(xs)}
yrdic = {i:y for i, y in enumerate(ys)}
nx = len(xs)
ny = len(ys)


fs = [[0] * (1+ny) for i in range(nx+1)]
for x,y in ps:
    ix = xdic[x]
    iy = ydic[y]
    fs[ix][iy] += 1

acc = [[0] * (1+ny) for i in range(nx+1)]
for i in range(nx):
    for j in range(ny):
        acc[i+1][j+1] = acc[i+1][j] + acc[i][j+1] - acc[i][j] + fs[i][j]

def calc(sx,sy,tx,ty):
    ix1 = xrdic[sx]
    ix2 = xrdic[tx]
    iy1 = yrdic[sy]
    iy2 = yrdic[ty]
    return (ix2-ix1) * (iy2-iy1)

# print(xs,xdic,".",ys,ydic)
ans = 10**20
for sx in range(nx+1):
    for sy in range(ny+1):
        for tx in range(sx+1, nx+1):
            for ty in range(sy+1, ny+1):
                cnt = acc[tx][ty] - acc[sx][ty] - acc[tx][sy] + acc[sx][sy]
                if cnt >= k:
                    S = calc(sx,sy,tx-1,ty-1)
                    ans = min(ans, S)
print(ans)