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

N = int(input())
xy = {}
for i in range(N):
  x, y = map(int, input().split())
  xy[i] = (x, y)
  
ret = float("inf")  

# 2点選んで傾きを決める
index = [i for i in range(N)]
for i, j in combinations(index, 2):
  x1, y1 = xy[i]
  x2, y2 = xy[j]

  if x1 == x2:
    diff_x = 0
    diff_y = min(abs(y1 - y2), abs(y2 - y1))
  else:
    if y1 == y2:
      diff_x = min(abs(x1 - x2), abs(x2 - x1))
    else:
      diff_x = x1 - x2
      diff_y = y1 - y2
  
  # 傾きの条件を満たす直線上の点をチェックしていく
  nocheck = [1 for k in range(N)]
  tmp_ret = 0
  q = Queue()
  for k in range(N):
    if nocheck[k]:
      tmp_ret += 1 
      nocheck[k] = 0
      x, y = xy[k]
      q.put((x + diff_x, y + diff_y))
      q.put((x - diff_x, y - diff_y))
      while not q.empty():
        _x, _y = q.get()
        for l in range(N):
          if nocheck[l]:
            __x, __y = xy[l]
            if (_x, _y) == (__x, __y):
              nocheck[l] = 0
              q.put((__x + diff_x, __y + diff_y))
              q.put((__x - diff_x, __y - diff_y))
              break
    if sum(nocheck) == 0:
      break
      
  ret = min(ret, tmp_ret)
  
print(ret)

Submission status: Runtime Error

Solution code:
from itertools import combinations
from queue import Queue

N = int(input())
xy = {}
for i in range(N):
  x, y = map(int, input().split())
  xy[i] = (x, y)
  
ret = float("inf")  

# 2点選んで傾きを決める
index = [i for i in range(N)]
for i, j in combinations(index, 2):
  x1, y1 = xy[i]
  x2, y2 = xy[j]

  if x1 == x2:
    diff_x = 0
    diff_y = min(abs(y1 - y2), abs(y2 - y1))
  else:
    if y1 == y2:
      diff_x = min(abs(x1 - x2), abs(x2 - x1))
    else:
      diff_x = x1 - x2
      diff_y = y1 - y2
  
  # 傾きの条件を満たす直線上の点をチェックしていく
  nocheck = [1 for k in range(N)]
  tmp_ret = 0
  q = Queue()
  for k in range(N):
    if nocheck[k]:
      tmp_ret += 1 
      nocheck[k] = 0
      x, y = xy[k]
      q.put((x + diff_x, y + diff_y))
      q.put((x - diff_x, y - diff_y))
      while not q.empty():
        _x, _y = q.get()
        for l in range(N):
          if nocheck[l]:
            __x, __y = xy[l]
            if (_x, _y) == (__x, __y):
              nocheck[l] = 0
              q.put((_x + diff_x, _y + diff_y))
              q.put((_x - diff_x, _y - diff_y))
              break
    if sum(nocheck) == 0:
      break
      
  ret = min(ret, tmp_ret)
  
print(ret)

Submission status: Runtime Error

Solution code:
from itertools import combinations


N = int(input())
xy = {}
for i in range(N):
  x, y = map(int, input().split())
  xy[i] = (x, y)
  
ret = float("inf")  

# 2点選んで傾きを決める
index = [i for i in range(N)]
for i, j in combinations(index, 2):
  x1, y1 = xy[i]
  x2, y2 = xy[j]

  if x1 == x2:
    diff_x = 0
    diff_y = min(abs(y1 - y2), abs(y2 - y1))
  else:
    if y1 == y2:
      diff_x = min(abs(x1 - x2), abs(x2 - x1))
    else:
      diff_x = x1 - x2
      diff_y = y1 - y2
  
  # 傾きの条件を満たす直線上の点をチェックしていく
  nocheck = [1 for k in range(N)]
  tmp_ret = 0
  for k in range(N):
    if nocheck[k]:
      tmp_ret += 1 
      nocheck[k] = 0
      x, y = xy[k]
      
      for l in range(N):
        if nocheck[l]:
          _x, _y = xy[l]
          if diff_x == 0 and x == _x:
            if y > _y:
              if (y - _y) % diff_y == 0:
                nocheck[l] = 0
            else:
              if (_y - y) % diff_y == 0:
                nocheck[l] = 0
          elif diff_y == 0 and y == _y:
            if x > _x:
              if (x - _x) % diff_x == 0:
                nocheck[l] = 0
            else:
              if (_x - x) % diff_x == 0:
                nocheck[l] = 0    
          else:
            if diff_x * (y - _y) == diff_y * (x - _x):
              nocheck[l] = 0
    if sum(nocheck) == 0:
      break
      
  ret = min(ret, tmp_ret)
  
