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 (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  
from functools import reduce
from math import gcd


def lcm(a, b):
    
    g = gcd(a, b)
    return a // g * b



N = a_int()
XY = read_tuple(N)
XY.sort()
if N == 1:
    print(1)
    exit()










PQcandi = []
for po1, po2 in combinations(XY, r=2):
    dx = po1[0] - po2[0]
    dy = po1[1] - po2[1]
    if dx < 0:
        dx *= -1
        dy *= -1
    elif dx == 0:
        dy = abs(dy)

    PQcandi.append((dx, dy))


def del_ball(p, q, XYtmp):
    ret = []
    
    x, y = XYtmp[0]
    for xx, yy in XYtmp[1:]:
        if xx == x + p and yy == y + q:
            x += p
            y += q
        else:
            ret.append((xx, yy))

    return ret


from copy import deepcopy
ans = INF
for p, q in PQcandi:
    XYtmp = deepcopy(XY)
    anstmp = 0
    while XYtmp:
        anstmp += 1
        XYtmp = del_ball(p, q, XYtmp)
    
    ans = min(ans, anstmp)
print(ans)

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

pq=[]
for i in range(n-1):
  for j in range(i+1,n):
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

ans=n
for p,q in pq:
  cnt=0
  for x,y in xy:
    if [x+p,y+q] in xy:
      cnt+=1
  '''
  for i in range(n):
    for j in range(n):
      if i==j:
        continue
      x1,y1=xy[i]
      x2,y2=xy[j]
      if (x2-x1)==p and (y2-y1)==q:
        cnt+=1
  '''

  ans=min(ans,n-cnt)
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  
from functools import reduce
from math import gcd


def lcm(a, b):
    
    g = gcd(a, b)
    return a // g * b



N = a_int()
XY = read_tuple(N)
if N == 1:
    print(1)
    exit()










PQcandi = []
for po1, po2 in combinations(XY, r=2):
    dx = po1[0] - po2[0]
    dy = po1[1] - po2[1]
    if dx < 0:
        dx *= -1
        dy *= -1
    elif dx == 0:
        dy = abs(dy)

    PQcandi.append((dx, dy))

print(N - max(Counter(PQcandi).values()))

Solution (Python):
from itertools import combinations
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
if N==1:
    print(1)
else:
    C = {}
    for z in combinations(X,2):
        x1,x2 = z
        a = x1[0]-x2[0]
        b = x1[1]-x2[1]
        if a>=0 and b>=0:
            if (a,b) not in C:
                C[(a,b)] = 0
            C[(a,b)] += 1
        elif a>0 and b<0:
            if (a,b) not in C:
                C[(a,b)] = 0
            C[(a,b)] += 1
        elif a==0 and b<0:
            if (a,-b) not in C:
                C[(a,-b)] = 0
            C[(a,-b)] += 1
        elif a<0 and b>0:
            if (-a,-b) not in C:
                C[(-a,-b)] = 0
            C[(-a,-b)] += 1
        elif a<0 and b==0:
            if (-a,b) not in C:
                C[(-a,b)] = 0
            C[(-a,b)] += 1
        elif a<0 and b<0:
            if (-a,-b) not in C:
                C[(-a,-b)] = 0
            C[(-a,-b)] += 1
    C = sorted(list(C.items()),key=lambda x:x[1],reverse=True)
    k = C[0][1]
    print(N-k)

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

ans=n

pq=[]
for i in range(n-1):
  for j in range(i+1,n):
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

for p,q in pq:
  cnt=0



  for i in range(n):
    for j in range(n):
      if i==j:
        continue
      x1,y1=xy[i]
      x2,y2=xy[j]
      if (x2-x1)==p and (y2-y1)==q:
        cnt+=1
  ans=min(ans,n-cnt)
print(ans)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
S = [l() for _ in range(N)]
ans = 0
pq = []
for i in S:
    for j in S:
        if i == j:
            continue
        pq.append((i[0]-j[0],i[1]-j[1]))
for p,q in set(pq):
    cnt = 0
    for i in S:
        for j in S:
            if i == j:
                continue
            if (i[0]-j[0],i[1]-j[1]) == (p,q):
                cnt += 1
    ans = max(ans,cnt)
print(N-ans)

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

ans=n

pq=[]
for i in range(n-1):
  for j in range(i+1,n):
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

for p,q in pq:
  cnt=0
  for x,y in xy:
    if [x+p,y+q] in xy:
        cnt+=1
  ans=min(ans,n-cnt)

print(ans)

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

ans=n

pq=[]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

for p,q in pq:
  cnt=0
  for x,y in xy:
    if [x+p,y+q] in xy:
        cnt+=1
  ans=min(ans,n-cnt)

print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
XY = []
for _ in range(N):
    x, y = mapint()
    XY.append((x, y))

from collections import defaultdict, Counter
dic = []
for i in range(N):
    x1, y1 = XY[i]
    for j in range(N):
        if i==j:
            continue
        x2, y2 = XY[j]
        dx, dy = x2-x1, y2-y1
        if dx==0 and dy==0:
            continue
        dic.append((dx, dy))
c = Counter(dic)
if len(c)==0:
    print(N)
else:
    (x, y), cnt = c.most_common()[0]
    print(N-cnt)

Solution (Python):
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    xy = [[int(x) for x in input().split()] for _ in range(n)]
    vec = list()
    for xy1, xy2 in itertools.combinations(xy, 2):
        p = xy2[0] - xy1[0]
        q = xy2[1] - xy1[1]
        vec.append((p, q))
        vec.append((-p, -q))
    c = collections.Counter(vec)
    if n >= 2:
        ans = max(c.values())
        print(n - ans)
    else:
        print(1)
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
n=int(input())
xy=[]
for i in range(n):
  x,y=map(int,input().split())
  xy.append((x,y))
pq=[]
for i in range(n):
  for j in range(n):
    if i==j:continue
    x1,y1=xy[i]
    x2,y2=xy[j]
    pq.append((x2-x1,y2-y1))
ans=n
for p,q in pq:
  t=0
  for x,y in xy:
    if (x+p,y+q) not in xy:
      t+=1
  ans=min(ans,t)
print(ans)

Solution (Python):
from collections import defaultdict
dic = defaultdict(int) 

N = int(input())
if N == 1:
  print(1)
  exit()
X = []
for i in range(N):
  x,y = map(int,input().split())
  X.append([x,y])

for i in range(N):
  for j in range(i+1,N):
    p = X[i][0] - X[j][0]
    q = X[i][1] - X[j][1]
    if p <0:
      p = -p;q=-q
    if p == 0 and q < 0:
      q=-q
    dic[(p,q)] +=1

path = max(dic.values())
ans = N-path

print(ans)

Solution (Python):
n=int(input())
balls=[]
for i in range(n):
  x,y=map(int,input().split())
  balls.append([x,y])
minans=n
for i in range(0,n-1):
  for j in range(i+1,n):
    p=balls[j][0]-balls[i][0]
    q=balls[j][1]-balls[i][1]
    ballset=set()
    ans=0
    for k in range(n):
      x=balls[k][0]
      y=balls[k][1]
      ballset.add(x*(10**10)+y)
    while ballset:
      current=ballset.pop()
      ballset.add(current)
      y=current%(10**10)
      x=(current-y)//(10**10)
      while (x-p)*(10**10)+(y-q) in ballset:
        x-=p
        y-=q
      while x*(10**10)+y in ballset:
        ballset.remove(x*(10**10)+y)
        x+=p
        y+=q
      ans+=1
    minans=min(minans,ans)
print(minans)

Solution (Python):
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
def solve(p,q):
  global N,X
  r=0
  for i in range(N):
    for j in range(N):
      if X[i][0]+p==X[j][0] and X[i][1]+q==X[j][1]:
        r-=1
  return r

P=0
for i in range(N):
  for j in range(i+1,N):
    P=min(P,solve(X[j][0]-X[i][0],X[j][1]-X[i][1]))
print(N+P)

Solution (Python):
from collections import defaultdict

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
if n == 1:
    print(1)
    exit()
d = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i== j:
            continue
        a,b = l[i]
        c,e = l[j]
        d[(a-c,b-e)] += 1
ans = n
m = max(d.values())
for i,j in d.items():
    if j != m:
        continue

    x,y = i
    if x==0 and y == 0:
        continue
    count = 0
    for c,d in l:
        if [c+x,d+y] in l:
            count += 1
    ans = min(ans,n-count)
print(ans)

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]





