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
from itertools import combinations

def main():
    input = sys.stdin.readline
    N = int(input())
    cord = set()
    for _ in range(N):
        x, y = map(int, input().split())
        cord.add((x, y))

    if N <= 2:
        return 1

    ans = 50
    for a in combinations(cord, 2):
        x1, y1 = a[0]
        x2, y2 = a[1]

        p = x2 - x1
        q = y2 - y1

        cnt1 = 0
        cnt2 = 0

        if p == q == 0:
            continue

        A = set()
        B = set()
        for x, y in cord:
            A.add((x-p, y-q))
            B.add((x+p, y+q))

        ans = min(ans, len(A - cord), len(B - cord))

    return ans


if __name__ == '__main__':
    print(main())

Solution (Python):
n = int(input())
if n == 1:
  print(1)
  exit()
xy = []
for _ in range(n):
  x, y = map(int, input().split())
  xy.append([x, y])

vecs = {}
for i in range(n):
  for j in range(i+1, n):
    if xy[i][0] < xy[j][0]:
      vec = (xy[j][0] - xy[i][0], xy[j][1] - xy[i][1])
    elif xy[i][0] > xy[j][0]:
      vec = (xy[i][0] - xy[j][0], xy[i][1] - xy[j][1])
    else:
      vec = (0, abs(xy[j][1] - xy[i][1]))
    
    if vec in vecs:
      vecs[vec] += 1
    else:
      vecs[vec] = 1

vec_max = max(list(vecs.values()))
print(n - vec_max)

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

sabun_dict = {}

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

for i in range(n):
  for j in range(n):
    x = point_list[i][0] - point_list[j][0]
    y = point_list[i][1] - point_list[j][1]
    if x == 0 and y == 0:
      continue
    if (x, y) in sabun_dict:
      sabun_dict[(x, y)] = sabun_dict[(x, y)] + 1
    else:
      sabun_dict[(x, y)] = 1

max_v = max(sabun_dict.values())

print(n - max_v)

Solution (Python):

import sys
import itertools
import operator
import collections

def solve(N: int, x: "List[int]", y: "List[int]"):
    if N == 1:
        print(1)
        return

    PL = list(zip(x,y))
    PL.sort(key = operator.itemgetter(0,1))

    pqdic = collections.defaultdict(list)
    for i in range(N-1):
        for j in range(i+1,N):
            p = PL[j][0] - PL[i][0]
            q = PL[j][1] - PL[i][1]
            pqdic[p,q].append((i,j))

    max_pqlen = 0
    for k,v in pqdic.items():
        max_pqlen = max(max_pqlen,len(v))

    print(N - max_pqlen)





def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    x = [int()] * (N)  
    y = [int()] * (N)  
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()

Solution (Python):

import time
import re
import math

def main():
    N=int(input())
    XY=[]
    for a in range(N):
        XY.append(list(map(int,input().split())))
    DL=[]
    for a in range(N):
        xa=XY[a][0]
        ya=XY[a][1]
        for b in range(N):
            if(b==a):continue
            xb=XY[b][0]
            yb=XY[b][1]
            d=D(xa,ya,xb,yb)
            DL.append(d)
    mx=0
    for a in range(len(DL)):
        mx=max([mx,DL.count(DL[a])])
    
    print(N-mx)
def D(x1,y1,x2,y2):
    x=x2-x1
    y=y2-y1
    return [x,y]
start=time.time()
main()

Solution (Python):

from itertools import product
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

m = 0
xy.sort(key=lambda x: (x[0], x[1]))
for l in range(n - 1):
    for r in range(l + 1, n):
        p = xy[r][0] - xy[l][0]
        q = xy[r][1] - xy[l][1]
        c = 0
        for i in range(n - 1):
            for j in range(i + 1, n):
                if xy[j][0] - xy[i][0] != p: continue
                if xy[j][1] - xy[i][1] != q: continue
                c += 1
                break
        m = max(m, c)