print(ret)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

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

m = {}
for i in range(N):
    for j in range(i, N):
        if i != j:
            x, y = L[i]
            x2, y2 = L[j]

            key = (x - x2, y - y2)

            if m.get(key) == None:
                m[key] = 0
            m[key] += 1

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

Submission status: Runtime Error

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

# B = [[[0, 0] for i in range(n)] for j in range(n)]
D = {}
for i in range(n):
    for j in range(i+1, n):
        dy = A[i][1] - A[j][1]
        dx = A[i][0] - A[j][0]
        try:
            D[(dx, dy)] += 1
        except:
            D[(dx, dy)] = 1

ans = n - max(list(D.values()))
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

points = [list( map(int,input().split(" "))) for _ in range(n)]
X = 0
Y = 1
ans = 10 ** 14
for i  in range(n):
  for j in range(n):
    if i == j:
      continue
    x1,y1 = points[i]
    x2,y2 = points[j]
    p = x1 - x2
    q = y1 - y2
    cost = n
    for point1 in points: #そのpointからcost0で遷移できる先があるかどうか
      fromx,fromy = point1
      for point2 in points:
        tox,toy = point2
        if fromx - tox == p and fromy - toy == q:
          cost -= 1
          break
    if ans < cost:
      ans = cost
print(cost)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b
# 問題文はよく読もうね！

# 実際にボールを拾っていくシミュレーションをしていっても十分間に合う

from itertools import combinations
from collections import defaultdict
from operator import itemgetter

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


def is_online(x0, y0, xa, ya, p, q):
    # x0,y0を通る直線がp,qで与えられたときに、xa,yaがその線上にあるか判別
    dx = xa - x0
    dy = ya - y0
    if dx == 0 and dy == 0:
        return True
    elif dx == 0 or dy == 0:
        return False
    # print(x0, y0, xa, ya, p, q)
    return (dy / dx) == (q / p)  # 傾きが同じならば線上にある


def pickballs(balls):
    # cnt most frequent p,q
    global ans

    # 最適なpq探索
    cnts = defaultdict(lambda: 0)
    for pa, pb in combinations(balls, 2):
        dx = pa[0] - pb[0]
        dy = pa[1] - pb[1]
        if dx == 0 or dy == 0:
            continue
        if dx < 0:
            dx *= -1
            dy *= -1
        cnts[(dx, dy)] += 1
    p, q = max(cnts.items(), key=itemgetter(1))[0]

    # 最適な最初のpickball探索
    cnts = defaultdict(lambda: 0)
    for p0 in balls:
        for p1 in balls:
            if p0 == p1:
                continue
            if is_online(p0[0], p0[1], p1[0], p1[1], p, q):
                cnts[p0] += 1
    x, y = max(cnts.items(), key=itemgetter(1))[0]

    # 実際にpickball
    ans += 1
    ret = []
    for p1 in balls:
        if is_online(x, y, p1[0], p1[1], p, q):
            continue
        ret.append(p1)
    return ret


while points:
    points = pickballs(points)
print(ans)

Submission status: Runtime Error

Solution code:
import collections

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

pq = []
for i in range(N):
  xi, yi = xy[i][0], xy[i][1]
  for j in range(i + 1, N):
    xj, yj = xy[j][0], xy[j][1]
    p, q = xj - xi, yj - yi
    pq.append((p, q))
#print(pq)

c = list(collections.Counter(pq).values())
c.sort()
print(N - c[-1])

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b


from itertools import combinations
from collections import defaultdict, Counter

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

# cnts = defaultdict(lambda: 0)
dxy = []
for pa, pb in combinations(points, 2):
    dx = pa[0] - pb[0]
    dy = pa[1] - pb[1]
    if dx < 0:
        dx *= -1
        dy *= -1
    dxy.append((dx, dy))
    # cnts[(dx, dy)] += 1

