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:
#[R,G,B,N] = list(map(int,input().split()))
import collections
N = int(input())
xy = [tuple(map(int,input().split())) for i in range(N)]
xy.sort( key = lambda x: (x[0],x[1]))
l = []
for i in range(N):
    for j in range(i+1,N):
        (x_diff, y_diff) = [xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]]
        l.append((x_diff, y_diff))
dic = collections.Counter(l)
val = dic.values()
print(N - max(val))

Submission status: Runtime Error

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

#print(n)
#print(xy)
#print(xy[0][1])

vec = []
vec2 = []

for i in range(n):
	for j in range(i + 1, n):
		x = xy[i][0] - xy[j][0]
		y = xy[i][1] - xy[j][1]
		z = [x, y]
		if z not in vec:
			vec.append(z)
		vec2.append(z)        

#print(vec)
#print(vec2)

#vec2 = list(set(vec))

cnt = 0
idx = 0

for i, x  in enumerate(vec):
	if cnt < vec2.count(x):
		cnt = vec2.count(x)
		idx = i

#print(cnt)
#print(idx)

pq = vec[idx]

#print(pq)
#print(pq[0])
#print(pq[1])

cst = 1

for i in range(1, n):
	pq_add_x = xy[i][0] + pq[0]
	pq_add_y = xy[i][1] + pq[1]
	pq_add = [pq_add_x, pq_add_y]
	#pq_sub_x = xy[i][0] - pq[0]
	#pq_sub_y = xy[i][1] - pq[1]
	#pq_sub = [pq_sub_x, pq_sub_y]
	if pq_add not in xy:
		#if pq_sub not in xy:
		cst += 1

print(cst)

Submission status: Runtime Error

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

#print(n)
print(xy)
#print(xy[0][1])

vec = []
vec2 = []

for i in range(n):
	for j in range(i + 1, n):
		x = xy[i][0] - xy[j][0]
		y = xy[i][1] - xy[j][1]
		z = [x, y]
		if z not in vec:
			vec.append(z)
		vec2.append(z)        

#print(vec)
#print(vec2)

#vec2 = list(set(vec))

cnt = 0
idx = 0

for i, x  in enumerate(vec):
	if cnt < vec2.count(x):
		cnt = vec2.count(x)
		idx = i

#print(cnt)
#print(idx)

pq = vec[idx]

print(pq)
#print(pq[0])
#print(pq[1])

cst = 1

for i in range(1, n):
	pq_add_x = xy[i][0] + pq[0]
	pq_add_y = xy[i][1] + pq[1]
	pq_add = [pq_add_x, pq_add_y]
	#pq_sub_x = xy[i][0] - pq[0]
	#pq_sub_y = xy[i][1] - pq[1]
	#pq_sub = [pq_sub_x, pq_sub_y]
	if pq_add not in xy:
		#if pq_sub not in xy:
		cst += 1

print(cst)

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
xy = [tuple(map(int,input().split())) for i in range(N)]
ct = Counter()
for i in range(N):
  for j in range(i+1,N):
    dx = xy[i][0]-xy[j][0]
    dy = xy[i][1]-xy[j][1]
    ct[(dx,dy)] += 1
print(N-max(ct.values()))

Submission status: Runtime Error

Solution code:
b = [
    [int(s) for s in input().split(' ')]
    for i in range(N)
]
b.sort(key=lambda p: p[1])
b.sort(key=lambda p: p[0])
d = {}
d_max = 0
for i in range(N):
    for j in range(i + 1, N):
        p = b[j][0] - b[i][0]
        q = b[j][1] - b[i][1]
        if not p in d:
            d[p] = {}
        d[p][q] = (d[p][q] if q in d[p] else 0) + 1
        d_max = max([d_max, d[p][q]])
print(N - d_max)

Submission status: Runtime Error

Solution code:
n = input()
arrx = []
arry = []
for i in range(n):
  arrx[i].append(input())
  arry[i].append(input())
b = set()
c = set()
for i in range(n-1):
  b.add(arrx[i+1]-arr[i])
  c.add(arry[i+1]-arr[i])
if len(b)==len(c):
  print(len(b))
elif len(b)>len(c):
  pint(len(b))
else  :
  print(len(c))

Submission status: Runtime Error

Solution code:
import collections


