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



Sample input:
2
1 1
2 2


Sample output:
1

Submission status: Runtime Error

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

import itertools

arr = list(itertools.combinations(List, 2))
vec = []

for i in range(len(arr)):
    vec.append([arr[i][1][0]-arr[i][0][0], arr[i][1][1]-arr[i][0][1]])

counter = collections.Counter(map(tuple, vec))
num = counter.most_common(1)[0][1]

print(N-num)

Submission status: Runtime Error

Solution code:
N = int(input())

d = {}
x = [0] * N
y = [0] * N
from collections import defaultdict
for i in range(N):
    x[i], y[i] = map(int, input().split())

d = defaultdict(int)
for i in range(N):
    for j in range(N):
        dx = x[i] - x[j]
        dy = y[i] - y[j]
        if i == j:
            continue
        d[(dx, dy)] += 1

print(N - max(d.values()))

Submission status: Runtime Error

Solution code:
def b_picking_up(N, Positions):
    from collections import defaultdict
    difference_count = defaultdict(int)  # xの差分とyの差分の組について、現れた回数
    before_x, before_y = Positions[0]
    for x, y in Positions[1:]:
        diff_x, diff_y = x - before_x, y - before_y
        difference_count[(diff_x, diff_y)] += 1
        before_x, before_y = x, y
    # print(difference_count)
    difference_count = sorted(difference_count.items(), key=lambda x: x[1], reverse=True)
    # print(difference_count)
    if difference_count[0][0] == (0, 0):
        if len(difference_count) == 1:
            return N
        else:
            p, q = difference_count[1][0]
    else:
        p, q = difference_count[0][0]

    ans = 1
    before_x, before_y = Positions[0]
    for x, y in Positions[1:]:
        diff_x, diff_y = x - before_x, y - before_y
        if (diff_x, diff_y) != (p, q):
            ans += 1
        before_x, before_y = x, y
    return ans

N = int(input())
Positions = [[int(i) for i in input().split()] for j in range(N)]
print(b_picking_up(N, Positions))

Submission status: Runtime Error

Solution code:
from collections import deque
from collections import defaultdict
N = int(input())
XY = list(sorted([tuple(map(int, input().split())) for _ in range(N)]))
PQ = []
for i in range(N-1):
    for j in range(i, N):
        PQ.append((XY[j][0]-XY[i][0], XY[j][1]-XY[i][1]))
PQ = list(set(PQ))
ans = N
for p, q in PQ:
    tmp1 = 1
    check = defaultdict(int)
    T = deque(XY.copy())
    for x, y in T:
        check[(x, y)] += 1
    x, y = T.popleft()
    cnt = 1
    while cnt < N:
        tmp2 = 1
        for s, t in T:
            if check[(s, t)] == 0:
                continue
            else:
                if s - p == x and t - q == y:
                    check[(s, t)] -= 1
                    tmp2 = 0
                    break
        if tmp2:
            x, y = T.popleft()
        else:
            x, y = s, t
        tmp1 += tmp2
        cnt += 1      
    ans = min(ans, tmp1)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
point = []
for i in range(n):
    x_, y_ = map(int, input().split())
    point.append([x_, y_])

point.sort()
ans = 0
x = point[:][0]
y = point[:][1]
for i in range(n):
    for j in range(i+1, n):
        count = 0
        p = x[j] - x[i]
        q = y[j] - y[i]
        for k in range(n):
            for l in range(k+1, n):
                if (x[l] - x[k] == p) and (y[l] - y[k] == q):
                    count += 1
        ans = max(ans, count)

print(n - ans)

Submission status: Runtime Error

Solution code:
n = int(input())
point = []
for i in range(n):
    x_, y_ = map(int, input().split())
    point.append((x_, y_))

point.sort(key=lambda x: x[0])
ans = 0
x = point[:][0]
y = point[:][1]
for i in range(n):
    for j in range(i+1, n):
        count = 0
        p = x[j] - x[i]
        q = y[j] - y[i]
        for k in range(n):
            for l in range(k+1, n):
                if (x[l] - x[k] == p) and (y[l] - y[k] == q):
                    count += 1
        ans = max(ans, count)

print(n - ans)

Submission status: Runtime Error

