;; -*- 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)


Measured memory_bytes: 30820