CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
nums=[int(eval(input())) for _ in range(N)]
sum_num = sum(nums)
dp = [0] * (sum_num+1)
dp[0] = 1
for num in nums:
  for i in range(sum_num+1)[::-1]:
    if dp[i] == 1 and i + num <= sum_num:
      dp[i+num] = 1
ans = 0
for i in range(sum_num+1):
  if dp[i] == 1 and i%10 != 0:
    ans = i
print(ans)


# Optimized solution
N = int(eval(input()))
nums=[int(eval(input())) for _ in range(N)]
sum_num = sum(nums)
dp = [0] * (sum_num+1)
dp[0] = 1
for num in nums:
  for i in range(sum_num+1)[::-1]:
    if dp[i] == 1:
      dp[i+num] = 1
ans = 0
for i in range(sum_num+1):
  if dp[i] == 1 and i%10 != 0:
    ans = i
print(ans)
# Original solution
N = int(eval(input()))
nums=[int(eval(input())) for _ in range(N)]
MAX = 10**4
dp = [0] * (MAX+1)
dp[0] = 1
for num in nums:
  for i in range(MAX+1)[::-1]:
    if dp[i] == 1 and (i + num) <= MAX+1:
      dp[i+num] = 1
ans = 0
for i in range(MAX+1):
  if dp[i] == 1 and i%10 != 0:
    ans = i
print(ans)


# Optimized solution
N = int(eval(input()))
nums=[int(eval(input())) for _ in range(N)]
MAX = 10**4
dp = [0] * (MAX+1)
dp[0] = 1
for num in nums:
  for i in range(MAX+1)[::-1]:
    if dp[i] == 1 and (i + num) <= MAX:
      dp[i+num] = 1
ans = 0
for i in range(MAX+1):
  if dp[i] == 1 and i%10 != 0:
    ans = i
print(ans)
# Original solution
n = int(eval(input()))
s = []
for i in range(n):
    s.append(int(eval(input())))

s.sort(reverse=True)

tmp = sum(s)

ruiseki = [tmp]
for i in range(n-1):
    ruiseki.append(ruiseki[-1] - s[i])

ans = 0
def DFS(depth, now):
    global ans

    if depth == n:
        if now%10 != 0:
            ans = max(ans, now)
        return
      
    if now + ruiseki[depth] <= ans:
        return

    DFS(depth+1, now+s[depth])
    DFS(depth+1, now)
DFS(0,0)
print(ans)

# Optimized solution
n = int(eval(input()))
s = []

geta = 0
for i in range(n):
    a = int(eval(input()))
    if a % 10 == 0:
        geta += a
    else:
        s.append(a)

n = len(s)
s.sort(reverse=True)

tmp = sum(s)

ruiseki = [tmp]
for i in range(n-1):
    ruiseki.append(ruiseki[-1] - s[i])

ans = 0
def DFS(depth, now):
    global ans

    if depth == n:
        if now%10 != 0:
            ans = max(ans, now)
        return
    if now + ruiseki[depth] <= ans:
        return
    DFS(depth+1, now+s[depth])
    DFS(depth+1, now)
DFS(0,0)
if ans != 0:
    ans += geta
print(ans)
# Original solution
x,a,b = list(map(int,input().split()))
print(([0,'B','A'][(abs(x-a)>abs(x-b))-(abs(x-a)<abs(x-b))]))

# Optimized solution
x,a,b=list(map(int,input().split()))
print(('AB'[abs(x-a)>abs(x-b)]))
# Original solution
Sunuke, A ,B = list(map(int,input().split()))
if abs(Sunuke-A) < abs(Sunuke-B):
    print("A")
else:
    print("B")

# Optimized solution
Sunuke, A ,B = list(map(int,input().split()))
print(("A"if abs(Sunuke-A) < abs(Sunuke-B) else "B"))
# Original solution
x,a,b = input().split()
x = int(x)
a = int(a)
b = int(b)

if x < a:
    distance_xa = a - x
else:
    distance_xa = x - a

if x < b:
     distance_xb = b - x
else:
     distance_xb = x - b