if n==1:
    print(1)
    quit()
cnt=0
sadic=defaultdict(int)
for i in range(n):
    x,y=xy[i]
    for j in range(n):
        if i==j:
            continue
        x2,y2=xy[j]
        p,q=x-x2,y-y2
        sadic[(p,q)]+=1

print(n-max(sadic.values()))

Solution (Python):



from collections import Counter

def main():
    N = int(input())
    S = [tuple(map(int,input().split())) for _ in range(N)]

    if N == 1:
        print(1)
    else:
        cnt = []
        for i in range(N-1):
            xi, yi = S[i]
            for j in range(i+1,N):
                xj, yj = S[j]
                cnt.append((xi-xj, yi-yj))
                cnt.append((xj-xi, yj-yi))
        A = Counter(cnt)
        ll = max(A.values())
        print(N-ll)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    C = [list(map(int, input().split())) for i in range(N)]
    ans = N
    for a,b in C:
        for x, y in C:
            if a == x and b == y:
                continue
            p, q = a -x , b - y
            CNT = 0
            for u, v in C:
                for s, t in C:
                    if u == s and v == t:
                        continue
                    if u-s == p and v-t == q:
                        CNT += 1
            ans = min(ans, N-CNT)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
x = [0] * n
y = [0] * n

for i in range(n):
    x[i], y[i] = map(int, input().split())