def calc(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    return xa - xb, ya - yb


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

a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        tmp = calc(balls[i], balls[j])
        a += [tmp, tuple(-i for i in tmp)]
counts = collections.Counter(a)

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

Submission status: Runtime Error

Solution code:
import collections


def calc(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    return xa - xb, ya - yb


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

a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        a.append(calc(balls[i], balls[j]))
counts = collections.Counter(a)

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

Submission status: Runtime Error

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    xy = sorted([LI() for _ in range(n)])
    d = collections.defaultdict(int)
    for i in range(n):
        x,y = xy[i]
        for j in range(i+1,n):
            x2,y2 = xy[j]
            d[(x-x2,y-y2)] += 1

    return n - max(d.values())


print(main())

Submission status: Runtime Error

Solution code:
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
 
import itertools
hoges = {}
for i in itertools.combinations(xy, 2):
    if i[0][0] - i[1][0] >= 0:
        hoge = (i[0][0] - i[1][0], i[0][1] - i[1][1])
    else:
        hoge = (i[1][0] - i[0][0], i[1][1] - i[0][1])
    hoges.setdefault(hoge, 0)
    hoges[hoge] += 1
# print(hoges)
max_v = max(hoges.values())
print(N - max_v)

Submission status: Runtime Error

Solution code:
from itertools import combinations
from operator import itemgetter
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
X, Y = list(map(list, zip(*XY)))

P = [abs(x1 - x2) for x1, x2 in combinations(X, 2)]
P = set(P)
if 0 in P:
    P.remove(0)
P = list(P)
Q = [abs(y1 - y2) for y1, y2 in combinations(Y, 2)]
Q = set(Q)
if 0 in Q:
    Q.remove(0)
Q = list(Q)
ans = 10**10

XY.sort()
for p in P:
    S = set()
    la = 0
    for x, y in XY:
        if (x, y) not in S:
            la += 1
        S.add((x+p, y))
    ans = min(ans, la)
XY1 = XY[:]
XY1.sort(ley = itemgetter(1))
for q in Q:
    S = set()
    la = 0
    for x, y in XY1:
        if (x, y) not in S:
            la += 1
        S.add((x, y+q))
    ans = min(ans, la)

for p in P:
    for q in Q:
        S = set()
        la = 0
        for x, y in XY:
            if (x, y) not in S:
                la += 1
            S.add((x+p, y+q))
        ans = min(ans, la)
        S = set()
        la = 0
        for x, y in XY:
            if (x, y) not in S:
                la += 1
            S.add((x+p, y-q))
        ans = min(ans, la)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
x = [xy[i][0] for i in range(N)]
y = [xy[i][1] for j in range(N)]
if N == 1:
    print(1)
    exit()
else:
    ans = N
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            dx,dy = x[j]-x[i],y[j]-y[i]
            cnt = 0
            for k in range(N):
                for l in range(N):
                    if k == l:
                        continue
                    if dx == x[k]-x[l] and dy == y[k]-y[l]:
                        cnt += 1
            ans = min(ans,N-cnt)

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)]

counter = Counter(((b1[0] - b2[0], b1[1] - b2[1]) for b1 in xy for b2 in xy if b1 != b2))
print(N - (counter.most_common()[0]+[(0,0)])[1])

Submission status: Runtime Error

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

counter = Counter(((b1[0] - b2[0], b1[1] - b2[1]) for b1 in xy for b2 in xy if b1 != b2))
print(N - counter.most_common()[0][1])

Submission status: Runtime Error

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

dic={}
for e in xy:
	for f in xy:
		if e==f:continue
		tmp=(e[0]-f[0],e[1]-f[1])
		dic[tmp]=dic.get(tmp,0)+1

mx=max(dic.values())
print(n-mx)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())

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

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(N):
        if i==j:
            continue;
        a=x[i]-x[j]
        b=y[i]-y[j]
        """
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        """
        l1.append(str(a)+"_"+str(b))
        #l1.append([a,b])
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))

Submission status: Runtime Error

Solution code:
from itertools import combinations

n = int(input())
balls = []
cost = n
for _ in range(n):
    x, y = map(int, input().split())
    balls.append((x, y))