Solution code:
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
xy.sort()
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
    for j in range(i+1,N):
        tmp = (xy[j][0]-xy[i][0],xy[j][1]-xy[i][1])
        d[tmp] += 1
print(N-max(d.values()))

Submission status: Runtime Error

Solution code:
t = []
print(max(t))

Submission status: Runtime Error

Solution code:
import itertools
import collections
n=int(input())
s=[list(map(int, input().split())) for i in range(n)]
ans=[]
x=list(itertools.permutations(s))

v=[]
r=[]
count=0
for i in range(len(x)):
    e=[]
    v=[]
    for j in range(n-1):
        a=x[i][j][0]
        b=x[i][j+1][0]
        c=x[i][j][1]
        d=x[i][j+1][1]
        v.append(b-a)
        v.append(d-c) 
    q=[v[i:i+2] for i in range(0,len(v),2)]
    for i in range(len(q)):
        e.append(q.count(q[i]))
    r.append(max(e))
    
print(n-max(r))

Submission status: Runtime Error

Solution code:
# 未完成
import numpy as np
N = int(input())
x = np.zeros(N)
y = np.zeros(N)
kouholist = []

if N == 1:
    print(1)
else:
    for i in range(N):
        x[i], y[i] = map(int, input().split())
    for m in range(N):
        for p in range(N):
            if m == p:
                continue
            diff_x = x[m] - x[p]
            diff_y = y[m] - y[p]
            if (diff_x, diff_y) not in kouholist:
                kouholist.append((diff_x, diff_y))

    for list_i in kouholist:
        ans_kari = 0
        for r in range(N):
            for q in range(N):
                if r == q:
                    continue
                if x[q] - x[r] == list_i[0] and y[q] - y[r] == list_i[1]:
                    ans_kari += 1
        ans.append(ans_kari)

    print("{}".format(N-max(ans)))

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
XY = []
XY_cand = []
for _ in range(N):
        x, y = map(int, input().split())
        XY.append((x,y))
for (x, y) in XY:
        for (i, j) in XY:
                if i != x or j != y:
                        XY_cand.append((i-x, j-y))
print(N - Counter(XY_cand).most_common()[0][1])

Submission status: Runtime Error

Solution code:
# 未完成
import numpy as np
N = int(input())
x = np.zeros(N)
y = np.zeros(N)
kouholist = []

for i in range(N):
    x[i], y[i] = map(int, input().split())
ans = []
for m in range(N):
    for p in range(N):
        if m == p:
            continue
        diff_x = x[m] - x[p]
        diff_y = y[m] - y[p]
        ans_kari = 0
        if (diff_x, diff_y) not in kouholist:
            kouholist.append((diff_x, diff_y))

for list_i in kouholist:
    ans_kari=0
    for r in range(N):
        for q in range(N):
            if r == q:
                continue
            if x[q] - x[r] == list_i[0] and y[q] - y[r] == list_i[1]:
                ans_kari += 1
    ans.append(ans_kari)

print("{}".format(N-max(ans)))

Submission status: Runtime Error

Solution code:
N=int(input())
po=[]
for i in range(N):
  po.append([int(i) for i in input().split()])
ds=[]
d2={}
if N==1:
	print(1)
for i in range(N-1):
  for j in range(i+1,N):
    ds.append(str(abs(po[i][0]-po[j][0]))+" "+str(abs(po[i][1]-po[j][1])))
for d in ds:
	if d in d2:
		d2[d]=d2[d]+1
	else:
		d2[d]=1
d3=sorted(d2.values())
print(N-d3[-1])

Submission status: Runtime Error

Solution code:
n=int(input())
xy = sorted([list(map(int,input().split())) for i in range(n)])
p=q=0
ans=0
dic={}
for i in range(n-1):
	for j in range(i+1,n):
		p = xy[j][0]-xy[i][0]
		q = xy[j][1]-xy[i][1]
		if (p,q) in dic:
			dic[(p,q)]+=1
		else:
			dic[(p,q)]=1
