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(map(int, input().split())) for _ ihn range(N)]


# 点を一番通る直線を求める？何個被るかが答えになるかも<=わｋらｎ
zm = []
for i in range(N-1):
    a=XY[i][0] - XY[i+1][0]
    b=XY[i][1] - XY[i+1][1]
    zm.append((a,b))
from collections import Counter
print(N - Counter(zm).most_common(1)[0][1])

Submission status: Runtime Error

Solution code:
from collections import Counter

N = int(input())

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

sub = []
for x1, y1 in xys:
    for x2, y2 in xys:
        if x1 != x2 or y1 != y2:
            sub.append((x1 - x2, y1 - y2))

c = Counter(sub)
m = max(c.values())

print(N - m)

Submission status: Runtime Error

Solution code:
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-1):
    x=z[i+1][0]-z[i][0]
    y=z[i+1][1]-z[i][1]
    dif.append([x,y])
dif.sort(reverse=True)
count=-1
buf=1
comp=dif[0]
ans=dif[0]
for i in range(1,n-1):
    if comp==dif[i]:
        #print(comp,dif[i])
        buf+=1
    else:
        #print(comp,dif[i],buf)
        if count<buf:
            count=buf
            ans=comp
        buf=0
        comp=dif[i]
if count<buf:
    count=buf
    ans=comp
print(n-count)

Submission status: Runtime Error

Solution code:
from math import gcd
# from fractions import gcd

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

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

res = 10 ** 100
for i in range(n):
    for j in range(i + 1, n):
        sa = []
        invalid = False
        for p,q in zip(l[i], l[j]):
            sa.append(p - q)

        # if not invalid:
        #     g = gcd(sa[0], sa[1])
        #     sa[0] //= g
        #     sa[1] //= g
        
        cnt = 0
        flag = [False] * n
        for p in range(n):
            if flag[p]:
                continue
            cnt += 1
            flag[p] = True
            for q in range(p + 1, n):
                if flag[q]:
                    continue
                sb = []
                for a,b in zip(l[p], l[q]):
                    sb.append(a - b)
                
                if sa[0] == 0:
                    if sb[0] == 0 and sb[1] % sa[1] == 0:
                        flag[q] = True
                elif sa[1] == 0:
                    if sb[1] == 0 and sb[0] % sa[0] == 0:
                        flag[q] = True
                else:
                    if sb[0] % sa[0] == 0 and sb[1] % sa[1] == 0:
                        if sb[0] // sa[0] == sb[1] // sa[1]:
                            flag[q] = True
        res = min(res, cnt)
print(res)

Submission status: Runtime Error

Solution code:
n=int(input())
l=[]
for iii in range(n):
  l.append(list(map(int,input().split())))
dic={}
for iii in range(n):
  for jjj in range(iii+1,n):
    a=str(abs(l[iii][0]-l[jjj][0]))+"_"+str(abs(l[iii][1]-l[jjj][1]))
    if a not in dic:
      dic[a]=0
    else:
      dic[a]+=1
b=max(dic.values())
print(n-b-1)

Submission status: Runtime Error

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

d = dict()
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x1, y1 = XY[i]
        x2, y2 = XY[j]
        x3, y3 = x2-x1, y2-y1
        if x3 < 0:
            x3, y3 = -1*x3, -1*y3
        pos = (x3, y3)
        if pos not in d:
            d[pos] = 0
        d[pos] += 1

