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 C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N, K;
    void solve()
    {
        N = cin.nextint;
        K = cin.nextint;
        var X = new int[N];
        var Y = new int[N];
        for (int i = 0; i < N; i++)
        {
            X[i] = cin.nextint;
            Y[i] = cin.nextint;
        }
        Array.Sort(X, Y);
        var ans = long.MaxValue;
        if (K == 2)
        {
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    ans = Math.Min(ans, (long)(X[j] - X[i]) * Math.Abs(Y[j] - Y[i]));
                }
            }
        }
        if (K == 3)
        {
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    for (int k = j + 1; k < N; k++)
                    {
                        int lx = X[i];
                        int rx = X[k];
                        int hy = Math.Min(Math.Min(Y[i], Y[j]), Y[k]);
                        int ly = Math.Max(Math.Max(Y[i], Y[j]), Y[k]);
                        ans = Math.Min(ans, (long)(rx - lx) * (ly - hy));
                    }
                }
            }

        }


        if (K >= 4)
        {
            
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    for (int k = j + 1; k < N; k++)
                    {
                        for (int l = k + 1; l < N; l++)
                        {
                            int lx = X[i];
                            int rx = X[l];
                            int hy = Math.Min(Math.Min(Y[i], Y[j]), Math.Min(Y[k], Y[l]));
                            int ly = Math.Max(Math.Max(Y[i], Y[j]), Math.Max(Y[k], Y[l]));
                            int cnt = 0;
                            for (int r = 0; r < N; r++)
                            {
                                if (lx <= X[r] && X[r] <= rx && hy <= Y[r] && Y[r] <= ly)
                                {
                                    cnt++;
                                }
                            }
                            if (cnt >= K)
                            {
                                ans = Math.Min(ans, (long)(rx - lx) * (ly - hy));
                            }
                        }
                    }
                }
            }

        }
        WriteLine(ans);

    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}