for b1, b2 in combinations(balls, 2):
    p, q = b1[0] - b2[0], b1[1] - b2[1]
    if p != 0 or q != 0:
        sub = 0
        for b3, b4 in permutations(balls, 2):
            dx, dy = b3[0] - b4[0], b3[1] - b4[1]
            if dx == p and dy == q:
                sub += 1
        cost = min(cost, n - sub)

print(max(cost, 1))

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
pq = []
for i in range(n):
    for j in range(n):
        r = (xy[i][0]-xy[j][0],xy[i][1]-xy[j][1])
        if i!=j:
            pq.append(r)
#print(pq)
ans = Counter(pq).most_common()
print(n-ans[0][1])

Submission status: Runtime Error

Solution code:
import itertools

n = int(input())
xy_list = [list(map(int, input().split())) for _ in range(n)]
counts = dict()
for (x1, y1), (x2, y2) in itertools.combinations(xy_list, 2):
    for pq in ((x2 - x1, y2 - y1), (x1 - x2, y1 - y2)):
        counts.setdefault(pq, 0)
        counts[pq] += 1
max_count = max(counts.values())
print(n - max_count)

Submission status: Runtime Error

Solution code:


def solve(n, x_list, y_list):
    if n <= 2:
        return 1

    matrix_dict = {}
    for i in range(n):
        for j in range(i, n):
            if i != j:
                d_x = x_list[j] - x_list[i]
                d_y = y_list[j] - y_list[i]
                if d_x < 0:
                    d_x, d_y = -d_x, -d_y
                if matrix_dict.get((d_x, d_y), None):
                    matrix_dict[(d_x, d_y)] += 1
                else:
                    matrix_dict[(d_x, d_y)] = 1
    depth_list = sorted([matrix_dict[item] for item in matrix_dict], reverse=True)
    return n - depth_list[0]


def main():
    n, x_list, y_list = input_from_console()
    print(solve(n, x_list, y_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Runtime Error

Solution code:
from collections import Counter
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
  x[i],y[i] = map(int, input().split())
a = []
for i in range(N):
  for j in range(i+1,N):
    a.append(str(x[j]-x[i])+'&'+str(y[j]-y[i]))
    
a=Counter(a)
common = a.most_common(1)[0][1]
print(N-common)

Submission status: Runtime Error

Solution code:
from itertools import combinations

n = int(input())
balls = []
cost = n
for _ in range(n):
    x, y = map(int, input().split())
    balls.append((x, y))

for b1, b2 in combinations(balls, 2):
    p, q = b1[0] - b2[0], b1[1] - b2[1]
    if p != 0 or q != 0:
        sub = 0
        for ball in balls:
            bx, by = ball
            dx, dy = bx - b2[0], by - b2[1]
            if dx % p == 0 and dy % q == 0 and dx // p == dy // q:
                sub += 1
        cost = min(cost, n - sub)

print(max(cost, 1))

Submission status: Runtime Error

Solution code:

N=int(input())

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

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(i+1,N-1):
        #if i==j:
        #    continue;
        a=x[i]-x[j]
        b=y[i]-y[j]
        """
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        """
        l1.append(str(a)+"_"+str(b))
        #l1.append([a,b])
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))

Submission status: Runtime Error

Solution code:
N=int(input())

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

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(N):
        if i==j:
            continue;
        a=x[i]-x[j]
        b=y[i]-y[j]
        """
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        """
        l1.append(str(a)+"_"+str(b))
        #l1.append([a,b])
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))

Submission status: Runtime Error

Solution code:
N=int(input())

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

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(N):
        if i==j;:
            continue;
        a=x[i]-x[j]
        b=y[i]-y[j]
        """
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        """
        l1.append(str(a)+"_"+str(b))
        #l1.append([a,b])
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))

Submission status: Runtime Error

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

if n == 1:
    print(1)
    exit()
    
diff_list = []
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        diff_list.append([lists[i][0]-lists[j][0],lists[i][1]-lists[j][1])
count_list = [diff_list.count[i] for i in set(diff_list)]

print(n-max(count_list))

Submission status: Runtime Error

Solution code:
N=int(input())

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

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(i+1,N):
        a=x[i]-x[j]
        b=y[i]-y[j]
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        #l1.append(str(a)+"_"+str(b))
        l1.append([a,b])
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))

Submission status: Runtime Error