xy.sort(key=lambda x: (x[1], x[0]))
for l in range(n - 1):
    for r in range(l + 1, n):
        p = xy[r][0] - xy[l][0]
        q = xy[r][1] - xy[l][1]
        c = 0
        for i in range(n - 1):
            for j in range(i + 1, n):
                if xy[j][0] - xy[i][0] != p: continue
                if xy[j][1] - xy[i][1] != q: continue
                c += 1
                break
        m = max(m, c)

print(n - m)

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

stock=[]

for i in range(N):
    for j in range(i+1,N):
        if xy[i][0]-xy[j][0]==0:
            if xy[i][1]-xy[j][1]>0:
                stock.append([xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]])
            else:
                stock.append([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]])
        elif xy[i][0]-xy[j][0]>0:
              stock.append([xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]])
        else:
              stock.append([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]])

stock.sort(key=lambda x:(x[0],x[1]))
counter=0
ans=0
for i in range(1,len(stock)):

    if stock[i]==stock[i-1]:
        counter+=1
    else:
        ans=max(ans,counter)
        counter=0
ans=max(ans,counter)
print(max(N-ans-1,1))

Solution (Python):
from collections import Counter
from itertools import combinations

N = int(input())
R = [[int(i) for i in input().split()] for _ in range(N)]

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

L = []
for (x1, y1), (x2, y2) in combinations(R, 2):
    L.append((x1 - x2, y1 - y2))
    L.append((-x1 + x2, -y1 + y2))

C = Counter(L)
print(N - C.most_common(1)[0][1])

Solution (Python):
N = int(input())
l = [list(map(int,input().split(" "))) for _ in range(N)]
ll = [tuple(i) for i in l]
same = 1
n = N**2 - N
ans_l = [()]*n
cnt = 0
for i in l:
    x = i[0]
    y = i[1]
    for j in l:
        if i==j:
            continue
        k = (j[0]-x,j[1]-y)
        ans_l[cnt] = k[:]
        cnt+=1
ans = 0
ans_l.sort()
for i in ans_l:
    k = i[0]
    same = 0
    for j in ans_l:
        if j[0] > k:
            break
        if i==j:
            same+=1
    ans = max(ans,same)
print(N-ans)

Solution (Python):
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]
x.sort()
ans = float('inf')
for d1 in x:
    for d2 in x:
        tmp = n
        if d1 == d2:
            continue
        p = d1[0] - d2[0]
        q = d1[1] - d2[1]
        s = set()
        for idx, d3 in enumerate(x):
            for d4 in x:
                if tuple(d4) not in s and d3 != d4 and (d4[0] - d3[0] == p and d4[1] - d3[1] == q or d4[0] - d3[0] == -p and d4[1] - d3[1] == -q):
                    tmp -= 1
                    break
            s.add(tuple(d3))
        ans = min(ans, tmp)
if n == 1:
    print(1)
else:
    print(max(1, ans))

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

d = set()
for i in range(N):
    for j in range(N):
        d.add((D[i][0] - D[j][0], D[i][1] - D[j][1]))


d = list(d)
num = float('inf')
for p, q in d:
    if p == 0 and q == 0:
        continue
    used = [0] * N
    prex, prey = D[0][0], D[0][1]
    used[0] = 1
    tmp = 1
    for k in range(N - 1):
        for i in range(N):
            if used[i]:
                continue
            if D[i][0] - prex == p and D[i][1] - prey == q:
                prex = D[i][0]
                prey = D[i][1]
                used[i] = 1
                break
        else:
            tmp += 1
            for i in range(N):
                if not used[i]:
                    prex = D[i][0]
                    prey = D[i][1]
                    used[i] = 1
                    break
    num = min(tmp, num)

print(num)

