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: Wrong Answer

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

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x


def get_2dline(p1, p2):
    if p1 == p2:
        return (0, 0, 0)
    _p1, _p2 = min(p1, p2), max(p1, p2)
    a, b, c = _p2[1] - _p1[1], _p1[0] - _p2[0], _p1[1] * _p2[0] - _p1[0] * _p2[1]
    g = gcd(gcd(a, b), c)
    return (a // g, b // g, c // g)


def main():
    n = int(input())
    points = []
    for _ in range(n):
        points.append(tuple(map(int, input().split())))

    line_set = set()
    for i in range(n):
        for j in range(n):
            a, b, c = get_2dline(points[i], points[j])
            line_set.add((a, b))
    line_set.discard((0, 0))

    res = 10**9
    for p, q in line_set:
        counter = set()
        for x, y in points:
            counter.add(p * x + q * y)
        res = min(res, len(counter))
    print(res)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    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("\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()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    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()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import collections
N = int(input())
alllist = []
minaslist = []
for i in range(N):
    a,b = map(int,input().split())
    alllist.append([a,b])

for i in range(N-1):
    minaslist.append((alllist[i+1][0]-alllist[i][0])**3 - (alllist[i+1][1]-alllist[i][1])**4)



ans = collections.Counter(minaslist)
print(len(ans))

Submission status: Wrong Answer

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


def calc(p,q):
    result = set()
    if p == 0:
        for x,y in XY:
            result.add(x)
        return len(result)
    for x,y in XY:
        result.add(y - Fraction(x,p) * q)
    #print(p,q,result)
    return len(result)

ans = 5000

for i in range(N-1):
    for j in range(i,N):
        p = XY[i][0] - XY[j][0]
        q = XY[i][1] - XY[j][1]
        ans = min(ans,calc(p,q))

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
list_ = [tuple(map(int, input().split())) for i in range(n)]
list_.sort()

ab = []
x_1, y_1 = list_[0]
for x_2, y_2 in list_[1:]:
    a = x_2 - x_1
    b = y_2 - y_1
    ab.append((a, b))
    x_1, y_1 = x_2, y_2

print(len(set(ab)))

Submission status: Wrong Answer

Solution code:
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
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
if N == 1:
	min_point = 1
print(min_point)

Submission status: Wrong Answer

Solution code:
N=int(input())
ball=[tuple(map(int,input().split())) for i in range(N)]
ans=N
for i in range(N-1):
    for j in range(i+1,N):
        cost=1
        p=ball[j][0]-ball[i][0]
        q=ball[j][1]-ball[i][1]
        used={i,j}
        for l in range(N):
            if l not in used:
                    x=ball[l][0]-ball[i][0]
                    y=ball[l][1]-ball[i][1]
                    a,b,c=False,False,False
                    if p==0:
                        if x==0:
                            a=True
                            c=True
                        if y%q==0:
                            b=True
                    elif q==0:
                        if y==0:
                            b=True
                            c=True
                            if x%p==0:
                                a=True
                    elif p!=0 and q!=0:
                        if x%p==0 and y%q==0 and x//p==y//q:
                            a,b,c=True,True,True
                    if a and b and c:
                        used|={l}
        for k in range(N):
            if k in used:
                continue
            else:
                cost+=1
                used|={k}
                for l in range(N):
                    if l not in used:
                        x=ball[l][0]-ball[k][0]
                        y=ball[l][1]-ball[k][1]
                        a,b,c=False,False,False
                        if p==0:
                            if x==0:
                                a=True
                                c=True
                            if y%q==0:
                                b=True
                        elif q==0:
                            if y==0:
                                b=True
                                c=True
                            if x%p==0:
                                a=True
                        elif p!=0 and q!=0:
                            if x%p==0 and y%q==0 and x//p==y//q:
                                a,b,c=True,True,True
                        if a and b and c:
                            used|={l}
        ans=min(ans,cost)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import defaultdict
from functools import reduce
from itertools import permutations

# s = input()
n = int(input())
# A = list(map(int, input().split()))
# a, b = map(int, input().split())

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

res = n+1

for n1, n2 in permutations(range(n) ,2):
    p = lis[n1][0] - lis[n2][0]
    q = lis[n1][1] - lis[n2][1]
    s = set(range(n))
    s.remove(n1)
    s.remove(n2)

    score = 1
    x = lis[n1][0]
    y = lis[n1][1]

    while True:
        x2 = x
        y2 = y
        while True:
            if ((x2+p), (y2+q)) in dic:
                i = dic[((x2+p), (y2+q))]
                if i in s:
                    s.remove(i)
                x2 = lis[i][0]
                y2 = lis[i][1]
            else:
                break
        x2 = x
        y2 = y
        while True:
            if ((x2-p), (y2-q)) in dic:
                i = dic[((x2-p), (y2-q))]
                if i in s:
                    s.remove(i)
                x2 = lis[i][0]
                y2 = lis[i][1]
            else:
                break

        if len(s) == 0:
            break
        i = s.pop()
        x = lis[i][0]
        y = lis[i][1]
        score += 1
    res = min(res, score)
print(res)

Submission status: Wrong Answer

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 = []

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

for i in range(N):
    for j in range(i+1, N):
        x_diff = xy[i][0] - xy[j][0]
        y_diff = 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: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
s=set()
l.sort(key=lambda x:x[0],reverse=True)
ans=0
for i in range(n-1,0,-1):
    val=(abs(l[i][0]-l[i-1][0]),abs(l[i][1]-l[i-1][1]))
    if(val not in s):
        s.add(val)
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

a = [list(map(int,input().split())) for i in range(N)]
pq = []
c = []
if N == 1:
    print(1)
    exit()
for i in range(N):
    if i == 0:
        x = a[0][0]
        y = a[0][1]
    else:
        p = a[i][0] - x
        q = a[i][1] - y
        x = a[i][0]
        y = a[i][1]
        if (p,q) not in pq:
            pq.append((p,q))
            c.append(1)
        else:
            for j in range(len(pq)):
                if (p,q) == pq[j]:
                    c[j] += 1
print(N - max(c))

Submission status: Wrong Answer

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(N):
    for j in range(i+1, N):
        nxy = xy[i]
        pxy = xy[j]
        counter[(nxy[0]-pxy[0], nxy[1]-pxy[1])] += 1

if N == 1:
    print(1)
else:
    print(N-counter.most_common(1)[0][1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[int]", y: "List[int]"):
    diffs = []
    #ret = float('inf')
    for i in range(N):
        for j in range(i + 1, N):
            diffs.append([x[j] - x[i], y[j] - y[i]])
            diffs.append([x[i] - x[j], y[i] - y[j]])
    diffs.sort()
    cnt = 0
    tmp = 1
    for i in range(1, len(diffs)):
        if diffs[i] == diffs[i - 1]:
            tmp += 1
        else:
            cnt = max(tmp, cnt)
            tmp = 1
    ret = (N - 1) - tmp
    ret = max(1, ret)
    print(ret)
    return


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]
ans = float('inf')
for d1 in x:
    for d2 in x:
        tmp = n
        if d1 == d2:
            continue
        p = abs(d1[0] - d2[0])
        q = abs(d1[1] - d2[1])
        for idx, d3 in enumerate(x):
            for d4 in x[(idx + 1):]:
                if d3 != d4 and abs(d4[0] - d3[0]) == p and abs(d4[1] - d3[1]) == q:
                    tmp -= 1
                    break
        ans = min(ans, tmp)
print(ans)

Submission status: Wrong Answer

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

dic = dict()
cx, cy = xy[0]
for x, y in xy[1:]:
    w = (x-cx,y-cy)
    if dic.get(w) is None:
        dic[w] = 0
    dic[w] += 1
    cx, cy = x, y

cnt = 1
m = 0
for x in dic:
    m = max(m, dic[x])
cnt += N - 1 - m
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
lpq=[]
for i in range(n):
  for j in range(n):
    if i==j:
      pass
    else:
      lpq.append([l[i][0]-l[j][0],l[i][1]-l[j][1]])
score=n-1
for i in lpq:
  s1=0
  for j in l:
    for k in l:
      if j==k:
        pass
      else:
        if j[0]-k[0]==i[0] and j[1]-k[1]==i[1]:
          s1+=1
  s=n-s1
  if s<score:
    score=s
print(score)

Submission status: Wrong Answer

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)
    dicx = defaultdict(lambda: 0)
    xy.sort(key=lambda v: v[0])
    for i in range(1, len(xy)):
        dx = xy[i][0] - xy[i-1][0]
        dy = xy[i][1] - xy[i-1][1]
        if dx == 0 or dy == 0:
            continue
        key = '%d %d' % (dx, dy)
        dicx[key] += 1
    dicy = defaultdict(lambda: 0)
    xy.sort(key=lambda v: v[1])
    for i in range(1, len(xy)):
        dx = xy[i][0] - xy[i-1][0]
        dy = xy[i][1] - xy[i-1][1]
        if dx == 0 or dy == 0:
            continue
        key = '%d %d' % (dx, dy)
        dicy[key] += 1
    nm = 0
    for v in dicx.values():
        if nm < v:
            nm = v
    for v in dicy.values():
        if nm < v:
            nm = v
    print(N - nm)

main()

Submission status: Wrong Answer

Solution code:
from itertools import combinations

N = int(input())
P = {tuple(map(int, input().split())) for _ in range(N)}

COST = float("inf")
for a, b in combinations(P, 2):
    p = a[0] - b[0]
    q = a[1] - b[1]
    cost = 0
    for point in P:
        x, y = point[0] + p, point[1] + q
        if (x, y) in P:
            pass
        else:
            cost += 1
    COST = min(COST, cost)

print(COST)

Submission status: Wrong Answer

Solution code:
n = int(input())
index=0
hashMap={}
listL = []
sumP=0
while index < n:
    x, y = map(int, input().split())
    listL.append([x, y])
    sumP+=1
    index+=1

index2=0
while index2 < len(listL):
    index3 = index2+1
    while index3 < len(listL):
        key = str(listL[index2][0]-listL[index3][0])+" " + \
            str(listL[index2][1]-listL[index3][1])
        if key in hashMap:
            hashMap[key] +=1
        else:
            hashMap[key] = 1
        index3+=1
    index2+=1

maxV = 0
for key in hashMap:
    if hashMap[key] > maxV:
        maxV = hashMap[key]
print(sumP-maxV)

Submission status: Wrong Answer

Solution code:
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
#
# xy.sort()
# xy = xy[::-1]
# sa = []
# for i in range(1, n):
#     sa.append([xy[i - 1][0] - xy[i][0], xy[i - 1][1] - xy[i][1]])
#
# xy.sort(key=lambda x:x[1])
# xy2 = xy
# print(xy2)
# xy2 = xy2[::-1]
# sa2 = []
# for i in range(1, n):
#     sa2.append([xy[i - 1][0] - xy[i][0], xy[i - 1][1] - xy[i][1]])
# print(sa, sa2)

sa = []
for i, j in xy:
    for k, l in xy:
        sa.append([i - k, j - l])

#sa1

ans = 10000000000000000000
for p, q in sa:
    tmp = 0
    for i in range(n):
        x = xy[i][0]
        y = xy[i][1]
        if xy[i - 1][0] == x - p and xy[i - 1][1] == y - q:
            1
        else:
            tmp += 1
    ans = min(ans, tmp)


print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
answer = []
x_pre , y_pre = map(int,input().split())
for i in range(N-1):
    x, y = map(int, input().split())
    answer.append([x-x_pre, y-y_pre])
    x_pre = x
    y_pre = y
ans = list(map(tuple,answer))

ans = set(ans)
print(len(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
X, Y = [], []
XY = []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    XY.append((x, y))

XY.sort()
D = []
for i in range(1,N):
    D.append((XY[i][0] - XY[i - 1][0], XY[i][1] - XY[i - 1][1]))

DS = list(set(D))

cnt = 0
for d in DS:
    cnt = max(cnt, D.count(d))

print(N-cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

X = []
for i in range(N-1):
    for j in range(i+1,N):
        X.append((balls[i][0] - balls[j][0], balls[i][1] - balls[j][1]))

Y = set(X)
res = 0
for x in X:
    res = max(res, X.count(x))
print(N-res)

Submission status: Wrong Answer

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())) if c else 1)


# 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: Wrong Answer

Solution code:
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
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: Wrong Answer

Solution code:
import numpy as np
n = int(input())

if n in [1, 2]:
  output = 1
else:

  xy = []
  for i in range(n):
    xy.append([int(x) for x in input().split()])

  xy = np.array(xy)

  output = 3

print(output)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n = int(input())
xy = sorted(sorted([list(map(int, input().split())) for i in range(n)], key=itemgetter(0)), key=itemgetter(1))
a = {}
last = []
for i in range(n):
    if i != 0:
        b = ",".join([str(xy[i][0] - last[0]), str(xy[i][1] - last[1])])
        if b not in a:
            a[b] = 1
        else:
            a[b] += 1
    last = xy[i]
ans = 0
for i in a.keys():
    if i == "0,0":
        a[i] = 0
for i in a.values():
    ans = max(ans, i)
print(n - ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[]
B=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append([a,b])
  
for i in range(n):
  for j in range(i):
    B.append([abs(A[i][0]-A[j][0]),abs(A[i][1]-A[j][1])])
    

l=0
for i in B:
  l=max(l,B.count(i))
print(n-l)

Submission status: Wrong Answer

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 = {}
xy.sort()
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
ans = 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: Wrong Answer

Solution code:
from fractions import gcd

n = int(input())
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, n):
                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: Wrong Answer

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

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

for val in d.values():
    m = max(m, val)
#print(d)
print(N-m)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
for _ in range(N):
    a, b = map(int, input().split())
    X.append((a, b))
mi = 1000
X = sorted(X)
for i in range(N):
    for j in range(i+1, N):
        p = X[j][0]-X[i][0]
        q = X[j][1]-X[i][1]
        if p == 0 and q == 0:
            continue
        if p < 0:
            p, q = -p, -q
        if p == 0 and q < 0:
            q = -q
        c = 0
        for k in range(N):
            for l in range(k):
                if X[l][0] == X[k][0] - p and X[l][1] == X[k][1] - q:
                    break
            else:
                c += 1
        mi = min(mi, c)
print(mi)

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal
def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return n,b
 
 
def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return n,b,c
 
 
def dv():
	n, m = map(int, input().split())
	return n,m
 
 
def dva():
	n, m = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return n,m,b
 
 
def eratosthenes(n): 
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))
 
 
 