table = {}

for i in range(n - 1):
    for j in range(i + 1, n):
        dx = x[i] - x[j]
        dy = y[i] - y[j]
        if (dx, dy) not in table:
            table[(dx, dy)] = 1
            table[(-dx, -dy)] = 1
        else:
            table[(dx, dy)] += 1
            table[(-dx, -dy)] += 1

m = 0

for key, value in table.items():
    m = max(m, value)

print(n - m)

Solution (Python):
N, *XY = map(int, open(0).read().split())
X = XY[::2]
Y = XY[1::2]
ans = N
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        p = X[i] - X[j]
        q = Y[i] - Y[j]
        cnt = 0
        for k in range(N):
            for l in range(N):
                if k == l:
                    continue
                if X[k] - X[l] == p and Y[k] - Y[l] == q:
                    cnt += 1
        ans = min(ans, N - cnt)
print(ans)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')
AtoZ = "abcdefghijklmnopqrstuvwxyz"






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  divisors.sort()
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




N = I()
data = ILL(N)

if N == 1:
  print(1)
  exit()

kouho = []
for i in range(N):
  for j in range(i+1,N):
    a,b = data[i]
    c,d = data[j]
    kouho.append((c-a,d-b))
MIN = INF
for x,y in kouho:
  ans = N
  for i in range(N):
    for j in range(i+1,N):
      a,b = data[i]
      c,d = data[j]
      if (a+x == c and b+y == d) or (c+x == a and d+y == b):
        ans -= 1
  MIN = min(MIN,ans)
print(MIN)

Solution (Python):
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]

ans = 0

for i in range(N-1):
  x1,y1 = xy[i]
  for j in range(i+1,N):
    x2,y2 = xy[j]
    p = x2-x1
    q = y2-y1
    cost = 0
    for x,y in xy:
      if [x-p,y-q] in xy:
        cost += 1
    ans = max(ans,cost)
    
print(N-ans)

Solution (Python):
n = int(input())
s = [list(map(int, input().split())) for _ in range(n)]
t = []
for i in range(n):
    for j in range(n):
        if not i == j:
            t.append([s[i][0] - s[j][0], s[i][1] - s[j][1]])
ans = n
for i in range(pow(n, 2) - n):
    cnt = 0
    for j in range(pow(n, 2) - n):
        if t[i][0] == t[j][0] and t[i][1] == t[j][1]:
            cnt += 1
    ans = min(ans, n - cnt)
print(ans)

Solution (Python):
from collections import Counter
n=int(input())
if n==1:
  print(1)
  exit()
xy=[tuple(map(int,input().split())) for _ in range(n)]


xy.sort()

l=[]
for i in range(n-1):
  for j in range(i+1,n):
    l.append((xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]))


print(n-Counter(l).most_common()[0][1])

Solution (Python):
from collections import defaultdict

n = int(input())
x, y = [0] * n, [0] * n
data = defaultdict(int)
for i in range(n):
    x[i], y[i] = map(int, input().split())

if n == 1:
    print(1)
    exit()
for i in range(n):
    for j in range(n):
        if i != j:
            data[x[j] - x[i], y[j] - y[i]] += 1

print(n - max(data.values()))

Solution (Python):
import sys
N = int(sys.stdin.readline().rstrip())

if N == 1:
    print(1)
    exit()

zahyo = []
for _ in range(N):
    x, y = map(int, sys.stdin.readline().rstrip().split())
    zahyo.append((x, y))
zahyo.sort()

p_q = set()
for i in range(N - 1):
    for j in range(i + 1, N):
        p = zahyo[j][0] - zahyo[i][0]
        q = zahyo[j][1] - zahyo[i][1]
        p_q.add((p, q))