Solution (Python):
def sol(inp=input):
    n=int(inp())
    pts=[tuple(map(int,inp().split())) for _ in range(n)]
    min_cost=n
    pt1=pts[0]
    for pt2 in pts[1:]:
        p,q=(pt1[0]-pt2[0],pt1[1]-pt2[1])
        cost=0
        for i,pt in enumerate(pts):
            if (pt[0]+p,pt[1]+q) not in pts:
                cost+=1
        min_cost=min(cost,min_cost)
    return '{}'.format(min_cost)
print(sol())

Solution (Python):
n=int(input())
z=[]
for i in range(n):
    x,y=map(int,input().split())
    z.append([x,y])
z.sort(reverse=True)
dif=[]
for i in range(n):
    for j in range(n):
        if i<j:
            x=z[j][0]-z[i][0]
            y=z[j][1]-z[i][1]
            dif.append([x,y])
dif.sort(reverse=True)
count=-1
buf=0
comp=[0,0]
ans=[0,0]
l=len(dif)
for i in range(l):
    if comp==dif[i]:
        buf+=1
    else:
        if count<buf:
            count=buf
            ans=comp
        buf=1
        comp=dif[i]
if count<buf:
    count=buf
    ans=comp
print(n-count)

Solution (Python):

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
xy.sort(key=lambda x: x[0])
tilt_map = {}

if N == 1:
    print(1)
else:
    for i in range(N):
        for j in range(i+1, N):
            a = xy[i]
            b = xy[j]
            tilt_x = a[0] - b[0]
            tilt_y = a[1] - b[1]
            if tilt_x == 0 and tilt_y < 0:
                tilt_y *= -1
            key = str(tilt_x) + ":" + str(tilt_y)
            if key in tilt_map:
                tilt_map[key] += 1
            else:
                tilt_map[key] = 1


    most_tilt = sorted(tilt_map.items(), key=lambda x: x[1], reverse=True)[0][1]
    print(N-most_tilt)

Solution (Python):
import collections
N = int(input())
ball_location = []
for i in range(N):
    x,y = map(int, input().split())
    ball_location.append([x,y])

vector = []
if N <= 2:
    print(1)
else:
    for i in range(N):
        first_point = ball_location[i]
        
        for next_point in ball_location[0:i] + ball_location[i+1:]:
            p = next_point[0] - first_point[0]
            q = next_point[1] - first_point[1]
            vector.append(str(p) + "," + str(q))
            
    print(N - collections.Counter(vector).most_common()[0][1])

Solution (Python):
import bisect
from operator import itemgetter
import math
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
xy = [IL() for i in range(N)]

if N == 1 or N == 2:
  print(1)
else:
  data = []
  cnt = 0
  for i in itertools.combinations(xy,2):
    rex,rey = i[0]
    x,y = i[1]
    if rex > x:
      rex,rey,x,y = x,y,rex,rey
    if rex == x:
      if rey > y:
        rex,rey,x,y = x,y,rex,rey
    data.append(str(x-rex)+str(y-rey))
  else:
    d = collections.Counter(data)
    cnt = max(cnt,d.most_common()[0][1])
  
  print(N-cnt)

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

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

ans = 10**9
for i in check:
    b = []
    for j in range(n):
        b.append([xy[j][0]-i[0],xy[j][1]-i[1]])
    c = n
    for j in range(n):
        if b[j] in xy:
            c -= 1
    if c < ans:
        ans = c
if n == 1:
    print(1)
else:
    print(ans)

Solution (Python):
N = int(input())
P = sorted([list(map(int, input().split())) for i in range(N)])
Z = set()
for x, y in P:
    Z.add((x, y))
X = []
ans = N - 1
for i in range(N):
    for j in range(i + 1, N):
        xi, yi = P[i]
        xj, yj = P[j]

        p, q = (xj - xi), (yj - yi)
        X.append((p, q))

for p, q in X:
    hit = 0
    for x, y in P:
        if (x - p, y - q) in Z:
            hit += 1
    ans = min(ans, N - hit)
