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:
import copy

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
ans = 10**10
for i in range(N-1):
  x_begin, y_begin = XY[i]
  for j in range(i+1, N):
    p = XY[j][0]-XY[i][0]
    q = XY[j][1]-XY[i][1]
    XY_tmp = copy.deepcopy(XY)
    x, y = XY_tmp[i]
    XY_tmp.pop(i)
    cost = 1
    sign = -1
    while XY_tmp:
      if (x+sign*p, y+sign*q) in XY_tmp:
        XY_tmp.pop(XY_tmp.index((x+sign*p, y+sign*q)))
        x += sign*p
        y += sign*q
      else:
        sign *= -1
        if sign < 0:
          cost += 1
          x_begin, y_begin = XY_tmp[0]
          XY_tmp.pop(0)
        x, y = x_begin, y_begin
    if cost < ans:
      ans = cost
print(ans if N > 2 else 1)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
ans = 10**10
for i in range(N-1):
  x_begin, y_begin = XY[i]
  for j in range(i+1, N):
    p = XY[j][0]-XY[i][0]
    q = XY[j][1]-XY[i][1]
    c = 0
    for k in range(N-1):
      for l in range(k+1, N):
        dx = XY[k][0]-XY[l][0]
        dy = XY[k][1]-XY[l][1]
        if dx == p and dy == q or dx == -p and dy == -q:
          c += 1
    ans = min(ans, N-c)
print(ans)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
ans = 10**10
for i in range(N-1):
  x_begin, y_begin = XY[i]
  for j in range(i+1, N):
    p = XY[j][0]-XY[i][0]
    q = XY[j][1]-XY[i][1]
    XY_tmp = copy.deepcopy(XY)
    x, y = XY_tmp[i]
    XY_tmp.pop(i)
    cost = 1
    sign = -1
    while XY_tmp:
      if (x+sign*p, y+sign*q) in XY_tmp:
        XY_tmp.pop(XY_tmp.index((x+sign*p, y+sign*q)))
        x += sign*p
        y += sign*q
      else:
        sign *= -1
        if sign < 0:
          cost += 1
          x_begin, y_begin = XY_tmp[0]
          XY_tmp.pop(0)
        x, y = x_begin, y_begin
    if cost < ans:
      ans = cost
print(ans)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
ans = 10**10
for i in range(N-1):
  x_begin, y_begin = XY[i]
  for j in range(i+1, N):
    p = XY[j][0]-XY[i][0]
    q = XY[j][1]-XY[i][1]
    XY_tmp = copy.deepcopy(XY)
    x, y = XY_tmp[i]
    XY_tmp.pop(i)
    cost = 1
    sign = -1
    while XY_tmp:
      if (x+sign*p, y+sign*q) in XY_tmp:
        XY_tmp.pop(XY_tmp.index((x+sign*p, y+sign*q)))
        x += sign*p
        y += sign*q
      else:
        sign *= -1
        if sign < 0:
          cost += 1
          x, y = XY_tmp[0]
          XY_tmp.pop(0)
        else:
          x, y = x_begin, y_begin
    if cost < ans:
      ans = cost
print(ans)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
ans = 10**10
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]
    XY_tmp = copy.deepcopy(XY)
    x, y = XY_tmp[i]
    XY_tmp.pop(i)
    cost = 1
    sign = -1
    while XY_tmp:
      if (x+sign*p, y+sign*q) in XY_tmp:
        XY_tmp.pop(XY_tmp.index((x+sign*p, y+sign*q)))
        x += sign*p
        y += sign*q
      else:
        sign *= -1
        if sign < 0:
          cost += 1
          x, y = XY_tmp[0]
          XY_tmp.pop(0)
    if cost < ans:
      ans = cost
print(ans)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
ans = 10**10
for i in range(N):
  for j in range(i, N):
    p = XY[j][0]-XY[i][0]
    q = XY[j][1]-XY[i][1]
    XY_tmp = copy.deepcopy(XY)
    x, y = XY_tmp[i]
    XY_tmp.pop(i)
    cost = 1
    sign = -1
    while XY_tmp:
      if (x+sign*p, y+sign*q) in XY_tmp:
        XY_tmp.pop(XY_tmp.index((x+sign*p, y+sign*q)))
        x += sign*p
        y += sign*q
      else:
        sign *= -1
        if sign < 0:
          cost += 1
          x, y = XY_tmp[0]
          XY_tmp.pop(0)
    if cost < ans:
      ans = cost
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
	for j in range(n):
		if i==j:
			continue
		xi, yi = xy[i]
		xj, yj = xy[j]
		pq.append((xi - xj, yi - yj))
