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 <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M, K, H, W;
ll MOD = 1000000007;
int ans = 0;
//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<int ,int> firstElof, pair<int,int> secondElof)
{
	return firstElof.second > secondElof.second;
}
int Keta(ll F) {
	int keta = 1;
	while (F/10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
//////////////

int main()
{
	cin >> N;
	vector<pair<ll,ll>>XY(N);
	vector<pair<ll, ll>>XY2(N);
	for (i = 0; i < N; i++) {
		cin >> XY[i].first >> XY[i].second;
		XY2[i].first = XY[i].second;
		XY2[i].second = XY[i].first;
	}
	sort(XY.begin(), XY.end());
	sort(XY2.begin(), XY2.end());
	vector<vector<int>> gapX(N, vector<int>(N, 0));
	vector<vector<int>> gapY(N, vector<int>(N, 0));
	for (i = 0; i < N-1; i++) {
		for (j = i + 1; j < N; j++) {
			gapX[i][j] = XY[j].first - XY[i].first;
			gapY[i][j] = XY[j].second - XY[i].second;
		}
	}
	for (i = 0; i < N - 1; i++) {
		for (j = 0; j < N; j++) {
			int count = 1;
			ll X = gapX[i][j];
			ll Y = gapY[i][j];
			int now = j;
			int next = j + 1;
			while (next < N) {
				if (gapX[now][next] == X && gapY[now][next] == Y) {
					now = next;
					next = now + 1;
					count++;
				}
				else {
					next++;
				}
			}
			ans = max(ans, count);
		}
	}
	for (i = 0; i < N - 1; i++) {
		for (j = i + 1; j < N; j++) {
			gapX[i][j] = XY2[j].second - XY2[i].second;
			gapY[i][j] = XY2[j].first - XY2[i].first;
		}
	}
	for (i = 0; i < N - 1; i++) {
		for (j = 0; j < N; j++) {
			int count = 1;
			ll X = gapX[i][j];
			ll Y = gapY[i][j];
			int now = j;
			int next = j + 1;
			while (next < N) {
				if (gapX[now][next] == X && gapY[now][next] == Y) {
					now = next;
					next = now + 1;
					count++;
				}
				else {
					next++;
				}
			}
			ans = max(ans, count);
		}
	}
	cout << N - ans;
}