ans = float("inf")
for p, q in p_q:
    used = set()
    ans_tmp = 0
    for i in range(N):
        if i not in used:
            x_base = zahyo[i][0]
            y_base = zahyo[i][1]
            ans_tmp += 1
            for j, (x, y) in enumerate(zahyo[i + 1:], 1):
                if x - x_base == p and y - y_base == q:
                    used.add(i + j)
                    x_base = x
                    y_base = y
    ans = min(ans_tmp, ans)
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
'''


 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
'''
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()

arr=[list(mii()) for _ in range(n)]

chk={}

for i in arr:
    for j in arr:
        if i!=j:
            p=i[0]-j[0]
            q=i[1]-j[1]

            if str(p)+","+str(q) in chk:
                chk[str(p)+","+str(q)]+=1
            else:
                chk[str(p)+","+str(q)]=1

places="w"
num=0

for i,j in chk.items():
    if j>num:
        num=j
        places=i

print(n-num)

Solution (Python):
N = int(input())
XYs = [list(map(int, input().split())) for _ in range(N)]

dic = {}
tmp = 0

for i in range(N):
  for j in range(N):
    if i == j:
      continue
    p = XYs[j][0] - XYs[i][0]
    q = XYs[j][1] - XYs[i][1]

    if "{}_{}".format(p,q) not in dic:
      dic["{}_{}".format(p,q)] = 1
    else:
      dic["{}_{}".format(p,q)] += 1
      
for k in dic:
  if tmp < dic[k]:
    tmp = dic[k]

print(N-tmp)

Solution (Python):
import fractions
n = int(input())
z = [list(map(int,input().split())) for _ in range(n)]
if n == 1:
	print(1)
else:
	a = []
	ans = 10**18
	for i in range(n):
		for j in range(i+1, n):
			a.append((z[i][0]-z[j][0], z[i][1]-z[j][1]))
	for i, j in a:
		tmpans = n
		for k, l in z:
			if [k-i, l-j] in z:
				tmpans -= 1
		ans = min(ans, tmpans)
	print(ans)