ans = 1e9
for p, q in pq:
	cost = 0
	for x, y in xy:
		if (x + p, y + q) in xy:
			pass
		else:
			cost += 1
	ans = min(ans, cost)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
	for j in range(n):
		xi, yi = xy[i]
		xj, yj = xy[j]
		if xi==xj or yi==yj:
			continue
		pq.append((xi - xj, yi - yj))
ans = 1e9
for p, q in pq:
	cost = 0
	for x, y in xy:
		if (x + p, y + q) in xy:
			pass
		else:
			cost += 1
	ans = min(ans, cost)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
	for j in range(i + 1, n):
		xi, yi = xy[i]
		xj, yj = xy[j]
		if xi==xj or yi==yj:
			continue
		pq.append((xi - xj, yi - yj))
ans = 1e9
for p, q in pq:
	cost = 0
	for x, y in xy:
		if (x + p, y + q) in xy:
			pass
		else:
			cost += 1
	ans = min(ans, cost)
print(ans)

Submission status: Wrong Answer

Solution code:

# coding: utf-8
# Your code here!
N=int(input())

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

dis=[[0]*(N) for i in range(N)]
#print(dis)

for i in range(N):
    for j in range(N):
        if i!=j:
            dis[i][j]=[abs(l[i][0]-l[j][0]),abs(l[i][1]-l[j][1])]

temp=0
for i in range(N-1):
    for item in dis[i]:
        if item!=0:
            temp=max(sum(x.count(item) for x in dis),temp)
            #print(i,item,temp)
            
#print(l)
#print(dis)
print(N-temp//2)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
N=int(input())

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

dis=[[0]*(N) for i in range(N-1)]
#print(dis)

for i in range(N-1):
    for j in range(i+1,N):
        dis[i][j]=[abs(l[i][0]-l[j][0]),abs(l[i][1]-l[j][1])]

temp=0
for i in range(N-1):
    for item in dis[i]:
        if item!=0:
            temp=max(sum(x.count(item) for x in dis),temp)

#print(l)
#print(dis)
print(N-temp)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())

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

dis=[[0]*(N) for i in range(N-1)]
#print(dis)

for i in range(N-1):
    for j in range(i+1,N):
        dis[i][j]=[l[i][0]-l[j][0],l[i][1]-l[j][1]]

temp=0
for i in range(N-1):
    for item in dis[i]:
        if item!=0:
            temp=max(sum(x.count(item) for x in dis),temp)

#print(l)
#print(dis)
print(N-temp)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
for _ in range(n):
    line = list(map(int, input().split()))
    x.append(line[0])
    y.append(line[1])
if n >= 2:
    slope = []
    for i in range(n):
        for j in range(i+1, n):
            X = x[j] - x[i]
            Y = y[j] - y[i]
            if X != 0:
                if X < 0:
                    X = -X
                    Y = -Y
                slope.append([X, Y])
            if X == 0:
                slope.append([X, -Y])
    cnt = []
    for i in slope:
        cnt.append(slope.count(i))
    print(n - max(cnt))
else:
    print(1)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
for _ in range(n):
    line = list(map(int, input().split()))
    x.append(line[0])
    y.append(line[1])
if n >= 2:
    slope = []
    for i in range(n):
        for j in range(i+1, n):
            X = x[j] - x[i]
            Y = y[j] - y[i]
            if X < 0:
                X = -X
                Y = -Y
            slope.append([X, Y])
    cnt = []
    for i in slope:
        cnt.append(slope.count(i))
    print(n - max(cnt))
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
cmin = 100
for y in itertools.combinations(X,2):
    x1,y1 = y[0]
    x2,y2 = y[1]
    p = x2-x1
    q = y2-y1
    cnt0 = 0
    cnt1 = 0
    for i in range(N):
        x,y = X[i]
        if [x+p,y+q] in X:
            cnt0 += 1
        if [x-p,y-q] in X:
            cnt1 += 1
    cnt = max(cnt0,cnt1)
    cmin = min(cmin,N-cnt)