print(n-max(dic.values()))

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    n = int(input())
    ball = [list(map(int, input().split(' '))) for i in range(n)]
    # ball = list(map(list, set(map(tuple, ball))))
    ball = np.array(ball, dtype=int)
    # print(ball)

    l1 = []
    for i in range(len(ball)):
        for j in range(len(ball)):
            if i == j: continue
            dis1 = ball[i] - ball[j]
            l1.append(list(dis1))

    c1 = []
    for i in range(len(l1)):
        c1.append(l1.count(l1[i]))
    m1 = np.max(np.array(c1, dtype=int))

    print(n-m1)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import collections
import sys
n = int(input())
if n == 1:
	print(1)
    sys.exit()
tmp = []
for _ in range(n):
	x, y = map(int,input().split())
	tmp.append([x,y])
ball_axis = sorted(tmp)

diff = []
for i in range(1,n):
	diff.append(str(ball_axis[i][0]-ball_axis[i-1][0])+','+str(ball_axis[i][1]-ball_axis[i-1][1]))

max_diff_count = collections.Counter(diff).most_common()[0][1]
print(n-max_diff_count)

Submission status: Runtime Error

Solution code:
N=int(input())
po=[]
for i in range(N):
  po.append([int(i) for i in input().split()])
ds=[]
d2={}
for i in range(N-1):
  for j in range(i+1,N):
    ds.append(str(abs(po[i][0]-po[j][0]))+" "+str(abs(po[i][1]-po[j][1])))
for d in ds:
	if d in d2:
		d2[d]=d2[d]+1
	else:
		d2[d]=1
print("n-ti")
d2=sorted(d2.values())
print(N-d2[-1])

Submission status: Runtime Error

Solution code:
N=int(input())
po=[]
for i in range(N):
  po.append([int(i) for i in input().split()])
ds=[]
d2={}
for i in range(N-1):
  for j in range(i+1,N):
    ds.append(str(abs(po[i][0]-po[j][0]))+" "+str(abs(po[i][1]-po[j][1])))
for d in ds:
	if d in d2:
		d2[d]=d2[d]+1
	else:
		d2[d]=1
d2=sorted(d2.values())
print(N-d2[-1])

Submission status: Runtime Error

Solution code:
n = int(input())
xy = []
pq = {}

for i in range(n):
    (x, y) = list(map(int, input().split()))
    xy = xy + [(x, y)]
    for (x_p, y_p) in xy:
        if (x-x_p, y-y_p) != (0, 0):
            if (x-x_p, y-y_p) in pq.keys():
                pq[(x-x_p, y-y_p)] = pq[(x-x_p, y-y_p)] + 1
            else:
                pq[(x-x_p, y-y_p)] = 1
print(n - max([1, max(pq.values())]))

Submission status: Runtime Error

Solution code:

# -*- coding: utf-8 -*-
# @Date    : 2019-06-15 20:02:29
# @Author  : raj lath (oorja.halt@gmail.com)
# @Link    : link
# @Version : 1.0.0

import sys
sys.setrecursionlimit(10**5+1)

inf     =  int(10 ** 20)
max_val =  inf
min_val = -inf

RW  = lambda : sys.stdin.readline().strip()
RI  = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
from collections import defaultdict

nb_points = RI()
points    = [RMI() for _ in range(nb_points)]
pq = defaultdict(int)
for i in range(nb_points):
    for j in range(nb_points):
        if i == j : continue
        p1 = points[i][0] - points[j][0]
        q1 = points[i][1] - points[j][1]
        pq[(p1, q1)]  = pq.get((p1, q1), 0) + 1
print(nb_points - max(pq.values()))

Submission status: Runtime Error

Solution code:
N=int(input())
po=[]
for i in range(N):
  po.append([int(i) for i in input().split()])
ds=[]
d2={}
for i in range(N):
  for j in range(i+1,N):
    ds.append(str(abs(po[i][0]-po[j][0]))+" "+str(abs(po[i][1]-po[j][1])))
for d in ds:
	if d in d2:
		d2[d]=d2[d]+1
	else:
		d2[d]=1
d2=sorted(d2.values())
print(N-d2[-1])

Submission status: Runtime Error

Solution code:
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    xy = ii2nnn(N)
    dic = defaultdict(lambda: 0)
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            dx = xy[i][0] - xy[j][0]
            dy = xy[i][1] - xy[j][1]
            if dx == 0 and dy == 0:
                continue
            dic[(dx, dy)] += 1
    n = N - max(dic.values())
    print(n)

