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 Rust (1.15.1) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        m: usize,
        mut xy: [(isize, isize); n],
    }
    xy.sort_by_key(|&(x, _)| x);
    let mut x = HashMap::new();
    let mut x_index = HashMap::new();
    for i in 0..n {
        x.insert(xy[i].0, i);
        x_index.insert(i + 1, xy[i].0);
    }
    xy.sort_by_key(|&(_, y)| y);
    let mut y = HashMap::new();
    let mut y_index = HashMap::new();
    for i in 0..n {
        y.insert(xy[i].1, i);
        y_index.insert(i + 1, xy[i].1);
    }

    let mut count = vec![vec![0; n]; n];
    for i in 0..n {
        let (xi, yi) = xy[i];
        count[x[&xi]][y[&yi]] += 1;
    }
    // eprintln!("{:?}", count);
    let mut count_acc = vec![vec![0; n + 1]; n + 1];
    for i in 1..=n {
        for j in 1..=n {
            count_acc[i][j] = count[i - 1][j - 1] + count_acc[i - 1][j] + count_acc[i][j - 1]
                - count_acc[i - 1][j - 1];
        }
    }
    // eprintln!("{:?}", count_acc);
    let mut s = INF as isize;
    for i in 1..=n {
        for j in 1..=n {
            for k in 1..i {
                for l in 1..j {
                    if count_acc[i][j] - count_acc[k - 1][j] - count_acc[i][l - 1]
                        + count_acc[k - 1][l - 1]
                        >= m
                    {
                        // eprintln!(
                        //     "{} {} {} {}",
                        //     x_index[&i], x_index[&k], y_index[&j], y_index[&l]
                        // );
                        let t = (x_index[&i] - x_index[&k]) * (y_index[&j] - y_index[&l]);
                        s = min(s, t);
                    }
                }
            }
        }
    }
    println!("{}", s);
}
*/

fn main() {
    let exe = "/tmp/bin7B9BCB53";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";