Problem:
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.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XY):
    XY = [tuple(v) for v in XY]
    XY.sort()

    @lru_cache(maxsize=None)
    def f(i, v, x, y):
        ans = 0
        for j, u in enumerate(XY[i+1:]):
            if v[0] - u[0] == x and v[1] - u[1] == y:
                ans = max(ans, f(i+j+1, u, x, y) + 1)
            else:
                ans = max(ans, f(i+j+1, u, x, y))
        return ans

    ans = 0
    for i in range(N):
        print(i)
        for j in range(i+1, N):
            if XY[i][0]-XY[j][0] == 0 and XY[i][1]-XY[j][1] == 0:
                continue
            ans = max(ans, f(i, XY[i], XY[i][0]-XY[j][0], XY[i][1]-XY[j][1]))
    return N - ans


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()


Fixed, accepted submission:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return tuple(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XY):
    c = Counter()
    for i in range(N):
        x, y = XY[i]
        for j in range(N):
            if i == j:
                continue
            a, b = XY[j]
            c[(x-a, y-b)] += 1

    if not c:
        return N
    return N - c.most_common(1)[0][1]


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()