print(max(1, ans))

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

PQ = []
for i in range(N):
    for j in range(i+1, N):
        now = [ XY[j][0] - XY[i][0], XY[j][1] - XY[i][1] ]
        if not now in PQ:
            PQ.append(now)

ans = N
for r in range(len(PQ)):
    cnt = N
    for i in range(N):
        nxt = [ XY[i][0] + PQ[r][0], XY[i][1] + PQ[r][1] ]
        if nxt in XY:
            cnt -= 1
    ans = min(ans, cnt)

print(ans)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n,k = LI()
    print(n%k)
    return


def B():
    n = I()
    po = LIR(n)
    if n == 1:
        print(1)
        quit()
    ans = float("inf")
    for i in range(n):
        for j in range(n):
            if i == j:continue
            x,y = po[i]
            s,t = po[j]
            p,q = s-x,t-y
            m = n
            for k in range(n):
                for l in range(n):
                    if (po[k][0]-po[l][0],po[k][1]-po[l][1]) == (p,q):m -= 1
            if m < ans:
                ans = m
    print(ans)
    return


def C():
    n = I()
    a = LI()
    a.sort()
    if a[0] >= 0:
        print(sum(a)-2*a[0])
        for i in range(1,n-1):
            print(a[0],a[i])
            a[0] -= a[i]
        print(a[n-1],a[0])
    else:
        if a[-1] < 0:
            print(2*a[-1]-sum(a))
            for i in range(n-1):
                print(a[-1],a[i])
                a[-1] -= a[i]
        else:
            m = bisect.bisect_left(a,0)
            p = n-m
            ans = -sum(a[:m])+sum(a[m:])
            print(ans)
            if p > m:
                l = a[-1]
                a = a[:-1]
                a = a[::-1]
                p -= 1
                p,m = m,p
                k = a[m]-a[m-1]
                print(a[m],a[m-1])
                for i in range(p-1):
                    print(a[m-i-2],k)
                    k = a[m-i-2]-k
                    print(a[m+i+1],k)
                    k = a[m+i+1]-k
                for i in range(m-p):
                    print(k,a[i])
                    k -= a[i]
                print(l,k)
            else:
                k = a[m]-a[m-1]
                print(a[m],a[m-1])
                for i in range(p-1):
                    print(a[m-i-2],k)
                    k = a[m-i-2]-k
                    print(a[m+i+1],k)
                    k = a[m+i+1]-k
                for i in range(m-p):
                    print(k,a[i])
                    k -= a[i]
    return


def D():
    n = I()

    return


def E():
    n = I()

    return


def F():
    n = I()

    return


def G():
    n = I()

    return


def H():
    n = I()

    return


def I_():
    n = I()

    return


def J():
    n = I()

    return


if __name__ == "__main__":
    B()