main()

Submission status: Runtime Error

Solution code:
n = int(input())
xy = []
ans = []

for i in range(n):
    xin,yin = map(int,input().split())
    xy.append([xin,yin])

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

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

res = [ans.count(e) for e in set(ans)]
print(n-max(res))

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
X = []
for i in range(N):
    xi,yi = map(int,input().split())
    X.append((xi,yi))
L = []
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x,y = X[i][0]-X[j][0],X[i][1]-X[j][1]
        L.append((x,y))
m = Counter(L).most_common()[0][1]
print(N-m)

Submission status: Runtime Error

Solution code:
# 未完成
import numpy as np
N = int(input())
x = np.zeros(N)
y = np.zeros(N)
kouhokist = []

for i in range(N):
    x[i], y[i] = map(int, input().split())
ans = []
for m in range(N):
    for p in range(N):
        if m == p:
            continue
        diff_x = x[m] - x[p]
        diff_y = y[m] - y[p]
        ans_kari = 0
        for r in range(N):
            for q in range(N):
                if r == q:
                    continue
                if x[q] - x[r] == diff_x and y[q] - y[r] == diff_y:
                    ans_kari += 1
        ans.append(ans_kari)

print("{}".format(N-max(ans)))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
x = np.zeros(N)
y = np.zeros(N)

for i in range(N):
    x[i], y[i] = map(int, input().split())
for j in range(N):
    for k in range(N-1):
        if x[k] > x[k + 1]:
            x[k], y[k] = x[k + 1], y[k + 1]
        elif x[k] == x[k + 1] and y[k] > y[k + 1]:
            x[k], y[k] = x[k + 1], y[k + 1]

ans = []
for p in range(N-1):
    for m in range(p+1, N):
        diff_x = x[m] - x[p]
        diff_y = y[m] - y[p]
        ans_kari = 0
        for r in range(N-1):
            for q in range(r+1, N):
                if x[q] - x[r] == diff_x and y[q] - y[r] == diff_y:
                    ans_kari += 1
        ans.append(ans_kari)

print("{}".format(N-max(ans)))

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    n = int(input())
    ball = [list(map(int, input().split(' '))) for i in range(n)]
    ball = list(map(list, set(map(tuple, ball))))
    ball = np.array(ball, dtype=int)
    # print(ball)

    l1 = []
    l2 = []
    for i in range(len(ball)):
        for j in range(i, len(ball)):
            if i == j: continue
            dis1 = ball[i] - ball[j]
            dis2 = ball[j] - ball[i]
            l1.append(list(dis1))
            l2.append(list(dis2))
    # print(l1, l2)
    # c1 = collections.Counter(l1)
    # c2 = collections.Counter(l2)

    c1 = []
    c2 = []
    for i in range(len(l1)):
        c1.append(l1.count(l1[i]))
        c2.append(l2.count(l2[i]))
    m1 = np.max(np.array(c1, dtype=int))
    m2 = np.max(np.array(c2, dtype=int))

    print(max(1,n-max(m1,m2)))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import statistics
N = int(input())

x = []
sub_x=[]
sub_y=[]


for i in range(N):
  x.append(list(map(int, input().split())))
  
x.sort()
#y.sort()
for i in range(len(x)-1,0, -1):
  mysub_x = [(x[i][0] - x[i-1][0])]
  mysub_y = [(x[i][1] - x[i-1][1])]
  if mysub_x != [0]:
    sub_x += mysub_x
  if mysub_y != [0]:
    sub_y += mysub_y


p = statistics.mode(sub_x)
#print(sub_x, p)
q = statistics.mode(sub_y)

ans = 0
for i in range(N-1):
    if abs(x[i][0] - x[i+1][0]) != abs(p) or abs(x[i][1] - x[i+1][1]) != abs(q):
      #print('dif')
      #print(ans, i)
      ans += 1

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

Submission status: Runtime Error

Solution code:

# -*- coding: utf-8 -*-
# @Date    : 2019-06-15 20:02:29
# @Author  : raj lath (oorja.halt@gmail.com)
# @Link    : link
# @Version : 1.0.0

