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 OCaml (4.02.3) (judge verdict: Wrong Answer)

(* n: int ref *)
let n = ref 0

(* k: int ref *)
let k = ref 0

(* pos: (int * int) list ref *)
let pos = ref []

(* sort_x: ('a * 'a) list -> ('a * 'a) list *)
let sort_x lst =
  List.sort (fun (x1, _) (x2, _) -> if x1 < x2 then -1 else 1) lst

(* sort_y: ('a * 'a) list -> ('a * 'a) list *)
let sort_y lst =
  List.sort (fun (_, y1) (_, y2) -> if y1 < y2 then -1 else 1) lst

(* minimum: 'a list -> 'a *)
let minimum lst =
  List.fold_left min max_int lst

(* soi: int -> string *)
let soi = string_of_int
(* pr: int -> unit *)
let pr x = print_endline (soi x)

(* calc_area: (int * int) list -> int *)
let calc_area lst = match lst with
  | [] -> 0
  | _ ->
    (* let _ = if List.length lst <> !k then failwith "err" in *)
    let h (x1, x2, y1, y2) (x, y) =
      (min x1 x, max x2 x, min y1 y, max y2 y)
    in
    let (x_min, x_max, y_min, y_max) =
      List.fold_left h (max_int, min_int, max_int, min_int) lst
    in
    (x_max - x_min) * (y_max - y_min)

(* heads: int -> 'a list -> 'a list *)
let rec heads len l = match l with
  | _ when len = 0 -> []
  | [] -> raise Not_found
  | x :: xs -> x :: (heads (len - 1) xs)

(* get_k_areas: ('a * 'a) list -> int list *)
let rec get_k_areas lst = match lst with
  | [] -> []
  | _ :: xs ->
    if List.length lst < !k then
      []
    else
      let l = heads !k lst in
      (calc_area l) :: (get_k_areas xs)

(* get_areas_on_x: unit -> int list *)
let get_areas_on_x () =
  !pos
  |> sort_x
  |> get_k_areas

(* get_areas_on_y: unit -> int list *)
let get_areas_on_y () =
  !pos
  |> sort_y
  |> get_k_areas

(* main: unit -> int *)
let main () =
  let sq_lst1 = get_areas_on_x () in
  let min1 = minimum sq_lst1 in
  let sq_lst2 = get_areas_on_y () in
  let min2 = minimum sq_lst2 in
  min min1 min2

(* subst: int -> int -> (int * int) list -> unit *)
let subst n_ k_ lst =
  n := n_;
  k := k_;
  pos := lst

(* start: int -> int -> (int * int) list -> unit *)
let start n_ k_ lst =
  subst n_ k_ lst;
  main ()
  |> string_of_int
  |> print_endline

(* test: unit -> unit *)
(*
let test () =
  subst 4 4 [(1, 4); (3, 3); (6, 2); (8, 1)];
  assert (main () == 21);
  subst 4 2 [(0, 0); (1, 1); (2, 2); (3, 3)];
  assert (main () == 1);
  subst 4 3 [(-1000000000, -1000000000);
             (1000000000, 1000000000);
             (-999999999, 999999999);
             (999999999, -999999999)];
  assert (main () == 3999999996000000001)

let _ = test ()
*)
(* read_2int: (int -> int -> 'a) -> 'a *)
let rec read_2int cont =
  Scanf.sscanf (read_line ()) "%d %d" cont

let _ = if true then
  read_2int (fun n_ k_ ->
    let rec h cont acc =
      if List.length acc = n_ then cont acc
      else read_2int (fun a b -> h cont ((a, b) :: acc))
    in
    h (start n_ k_) [])