print(cmin)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    xy = [list(map(int, input().split())) for i in range(n)]
    
    d = defaultdict(int)
    for i in range(n):
        for j in range(i+1,n):
            if i == j:
                continue
            aaa = xy[i][0] - xy[j][0]
            bbb = xy[i][1] - xy[j][1]
            # if aaa > 0 and bbb >0:
            #     g = gcd(aaa, bbb)
            #     aaa //= g
            #     bbb //= g
            # else:
            #     if aaa > 0:
            #         aaa = 1
            #     else:
            #         bbb = 1

            d[(aaa,bbb)]+=1
            #d[(bbb,aaa)]+=1
    ans = float("inf")
    for k, v in d.items():
        #print(k,v)
        ans = min(ans, n - v)

    print(ans)

    






    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    xy = [list(map(int, input().split())) for i in range(n)]
    
    #l = [[float("inf") for i in range(n)] for j in range(n)]
    d = defaultdict(int)
    for i in range(n):
        for j in range(i+1,n):
            # if i == j:
            #     continue
            aaa = xy[i][0] - xy[j][0]
            bbb = xy[i][1] - xy[j][0]
            if aaa > 0 and bbb >0:
                g = gcd(aaa, bbb)
                aaa //= g
                bbb //= g
            else:
                if aaa > 0:
                    aaa = 1
                else:
                    bbb = 1

            d[(aaa,bbb)]+=1
    ans = float("inf")
    for v in d.values():
        ans = min(ans, v)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[tuple(map(int,input().split())) for _ in range(n)]
pq=[]
for i in range(n):
    for j in range(n):
        if i==j:
            continue
        sx,sy=xy[i]
        gx,gy=xy[j]
        pq.append((gx-sx,gy-sy))


se=set(xy)

ans=float("inf")
for p,q in pq:
    now=0
    for x,y in xy:
        if (x+p,y+q) not in se:
            now+=1
    ans=min(ans,now)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
count=1
ans=100000000
p=0
q=0
for i in range(n):
    x.append(list(map(int,input().split())))
x.sort()
for i in range(n):
    for j in range(n):
        p=x[j][0]-x[i][0]
        q=x[j][1]-x[i][1]
        for k in range(n):
            for m in range(n):
                #print(p,q)
                #rint(x[k],x[m])
                if k==m and k==n-1:
                    count=1
                    continue
                if k==m:
                    continue
                if x[k][0]+p!=x[m][0] or x[k][1]+q!=x[m][1]:
                    count+=1
                #print(count)
                if m==n-1:
                    if ans>count:
                        ans=count
                        count=0
                    else:
                        count=0
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[0]*n
y=[0]*n
count=1
ans=100000000
p=0
q=0
for i in range(n):
    x[i],y[i]=map(int,input().split())
if n==1:
    ans=1
else:
    for j in range(n):
        for l in range(n):
            if x[j]!=x[l]:
                p=x[j]-x[l]
            else:
                p=0
            if y[j]!=y[l]:
                q=y[j]-y[l]
            else:
                q=0
            #print(p,q)
            #print("--------")
            for k in range(n):
                for m in range(n):
                    if m==k and k==n-1:
                        count=1
                        continue
                    if m==k:
                        continue
                    if x[k]+p==x[m] and y[k]+q==y[m]:
                        count+=0
                    else:
                        count+=1
                    #print(x[k],y[k],'|',x[k],y[m])
                    #print(count)
                    if m==n-1:
                        #print('--------')
                        if ans>count:
                            ans=count
                            count=0
                        else:
                            count=0
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[0]*n
y=[0]*n
count=1
ans=100000000
p=0
q=0
for i in range(n):
    x[i],y[i]=map(int,input().split())
if n==1:
    ans=1
else:
    for j in range(n-1):
        if x[j]!=x[j+1]:
            p=x[j]-x[j+1]
        else:
            p=0
        if y[j]!=y[j+1]:
            q=y[j]-y[j+1]
        else:
            q=0
        #print(p,q)
    #print("--------")
    for k in range(n-1):
        #print(x[k+1],y[k+1])
        #print(x[k],y[k])
        if x[k+1]+p==x[k] and y[k+1]+q==y[k]:
            count+=0
        else:
            count+=1
        #print(count)
    if ans>count:
        ans=count
        count=1
    else:
        count=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[0]*n
y=[0]*n
count=1
ans=100000000
p=0
q=0
for i in range(n):
    x[i],y[i]=map(int,input().split())
for j in range(n-1):
    if x[j]!=x[j+1]:
        p=x[j]-x[j+1]
    if y[j]!=y[j+1]:
        q=y[j]-y[j+1]
    #print(p,q)
    #print("--------")
    for k in range(n-1):
        #print(x[k+1],y[k+1])
        #print(x[k],y[k])
        if x[k+1]+p==x[k] and y[k+1]+q==y[k]:
            count+=0
        else:
            count+=1
        #print(count)
    if ans>count:
        ans=count
        count=1
    else:
        count=1