print(N - max(Counter(dxy).values()))

# print(N - max(cnts.values()))

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b


from itertools import combinations
from collections import defaultdict

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

cnts = defaultdict(lambda: 0)
for pa, pb in combinations(points, 2):
    dx = pa[0] - pb[0]
    dy = pa[1] - pb[1]
    if dx < 0:
        dx *= -1
        dy *= -1
    cnts[(dx, dy)] += 1

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

Submission status: Runtime Error

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

#2ボールの相対座標をぜんぶ調べる
R=[(x[0]-y[0],x[1]-y[1]) for x in balls for y in balls]
C=Counter(R).most_common(2)

#いちばん多い相対座標を(p,q)とする
#C[0]は(0,0)なので除外
print(N-(C[1][1]))

Submission status: Runtime Error

Solution code:
from collections import defaultdict


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

    dd = defaultdict(int)
    for i in range(N - 1):
        for j in range(i + 1, N):
            a = (XY[j][0] - XY[i][0], XY[j][1] - XY[i][1])
            dd[a] += 1

    pq = max(dd, key=dd.get)

    cnt = 0
    for x, y in XY:
        if [x + pq[0], y + pq[1]] in XY:
            cnt += 1

    print(N - cnt)


main()

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter
n = int(input())
ls = []
for i in range(n):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    ls.append((x, y))
res = []
for i in range(n - 1):
    for j in range(i+1, n):
        res.append((ls[j][0] - ls[i][0], ls[j][1] - ls[i][1]))
ct = Counter(res)
print(n - max(ct.values()))

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter
n = int(input())
ls = []
for i in range(n):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    ls.append((x, y))
res = [[0 for i in range(n)] for j in range(n)]
ct = Counter()
for i in range(n - 1):
    for j in range(i+1, n):
        res[i][j] = (ls[j][0] - ls[i][0], ls[j][1] - ls[i][1])
        res[j][i] = (- ls[j][0] + ls[i][0], - ls[j][1] + ls[i][1])
    ct.update(res[i])
ct.pop(0)
print(n - max(ct.values()))

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
xy = [tuple([int(i) for i in input().split()]) for _ in range(N)]
ary = []
for i, t in enumerate(xy[:-1]):
    x = t[0]
    y = t[1]
    for x2, y2 in xy[i+1:]:
        p = x2-x
        q = y2-y
        ary.append((p, q))
c = dict(Counter(ary))
print(N-max(c.values()))

Submission status: Runtime Error

Solution code:
import sys
from itertools import combinations
from collections import Counter
read = sys.stdin.read

N, *xy = map(int, read().split())
pq = []
for (a1, b1), (a2, b2) in combinations(zip(*[iter(xy)] * 2), 2):
    p = a1 - a2
    q = b1 - b2
    pq.append((p, q))
    pq.append((-p, -q))

print(N - Counter(pq).most_common()[0][1])

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


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

    import collections
    D = collections.defaultdict(int)
    import itertools
    for a, b in itertools.combinations(A, 2):
        p = a[0] - b[0]
        q = a[1] - b[1]
        D[(p, q)] += 1
    d = sorted(D.values())
    print(N - d[-1])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def examB():
    N = I()
    X = [0]*N; Y = [0]*N
    for i in range(N):
        X[i],Y[i] = LI()
    pq = defaultdict(int)
    for i in range(N):
        for j in range(i+1,N):
            curx = X[j]-X[i]
            cury = Y[j]-Y[i]
            pq[curx,cury] +=1
    ans = N - max(pq.values())
    print(ans)

from string import digits
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Runtime Error

Solution code:
from collections import Counter
import itertools as it

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

d=[(c[1][0]-c[0][0],c[1][1]-c[0][1]) for c in it.combinations(l,2)]
ans=N-max(dict(Counter(d)).values())

print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
# タプルの辞書
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
diff = []
for i in range(N):
    xi, yi = XY[i]
    for j in range(i+1, N):
        xj, yj = XY[j]
        diff.append((xj-xi, yj-yi))
c = Counter(diff)
print(N-max(c.values()))