# print(d[max(d, key=lambda x: d[x])])
print(N - max(d.values())//2)

Submission status: Runtime Error

Solution code:
import math
import collections
import itertools

N = int(input())

x, y = [], []

for i in range(N):
    xx, yy = list(map(int, input().split()))
    x.append(xx)
    y.append(yy)

l = []

for c in itertools.combinations(range(N), 2):
    x1 = x[c[0]]
    y1 = y[c[0]]
    x2 = x[c[1]]
    y2 = y[c[1]]

    l.append((abs(x1-x2), abs(y1-y2)))

c = collections.Counter(l)
a = N - c.most_common()[0][1]

print(max(a, 1))

Submission status: Runtime Error

Solution code:
import collections

n = int(input())

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

vec = []
vec_set = []

for i in range(n):
    vec2 = []
    for j in range(n):
        vec2.append((x[i] - x[j], y[i] - y[j]))
        vec_set.append((x[i] - x[j], y[i] - y[j]))
    vec.append(vec2)

cc = collections.Counter(vec_set)

v_l = []
for key,value in cc.items():
    if key != (0,0):
        v_l.append(value)
print(n - max(v_l))

Submission status: Runtime Error

Solution code:
from itertools import combinations as c
from collections import Counter

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

l.sort()
m=c(l,2)
ans=[]
for v in m:
    ans.append(str([v[1][0]-v[0][0],v[1][1]-v[0][1]]))
a=Counter(ans).most_common()[0][1]
print(n-a)

Submission status: Runtime Error

Solution code:
import collections
N = int(input())
xy_array = [list(map(int, input().split())) for i in range(N)]
# print(xy_array)
distance_array = []
for i in range(N):
    x_i, y_i = xy_array[i]
    for j in range(N):
        if i == j:
            continue
        x_j, y_j = xy_array[j]
        distance_array.append((x_i - x_j, y_i - y_j))

ans_array = collections.Counter(distance_array)
max_count = ans_array.most_common()[0][1]
print(N - max_count)

Submission status: Runtime Error

Solution code:
N = input()
N = int(N)
s = [[ int(i) for i in input().split()] for i in range(N)]
hoge = []
import collections

for i in s:
    for k in s:
        if k != i:
            hoge1 = (i[0] - k[0],i[1] - k[1])
            if hoge1[0] < 0:
                hoge1 = (k[0] - i[0],k[1] - i[1])
            hoge.append(hoge1)

c = collections.Counter(hoge)

print(N - c.most_common()[0][1] // 2)

Submission status: Runtime Error

Solution code:
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
    if sx-fx < 0 or sy-fy < 0:
        continue
    else:
        ans[(sx-fx, sy-fy)] += 1
print(min(1, N - ans.most_common()[0][1]))

Submission status: Runtime Error

Solution code:
from collections import defaultdict

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

d = defaultdict(lambda: 0)
for x in range(n):
	for y in range(n):
		d[(balls[x][0] - balls[y][0], balls[x][1] - balls[y][1])] += 1

del d[(0, 0)]
print(n - max(d.values()))

Submission status: Runtime Error

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

l = {}

for i in range(N):
    for j in range(i + 1, N):
        p = x[i] - x[j]
        q = y[i] - y[j]
        if p < 0:
            p = -p
            q = -q
        if str([p, q]) in l:
            l[str([p, q])] += 1
        else:
            l[str([p, q])] = 1

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

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
xy = [LIST() for _ in range(N)]
xy.sort(key=lambda x:(x[0], x[1]))
# print(xy)
delta = defaultdict(int)
for i in range(N):
	for j in range(N):
		if i != j:
			delta[(xy[j][0]-xy[i][0], xy[j][1]-xy[i][1])] += 1
print(1+(N-1)-max(delta.values()))

Submission status: Runtime Error

Solution code:
import sys

readline = sys.stdin.readline

N = int(readline())

XY = [list(map(int, readline().split())) for i in range(N)]

diff_list = {}

for x1, y1 in XY:
    for x2, y2 in XY:
        if x1 == x2 and y1 == y2:
            continue
        diffx = x2 - x1
        diffy = y2 - y1
        diff = (diffx, diffy)
        if not (diff in diff_list): diff_list[diff] = 0
        diff_list[diff] += 1

m = max(diff_list.values())

ans = N - m

print(ans)

Submission status: Runtime Error

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

diff={}
for i in range(N):
    for j in range(i+1, N):
        a=(xy[i][0]-xy[j][0], xy[i][1]-xy[j][1])
        diff[a]=diff.get(a,0)+1
# print(diff)
print(N-max(diff.values()))

Submission status: Runtime Error

Solution code:
N=int(input())
B=sorted([list(map(int,input().split())) for i in range(N)])
d={}
for i in range(N):
    for j in range(i+1,N):
        x=(B[j][0]-B[i][0],B[j][1]-B[i][1])
        if x in d:
            d[x]+=1
        else:
            d[x]=1
print(N-max(d.values()))

Submission status: Runtime Error

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

d = dict()
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        x1,y1 = l[i]
        x2,y2 = l[j]
        if d.__contains__((x2-x1,y2-y1)):
            d[(x2-x1,y2-y1)] += 1
        else:
            d[(x2-x1,y2-y1)] = 1
maxV = max(list(d.values()))

print(n-maxV)

Submission status: Runtime Error

Solution code:
import collections

def solve(n, points):
    a = []
    for i in range(n-1):
        for j in range(i + 1, n):
            x = points[i][0] - points[j][0]
            y = points[i][1] - points[j][1]
            if x > 0:
                a.append((x, y))
            elif x < 0:
                a.append((-x, -y))
            else:
                a.append((0, abs(y)))

    c = collections.Counter(a).most_common()[0][1]
    return n - c

n = int(input())
points = [list(map(int, input().split(' '))) for _ in range(n)]
print(solve(n, points))

Submission status: Runtime Error

Solution code:
N = int(input())
x = [0]*N
y = [0]*N
L1_dict = dict()
for i in range(N):
    x[i], y[i] = map(int, input().split())
for i in range(N-1):
    for j in range(i, N):
        if i != j:
            x_diff = x[j] - x[i]
            y_diff = y[j] - y[i]
            if (x_diff, y_diff) not in L1_dict:
                L1_dict[(x_diff, y_diff)] = 1
            else:
                L1_dict[(x_diff, y_diff)] = 1 + L1_dict[(x_diff, y_diff)]
M = max(L1_dict.values())

print(N - M)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys
from itertools import combinations
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
xy=[]
for i in range(N):
    x,y=MAP()
    xy.append((x, y))

C=Counter()
for comb in combinations(xy, 2):
    a,b=comb
    C[(a[0]-b[0], a[1]-b[1])]+=1

mx=max(C.values())
print(N-mx)

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
xy =[]
for i in range(n):
    x,y = map(int,input().split())
    xy.append((x,y))
xy2 = xy[:]
c = collections.Counter()
for x,y in xy:
    for w,z in xy2:
        c[(x-w,y-z)] +=1
print(n-c.most_common(2)[1][1])

Submission status: Runtime Error

Solution code:
N = int(input())
sheet = []
for i in range(N):
  line = input().split()
  sheet += [(int(line[0]), int(line[1]))]

dic = {}
for i in range(N):
  start = sheet[i]
  for j in range(i+1, N):
    vec = ((sheet[j][0]-sheet[i][0]), sheet[j][1]-sheet[i][1])
    if vec not in dic.keys():
      dic[vec]=1
    else:
      dic[vec]+=1

a = max(dic.values())
print(N-a)

Submission status: Runtime Error

Solution code:

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

min_point = 100
for i in range(N-1):
	for j in range(i+1, N):
		p = P[i]
		q = P[j]
		if p[0] <=  q[0] and p[1] <= q[1]:
			x = q[0]-p[0]
			y = q[1]-p[1]
			point = 0
			mp = [False for _ in range(N)]
			count = N
			index = 0
			qu = queue.Queue()
			while count:
				if not mp[index]:
					point += 1
					qu.put(P[index])
					mp[index] = True
					count -= 1
					while not qu.empty():
						top = qu.get()
						for k in range(N):
							if not mp[k] and ((top[0]-x == P[k][0] and top[1]-y == P[k][1]) or (top[0]+x == P[k][0] and top[1]+y == P[k][1])):
								count -= 1
								qu.put(P[k])
								mp[k] = True
				index += 1
			if point < min_point:
				min_point = point

print(min_point)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python

n = int( input() )
xy = []
for _ in range(n): xy.append( [ int(x) for x in input().strip().split() ] )
#
distmap = dict()
for i in range(n):
    xi,yi = xy[i]
    for j in range(i+1,n):
        xj, yj = xy[j]
        xd = xi - xj
        yd = yi - yj
        k = "{} {}".format(xd,yd)
        distmap[k]= distmap.get(k,0) + 1
#
d = max( distmap.values() )
print( n-d )

Submission status: Runtime Error

Solution code:
from collections import defaultdict
N = int(input())
d = defaultdict(int)
sx, sy = map(int, input().split())

for i in range(1, N):
    x, y = map(int, input().split())
    d[(x-sx, y-sy)] += 1
    sx, sy = x, y

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
d = defaultdict(int)
for i in range(n):
    x1, y1 = xy[i]
    for j in range(i+1, n):
        x2, y2 = xy[j]
        d["%d:%d" % (x2-x1, y2-y1)] += 1

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from collections import defaultdict
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())

    c = defaultdict(int)
    p = []

    for i in range(n):
        pi = [int(j) for j in input().split()]

        for pj in p:
            c[(abs(pi[0] - pj[0]), abs(pi[1] - pj[1]))] += 1

        p.append(pi)

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


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:



def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g



n = int(input())
b1 = []

for i in range(n):
    b1.append(list(map(int,input().split())))

b2 = b1.copy()

b1.sort(key=lambda x:(x[0],x[1]))
b2.sort(key=lambda x:(x[1],x[0]))
# print(b1)
# print(b2)

l1_x = {}
l1_y = {}

bef_x = b1[0][0]
bef_y = b1[0][1]
for i in range(1,n):
    diff_x = b1[i][0]-bef_x
    diff_y = b1[i][1]-bef_y
    bef_x = b1[i][0]
    bef_y = b1[i][1]

    if not diff_x in l1_x:
        l1_x[diff_x] = 1
    else:
        l1_x[diff_x]+=1

    if not diff_y in l1_y:
        l1_y[diff_y] = 1
    else:
        l1_y[diff_y]+=1

x_step = max(l1_x,key = l1_x.get)
y_step = max(l1_y,key = l1_y.get)


cost1 = 1
bef_x = b1[0][0]
bef_y = b1[0][1]
for i in range(1,n):
    diff_x = b1[i][0]-bef_x
    diff_y = b1[i][1]-bef_y
    bef_x = b1[i][0]
    bef_y = b1[i][1]

    if diff_x != x_step or diff_y != y_step:
        cost1 += 1


#*****************************************************
l1_x = {}
l1_y = {}

bef_x = b2[0][0]
bef_y = b2[0][1]
for i in range(1, n):
    diff_x = b2[i][0] - bef_x
    diff_y = b2[i][1] - bef_y
    bef_x = b2[i][0]
    bef_y = b2[i][1]

    if not diff_x in l1_x:
        l1_x[diff_x] = 1
    else:
        l1_x[diff_x] += 1

    if not diff_y in l1_y:
        l1_y[diff_y] = 1
    else:
        l1_y[diff_y] += 1

x_step = max(l1_x, key = l1_x.get)
y_step = max(l1_y, key = l1_y.get)

cost2 = 1
bef_x = b2[0][0]
bef_y = b2[0][1]
for i in range(1, n):
    diff_x = b2[i][0] - bef_x
    diff_y = b2[i][1] - bef_y
    bef_x = b2[i][0]
    bef_y = b2[i][1]

    if diff_x != x_step or diff_y != y_step:
        cost2 += 1

print(min(cost1,cost2))

Submission status: Runtime Error

Solution code:
import collections


n = int(input())

l = []
for i in range(n):
    xa,ya = map(int,input().split())
    l.append([xa,ya])

s = []
for i in range(n):
    for k in range(i+1,n):
        if (l[k][0]-l[i][0] > 0) == (l[k][1]-l[i][1] > 0):
            sign = 1
        else:
            sign = 0
        dist = ((l[k][0]-l[i][0]),(l[k][1]-l[i][1]),sign)
        s.append(dist)

#print(s)

c = collections.Counter(s)
print(n - c.most_common()[0][1])

Submission status: Runtime Error

Solution code:
from collections import Counter
def solve(N, XY):
    XY = sorted(XY)
    cnt = Counter()
    d = []
    for (x0, y0), (x1, y1) in zip(XY, XY[1:]):
        d.append((x0 - x1, y0 - y1))
    m = Counter(d).most_common()[0]
    return len(XY) - m[1]

def main():
    N = int(input())

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

    print(solve(N, XY))

main()

Submission status: Runtime Error

Solution code:
from sys import stdin
import math
import fractions
from collections import deque
import collections
import itertools

INF = 10 ** 10


# N個のボールがあり、i番目のボールは(xi, yi)にある
N = int(stdin.readline().rstrip())
xy = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

data = []

for i in range(N):
    for j in range(i+1, N):
        x_diff = abs(xy[i][0] - xy[j][0])
        y_diff = abs(xy[i][1] - xy[j][1])

        data.append("{0},{1}".format(x_diff, y_diff))

c = collections.Counter(data)

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

Submission status: Runtime Error

Solution code:
import itertools
import collections
n=int(input())
X=[]
for i in range(n):
  X.append([int(i) for i in input().split()])
X.sort(key=lambda x:(x[0],x[1]))
Y=[]
for c in itertools.combinations(range(n),2):
  x1,y1,x2,y2=X[c[0]][0],X[c[0]][1],X[c[1]][0],X[c[1]][1]
  Y.append((x2-x1,y2-y1))
yy=collections.Counter(Y)
print(n-yy.most_common()[0][1])

Submission status: Runtime Error

Solution code:
from collections import Counter

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

diffs = []
for i in range(N):
    for j in range(N):
        if i == j:
            pass
        else:
            x = points[i][0] - points[j][0]
            y = points[i][1] - points[j][1]
            diffs.append("{}_{}".format(x, y))

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

Submission status: Runtime Error

Solution code:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint

N = int(input())
P = []
for _i in range(N):
    P.append([ int(x) for x in input().split() ])

diff = defaultdict(int)
for i in range(N):
    for j in range(i+1,N):
        key = "{} - {}".format(abs(P[i][0]-P[j][0]), abs(P[i][1]-P[j][1]))
        diff[key] += 1

key = max (diff.keys(), key=lambda x: diff[x])
print(N-diff[key])

Submission status: Runtime Error

Solution code:


def main():
    n = input()
    xy = []
    for _ in xrange(n):
        x, y = map(int, raw_input().split())
        xy.append([x, y])
    count = {}
    for i in xrange(n - 1):
        x0, y0 = xy[i]
        for j in xrange(i + 1, n):
            x1, y1 = xy[j]
            key = (x1 - x0, y1 - y0)
            try:
                count[key] += 1
            except KeyError:
                count[key] = 1
    print n - max(count.values())


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools
from collections import Counter

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

ans = Counter()

for first, second in list(itertools.permutations(point, 2)):
    fx, fy = first
    sx, sy = second
    if sx-fx < 0 or sy-fy < 0:
        continue
    else:
        ans[(sx-fx, sy-fy)] += 1
print(N - ans.most_common()[0][1])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from itertools import product
from collections import Counter

def main():
    N = II()
    XY = []
    for _ in range(N):
        XY.append(LI())
    cnt = Counter()
    for p0, p1 in product(XY, repeat=2):
        dx, dy = p1[0] - p0[0], p1[1] - p0[1]
        if dx != 0 or dy != 0:
            cnt[(dx, dy)] += 1
    ans = N - max(cnt.values())
    return ans

print(main())

Submission status: Runtime Error

Solution code:
from itertools import combinations
from collections import Counter

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

X.sort()
diff = []
for i, j in combinations(range(N), 2):
    diff.append((X[i][0] - X[j][0], X[i][1] - X[j][1]))
print(N - Counter(diff).most_common()[0][1])

Submission status: Runtime Error

Solution code:
import math
import statistics
n=int(input())
x=[0]*n
y=[0]*n
X=[0]*(n-1)
Y=[0]*(n-1)
for i in range(n):
  x[i], y[i] = map(int,input().split())
x=sorted(x)
y=sorted(y)
for i in range(n-1):
  X[i] = x[i+1] - x[i]
  Y[i] = y[i+1] - y[i]
modex = statistics.mode(X)
modey = statistics.mode(Y)
lx = X.count(modex)
ly = Y.count(modey)
print(n-min(lx,ly))

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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

xy = np.array(xy)

count_dic = {}
for i in range(N):
    for j in range(i+1,N):
        diff = xy[i] - xy[j]
        p,q = diff
        pq = str(p)+str(q)
        if pq in count_dic:
            count_dic[pq] += 1
        else:
            count_dic[pq] = 1

for k,v in sorted(count_dic.items(), key = lambda x:x[-1]):
    ans = N - v - 1
    break
print(max(1,ans))

Submission status: Runtime Error

Solution code:
from collections import Counter

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

if N == 1:
    print(1)

pos.sort(reverse = True)

cnt = Counter()

for i in range(N):
    a,b = pos[i]
    for j in range(i+1,N):
        c,d = pos[j]
        t = (a - c, b - d)
        cnt[t] += 1

ans = N - cnt.most_common()[0][1]
print(ans)

Submission status: Runtime Error

Solution code:
N = input()
N = int(N)
s = [[ int(i) for i in input().split()] for i in range(N)]
hoge = []
import collections

for i in s:
    for k in s:
        if k != i:
            hoge1 = (i[0] - k[0],i[1] - k[1])
            if hoge1[0] < 0:
                hoge1 = hoge1 * -1
            hoge.append(hoge1)

c = collections.Counter(hoge)
print(N - c.most_common()[0][1] // 2)

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
xy = sorted(xy, key=lambda x: x[0])
counter = Counter()
for i in range(1, N):
    nxy = xy[i]
    pxy = xy[i-1]
    counter[(nxy[0]-pxy[0], nxy[1]-pxy[1])] += 1

print(N-counter.most_common(1)[0][1])

Submission status: Runtime Error

Solution code:
n = int(input())
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))
xy.sort(key = lambda x: x[1])
xy.sort()
dif = []
for i in range(n):
    for j in range(i + 1, n):
        dif.append((xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]))