print(ans)

Submission status: Wrong Answer

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

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

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

print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])

Submission status: Wrong Answer

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

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

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

print(Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common())
print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])

Submission status: Wrong Answer

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

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

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

print(Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common())
print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

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

XY.sort(key=itemgetter(1))
XY.sort(key=itemgetter(0))

ans = N+1
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]
        cost1 = N
        cost2 = N
        for x, y in XY:
            if [x+p, y+q] in XY:
                cost1 -= 1
            if [x-p, y-q] in XY:
                cost2 -= 1
        ans = min([ans, cost1, cost2])
print(ans)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

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

XY.sort(key=itemgetter(1))
XY.sort(key=itemgetter(0))

ans = N+1
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]
        cost = N
        for x, y in XY:
            if [x+p, y+q] in XY:
                cost -= 1
        ans = min(ans, cost)
print(ans)

Submission status: Wrong Answer

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

ans=0
while 1:
  ans+=1
  mp=[0,0,0]
  for i in range(len(xy)):
    for j in range(i+1,len(xy)):
      r=2
      while 1:
        if [xy[i][0]+(xy[j][0]-xy[i][0])*r,xy[i][1]+(xy[j][1]-xy[i][1])*r] not in xy:
          break
        else:
          r+=1
      if r>mp[0]:
        mp=[r,i,j]
  #print(mp)

  sx=xy[mp[1]][0]
  sy=xy[mp[1]][1]
  dx=xy[mp[2]][0]-xy[mp[1]][0]
  dy=xy[mp[2]][1]-xy[mp[1]][1]
  for i in range(mp[0]):
    a=[dx*i+sx,dy*i+sy]
    del xy[xy.index(a)]
  #print(xy)
  if len(xy)==0:
    break
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
if N==1:
  print(1)
else:
  arr = sorted(arr,key=lambda x:(x[0],x[1]))
  diff_arr = []
  for j in range(N):
    for k in range(1,N-j):
      diff_arr.append(str(arr[j+k][0]-arr[j][0])+'_'+str(arr[j+k][1]-arr[j][1]))
  print(diff_arr)
  c = collections.Counter(diff_arr)
  print(N-max(c.values()))

Submission status: Wrong Answer

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

ans = dict()

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

for i in range(n):
    for j in range(i+1, n):
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        if ans.get((p, q)) == None:
            ans[(p, q)] = 1
        else:
            ans[(p, q)] += 1
# print(ans)
print(n-max(ans.values()))

Submission status: Wrong Answer

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

ans = dict()

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

for i in range(n):
    for j in range(i+1, n):
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        if ans.get((p, q)) == None:
            ans[(p, q)] = 1
        else:
            ans[(p, q)] += 1
# print(ans)
print(list(ans.values()).count(max(ans.values())))

Submission status: Wrong Answer

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

ans = dict()

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

for i in range(n):
    for j in range(i+1, n):
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        if ans.get((p, q)) == None:
            ans[(p, q)] = 1
        else:
            ans[(p, q)] += 1
print(ans)
print(list(ans.values()).count(max(ans.values())))

Submission status: Wrong Answer

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

ans = 10**9

for i in range(n):
    for j in range(i+1, n):
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        cost = 0
        b = set()
        # print('p,q='+str(p)+','+str(q))
        for k in xy:
            if (p == 0):
                seppen = k[0]
            elif (q == 0):
                seppen = k[0]
            else:
                seppen = round(k[1] - k[0] * q / p, 10)
            # print(seppen)
            if (not seppen in b):
                cost += 1
                b.add(seppen)
        # print(b)
        #print('cost:' + str(cost))
        ans = min(ans, cost)
print(ans)

Submission status: Wrong Answer

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

ans = 10**9

for i in range(n):
    for j in range(i+1, n):
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        cost = 0
        b = set()
        # print('p,q='+str(p)+','+str(q))
        for k in xy:
            seppen = round(k[1] - k[0] * q / p, 10) if p != 0 else k[1]
            # print(seppen)
            if (not seppen in b):
                cost += 1
                b.add(seppen)
        #print('cost:' + str(cost))
        ans = min(ans, cost)
print(ans)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
from collections import defaultdict

