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

#![allow(unused_imports)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repositry is at "https://github.com/Loptall/prcn_lib"

/*
    青perfほしいよ〜！
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::fmt;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{
    clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Signed, Unsigned, Zero,
};
use permutohedron::Heap;
use proconio::{
    derive_readable, fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub trait Visualize {
    fn visualize(&self, split: &str);
    fn continuous(&self) {
        self.visualize("");
    }
    fn spaces(&self) {
        self.visualize(" ");
    }
    fn lines(&self) {
        self.visualize("\n");
    }
}
macro_rules ! impl_vis_for_sized {($ ($ t : ty ) ,+ ) => {$ (impl Visualize for $ t {fn visualize (& self , _split : & str ) {print ! ("{}" , self ) ; } } ) + } ; }
impl_vis_for_sized! {usize , u8 , u16 , u32 , u64 , u128 , isize , i8 , i16 , i32 , i64 , i128 , String , & str }
impl<T: fmt::Display> Visualize for [T] {
    fn visualize(&self, split: &str) {
        print!("{}", self.iter().join(split));
    }
}
/// macro to output answer improved to println
///
/// this macro will print '\n' at the last.
///
/// # Patterns
///
/// `,`, it means one space, it formats the elements, which is before, space-split.
/// And insert a space after the prefix, unless it is at last.
///
/// `=>`, it means empty string, it formats the element, witch is before, without any split.
/// And insert nothing between two element.
///
/// `;`, it means newline(\n), it formats the element, witch is before, newline-split.
/// And insert a newline after the prefix, unless it is at last.
///
/// # Eample
///
/// ```
/// #[test]
/// fn vis_test() {
///     let a = 1;
///     let b = 2;
///     let c = 3;
///
///     let v = vec!['a', 'b', 'c'];
///
///     // single element test ...
///
///     vis!(a); // 1\n
///     vis!(a,); // 1\n
///     vis!(a =>); // 1\n
///     vis!(a;); // 1\n
///
///     println!();
///
///     vis!(a + b); // 3\n
///
///     println!();
///
///     vis!(v); // a b c\n
///     vis!(v,); // a b c\n
///     vis!(v =>); // abc\n
///     vis!(v;); // a\nb\nc\n
///
///     println!();
///
///     // multi elements connected by common operater test ...
///
///     println!();
///
///     vis!(a, b); // 1 2\n
///     vis!(a, b, c); // 1 2 3\n
///     vis!(a, b, c;); // 1 2 3\n
///
///     println!();
///
///     vis!(a => b); // 12\n
///     vis!(a => b => c); // 123\n
///     vis!(a => b => c ,); // 123\n
///
///     println!();
///
///     vis!(a; b); // 1\n2\n
///     vis!(a; b; c); // 1\n2\n3\n
///     vis!(a; b; c =>); // 1\n2\n3\n
///
///     println!();
///
///     // multi elements connected by different operater test ...
///
///     vis!(a, b; c); // 1 2\n3\n
///     vis!(a; b, c); // 1\n2 3\n
///     vis!(a => b, c); // 12 3\n
///     vis!(a; b => c); // 1\n23\n
///
///     println!();
///
///     vis!(a, v); // 1 a b c\n;
///     vis!(a, v;); // 1 a\nb\nc\n;
///     vis!(a => v =>); // 1abc\n;
///
///     println!("\d");
///     // panic!()
/// }
/// ```
#[macro_export]
macro_rules ! vis {() => {println ! () ; } ; ($ last : expr ; ) => {$ last . lines () ; vis ! () } ; ($ last : expr => ) => {$ last . continuous () ; vis ! () ; } ; ($ last : expr $ (, ) ? ) => {$ last . spaces () ; vis ! () ; } ; ($ first : expr ; $ ($ rest : tt ) * ) => {$ first . lines () ; println ! () ; vis ! ($ ($ rest ) * ) ; } ; ($ first : expr => $ ($ rest : tt ) * ) => {$ first . continuous () ; vis ! ($ ($ rest ) * ) ; } ; ($ first : expr , $ ($ rest : tt ) * ) => {$ first . spaces () ; print ! (" " ) ; vis ! ($ ($ rest ) * ) ; } ; }

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const ASCII_A: u8 = 65;
pub const ASCII_0: u8 = 48;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        ball: [(i64, i64); n]
    }

    if n == 1 {
        vis!(1);
        return;
    }

    let ball = ball.into_iter().sorted().collect_vec();

    let mut ans = MAX;
    for i in 0..n {
        for j in 0..n {
            if i == j {
                continue;
            }
            let p = ball[i].0 - ball[j].0;
            let q = ball[i].1 - ball[j].1;

            let mut cnt = 0usize;
            for a in ball.iter() {
                let under = (a.0 - p, a.1 - q);
                if !ball.contains(&under) {
                    cnt += 1;
                }
            }
            ans = min(ans, cnt);
        }
    }

    vis!(ans);
}