Solution (Python):
n=int(input())
l=[tuple(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:x[0])
s=set()
fa=n-1
if(n==1):
    print(1)
    quit()
for i in range(n):
    for j in range(i+1,n):
        x,y=sorted([l[i],l[j]],key=lambda x:x[0])
        p=l[j][0]-l[i][0]
        q=l[j][1]-l[i][1]
        s=set(l)
        ans=n
        for x,y in l:
            if((x+p,y+q) in s):
                ans-=1
        fa=min(fa,ans)
print(fa)

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

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

if N == 1:
    print(1)
else:
    pq = {}
    for i in range(N-1):
        for j in range(i+1, N):
            p, q = balls[i][0] - balls[j][0], balls[i][1] - balls[j][1]
            if p < 0 or (p == 0 and q < 0):
                p, q = -p, -q
            if (p, q) in pq:
                pq[(p, q)] += 1
            else:
                pq[(p, q)] = 1

    ans = N - max(pq.values())
    print(ans)

Solution (Python):
INF = 10 ** 100
n = int(raw_input())
ns = []

for i in xrange(n):
    (y, x) = map(int, raw_input().split())
    ns.append((y, x))

ns.sort()

ans = INF

if n == 1:
    ans = 1

for i in xrange(n):
    for j in xrange(i + 1, n):
        dy, dx = ns[j][0] - ns[i][0], ns[j][1] - ns[i][1]

        ps = ns[:]
        st = set(ps)
        cnt = 0

        for p in ps:
            if p not in st:
                continue
            st.remove(p)
            cnt += 1
            y, x = p
            while st:
                ny, nx = y + dy, x + dx
                if (ny, nx) not in st:
                    break
                st.remove((ny, nx))
                y, x = ny, nx
        ans = min(ans, cnt)

print ans

Solution (Python):
N = int(input())
xy = [[int(i) for i in input().split()] for i in range(N)]
xy = sorted(xy)


d = {}
m = 0
for i in range(N):
    for j in range(i+1, N):
        a, b = xy[i][0]-xy[j][0], xy[i][1]-xy[j][1]
        if (a, b) in d:
            d[a, b] += 1
        else:
            d[a, b] = 1

for val in d.values():
    m = max(m, val)

print(N-m)

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

balls = []

for _ in range(n):
    a, b = map(int, input().split())
    balls.append((a,b))

costmax = n
costmin = 0
ans = costmax

if n == 1:
    ans = 1
elif n == 2:
    ans = 1
else:
    c_divs = []
    for i in range(n):
        x = balls[i][0]
        y = balls[i][1]

        for j in range(n):
            c_divs.append((balls[j][0] - x, balls[j][1] - y))
            


    import collections
    c = collections.Counter(c_divs)

    if c.most_common()[0][0] == (0,0):
        save = c.most_common()[1][1]
    else:
        save = c.most_common()[0][1]
    ans = ans - save


print(ans)

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

ball_position = []
for _ in range(N):
    i, j = map(int, input().split())
    ball_position.append((i, j))

    
def tup2_diff(a, b):
    ai, aj = a
    bi, bj = b
    return ((ai - bi, aj - bj))
  
calculation_list = []
for i in range(len(ball_position)):
    for j in range(len(ball_position)):
        if i == j:
            continue
        else:
            x , y = tup2_diff(ball_position[i], ball_position[j])
            if x > 0 or (x == 0 and y > 0):
                calculation_list.append((x, y))
           
import collections

c = collections.Counter(calculation_list).most_common(1)
if N == 1:
    print(1)
else:
    print(N - calculation_list.count(c[0][0]))

Solution (Python):
import itertools


n = int(input())
xs, ys = list(), list()
points = list()
for i in range(n):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)
    points.append((x, y))

candidates = list()
indices = itertools.combinations(range(n), 2)
points = sorted(points)
for i, j in indices:
    p = points[j][0] - points[i][0]
    q = points[j][1] - points[i][1]
    candidates.append((p, q))

ans = n * 2
for p, q in candidates:
    indices = list(range(n))
    cost = 0

    idx = 0
    cost += 1

    while True:
        x, y = points[idx]
        indices.remove(idx)
        if len(indices) == 0:
            break

        try:
            idx = points.index((x + p, y + q))
        except Exception:
            idx = indices[0]
            cost += 1
    
    ans = min(ans, cost)

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

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

distlist=[]
distnum=[]

for i in range(n):
    for j in range(n):
        vec=[xy[i][0]-xy[j][0], xy[i][1]-xy[j][1]]
        if(i==j):
             continue
        flag=0
        for k in range(len(distlist)):
            if(distlist[k][0]==vec[0] and distlist[k][1]==vec[1]):
                distnum[k] += 1
                flag=1
                break
        if(flag==0):
            distlist.append(vec)
            distnum.append(1)

if(n==1):
    print(1)
else:
    print(max(n-max(distnum),1))