if distance_xa < distance_xb:
      print("A")
else:
      print("B")

# Optimized solution
x,a,b = input().split()
x = int(x)
a = int(a)
b = int(b)
# print("x = ", x)
# print("a = ", a)
# print("b = ", b)

if x < a:
    distance_xa = a - x
else:
    distance_xa = x - a
# print("distance_xa = ", distance_xa)

if x < b:
     distance_xb = b - x
else:
     distance_xb = x - b
# print("distance_xb = ", distance_xb) 

if distance_xa < distance_xb:
      print("A")
else:
      print("B")
# Original solution
x,a,b = (int(i) for i in input().split())
print(("A" if abs(x-a) < abs(x-b) else "B"))

# Optimized solution
def main():
    x, a, b = (int(i) for i in input().split())
    if abs(a - x) < abs(b - x):
        print("A")
    else:
        print("B")


if __name__ == '__main__':
    main()
# Original solution
x, a, b = list(map(int, input().split()))
ans = 'A'
if abs(x-a)>abs(x-b):
  ans='B'
print(ans)

#print(*ans, sep='\n')


# Optimized solution
A, B, C = list(map(int, input().split()))
def check():
    if abs(B-A)<abs(C-A):
        return 'A'
    return 'B'
print((check()))
# Original solution
x,a,b=input().split()
x=int(x)
a=int(a)
b=int(b)
y1=x-a
y2=x-b
y1=abs(y1)
y2=abs(y2)
if y1<y2:
  print("A")
else:
  print("B")

# Optimized solution
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)
#print("x =", x)
#print("a =", a)
#print("b =", b)

if x < a:
  xa = a - x
else:
  xa = x - a
  
if x < b:
  xb = b - x
else:
  xb = x - b

if xa > xb:
  print('B')
else:
  print('A')
# Original solution
x,a,b=list(map(int,input().split()));print(('AB'[abs(a-x)>abs(b-x)]))

# Optimized solution
x,a,b=list(map(int,input().split()))
print(('AB'[(x+x>a+b)^(a>b)]))
# Original solution
x,a,b=list(map(int,input().split()))


if abs(x-a)<abs(x-b):
	print("A")
else:
	print("B")


# Optimized solution
x,a,b=list(map(int,input().split()))

flg=0
if b<a:
	b,a=a,b
	flg=1

ans = ["A","B"]

if 2*x<b+a:
	print((ans[flg]))
else:
	print((ans[-1+flg]))
# Original solution
x, a, b = list(map(int,input().split()))
A = abs(x - a)
B = abs(x - b)
if(A < B):
  print('A')
else:
  print('B')

# Optimized solution
x, a, b = list(map(int,input().split()))
if(abs(x-a) < abs(x-b)):
  print('A')
else:
  print('B')
# Original solution
x,a,b=list(map(int,input().split()))
if abs(x-a)<abs(x-b):
    print("A")
else:
    print("B")


# Optimized solution
x,a,b=list(map(int,input().split()))
print(("A" if abs(x-a)<abs(x-b) else "B"))
# Original solution
import math
MOD = pow(10, 9)+7
N, M = list(map(int, input().split()))

if abs(N - M) > 1:
	print(0)
else:
	if N == M:
		res = ( math.factorial(N) * math.factorial(N) * 2 )%MOD
	else:
		res = ( math.factorial(N) * math.factorial(M) )%MOD
	print(res)

# Optimized solution
MOD = pow(10, 9)+7
N, M = list(map(int, input().split()))

def myfact(num):
	res = 1
	for i in range(num+1)[1:]:
		res *= i
		if res > MOD:
			res %= MOD
	return res
if abs(N - M) > 1:
	print(0)
else:
	if N == M:

		res = ( myfact(N) * myfact(N) * 2 )%MOD
	else:
		res = ( myfact(N) * myfact(M) )%MOD
	print(res)
# Original solution
M,N=input().split(' ')
M=int(M)
N=int(N)

res=1
if M==N:
    for i in range(1, M+1):
        res*=i
    res=res*res*2