Submission status: Runtime Error

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = [inpl() for i in range(n)]
a.sort(key=lambda x:x[1])
a.sort()
z = []
# pprint.pprint(a)
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        z.append((a[i][0]-a[j][0], a[i][1]-a[j][1]))
c = Counter(z)
# pprint.pprint(c)
print(n-c.most_common()[0][1])

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

for i in range(N):
    A[i]-=(i+1)

a=2*N
b=sum([A[i]*2 for i in range(N)])

x1=b//a
x2=-(-b//a)
x0=min(x1,x2)-1
x3=max(x1,x2)+1
X=[x0,x1,x2,x3]

ans=10**18
def count(num):
    temp=0
    for i in range(N):
        temp+=abs(A[i]-num)
    return temp

for x in X:
    ans=min(count(x),ans)

print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from collections import Counter

def main():
    n = int(input().strip())
    p = []
    for i in range(n):
        x, y = map(int, input().strip().split())
        p.append((x, y))
    vtable = [0] * n**2
    for i in range(n):
        for j in range(n):
            vtable[i * n + j] = (p[i][0] - p[j][0], p[i][1] - p[j][1])
    c = sorted(Counter(vtable).values(), reverse=True)
    print(n - c[1])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

for i in range(n):
    usedx=[]
    usedy=[]
    x1,y1=xy[i]
    for j in range(n):
        if i==j:
            continue
        x,y=xy[j]

        if x-x1 not in usedx and x-x1!=0:
            if x-x1 not in da:
                da[x-x1]=1
            else:
                da[x-x1]=da[x-x1]+1
            usedx.append(x-x1)

        if y-y1 not in usedy and y-y1!=0:
            if y-y1 not in db:
                db[y-y1]=1
            else:
                db[y-y1]=db[y-y1]+1
            usedy.append(y-y1)
print(n-min(max(da.values()),max(db.values())))

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
v = []
for i in range(n):
    for j in range(n):
        if i == j: continue
        x, y = xy[j]
        px, py = xy[i]
        v.append((x-px, y-py))
num = Counter(v).most_common(1)[0][1]
print(n - num)

Submission status: Runtime Error

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

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: Runtime Error

Solution code:
N=int(input())

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

c={}
for i in range(N):
    for j in range(N):
        if i!=j:
            p=P[j][0]-P[i][0]
            q=P[j][1]-P[i][1]
            temp=str(p)+"_"+str(q)
            if temp in c:
                c[temp]+=1
            else:
                c[temp]=1
c_num=[]
for j in c:
    c_num.append(c[j])

print(N-max(c_num))

Submission status: Runtime Error

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

if N == 1:
    print(1)
memo = {}

for i in range(N-1):
    for j in range(i+1,N):
        dx = x[j] - x[i]
        dy = y[j] - y[i]
        if (dx,dy) in memo:
            memo[(dx,dy)] += 1
        elif (-dx,-dy) in memo:
            memo[(-dx,-dy)] += 1
        else:
            memo[(dx,dy)] = 1
        #print(memo)

M = max(memo.values())

print(N-M)

Submission status: Runtime Error

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

memo = {}

for i in range(N-1):
    for j in range(i+1,N):
        dx = x[j] - x[i]
        dy = y[j] - y[i]
        if (dx,dy) in memo:
            memo[(dx,dy)] += 1
        elif (-dx,-dy) in memo:
            memo[(-dx,-dy)] += 1
        else:
            memo[(dx,dy)] = 1
        #print(memo)

M = max(memo.values())

print(N-M)

Submission status: Runtime Error

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

memo = {}

for i in range(N-1):
    for j in range(i+1,N):
        dx = x[j] - x[i]
        dy = y[j] - y[i]
        if ((dx,dy) in memo) or ((-dx,-dy) in memo):
            memo[(dx,dy)] += 1
        else:
            memo[(dx,dy)] = 1
        #print(memo)

M = max(memo.values())

print(N-M)

Submission status: Runtime Error

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

memo = {}

for i in range(N-1):
    for j in range(i+1,N):
        dx = x[j] - x[i]
        dy = y[j] - y[i]
        if ((dx,dy) in memo) or ((-dx,-dy) in memo):
            memo[(dx,dy)] += 1
        else:
            #memo[(dx,dy)] = 1
        print(memo)

M = max(memo.values())

print(N-M)

Submission status: Runtime Error

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

memo = {}

for i in range(N-1):
    for j in range(i+1,N):
        dx = x[j] - x[i]
        dy = y[j] - y[i]
        if ((dx,dy) in memo) or ((-dx,-dy) in memo):
            memo[(dx,dy)] += 1
        else:
            memo[(dx,dy)] = 1

M = max(memo.values())

print(N-M)

Submission status: Runtime Error

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

memo = {}

for i in range(N-1):
    for j in range(i+1,N):
        dx = abs(x[j] - x[i])
        dy = abs(y[j] - y[i])
        if (dx,dy) in memo:
            memo[(dx,dy)] += 1
        else:
            memo[(dx,dy)] = 1

M = max(memo.values())

print(N-M)

Submission status: Runtime Error

Solution code:
#%%
import collections

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

l = []
for i in range(n):
    for j in range(n):
        tmp = str(x[i]-x[j]) + ' ' + str(y[i]-y[j])
        l.append(tmp)

c = collections.Counter(l)
a = list(c.values())
#print(a)
a.sort(reverse=True)
print(n-a[1])

Submission status: Runtime Error

Solution code:
#%%
import collections

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

l = []
for i in range(n):
    for j in range(n):
        tmp = str(x[i]-x[j]) + ' ' + str(y[i]-y[j])
        l.append(tmp)

c = collections.Counter(l)
a = (list(c.values())[1])
print(n-a)

Submission status: Runtime Error

Solution code:
n=int(input())
lists=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append([a,b])
diflist=[]
for i in range(n):
    for j in range(n):
        if i!=j:
            add=(lists[i][0]-lists[j][0],lists[i][1]-lists[j][1])
            diflist.append(add)
        else:
            continue
import collections
dic=collections.Counter(diflist)
value=dic.values()
a=max(value)
print(n-a)

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
#result = {0:0}
md = defaultdict(int)
#md[0] = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            p = di[i][0] - di[j][0]
            q = di[i][1] - di[j][1]
            #result[(p,q)] = result.get((p,q), 0)+1
            md[(p,q)] += 1
#print(result)
#print(n - max(result.values()))
#print(md)
print(n - max(md.values()))

Submission status: Runtime Error

Solution code:
#from collections import defaultdict
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
#result = {0:0}
md = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            p = di[i][0] - di[j][0]
            q = di[i][1] - di[j][1]
            #result[(p,q)] = result.get((p,q), 0)+1
            md[(p,q)] += 1
#print(result)
#print(n - max(result.values()))
#print(md)
print(n - max(md.values()))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
result = {}
md = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            p = di[i][0] - di[j][0]
            q = di[i][1] - di[j][1]
            result[(p,q)] = result.get((p,q), 0)+1
            md[(p,q)] += 1
#print(result)
print(n - max(result.values()))
#print(md)
#print(n - max(md.values()))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
di.sort(reverse = True)
result = {}
md = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            p = di[i][0] - di[j][0]
            q = di[i][1] - di[j][1]
            result[(p,q)] = result.get((p,q), 0)+1
            md[(p,q)] += 1
#print(result)
print(n - max(result.values()))
#print(md)
#print(n - max(md.values()))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
di.sort(reverse = True)
result = {}
md = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            p = di[i][0] - di[j][0]
            q = di[i][1] - di[j][1]
            result[(p,q)] = result.get((p,q), 0)+1
            md[(p,q)] += 1
#print(result)
#print(max(result.values()))
#print(md)
print(n - max(md.values()))

Submission status: Runtime Error

Solution code:
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
di.sort(reverse = True)
result = []
for i in range(n-1):
    result.append([di[i][0]-di[i+1][0], di[i][1]-di[i+1][1]])
result.sort()
counter = []
z = 1
c = 1
hantei = result[0]
while z <= n-1:
    if z < n-1:
        if hantei == result[z]:
            c += 1
            z += 1
        else:
            counter.append(c)
            c = 1
            hantei = result[z]
            z += 2
    else:
        counter.append(c)
        z += 1
print(n-max(counter))

Submission status: Runtime Error

Solution code:
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
di.sort(reverse = True)
result = []
for i in range(n-1):
    result.append([di[i][0]-di[i+1][0], di[i][1]-di[i+1][1]])
result.sort()
counter = []
z = 1
c = 1
hantei = result[0]
while z <= n-1:
    if z < n-1:
        if hantei == result[z]:
            c += 1
            z += 1
        else:
            counter.append(c)
            c = 1
            hantei = result[z]
            z += 1
    else:
        counter.append(c)
        z += 1
print(n-max(counter))

Submission status: Runtime Error

Solution code:
from statistics import mode
N = int(input())
if N == 1:
  print(1)
else:
  arr = [list(map(int,input().split())) for _ in range(N)]
  arr = sorted(arr,key=lambda x:(x[0],x[1]))
  diff_arr = [str(arr[i+1][0]-arr[i][0])+'_'+str(arr[i+1][1]-arr[i][1]) for i in range(N-1)]
  mode = mode(diff_arr)
  print(N - diff_arr.count(mode))

Submission status: Runtime Error

Solution code:
from statistics import mode
N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
arr = sorted(arr,key=lambda x:(x[0],x[1]))
diff_arr = [str(arr[i+1][0]-arr[i][0])+'_'+str(arr[i+1][1]-arr[i][1]) for i in range(N-1)]
mode = mode(diff_arr)
print(N - diff_arr.count(mode))

Submission status: Runtime Error

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

ans = dict()

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(list(ans.values()).count(max(ans.values())))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n=int(input())
p=[list(map(int,input().split())) for i in range(n)]
dic=defaultdict(int)
for i, (x,y)in enumerate(p):
  for j, (u,v) in enumerate(p):
    if i==j:
      continue
    dic[(x-u,y-v)]+=1
print(n-max(dic,key=lambda z:z[1])[1])

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n=int(input())
p=[list(map(int,input().split())) for i in range(n)]
dic=defaultdict(int)
for i, (x,y)in enumerate(p):
  for j, (u,v) in enumerate(p):
    if i==j:
      continue
    dic[(x-u,y-v)]+=1
print(n-max(dic,key=lambda z:z[1]))

Submission status: Runtime Error

Solution code:
from itertools import combinations

n = int(input())
xy_array = [[int(x) for x in input().split()] for y in range(n)]
comb_xy = combinations(xy_array, 2)
ans = float("INF")
res_x = 0
res_y = 0

for i, j in comb_xy:
    xx = j[0]-i[0]
    yy = j[1]-i[1]
    tmp = 0
    base_x = xy_array[0][0]
    base_y = xy_array[0][1]
    for x, y in xy_array[1:]:
        if base_x + xx == x and base_y + yy == y:
            pass
        else:
            tmp += 1
        base_x = x
        base_y = y
    tmp = min(tmp, ans)
print(tmp+1)

Submission status: Runtime Error

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

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

d = defaultdict(int)

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

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

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
a = []
ans = []
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: Runtime Error

Solution code:
import itertools
import collections
N=int(input())
X=[0]*N
Y=[0]*N
for i in range(N):
    X[i],Y[i]=[int(x) for x in input().split()]
p=[]
for c in list(itertools.permutations(zip(X,Y), 2)):
    p.append(str(c[1][0]-c[0][0]) + ',' +str(c[1][1]-c[0][1]))
    #print(c,c[1][0]-c[0][0],c[1][1]-c[0][1])
#print(p)
print(N - collections.Counter(p).most_common()[0][1])

Submission status: Runtime Error

Solution code:
N = int(input())
s_dict = {}
cood_list=[]
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(len(cood_list)):
        p = a - cood_list[j][0]
        q = b - cood_list[j][1]
        s = str(p)+","+str(q)
        if s not in s_dict:
            s_dict[s] = 1
        else:
            s_dict[s] += 1
    cood = [a,b]
    cood_list.append(cood)
print(N-max(s_dict.values()))

Submission status: Runtime Error

Solution code:
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

n = i()
xy = mi(n)


for i in range(1, n):
    p = xy[i][0] - xy[i - 1][0]
    q = xy[i][1] - xy[i - 1][1]
    ansli.append(str(p) + "+" + str(q))

d = defaultdict(int)

for i in ansli:
    d[i] += 1
ans += max(d.values())

print(n - ans)