Solution (Python):
from collections import defaultdict
from sys import stdin

def main():
    N = int(input())
    XY = [tuple(map(int, input().split())) for _ in [0] * N]

    if N == 1:
        print(1)
        return

    XY.sort()
    cnt = defaultdict(int)
    for i in range(N):
        x1, y1 = XY[i]
        for j in range(i + 1, N):
            x2, y2 = XY[j]
            p = x2 - x1
            q = y2 - y1
            cnt[(p, q)] += 1
    print(N - max(cnt.values()))

input = lambda: stdin.readline()
main()

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

xy = []
xyvec = {}

for i in range(N):
  x, y = map(int, input().split())
  for _x, _y in xy:
    if (x - _x, y - _y) in xyvec:
      xyvec[(x - _x, y - _y)].append(((_x, _y), (x, y)))
      xyvec[(_x - x, _y - y)].append(((x, y), (_x, _y)))
    else :
      xyvec[(x - _x, y - _y)] = [((_x, _y), (x, y))]
      xyvec[(_x - x, _y - y)] = [((x, y), (_x, _y))]

  xy.append((x, y))

result = N
for key in xyvec:
  temp_result = N - len(xyvec[key])
  if result > temp_result :
    result = temp_result

print(result)

Solution (Python):
from collections import Counter
n = int(input())
a = sorted(tuple(map(int, input().split())) for _ in range(n))
c = Counter((y[0] - x[0], y[1] - x[1]) for i, x in enumerate(a) for y in a[:i])
print(n - max(c.values(), default=0))

Solution (Python):
import sys
input = sys.stdin.readline


N=int(input())
B=[tuple(map(int,input().split())) for i in range(N)]

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

PQ=set()

for i in range(N-1):
    x1,y1=B[i]
    for j in range(i+1,N):
        x2,y2=B[j]

        u,v=x2-x1,y2-y1

        PQ.add((u,v))

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):  
    if find(x) != find(y):
        Group[find(y)]=Group[find(x)]=min(find(y),find(x))
ANS=50

for p,q in PQ:

    Group=[i for i in range(N)]

    for i in range(N-1):
        for j in range(i+1,N):
            if B[i][0]+p==B[j][0] and B[i][1]+q==B[j][1]:
                Union(i,j)
            if B[i][0]-p==B[j][0] and B[i][1]-q==B[j][1]:
                Union(i,j)

    G2=[find(i) for i in range(N)]
    ANS=min(ANS,len(set(G2)))

print(ANS)

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

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

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

balls.sort()  
sorted(balls, key=lambda x: x[1])

hyo={}

for i in range(n):
  for j in range(i+1,n):
    difx=balls[j][0]-balls[i][0]
    dify=balls[j][1]-balls[i][1]
    if (difx,dify) in hyo.keys():
      hyo[(difx,dify)] +=1
    else:
      hyo[(difx,dify)] =1


p,q=max(hyo,key=hyo.get)

chk=[1]*n

for i in range(n-1,-1,-1):
  x=balls[i][0]-p
  y=balls[i][1]-q
  if [x,y] in balls:
    chk[i]=0


print(sum(chk))

Solution (Python):
from itertools import combinations
n=int(input())
if n == 1:
    print(1)
else:
    xs = []
    for _ in range(n):
        x,y=map(int,input().split())
        xs.append((x,y))
    
    def func(c):
        p,q=(xs[c[0]][0]-xs[c[1]][0],xs[c[0]][1]-xs[c[1]][1])
        ys=[(x,y) for x,y in xs if (x-p,y-q) not in xs]
        return len(ys)
    
    c = combinations(range(n),2)
    print(min(map(func, c)))

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
import math


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def mod_inv(x):
    
    global mod
    return pow(x, mod - 2, mod)


def gcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    ret = math.factorial(x)
    ret = ret // (math.factorial(x - y) * math.factorial(y))

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    n = intin()
    xylist = intinl(n)

    pqtoij = defaultdict(list)

    for i in range(n):
        for j in range(i + 1, n):
            x1, y1 = xylist[i]
            x2, y2 = xylist[j]

            if x1 - x2 > 0:
                p = x1 - x2
                q = y1 - y2
            if x1 - x2 < 0:
                p = -(x1 - x2)
                q = -(y1 - y2)
            if x1 - x2 == 0:
                if y1 - y2 > 0:
                    p = x1 - x2
                    q = y1 - y2
                if y1 - y2 < 0:
                    p = -(x1 - x2)
                    q = -(y1 - y2)

            pqtoij[(p, q)].append((i, j))

    maxcount = 0

    for (p, q), ijlist in pqtoij.items():
        checked = []
        count = 0
        for i, j in ijlist:
            if (i, j) in checked:
                continue
            count += 1
            checked.append((i, j))
        maxcount = max(maxcount, count)

    print(n - maxcount)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
cnt = dict()
xy = [tuple(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
    exit()
for x1, y1 in xy:
    for x2, y2 in xy:
        if x1 == x2 and y1 == y2:
            continue
        dx = x1 - x2
        dy = y1 - y2
        if (dx, dy) not in cnt:
            cnt[(dx, dy)] = 1
        else:
            cnt[(dx,dy)] += 1
print(n - max(cnt.values()))

Solution (Python):
import sys
import collections
n = int(input())
z = [list(map(int, input().split())) for _ in range(n)]
z.sort()
pq_pattern = []
pq_counter = [1]*(n-1)*n

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

for i in range(n):
    for j in range(n):
        if not i == j:
            if [z[j][0] - z[i][0], z[j][1] - z[i][1]] in pq_pattern:
                
                pq_counter[pq_pattern.index([z[j][0] - z[i][0], z[j][1] - z[i][1]])] += 1
            else:
                pq_pattern.append([z[j][0] - z[i][0], z[j][1] - z[i][1]])
print(n-max(pq_counter))

Solution (Python):
import itertools
from collections import Counter

N = int(input())
point = [tuple(map(int, input().split())) for _ in range(N)]

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

for first, second in list(itertools.permutations(point, 2)):
    fx, fy = first
    sx, sy = second
    ans[(sx-fx, sy-fy)] += 1

print(max(1, N - ans.most_common()[0][1]))

Solution (Python):
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

n = int(input())
X, Y = zip(*[[int(i) for i in input().split()] for j in range(n)])

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

used = [False] * n
D = {(X[i], Y[i]): i for i in range(n)}

def dfs(i, p, q):
    if used[i]:
        return
    used[i] = True
    if (X[i] + p, Y[i] + q) in D:
        dfs(D[X[i] + p, Y[i] + q], p, q)
    if (X[i] - p, Y[i] - q) in D:
        dfs(D[X[i] - p, Y[i] - q], p, q)

ans = int(1e12)

for i in range(n):
    for j in range(i + 1, n):
        p = X[i] - X[j]
        q = Y[i] - Y[j]
        used = [False] * n
        cnt = 0
        for k in range(n):
            if used[k]:
                continue
            cnt += 1
            dfs(k, p, q)

        ans = min(ans, cnt)

print(ans)

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

import copy

List.sort(key=lambda x:x[0])

result = float('inf')


for i in range(N):
    if N == 1:
        result = 1
        break
    for j in range(N-i-1):
        p = List[i+j+1][0] - List[i][0]
        q = List[i+j+1][1] - List[i][1]
        tmp_list = copy.deepcopy(List)
        cost = 0
        
        for k in range(N):
            if [tmp_list[0][0] + p, tmp_list[0][1] + q] in List:
                tmp_cost = 0
            else:
                tmp_cost = 1
            cost += tmp_cost
            del tmp_list[0]
        if result > cost:
            result = cost
                    
print(result)