elif M-N==1:
    for i in range(1, N+1):
        res*=i
    res*=res*M
elif M-N==-1:
    for i in range(1, M+1):
        res*=i
    res*=res*N
else:
    res=0

print((res%(10**9+7)))


# Optimized solution
from math import *
M,N=input().split(' ')
M=int(M)
N=int(N)

res=1
if M==N:
    res=factorial(M)
    res=res*res*2
elif M-N==1:
    res=factorial(N)
    res*=res*M
elif M-N==-1:
    res=factorial(M)
    res*=res*N
else:
    res=0

print((res%(10**9+7)))
# Original solution
from math import factorial

n, m = list(map(int, input().split()))
if abs(n - m) > 1:
    print((0))
elif n == m:
    print(((factorial(n) * factorial(m) * 2) % (10 ** 9 + 7)))
else:
    print((factorial(n) * factorial(m)))

# Optimized solution
def factorial(x):
    res = 1
    for i in range(1, x):
        res *= i + 1
        res %= 10 ** 9 + 7
    return res

n, m = list(map(int, input().split()))
if abs(n - m) > 1:
    print((0))
elif n == m:
    print(((factorial(n) * factorial(m) * 2) % (10 ** 9 + 7)))
else:
    print((factorial(n) * factorial(m) % (10 ** 9 + 7)))
# Original solution
import math
n, m = list(map(int,input().split()))

sum = 0
if -2<n-m<2:
    if n<m:
        n,m = m,n
    sum = math.factorial(n)*math.factorial(m)*2**(m-n+1)
    sum %= 1000000007
print(sum)

# Optimized solution
n, m = list(map(int,input().split()))
MOD = 1000000007

def f(n):
    ans = 1
    for i in range(1,n+1):
        ans*=i
        ans%=MOD
    return ans

sum = 0
if -2<n-m<2:
    if n<m:
        n,m = m,n
    sum = f(n)*f(m)*2**(m-n+1)
    sum %= MOD
print(sum)
# Original solution
MOD = 10 ** 9 + 7

def kaijo(n):
    k = 1
    for i in range(1, n + 1):
        k *= i % MOD
    return k

n, m = list(map(int, input().split()))
if n == m:
    print(((kaijo(n) ** 2 * 2) % MOD))
elif abs(n - m) > 1:
    print((0))
else:
    if n < m:
        print(((kaijo(n) ** 2 * m) % MOD))
    else:
        print(((kaijo(m) ** 2 * n) % MOD))

# Optimized solution
MOD = 10 ** 9 + 7

def kaijo(n):
    k = 1
    for i in range(1, n + 1):
        k = k * i % MOD
    return k

n, m = list(map(int, input().split()))
if n == m:
    print(((kaijo(n) ** 2 * 2) % MOD))
elif abs(n - m) > 1:
    print((0))
else:
    if n < m:
        print(((kaijo(n) ** 2 * m) % MOD))
    else:
        print(((kaijo(m) ** 2 * n) % MOD))
# Original solution
import math

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

if abs(n-m) > 1:
    print((0))
    exit()

if abs(n-m) == 0:
    ans = math.factorial(n) * math.factorial(m) * 2 % mod
    print(ans)
else:
    ans = math.factorial(n) % mod * math.factorial(m) % mod
    print(ans)

# Optimized solution
import math

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

if abs(n-m) > 1:
    print((0))
else:
    ans = 1

    for i in range(1, n+1):
        ans = ans * i % mod
    for j in range(1, m+1):
        ans = ans * j % mod

    if abs(n-m) == 0:
        print((2 * ans % mod))
    else:
        print((ans % mod))
# Original solution
n, m = list(map(int, input().split()))

def fac(x):
    ans = 1
    for i in range(1, x + 1):
        ans = ans * i
    return(ans)

if n < m:
    n, m = m, n

if n - m >= 2:
    print((0))
elif n - m == 1:
    print(((fac(m)) ** 2 * n % (10 ** 9 + 7) ))
else:
    print(((fac(n)) ** 2 * 2 % (10 ** 9 + 7)))

# Optimized solution
n, m = list(map(int, input().split()))