import sys
sys.setrecursionlimit(10**5+1)

inf     =  int(10 ** 20)
max_val =  inf
min_val = -inf

RW  = lambda : sys.stdin.readline().strip()
RI  = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
from collections import defaultdict

nb_points = RI()
points    = [RMI() for _ in range(nb_points)]
pq = defaultdict(int)
for i in range(nb_points):
    for j in range(nb_points):
        if i == j : continue
        p1 = points[i][0] - points[j][0]
        q1 = points[i][1] - points[j][1]
        pq[(p1, q1)] += 1
print(nb_points - max(pq.values()))

Submission status: Runtime Error

Solution code:
# div2019-2B - Picking Up
from collections import defaultdict

n = int(input())
arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])
cnt = defaultdict(0)
for i in range(n):
    for j in range(i + 1, n):
        dif = (arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])
        cnt[dif] += 1
print(cnt)
print(n - max(cnt.values(), default=0))

Submission status: Runtime Error

Solution code:
n = int(input())
l1 = []
l2 = []
l3 = []
for i in range(n):
    x, y = map(int, input().split())
    l1.append((x, y))
l1.sort()
if n == 0:
    print(1)
else:
    for i in range(n-1):
        x1, y1 = l1[i]
        x2, y2 = l1[i+1]
        p = x2 - x1
        q = y2 - y1
        l2.append((p, q))
l2.sort()
p, q = l2[0]
cnt = 0
l3.append(cnt)
for P, Q in l2:
    if (P == p) and (Q == q):
        cnt += 1
        l3.append(cnt)
    else:
        cnt = 1
        l3.append(cnt)
print(n - max(l3))

Submission status: Runtime Error

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

if n == 1:
  print(1)

ans = []
for i in range(n):
  for j in range(n):
    if i == j:
      continue
    p = x[i]-x[j]
    q = y[i]-y[j]
    count = 0
    for k in range(n):
      for l in range(n):
        if p == x[k]-x[l] and q == y[k]-y[l]:
          count += 1
          ans.append(count)
print(n-max(ans))

Submission status: Runtime Error

Solution code:
from collections import Counter

N = int(input())

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

d = []
for i, p1 in enumerate(p):
    for j, p2 in enumerate(p):
        if i == j:
            continue
        x = p1[0] - p2[0]
        y = p1[1] - p2[1]
        d.append((x, y))

c = Counter(d)
# print(c)
print(N - c.most_common()[0][1])

Submission status: Runtime Error

Solution code:
N = int(input())
cnt = 1
ruiseki_x = []
ruiseki_y = []
list_x = []
list_y = []
lists = []
for i in range(N):
    x,y = map(int,input().split())
    list_x.append(x)
    list_y.append(y)
for i in range(1,N):
    ruiseki_x.append(list_x[i-1] - list_x[i])
    ruiseki_y.append(list_y[i-1] - list_y[i])
c = list(zip(ruiseki_x,ruiseki_y))
count = 0
for i in range(len(c)):
    count = 0
    for j in range(len(c)):
        if c[i] == c[j]:
            count += 1
    lists.append(count)
cnt += len(c) - max(lists)
print(cnt)

Submission status: Runtime Error

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

if n == 1:
    print(1)

ans = []
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        p = x[i]-x[j]
        q = y[i]-y[j]
        count = 0
        for k in range(n):
            for l in range(n):
                if p == x[k]-x[l] and q == y[k]-y[l]:
                    count += 1
                ans.append(count)

