Problem:
Score : 300 points

Problem Statement

There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).

We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation:

Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.

Find the minimum total cost required to collect all the balls when we optimally choose p and q.

Constraints

1 \leq N \leq 50

|x_i|, |y_i| \leq 10^9

If i \neq j, x_i \neq x_j or y_i \neq y_j.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
:
x_N y_N

Output

Print the minimum total cost required to collect all the balls.

Sample Input 1

2
1 1
2 2

Sample Output 1

1

If we choose p = 1, q = 1, we can collect all the balls at a cost of 1 by collecting them in the order (1, 1), (2, 2).

Sample Input 2

3
1 4
4 6
7 8

Sample Output 2

1

If we choose p = -3, q = -2, we can collect all the balls at a cost of 1 by collecting them in the order (7, 8), (4, 6), (1, 4).

Sample Input 3

4
1 1
1 2
2 1
2 2

Sample Output 3

2

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n;
    cin>>n;
    vector< pll > co;
    int used[ n+5] = {};
    ll i, j;
    FOR0(i, n)
    {
        ii temp;
        cin>>temp.ff>>temp.ss;
        co.push_back(ii(temp.ff, temp.ss));
    }
    vector< pll > pos;
    FOR0(i, n)
    {
        FOR(j, i+1, n)
        {
            ll p, q;
            p = co[i].ff - co[j].ff;
            q  = co[i].ss - co[j].ss;
            pos.push_back(pll(p,q));
        }
    }
    ll si = pos.size();
    ll ans = inf;
    FOR0(i, si)
    {
        multiset<pll> s;
        multiset<pll>::iterator it;
        ll cur = 0;
        ll p = pos[i].ff, q = pos[i].ss;
        FOR0(j, n) s.insert(co[j]);
        FOR0(j, n)
        {
            if(s.find(co[j]) == s.end()) continue;
            cur++;
            pll front, back;
            front.ff = back.ff = co[j].ff;
            front.ss = back.ss = co[j].ss;
            while( 1 )
            {
                bool is = false;
                it = s.find(pll(front.ff + p, front.ss+q));
                if(it!=s.end())
                {
                    front.ff += p;
                    front.ss += q;
                    s.erase(it);
                    is = true;
                }
                it = s.find(pll(back.ff -p, back.ss - q));
                if(it!=s.end())
                {
                    back.ff -= p;
                    back.ss -= q;
                    s.erase(it);
                    is = true;
                }
                if(!is) break;
            }
        }
        ans = MIN2(ans, cur);
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}