def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return n,b,m,c
 
 
def dvs():
	n = int(input())
	m = int(input())
	return n, m
 

n = int(input())
a = []
for i in range(n):
	x, y = map(int, input().split())
	a.append((x, y))
d = {}
if n == 1:
	print(1)
	exit()
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 = (x1- x2)
		rz2 = (y1 - y2)
		d[(rz1, rz2)] = d.get((rz1,rz2), 0) + 1
print(n - max(d.values()))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

xy.sort(key=lambda x: (x[0], x[1]))
m = 0
for i in range(n - 1):
    dx = xy[i + 1][0] - xy[i][0]
    c = 0
    for j in range(n - 1):
        if xy[j + 1][0] - xy[j][0] == dx:
            c += 1
    m = max(m, c)

xy.sort(key=lambda x: (x[1], x[0]))
m = 0
for i in range(n - 1):
    dy = xy[i + 1][1] - xy[i][1]
    c = 0
    for j in range(n - 1):
        if xy[j + 1][1] - xy[j][1] == dy:
            c += 1
    m = max(m, c)

print(n - m)

Submission status: Wrong Answer

Solution code:
from fractions import *

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

ans = min(len(set(x)), len(set(y)))
for a in range(N):
  for b in range(a):
    p = x[a]-x[b]
    q = y[a]-y[b]
    if p!=0 and q!=0:
      s = set()
      for i in range(N):
        s.add(y[i]-x[i]*Fraction(q, p))
      ans = min(ans, len(s))
print ans

Submission status: Wrong Answer

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

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

ans = float("inf")
for i in range(n - 1):
    for j in range(1, n - i):
        p = point[i + j][0] - point[i][0]
        q = point[i + j][1] - point[i][1]
        num = 1
        for k in range(n - 1):
            if point[k][0] + p == point[k + 1][0] and point[k][1] + q == point[k + 1][1]:
                num = num
            else:
                num += 1
        ans = min(ans, num)
print(ans)