print(n-max(ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return tuple(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XY):
    c = Counter()
    for i in range(N):
        x, y = XY[i]
        for j in range(N):
            if i == j:
                continue
            a, b = XY[j]
            c[(x-a, y-b)] += 1

    return N - c.most_common(1)[0][1]


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
memo = {}
pq = []
for i in range(N-1):
    for j in range(i+1,N):
        pq.append([xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]])
for p, q in pq:
    index = str(p) + str(q)
    if index in memo:
        memo[index] += 1
    else:
        memo[index] = 1
print(N-max(memo.values()))

Submission status: Runtime Error

Solution code:
N = [int(i) for i in input().split()][0]

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

salist=[]
for i in range(1,len(balls),1):
  for j in range(i,len(balls),1):
    sax = balls[j][0]-balls[i][0]
    say = balls[j][1]-balls[i][1]
    salist.append([sax,say])
print(salist)

balls.reverse()
costs=[]
for i,sa in enumerate(reversed(salist)):
  cost=1
  for i in range(0,len(balls)-1,1):
    if balls[i+1][0]!=balls[i][0]-sa[0] and balls[i+1][1]!=balls[i][1]-sa[1]:
      cost+=1
  costs.append(cost)

print(min(costs))

Submission status: Runtime Error

Solution code:
n = int(input());
point = [[0]*2 for i in range(n) ];
for i in range(n) :
	s = input().split(" ");
	point[i][0] = int(s[0]);
	point[i][1] = int(s[1]);

dict = {}
for i in range(n) :
	for j in range(n) :
		if i != j  :
			x = point[i][0] - point[j][0];
			y = point[i][1] - point[j][1];
			if (x,y) in dict:
				dict[(x,y)] += 1
			else:
				dict[(x,y)] = 1
print(n-max(dict.values()));

Submission status: Runtime Error

Solution code:
n = int(input())
xy = []
ans = []

for i in range(n):
    xin,yin = map(int,input().split())
    xy.append([xin,yin])

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

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

res = [ans.count(e) for e in set(ans)]
print(n-max(res))

Submission status: Runtime Error

Solution code:
from collections import defaultdict as de
s=de(int)
n=int(input())
a=sorted([list(map(int,input().split()))for i in range(n)])
for i in range(n):
    for j in range(i):
        s[(a[i][0]-a[j][0],a[i][1]-a[j][1])]+=1
print(n-max(s.values()))

Submission status: Runtime Error

Solution code:
n = int(input())
xy = []
ans = []

for i in range(n):
    xin,yin = map(int,input().split())
    xy.append((xin,yin))

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

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

res = [ans.count(e) for e in ans]
print(n-max(res))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n = int(input())
s = [list(map(int,input().split())) for i in range(n)]
s.sort()
c = []
for i in range(n):
    for j in range(i+1,n):
        x = s[j][0] - s[i][0]
        y = s[j][1] - s[i][1]
        c.append(str(x) + " " + str(y))
r = defaultdict(int)
for g in c:
    r[g] += 1
q = list(r.values())
q1 = max(q)
print(n-q1)

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    n = int(input())
    ball = [list(map(int, input().split(' '))) for i in range(n)]
    ball = np.array(ball, dtype=int)
    # print(ball)

    l1 = []
    l2 = []
    for i in range(n):
        for j in range(i, n):
            if i == j: continue
            dis1 = ball[i] - ball[j]
            dis2 = ball[j] - ball[i]
            l1.append(list(dis1))
            l2.append(list(dis2))
    # print(l1, l2)
    # c1 = collections.Counter(l1)
    # c2 = collections.Counter(l2)

    c1 = []
    c2 = []
    for i in range(len(l1)):
        c1.append(l1.count(l1[i]))
        c2.append(l2.count(l2[i]))
    m1 = np.max(np.array(c1, dtype=int))
    m2 = np.max(np.array(c2, dtype=int))

    print(max(1,max(m1,m2)))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from collections import defaultdict as de
s=de(int)
n=int(input())
a=sorted([list(map(int,input().split()))for i in range(n)])
for i in range(n):
    for j in range(i-1):
        s[(a[i][0]-a[j][0],a[i][1]-a[j][1])]+=1
print(n-max(s.values()))

Submission status: Runtime Error

Solution code:
N = [int(i) for i in input().split()][0]

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

salist=[]
for i in range(1,len(balls),1):
  for j in range(i,len(balls),1):
    sax = balls[i][0]-balls[j-1][0]
    say = balls[i][1]-balls[j-1][1]
    salist.append([sax,say])

balls.reverse()
costs=[]
for i,sa in enumerate(reversed(salist)):
  cost=1
  for i in range(0,len(balls)-1,1):
    if balls[i+1][0]!=balls[i][0]-sa[0] and balls[i+1][1]!=balls[i][1]-sa[1]:
      cost+=1
  costs.append(cost)

print(min(costs))

Submission status: Runtime Error

Solution code:
N=int(input())
xy=[list(map(int,input().split())) for _ in [0]*N]

pq = dict()
for i in range(N):
    for j in range(N):
        if i==j:continue
        p = xy[i][0] - xy[j][0]
        q = xy[i][1] - xy[j][1]
        pq[(p,q)] = pq.get((p,q),0)+1

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

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
s = [list(map(int,input().split())) for i in range(n)]
s.sort()
c = []
for i in range(n):
    for j in range(i+1,n):
        x = s[j][0] - s[i][0]
        y = s[j][1] - s[i][1]
        c.append(str(x) + " " + str(y))
 
r = Counter(c)
q = list(r.values())
q1 = max(q)
print(n-q1)

Submission status: Runtime Error

Solution code:
n=int(input())
r=[]
a=[]
for i in range(n):
  b,c=(int(j) for j in input().split())
  for k in range(i):
    d=a[k][0]-b
    e=a[k][1]-c
    if d<0:
      d=-d
      e=-e
    elif d=0:
      if e<0:
        e=-e
    r.append([d,e])
  a.append([b,c])
r.sort()
if n>1:
  p=r[0]
x=1
z=0
t=0
q=[]
for i in range(len(r)-1):
  if r[i]==r[i+1]:
    x=x+1
    if x>z:
      p=r[i]
      z=x
  else:
    x=1
for j in range(n-1):
  for i in range(n-1):
    if a[i][0]>a[i+1][0]:
      w=a[i]
      a[i]=a[i+1]
      a[i+1]=w
    elif a[i][0]==a[i+1][0]:
      if (a[i][1]-a[i+1][1])*p[1]>0:
        w=a[i]
        a[i]=a[i+1]
        a[i+1]=w
if n==1:
  print(1)
else:
  for i in range(n):
    if a[i] not in q:
      t=t+1
    q.append([a[i][0]+p[0],a[i][1]+p[1]])
  print(t)

Submission status: Runtime Error

Solution code:
from collections import defaultdict as de
s=de(int)
n=int(input())
a=sorted([list(map(int,input().split()))+[0]for i in range(n)])
for i in range(n):
    for j in range(n):
        if i!=j:
            s[(a[i][0]-a[j][0],a[i][1]-a[j][1])]+=1
print(n-max(s.values()))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
if n == 1:
  print(1)
else:
  
xy = []
for i in range(n):
    a = list(input().split())
    xy.append(a)

#print(xy)
s = n
for i in range(n-1):
    if xy[i][0] !="a":
        for j in range(i+1,n):
            if xy[j][0] !="a":
                p = int(xy[i][0])-int(xy[j][0])
                q = int(xy[i][1])-int(xy[j][1])
                m = n
                #print(p)
                #print(q)
                for c in range(n-1):
                    if xy[c][0] !="a":
                        for b in range(c+1,n):
                            #print(int(xy[c][0])-int(xy[b][0]))
                            if xy[b][0] != "a":
                                if abs(p) == abs(int(xy[c][0])-int(xy[b][0])) and abs(q) == abs(int(xy[c][1])-int(xy[b][1])):
                                    m -= 1
                                    xy[b][0] = "a"
                #print(m)
                if s>m:
                    s = m
                    #print("s"+ str(s))

print(s)

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
L = sorted([list(map(int,input().split())) for k in range(N)])
D = []

for k in range(N-1):
    for l in range(k+1,N):
        D.append((L[k][0]-L[l][0],L[k][1]-L[l][1]))

E = Counter(D).most_common()[0]
x, y = E[0][0], E[0][1]
used = []
ans = N
for k in range(N-1):
    for l in range(k+1,N):
        if L[k][0]-L[l][0] == x and L[k][1]-L[l][1] == y:
            if L[k] not in used and L[l] not in used:
                used.append(L[k])
                used.append(L[l])
                ans -= 1
            elif L[k] in used and L[l] not in used:
                used.append(L[l])
                ans -= 1
            elif L[k] not in used and L[l] in used:
                used.append(L[k])
                ans -= 1
            else:
                pass
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])

for i in range(n-1):
    for j in range(i+1, n):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = 0
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)