def fac(x):
    ans = 1
    for i in range(1, x + 1):
        ans = (ans * i) % (10 ** 9 + 7)
    return(ans)

if n < m:
    n, m = m, n

if n - m >= 2:
    print((0))
elif n - m == 1:
    print(((fac(m)) ** 2 * n % (10 ** 9 + 7) ))
else:
    print(((fac(n)) ** 2 * 2 % (10 ** 9 + 7)))
# Original solution
from functools import reduce
from operator import mul

def main():
  N,M = list(map(int,input().split()))
  if N == M:
    L = [i for i in range(1,N + 1)]
    ans = (reduce(mul,L) ** 2) * 2  % (10 ** 9 + 7)
    print(ans)
  elif N + 1 == M or M + 1 == N: 
    L1 = [i for i in range(1,N + 1)]
    L2 = [i for i in range(1,M + 1)]
    ans = (reduce(mul,L1)) * (reduce(mul,L2)) % (10 ** 9 + 7)
    print(ans)
  else:
    print((0))
main()

# Optimized solution
import sys
from functools import reduce,lru_cache
import math
from operator import mul

def main():
  #sys.setrecursionlimit(10 ** 5 + 1)
  N,M = list(map(int,input().split()))
  
  @lru_cache(maxsize = None)
  def recur(n):
    if n == 0:
      return 1
    else:
      m = n * recur(n - 1)
      return m
      
  if N == M:
    L = [i for i in range(1,N + 1)]
    #ans = (reduce(mul,L) ** 2) * 2  % (10 ** 9 + 7)
    ans = (math.factorial(M) ** 2) * 2 % ((10 ** 9) + 7)
    print(ans)
  elif abs(M - N) == 1: 
    ans = math.factorial(N) * math.factorial(M) % ((10 ** 9) + 7)
    print(ans)
    
  else:
    print((0))
    
main()
# Original solution
N = str(eval(input()))

if '9' in N:
    flag = 'Yes'
else:
    flag = 'No'
    
print(flag)


# Optimized solution
N = eval(input())

if '9' in str(N):
    x = 'Yes'
else:
    x = 'No'

print(x)
# Original solution
print((input().count("9")and"Yes"or"No"))

# Optimized solution
print(("YNeos"[input().count("9")<1::2]))
# Original solution
import heapq
n,k=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(n)]
x=[l[i][0] for i in range(n)]
x.sort()
y=[l[i][1] for i in range(n)]
y.sort()
ans=[]
for i1 in range(n):
  for i2 in range(i1+1,n):
    for i3 in range(n):
      for i4 in range(i3+1,n):
        ct=0
        for i5 in range(n):
          if x[i1]<=l[i5][0]<=x[i2] and y[i3]<=l[i5][1]<=y[i4]:ct+=1
        if ct>=k:
          ans.append(abs(x[i1]-x[i2])*abs(y[i3]-y[i4]))
heapq.heapify(ans)
print((heapq.heappop(ans)))

# Optimized solution
n,k=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(n)]
x=[l[i][0] for i in range(n)]
x.sort()
y=[l[i][1] for i in range(n)]
y.sort()
ans=[]
for i1 in range(n):
  for i2 in range(i1+1,n):
    for i3 in range(n):
      for i4 in range(i3+1,n):
        ct=0
        for i5 in range(n):
          if x[i1]<=l[i5][0]<=x[i2] and y[i3]<=l[i5][1]<=y[i4]:ct+=1
        if ct>=k:
          ans.append(abs(x[i1]-x[i2])*abs(y[i3]-y[i4]))
print((min(ans)))
# Original solution
N,K=list(map(int,input().split()))

point=[]
answer=10**19
for i in range(N):
  point.append(list(map(int,input().split())))
sorted(point)
for left in range(N):
  for right in range(N):
    dx=point[right][0]-point[left][0]
    for ceil in range(N):
      for bottom in range(N):
        if point[bottom][1] > point[ceil][1]:
          continue
        count=0
        for i in range(N):
          x=point[i][0]
          y=point[i][1]
          if point[left][0]<=x and x<=point[right][0] and point[bottom][1]<=y and y<=point[ceil][1]:
            count+=1
        if count>=K:
          answer=min(answer,dx*(point[ceil][1]-point[bottom][1]))
     
          