Solution code:
N=int(input())

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

x=[]
y=[]
XY=XY.set()
for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(i+1,N):
        a=x[i]-x[j]
        b=y[i]-y[j]
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        l1.append(str(a)+"_"+str(b))
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))

Submission status: Runtime Error

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

#print(n)
#print(xy)

vec = []

for i in n:
  for j in range(i, n):
  	x =xy[i,0]-xy[j,0]
    y =xy[i,1]-xy[j,1]
    z = [x, y]
    vec.append(z)

print(vec)

Submission status: Runtime Error

Solution code:
N=int(input())

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

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(i+1,N):
        a=x[i]-x[j]
        b=y[i]-y[j]
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        l1.append(str(a)+"_"+str(b))
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))

Submission status: Runtime Error

Solution code:
N=int(input())

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

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(i+1,N):
        a=x[i]-x[j]
        b=y[i]-y[j]
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        l1.append(str(a)+str(b))
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))

Submission status: Runtime Error

Solution code:
def solve(n, x_list, y_list):
    if n <= 2:
        return 1

    matrix_dict = {}
    for i in range(n):
        t_y = y_list[i]
        t_x = x_list[i]
        for j in range(i, n):
            if i != j:
                diff_x = x_list[j] - t_x
                diff_y = y_list[j] - t_y
                if matrix_dict.get((diff_x, diff_y), None):
                    matrix_dict[(diff_x, diff_y)] += 1
                else:
                    matrix_dict[(diff_x, diff_y)] = 1
    depth_list = sorted([matrix_dict[item] for item in matrix_dict], reverse=True)
    if depth_list:
        return n - depth_list[0]
    else:
        return n