count_dif = {}
for i in dif:
    count_dif.setdefault(i, 0)
    count_dif[i] += 1
print(n - max(count_dif.values()))

Submission status: Runtime Error

Solution code:
N = int(input())

XYs = []

for i in range(N):
    x,y = map(int,input().split())
    tmp = (x,y)
    XYs.append(tmp)

distances = {}

for index_fr in range(N):
    for index_to in range(N):
        if index_fr == index_to:
            continue
        fr = XYs[index_fr]
        to = XYs[index_to]
        key = str(fr[0] - to[0]) + str(fr[1] - to[1])
        if key in distances.keys():
            distances[key] += 1
        else:
            distances[key] = 1



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

Submission status: Runtime Error

Solution code:
def most_frequent(List):
    counter = 0
    num = List[0]

    for i in List:
        curr_frequency = List.count(i)
        if(curr_frequency> counter):
            counter = curr_frequency
            num = i

    return num

n = int(input())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([x,y])
c = sorted(c)
l = []
for i in range(len(c)-1):
    l.append([c[i+1][0]-c[i][0],c[i+1][1]-c[i][1]])
z = most_frequent(l)
l = 1
for i in range(1,len(c)):
    if(c[i][0]-c[i-1][0]!=z[0] or c[i][1]-c[i-1][1]!=z[1]):
        l+=1