print(answer)

# Optimized solution
#https://atcoder.jp/contests/abc075/submissions/2242350
N,K=list(map(int,input().split()))

points=[tuple(map(int,input().split())) for i in range(N)]
answer=10**19
sortx=sorted(points)
numberx = list(enumerate(sortx))

#n-k+1以降を左の頂点とすると点の数が明らかに足りない
for left,(x1,y1) in numberx[:N-K+1]:
  #left+K-1以降を右の頂点にしないと間に足りる点の数が入ってない
  for right,(x2,y2) in numberx[left+K-1:]:
    dx=x2-x1
    #left-rightの間でyについてsort
    sorty=sorted(y for x,y in sortx[left:right+1])
    #K個点を入れた状態で面積を求める
    for y3,y4 in zip(sorty,sorty[K-1:]):
      if y3<=y1 and y3<=y2 and y4>=y1 and y4>=y2:
        answer=min(answer,dx*(y4-y3))
         
print(answer)
# Original solution
n,k = list(map(int,input().split()))
ary = [list(map(int,input().split())) for _ in range(n)]
ary_x = sorted(ary)
ary_y = sorted(ary,key=lambda x:(x[1],x[0]))
ans = float("Inf")

for xi in range(n):
    for xj in range(1,n):
        for yi in range(n):
            for yj in range(1,n):
                count = 0
                lx,rx = ary_x[xi][0],ary_x[xj][0]
                by,uy = ary_y[yi][1],ary_y[yj][1]

                for i in range(n):
                    if lx <= ary[i][0] <= rx and by <= ary[i][1] <= uy:
                        count += 1
                if count >= k:
                    if ans > (rx - lx) * (uy - by):
                        ans = (rx - lx) * (uy - by)
print(ans)

# Optimized solution
n,k = list(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)
# Original solution
n,k = list(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)

# Optimized solution
N,K = list(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)
# Original solution
from itertools import combinations
 
n, k = [int(item) for item in input().split()]
xy = [[int(item) for item in input().split()] for _ in range(n)]
 
xsort = sorted(xy, key=lambda x: x[0])
ysort = sorted(xy, key=lambda x: x[1])
l = [i for i in range(n)]
 
def count_points_in_rec(x0, x1, y0, y1):
    count = 0
    for x, y in xy:
        if x < x0 or x1 < x or y < y0 or y1 < y:
            continue
        count += 1
    return count

ans = 5 * 10**18
comb = []
for a, b in combinations(l, 2):
    if b - a >= k-1:
        comb.append([a, b])
for a, b in comb:
    for c, d in comb:
        if count_points_in_rec(xsort[a][0], xsort[b][0], ysort[c][1], ysort[d][1]) == k:
            ans = min(ans, (xsort[b][0]-xsort[a][0]) * (ysort[d][1]-ysort[c][1]))
print(ans)

# Optimized solution
from itertools import combinations
 
n, k = [int(item) for item in input().split()]
xy = [[int(item) for item in input().split()] for _ in range(n)]
 
xsort = sorted(xy, key=lambda x: x[0])
ysort = sorted(xy, key=lambda x: x[1])
l = [i for i in range(n)]
 
cum = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        cum[i+1][j+1] = cum[i+1][j] + cum[i][j+1] - cum[i][j] + ([xsort[i][0], ysort[j][1]] in xy)

def count_points_in_rec(x0, x1, y0, y1):
    point = cum[x1+1][y1+1] - cum[x0][y1+1] - cum[x1+1][y0] + cum[x0][y0]
    return point

ans = 5 * 10**18
comb = []
for a, b in combinations(l, 2):
    if b - a >= k-1:
        comb.append([a, b])
for a, b in comb:
    for c, d in comb:
        if count_points_in_rec(a, b, c, d) == k:
            ans = min(ans, (xsort[b][0]-xsort[a][0]) * (ysort[d][1]-ysort[c][1]))