big = 10**10
N = int(input())
pt = [[int(x) for x in input().split()] for _ in range(N)]
pt.sort(key = itemgetter(1))
pt.sort(key = itemgetter(0))
di = defaultdict(int)
for i,p0 in enumerate(pt):
    for j,p1 in enumerate(pt):
        if(i>=j):continue
        p,q = p0[0]-p1[0],p0[1]-p1[1]
        di[p*big+q] += 1
maxd = 0
for i in di:
    if(i==0):continue
    maxd = max(di[i],maxd)
print(N-maxd)
print(di)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

big = 10**10
N = int(input())
pt = [[int(x) for x in input().split()] for _ in range(N)]
di = defaultdict(int)
for i,p0 in enumerate(pt):
    for j,p1 in enumerate(pt):
        if(i>=j):continue
        p,q = p0[0]-p1[0],p0[1]-p1[1]
        di[p*big+q] += 1
maxd = 0
for i in di:
    if(i==0):continue
    maxd = max(di[i],maxd)
print(N-maxd)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = []
ans = []
if n == 1:
    print(1)
    exit()
for _ in range(n):
    x, y = map(int, input().split())
    a.append([x, y])
for i in range(n):
    for j in range(i + 1, n):
        p = a[i][0] - a[j][0]
        q = a[i][1] - a[j][1]
        ans.append(str(p) + " " + str(q))
print(n - max(Counter(ans).values()))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import Counter
N = int(input())

pd = defaultdict(int)
qd = defaultdict(int)
C = [list(map(int, input().split())) for _ in range(N)]
C.sort(key=lambda x: x[1])
C.sort()

for c1, c2 in zip(C, C[1:]):
    pd[c1[0]-c2[0]] += 1
    qd[c1[1]-c2[1]] += 1

ap = None
aq = None
tmp = 0
for k,v in pd.items():
    if v > tmp:
        ap = k
        tmp = v
tmp = 0
for k,v in qd.items():
    if v > tmp:
        aq = k
        tmp = v

ans = 1
for c1, c2 in zip(C, C[1:]):
    if c1[0] - c2[0] != ap:
        ans += 1
    elif c1[1] - c2[1] != aq:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import Counter
N = int(input())

pd = defaultdict(int)
qd = defaultdict(int)
C = [list(map(int, input().split())) for _ in range(N)]
C.sort(key=lambda x: x[1])
C.sort()

for c1, c2 in zip(C, C[1:]):
    pd[c1[0]-c2[0]] += 1
    qd[c1[1]-c2[1]] += 1

ap = None
aq = None
tmp = 0
for k,v in pd.items():
    if v > tmp:
        ap = k
for k,v in qd.items():
    if v > tmp:
        aq = k

ans = 1
for c1, c2 in zip(C, C[1:]):
    if c1[0] - c2[0] != ap:
        ans += 1
    elif c1[1] - c2[1] != aq:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def main():

    N = int(input())
    if N == 1: return 1
    if N == 2: return 1

    ball = []
    for _ in range(N):
        x, y = map(int, input().split())
        ball.append((x, y))
    ball.sort()
    

    pq = []
    for i in range(N-1):
        x0, y0 = ball[i]
        for j in range(i+1, N):
            x1, y1 = ball[j]
            pq.append([x1-x0, y1-y0])
    print(pq)

    min_count = N
    for p, q in pq:
        count = 0
        visited = set()
        for b in ball:
            if b not in visited:
                count += 1
                z, w = b[0], b[1]
                while (z, w) in ball:
                    visited.add((z, w))
                    z += p
                    w += q
            # print(visited, count)
        min_count = min(min_count, count)

    return min_count

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

Submission status: Wrong Answer

Solution code:
def main():

    N = int(input())
    if N == 1: return 1
    if N == 2: return 1

    ball = []
    for _ in range(N):
        x, y = map(int, input().split())
        ball.append((x, y))
    ball.sort(key = lambda x: x[0])

    pq = []
    for i in range(N-1):
        x0, y0 = ball[i]
        for j in range(i+1, N):
            x1, y1 = ball[j]
            pq.append([x1-x0, y1-y0])

    min_count = N
    for p, q in pq:
        count = 0
        visited = set()
        for b in ball:
            if b not in visited:
                count += 1
                z, w = b[0], b[1]
                while (z, w) in ball:
                    visited.add((z, w))
                    z += p
                    w += q
            # print(visited, count)
        min_count = min(min_count, count)

    return min_count

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

Submission status: Wrong Answer

