Problem:
Score : 400 points

Problem Statement

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 1

4 4
1 4
3 3
6 2
8 1

Sample Output 1

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.

Sample Input 2

4 2
0 0
1 1
2 2
3 3

Sample Output 2

1

Sample Input 3

4 3
-1000000000 -1000000000
1000000000 1000000000
-999999999 999999999
999999999 -999999999

Sample Output 3

3999999996000000001

Watch out for integer overflows.

Solution in Common Lisp (SBCL 1.1.14) (judge verdict: Accepted)

;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (inline get-2dcumul))
(defun get-2dcumul (cumul-table i0 j0 i1 j1)
  "Returns the cumulative sum of the region given by the rectangle [i0, i1)*[j0,
j1). CUMUL-TABLE must be appropriately initialized beforehand."
  (+ (- (aref cumul-table i1 j1)
        (aref cumul-table i0 j1)
        (aref cumul-table i1 j0))
     (aref cumul-table i0 j0)))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (k (read))
         (xs (make-array n :element-type 'int32))
         (ys (make-array n :element-type 'int32))
         (ord-xs (make-array n :element-type 'uint8))
         (ord-ys (make-array n :element-type 'uint8))
         (cumul (make-array (list (+ n 1) (+ n 1)) :element-type 'uint8 :initial-element 0))
         (res most-positive-fixnum))
    (declare (uint8 n k) (uint62 res))
    (dotimes (i n)
      (setf (aref xs i) (read))
      (setf (aref ys i) (read))
      (setf (aref ord-xs i) i)
      (setf (aref ord-ys i) i))
    (setf ord-xs (sort ord-xs (lambda (i j) (< (aref xs i) (aref xs j)))))
    (setf ord-ys (sort ord-ys (lambda (i j) (< (aref ys i) (aref ys j)))))
    (dotimes (i n)
      (let ((ord-x (the uint8 (position i ord-xs)))
            (ord-y (position i ord-ys)))
        (incf (aref cumul (+ ord-y 1) (+ ord-x 1)))))
    (dotimes (y (+ n 1))
      (dotimes (x n)
        (incf (aref cumul y (+ x 1)) (aref cumul y x))))
    (dotimes (x (+ n 1))
      (dotimes (y n)
        (incf (aref cumul (+ y 1) x)  (aref cumul y x))))
    (dotimes (y1-ord n)
      (dotimes (x1-ord n)
        (loop for y2-ord from (+ 1 y1-ord) below n
              do (loop for x2-ord from (+ 1 x1-ord) below n
                       when (<= k (get-2dcumul cumul y1-ord x1-ord (+ 1 y2-ord) (+ 1 x2-ord)))
                       do (let ((y1 (aref ys (aref ord-ys y1-ord)))
                                (x1 (aref xs (aref ord-xs x1-ord)))
                                (y2 (aref ys (aref ord-ys y2-ord)))
                                (x2 (aref xs (aref ord-xs x2-ord))))
                            (setf res (min res (the fixnum (* (- y2 y1) (- x2 x1))))))))))
    (println res)))

#-swank(main)