print(ans)
# Original solution
N, K = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]

x = sorted(v for v, _ in X)
y = sorted(v for _, v in X)
ans = 10 ** 20
for x1 in x:
    for x2 in x:
        for y1 in y:
            for y2 in y:
                num = 0
                for i in range(N):
                    if x1 <= X[i][0] <= x2 and y1 <= X[i][1] <= y2:
                        num += 1
                if num >= K:
                    ans = min(ans, abs(x1 - x2) * abs(y1 - y2))
                    
print(ans)


# Optimized solution
N, K = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]

x = sorted(v for v, _ in X)
y = sorted(v for _, v in X)
ans = 10 ** 20
for i in range(N - 1):
    for j in range(i + 1, N):
        for k in range(N - 1):
            for l in range(k + 1, N):
                x1 = x[i]
                x2 = x[j]
                y1 = y[k]
                y2 = y[l]
                num = 0
                for n in range(N):
                    if x1 <= X[n][0] <= x2 and y1 <= X[n][1] <= y2:
                        num += 1
                if num >= K:
                    ans = min(ans, (x2 - x1) * (y2 - y1))

print(ans)
# Original solution
from itertools import product,combinations
N,K=list(map(int,input().split()))
L=[tuple(map(int,input().split())) for i in range(N)]
ans=10**37
def f(i,j,k,l):
    n=0
    s=min(L[j][0],L[i][0])
    t=max(L[j][0],L[i][0])
    u=min(L[k][1],L[l][1])
    w=max(L[k][1],L[l][1])
    for e in L:
        if s<=e[0]<=t and u<=e[1]<=w:
            n+=1
    if n>=K:
        return (t-s)*(w-u)
    return 10**37
for i,j in combinations(list(range(N)),2):
    for k,l in combinations(list(range(N)),2):
        #print(i,j,k,l)
        ans=min(ans,f(i,j,k,l))
print(ans)

# Optimized solution
N,K=list(map(int,input().split()))
L=[tuple(map(int,input().split())) for i in range(N)]
L.sort()
ans=10**37
for i in range(N):
    for j in range(i+1,N):
        t=L[j][0]-L[i][0]
        S=sorted(x[1] for x in L[i:j+1])
        for k in range(len(S)-K+1):
            u=S[K+k-1]-S[k]
            ans=min(ans,u*t)
print(ans)
# Original solution
N, K = list(map(int, input().split()))

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

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            if ans > area:
                ans = area
            
print(ans)


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

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

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            if ans > area:
                ans = area
            
print(ans)
# Original solution
from itertools import combinations

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

area = float('inf')

for x1,x2 in combinations(list(range(n)),2):
  for y1,y2 in combinations(list(range(n)),2):
    
    point = 0
    for i in range(n):
      if (min(P[x1][0],P[x2][0])<= P[i][0] <=max(P[x1][0],P[x2][0]) 
      and min(P[y1][1],P[y2][1])<= P[i][1] <=max(P[y1][1],P[y2][1])):
        point += 1
    if point==k:
      area = min(area,abs(P[x1][0]-P[x2][0])*abs(P[y1][1]-P[y2][1]))
      
print(area)

# Optimized solution
from itertools import combinations

n,k = list(map(int,input().split()))
Px = sorted([list(map(int,input().split())) for i in range(n)])
Py = sorted(Px,key=lambda p:p[1])

area = float('inf')

for x1 in range(n-1):
    for x2 in range(x1+1,n):
        for y1 in range(n-1):

            point = 0
            for y in range(y1,n):
                if Px[x1][0]<=Py[y][0]<=Px[x2][0]:
                    point += 1
                    if point == k:
                        area = min(area,(Px[x2][0]-Px[x1][0])*(Py[y][1]-Py[y1][1]))
                        break

print(area)
# Original solution
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, y2 in combinations(Y, 2):
        cnt = sum(x1 <= x <= x2 and y1 <= y <= y2 for x,y in Plot)
        if cnt == K:
            S = (x2-x1)*(y2-y1)
            ans = min(ans, S)
print(ans)


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