print(l)

Submission status: Runtime Error

Solution code:
def inverse(a):
    return pow(a, mod - 2, mod)

def main():
    n = int(input())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        x, y = tuple(map(int, input().split()))
        a[i] = x
        b[i] = y
    from collections import defaultdict
    d = defaultdict(lambda: 0)
    for i in range(n):
        for j in range(i+1, n):
            t = a[i] - a[j]
            y = b[i] - b[j]
            tmp = 1 if (t > 0 or (t == 0 and y > 0)) else -1
            d[(tmp * t, tmp * y)] += 1

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

main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# coding: utf-8

from collections import Counter

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    lx, ly = [], []
    for _ in range(n):
        x, y = rli()
        lx.append(x)
        ly.append(y)
    dd = {}
    dc = Counter()
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            d = (lx[i]-lx[j], ly[i]-ly[j])
            dd[(i, j)] = d
            dc[d] += 1
    v = dc.most_common()[0][1]
    print(n-v)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(n):
	x, y = map(int, input().split())
	a.append((x, y))
d = {}
for i in range(n):
	tc = a[i]
	for j in range(i + 1, n):
		nd = a[j]
		x1, y1, = tc[0], tc[1]
		x2, y2, = nd[0], nd[1]
		rz1 = abs(x1- x2)
		rz2 = abs(y1 - y2)
		d[(rz1, rz2)] = d.get((rz1,rz2), 0) + 1
print(n - max(d.values()))

Submission status: Runtime Error

Solution code:
from collections import Counter

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

pos.sort(reverse = True)

cnt = Counter()

for i in range(N):
    a,b = pos[i]
    for j in range(i+1,N):
        c,d = pos[j]
        t = (a - c, b - d)
        cnt[t] += 1

ans = N - cnt.most_common()[0][1]
print(ans)