Solution (Python):
n = int(input())
ans = n
L = [list(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
    for j in range(i+1, n):
        pq.append([L[j][0] - L[i][0], L[j][1] - L[i][1]])
for p, q in pq:
    cost = n
    for x, y in L:
        if [x-p, y-q] in L:
            cost -=1
    ans = min(ans, cost)
print(ans)

Solution (Python):
n = int(input())
if n == 1:
    print(1)
else:
    buf = []
    for i in range(n):
        x,y = map(int,input().split())
        buf.append([x,y])
    
    buf.sort()
    
    ans = 1e9
    for i in range(n):
        for j in range(i+1,n):
            p,q = buf[j][0]-buf[i][0],buf[j][1]-buf[i][1]
    
            ind = 0
            used = set()
            tcost = 0
            befx = 0
            befy = 0
            flag = False
            while True:
                befx,befy = buf[ind][0],buf[ind][1]
                tcost += 1
                for l in range(n):
                    if l not in used:
                        tx,ty = buf[l][0],buf[l][1]
                        if tx-befx == p and ty-befy == q:
                            befx = tx
                            befy = ty
                            used.add(l)
                while True:
                    ind += 1
                    if ind == n:
                        flag = True
                        break
                    if ind in used:
                        continue
                    else:
                        break
                if flag:
                    break
            if ans > tcost:
                
                
                ans = tcost
    
    print(ans)

Solution (Python):
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]

v={}
for i in range(N):
    for j in range(N):
        if i==j:
            continue
        vect=[x[i][0]-x[j][0],x[i][1]-x[j][1]]
        vs=str(vect[0])+","+str(vect[1])
        if vs in v:
            v[vs]+=1
        else:
            v[vs]=1

VM=0
for m in v:
    VM=max(VM,v[m])
print(N-VM)

Solution (Python):
from collections import defaultdict
import numpy as np
import sys

n = int(input())
xy = np.array([list(map(int, input().split())) for _ in range(n)])

if n == 1:
    print(1)
    sys.exit()

memo = defaultdict(int)

for i in xy:
    for j in xy:
        if np.all(i == j):
            continue
        else:
            tmp = j - i
            if tmp[0] < 0:
                tmp *= -1
            elif tmp[0] == 0 and tmp[1] < 0:
                tmp *= -1
            memo[str(tmp)] += 1

print(n - max(memo.values()) // 2)

Solution (Python):
import math

n=int(input())

XY=[]

for i in range(n):
    x,y=map(int,input().split())
    XY.append([x,y])

v=[]

for i in range(n):
    for j in range(n):
        if j!=i:
            v.append([XY[i][0]-XY[j][0],XY[i][1]-XY[j][1]])


c=0
for vx,vy in v:
    cv=0
    for i in range(n):
        for j in range(n):
            if j!=i and [XY[i][0]-XY[j][0],XY[i][1]-XY[j][1]]==[vx,vy]:
                cv+=1
    c=max(cv,c)

print(n-c)

Solution (Python):
from collections import Counter
n=int(input())
if n==1:
  print(1)
  exit()
xy=[tuple(map(int,input().split())) for _ in range(n)]
xy.sort()
l=[]
for i in range(n-1):
  for j in range(i+1,n):
    l.append((xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]))
print(n-Counter(l).most_common()[0][1])

Solution (Python):
N = int(input())

points = [list(map(int, input().split())) for _ in range(N)]
vec_dic = {}

max_same = 0
for i in range(N):
    x1,y1 = points[i]
    for j in range(N):
        if i == j:
            continue
        x2,y2 = points[j]
        d_x = x2 - x1
        d_y = y2 - y1
        if d_x in vec_dic.keys():
            if d_y in vec_dic[d_x].keys():
                vec_dic[d_x][d_y] += 1
                max_same = max(max_same, vec_dic[d_x][d_y])
            else:
                vec_dic[d_x][d_y] = 1
                max_same = max(max_same,1)
        else:
            vec_dic[d_x] = {d_y: 1}
            max_same = max(max_same, 1)
print(N-max_same)

Solution (Python):
n = int(input())
ball = []
for i in range(n):
    ball.append(list(map(int, input().split())))

ans = 1000
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        temp = 0
        x0, y0 = ball[i]
        x1, y1 = ball[j]
        p, q = x1-x0, y1-y0
        used = [False]*(n)
        for k in range(n):
            if not used[k]:
                temp += 1
                x0, y0 = ball[k]
                used[k] = True

                x, y = x0, y0
                while True:
                    f = 0
                    for l in range(n):
                        if used[l]:
                            continue
                        if x + p == ball[l][0] and y + q == ball[l][1]:
                            used[l] = True
                            x += p
                            y += q
                            f = 1
                    if f == 0:
                        break

                x, y = x0, y0
                while True:
                    f = 0
                    for l in range(n):
                        if used[l]:
                            continue
                        if x - p == ball[l][0] and y - q == ball[l][1]:
                            used[l] = True
                            x -= p
                            y -= q
                            f = 1
                    if f == 0:
                        break

        ans = min(ans, temp)

if n == 1:
    print(1)
else:
    print(ans)

Solution (Python):
n = int(input())
grid = []
if n == 1:
    print(1)
    exit()
for _ in range(n):
    x,y = map(int,input().split())
    grid.append((x,y))
S = set(grid)
ans = float("inf")
for i in range(n-1):
    for j in range(i+1,n):
        cnt = 0
        p = grid[i][0]-grid[j][0]
        q = grid[i][1]-grid[j][1]
        for k in range(n):
            if (grid[k][0]-p,grid[k][1]-q) in S:
                cnt += 1
        else:
            ans = min(n-cnt,ans)
print(ans)

Solution (Python):
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    
    N = II()
    coordinates = []
    diffs = defaultdict(int)
    for i in range(N):
        coordinates.append(LMIIS())
    coordinates.sort()
    for i in range(N):
        x1,y1 = coordinates[i]
        for j in range(i+1,N):
            x2,y2 = coordinates[j]
            diffs[(x1-x2,y1-y2)] += 1
    
    max_diff = ()
    max_count = 0

    for k,v in diffs.items():
        if max_count < v:
            max_count = v
            max_diff = k
    print(N-max_count)


if __name__ == '__main__':
    main()

Solution (Python):
import collections

N = int(input())

if N == 1:
    print(1)
    exit()

x_y = []
for _ in range(N):
    x_y.append(list(map(int, input().split())))

x_y.sort(key=lambda x: (x[0], x[1]))
pq_cand = []
for i in range(N):
    for j in range(i + 1, N):
        pq_cand.append((x_y[j][0] - x_y[i][0], x_y[j][1] - x_y[i][1]))

pqc = collections.Counter(pq_cand)
_, x = max(pqc.items(), key=lambda x: x[1])
print(N - 1 - x + 1)