def main():
    n, x_list, y_list = input_from_console()
    print(solve(n, x_list, y_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Runtime Error

Solution code:
n = int(input())
xy = set(tuple(map(int, input().split())) for _ in range(n))

costs = []
for a in xy:
    besides_a = xy - {a}
    for b in besides_a:
        p = b[0] - a[0]
        q = b[1] - a[1]
        arrow_num = 0
        for c in xy:
            if (c[0] + p, c[1] + q) in xy:
                arrow_num += 1
        cost = n - arrow_num
        costs.append(cost)

print(min(costs))

Submission status: Runtime Error

Solution code:

def input_from_console():
    n = int(input())
    x_list = []
    y_list = []

    for i in range(n):
        x, y = map(int, input().split())
        x_list.append(x)
        y_list.append(y)
    return n, x_list, y_list


def solve(n, x_list, y_list):
    if n == 2:
        return 1

    matrix_dict = {}
    for i in range(n):
        t_y = y_list[i]
        t_x = x_list[i]
        for j in range(i + 1, n):
            diff_x = x_list[j] - t_x
            diff_y = y_list[j] - t_y
            if matrix_dict.get((diff_x, diff_y), None):
                matrix_dict[(diff_x, diff_y)] += 1
            else:
                matrix_dict[(diff_x, diff_y)] = 1
    depth_list = sorted([matrix_dict[item] for item in matrix_dict], reverse=True)
    # total = 0
    # print("stepts", steps)
    # print(depth_list)
    return n - depth_list[0]
    # for item in depth_list:
    #     steps -= item
    #     total += 1
    #     if steps <= 0:
    #         return total


def main():
    n, x_list, y_list = input_from_console()
    print(solve(n, x_list, y_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Runtime Error

Solution code:
from fractions import Fraction
from collections import Counter


class PickingUp:
    def __init__(self):
        self.N = int(input())
        self.points = []
        for n in range(self.N):
            self.points.append([int(n) for n in input().split()])

    def main(self):
        pattern_list = []
        slope_list = []
        for s in range(self.N):
            for e in range(s + 1, self.N):
                slope = self.__cal_slope(self.points[s], self.points[e])
                slope_list.append(slope)

        c = Counter(slope_list)
        most = c.most_common()[0][1]

        if self.N == 1:
            pattern_list.append(1)
        else:
            print(self.N - most)

    def __cal_slope(self, s, e):
        if s[0] != e[0]:
            return Fraction((s[1] - e[1]), (s[0] - e[0]))
        else:
            return None

    def __cal_section(self, slope, point):
        if slope is not None:
            return point[1] - slope * point[0]
        else:
            return point[0]


pickingUp = PickingUp()
pickingUp.main()

Submission status: Runtime Error

Solution code:
class UnionFind:
    def __init__(self, size: int):
        self.__root = [-1] * size

    def find(self, x: int)->int:
        if self.__root[x] < 0:
            return x
        self.__root[x] = self.find(self.__root[x])
        return self.__root[x]

    def same(self, x: int, y: int)->bool:
        return self.find(x) == self.find(y)

    def unite(self, x: int, y: int)->bool:
        rx, ry = self.find(x), self.find(y)

        if rx == ry:
            return False

        if ry < rx:
            rx, ry = ry, rx

        self.__root[rx] += self.__root[ry]
        self.__root[ry] = rx

        return True


def picking_up(N: int, balls: list)->int:
    mp = {}
    for x1, y1 in balls:
        for x2, y2 in balls:
            if x1 == x2 and y1 == y2:
                continue
            mp.setdefault((x2-x1, y2-y1), 0)
            mp[(x2-x1, y2-y1)] += 1
    return N-max(mp.values())


if __name__ == "__main__":
    N = int(input())
    balls = [tuple(map(int, input().split())) for _ in range(N)]

    ans = picking_up(N, balls)
    print(ans)

Submission status: Runtime Error

Solution code:
    N = int(input())
    xy = [list(map(int, input().split())) for _ in range(N)]
    xy.sort()
     
    ans = 0
    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]
            merge = 0
            for k in range(N):
                if [xy[k][0]+p, xy[k][1]+q] in xy:
                    merge += 1
            ans = max(ans, merge)
    print(N-ans)

Submission status: Runtime Error

Solution code:
n=int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
xy.sort()
ans=0
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]
        mer=0
        for i in range (k):
          if [xy[k][0]+p, xy[k][1]+q] in xy:
            merge += 1
        ans = max(ans, merge)
print(N-ans)

Submission status: Runtime Error

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

res = []
count = 0
for i in range(N):
  for j in range(i,N):
#コストの和の最小値を求める
#これ以上進めない点が何個あるか数えれば良い
    p = x[i] - x[j]
    q = y[i] - y[j]
    count = 0
    for item in xy:
      if [item[0]+p,item[1]+q] not in xy:
        count += 1
    if count != 0: res.append(count)


print(min(res))

Submission status: Runtime Error

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

res = []
count = 0
for i in range(N):
  for j in range(i+1,N):
#コストの和の最小値を求める
#これ以上進めない点が何個あるか数えれば良い
    p = x[i] - x[j]
    q = y[i] - y[j]
    count = 0
    for item in xy:
      if [item[0]+p,item[1]+q] not in xy:
        count += 1
    if count != 0: res.append(count)


print(min(res))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
 
N = int(input())
xy = []
for _ in range(N):
    x, y = inpl()
    xy.append((x,y))
xy.sort()
 
edges = defaultdict(int)
for i in range(N):
    for j in range(i+1,N):
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        p, q = x2-x1, y2-y1
        edges[(p,q)] += 1
 
print(N - max(edges.values()))

Submission status: Runtime Error

Solution code:
from itertools import *
from collections import *
n = int(input())
points = [ list(map(int,input().split())) for _ in range(n)]
points.sort()
pairpoints = []
vecs = []
for i in range(n):
    for j in range(i+1,n):
        vecs.append((points[j][0] - points[i][0],points[j][1] - points[i][1]))
#print(vecs)
pqvec = Counter(vecs).most_common()
p = pqvec[0][0][0]
q = pqvec[0][0][1]
cost = 1
for i in range(n-1):
    if points[i+1][0] - points[i][0] != p or points[i+1][1] - points[i][1] != q:
        cost += 1
print(cost)

Submission status: Runtime Error

Solution code:
import sys

def main():
    n = int(input())
    w = [tuple(map(int,input().split())) for x in range(n)]
    w.sort(key=lambda x: x[0])

    pqs = {}
    for i in range(n):
        for j in range(i+1,n):
            x = w[j][0] - w[i][0]
            y = w[j][1] - w[i][1]
            if (x,y) not in pqs:
                pqs[(x,y)] = 1
            else:
                pqs[(x,y)] += 1

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

if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
from itertools import permutations
from collections import Counter


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

for _ in range(n):
    x, y = map(int, input().split())
    balls.append((x, y))

counter = Counter()
for b1, b2 in permutations(balls, 2):
    p, q = b1[0] - b2[0], b1[1] - b2[1]
    counter[(p, q)] += 1

(p, q), val = counter.most_common(1)[0]
print(n - val)

Submission status: Runtime Error

Solution code:
from itertools import permutations
from collections import Counter


n = int(input())
balls = []
cost = n
for _ in range(n):
    x, y = map(int, input().split())
    balls.append((x, y))

counter = Counter()
for b1, b2 in permutations(balls, 2):
    p, q = b1[0] - b2[0], b1[1] - b2[1]
    counter[(p, q)] += 1

(p, q), val = counter.most_common(1)[0]
print(n - val)

Submission status: Runtime Error

Solution code:
import sys

def main():
    n = int(input())
    w = [tuple(map(int,input().split())) for x in range(n)]

    pqs = {}
    for i in range(n):
        for j in range(i+1,n):
            x = abs(w[i][0] - w[j][0])
            y = abs(w[i][1] - w[j][1])
            if (x,y) not in pqs:
                pqs[(x,y)] = 1
            else:
                pqs[(x,y)] += 1

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

if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
import collections
N = int(input())
if N == 1:
  print(1)
elif N == 2:
  print(1)
else:
  ball = [tuple(map(int, input().split())) for _ in range(N)]
  ball = ball.sorted()
  diff = [tuple((ball[i][0] - ball[j][0], ball[i][1] - ball[j][1])) for i in range(N) for j in range(i + 1, N)]
  c = collections.Counter(diff)
  ans = c.most_common()[0][1]
  print(N - ans)

Submission status: Runtime Error

Solution code:
N = int(input())
x = []
y = []
for _ in range(N):
  inp = input().split(' ')
  x += inp[0]
  y += inp[1]
x = list(map(int, x))
y = list(map(int, y))

pq = {}
for i in range(N):
  for j in range(N):
    if i == j:
      continue
    
    xydif = (x[i]-x[j], y[i]-y[j])
    
    if xydif not in pq:
      pq[xydif] = 1
    else:
      pq[xydif] += 1

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

Submission status: Runtime Error

Solution code:
N = int(input())
x = []
y = []
for _ in range(N):
  inp = input().split(' ')
  x += inp[0]
  y += inp[1]
x = list(map(int, x))
y = list(map(int, y))

pq = {}
for i in range(N):
  for j in range(N):
    if i == j:
      break
    
    xydif = (x[i]-x[j], y[i]-y[j])
    
    if xydif not in pq:
      pq[xydif] = 1
    else:
      pq[xydif] += 1

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

Submission status: Runtime Error

Solution code:
# Picking Up
# グラフ,有向グラフ,ベクトル, ２次元、コスト,

N = int(input())
S = []
for _ in range(N):
    x, y = map(int, input().split())
    S.append([x, y])
cost = N
d = {}
for l,le in enumerate(S):
    for m, me in enumerate(S):
        if l == m:
            continue
        t = (me[0] - le[0], me[1] - le[1])
        if t in d:
            d[t] +=1
        else:
            d[t] = 1

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

Submission status: Runtime Error

Solution code:
import collections

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

pq = []
cost = N

for xyi in xy:
    for xyj in xy:
        pq.append((xyi[0]-xyj[0], xyi[1]-xyj[1]))

count = collections.Counter(pq)
if (count.most_common()[0][0] == (0,0)):
    print(N - count.most_common()[1][1])
else:
    print(N - count.most_common()[0][1])

Submission status: Runtime Error

Solution code:
n=int(input())
o=[]
for i in range(n):
    x,y=map(int,input().split())
    o.append([x,y])
o.sort()
p2=[]
q2=[]
c=[]
if n==1:
    print(1)
else:
    for i in range(n):
        for j in range(i+1,n):
            p2=o[j][0]-o[i][0]
            q2=o[j][1]-o[i][1]
            c.append(str(p2)+" "+str(q2))
    r=defaultdict(int)
    for f in c:
        r[f]+=1
    p=list(r.values())
    q=max(p)
    print(n-q)

Submission status: Runtime Error

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

import itertools
import collections

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

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

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

print(N-num)