Solution code:
def main():

    N = int(input())
    if N == 1: return 1
    if N == 2: return 1

    ball = []
    for _ in range(N):
        x, y = map(int, input().split())
        ball.append([x, y])
    ball.sort(key = lambda x: x[0])

    pq = []
    for i in range(N-1):
        x0, y0 = ball[i]
        for j in range(i+1, N):
            x1, y1 = ball[j]
            pq.append([x1-x0, y1-y0])

    min_count = float('inf')
    for p, q in pq:
        count = 0
        visited = set()
        for x, y in ball:
            if (x, y) not in visited:
                visited.add((x, y))
                count += 1
                z, w = x, y
                while [z+p, w+q] in ball and (z+p, w+q) not in visited:
                    visited.add((z+p, w+q))
                    z, w = z+p, w+q
            # print(visited, count)
        min_count = min(min_count, count)

    return min_count

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

Submission status: Wrong Answer

Solution code:
def main():

    N = int(input())
    if N == 1: return 1
    if N == 2: return 1

    ball = []
    for _ in range(N):
        x, y = map(int, input().split())
        ball.append([x, y])
    ball.sort(key = lambda x: x[0])

    pq = []
    for i in range(N):
        x0, y0 = ball[i]
        for j in range(N):
            if i != j:
                x1, y1 = ball[j]
                pq.append([x1-x0, y1-y0])

    min_count = float('inf')
    for p, q in pq:
        count = 0
        visited = set()
        for x, y in ball:
            if (x, y) not in visited:
                visited.add((x, y))
                count += 1
                z, w = x, y
                while [z+p, w+q] in ball and (z+p, w+q) not in visited:
                    visited.add((z+p, w+q))
                    z, w = z+p, w+q
            # print(visited, count)
        min_count = min(min_count, count)

    return min_count

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

Submission status: Wrong Answer

Solution code:
def main():

    N = int(input())
    if N == 1: return 1
    if N == 2: return 1
    
    ball = []
    for _ in range(N):
        x, y = map(int, input().split())
        ball.append([x, y])
    ball.sort(key = lambda x: x[0])

    pq = []
    for i in range(N):
        x0, y0 = ball[i]
        for j in range(N):
            if i != j:
                x1, y1 = ball[j]
                pq.append([x1-x0, y1-y0])

    min_count = float('inf')
    for p, q in pq:
        count = 0
        visited = set()
        for x, y in ball:
            if (x, y) not in visited:
                visited.add((x, y))
                count += 1
                z, w = x, y
                while [z+p, w+q] in ball:
                    visited.add((z+p, w+q))
                    z, w = z+p, w+q
            # print(visited, count)
        min_count = min(min_count, count)

    return min_count

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

Submission status: Wrong Answer

Solution code:
def main():

    N = int(input())
    ball = []
    for _ in range(N):
        x, y = map(int, input().split())
        ball.append([x, y])
    ball.sort(key = lambda x: x[0])

    pq = []
    for i in range(N):
        x0, y0 = ball[i]
        for j in range(N):
            if i != j:
                x1, y1 = ball[j]
                pq.append([x1-x0, y1-y0])

    min_count = float('inf')
    for p, q in pq:
        count = 0
        visited = set()
        for x, y in ball:
            if (x, y) not in visited:
                visited.add((x, y))
                count += 1
                z, w = x, y
                while [z+p, w+q] in ball:
                    visited.add((z+p, w+q))
                    z, w = z+p, w+q
            # print(visited, count)
        min_count = min(min_count, count)

    return min_count

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

Submission status: Wrong Answer

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

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

for i in range(n):
    for j in range(i+1, n):
        if (xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]) not in dict_xy:
            dict_xy[xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]] = 1
        else:
            dict_xy[xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]] += 1

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

Submission status: Wrong Answer

Solution code:
def deposit(p,q):
    ans_list = []
    temp_list = []
    before = [0,0]
    for i, v in enumerate(point_list):
        if i == 0:
            temp_list.append(v)
        else:
            if [before[0]+p,before[1]+q] == v:
                temp_list.append(v)
            else:
                ans_list.append(temp_list)
                temp_list = [v]
        before = v

    ans_list.append(temp_list)
    return len(ans_list)

n = int(input())
point_list = sorted([ [ int(v) for v in input().split() ] for i in range(n) ])

ans = n
for k in [ (i,j) for i in range(n) for j in range(n) ]:
    i, j = k
    p, q = point_list[j][0] - point_list[i][0], point_list[j][1] - point_list[i][1]
    ans = min(deposit(p,q),ans)

print(ans)