Score : $400$ points
The Republic of AtCoder lies on a Cartesian coordinate plane.
It has $N$ towns, numbered $1,2,\dots,N$. Town $i$ is at $(x_i, y_i)$, and no two different towns are at the same coordinates.
There are teleportation spells in the nation. A spell is identified by a pair of integers $(a,b)$, and casting a spell $(a, b)$ at coordinates $(x, y)$ teleports you to $(x+a, y+b)$.
Snuke is a great magician who can learn the spell $(a, b)$ for any pair of integers $(a, b)$ of his choice. The number of spells he can learn is also unlimited.
To be able to travel between the towns using spells, he has decided to learn some number of spells so that it is possible to do the following for every pair of different towns $(i, j)$.
At least how many spells does Snuke need to learn to achieve the objective above?
Input is given from Standard Input in the following format:
$N$ $x_1$ $y_1$ $x_2$ $y_2$ $\vdots$ $x_N$ $y_N$
Print the minimum number of spells Snuke needs to learn.
3 1 2 3 6 7 4
6
The figure below illustrates the positions of the towns (along with the coordinates of the four corners).
If Snuke learns the six spells below, he can get from Town $i$ to Town $j$ by using one of the spells once for every pair $(i,j)$ $(i \neq j)$, achieving his objective.
Another option is to learn the six spells below. In this case, he can get from Town $i$ to Town $j$ by using one of the spells twice for every pair $(i,j)$ $(i \neq j)$, achieving his objective.
There is no combination of spells that consists of less than six spells and achieve the objective, so we should print $6$.
3 1 2 2 2 4 2
2
The optimal choice is to learn the two spells below:
4 0 0 0 1000000000 1000000000 0 1000000000 1000000000
8