Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03363 (python)

Fixed submission:
import collections

def main(N,A):
    B=[0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]

        B.append(T)
    c = collections.Counter(B)

    for i in range(len(c)):
        k, v = c.popitem()
        for z in range(v):
            count += z

    return print(count)

if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))

    main(N,A)

Buggy submission (verdict: Runtime Error):
def main(N,A):
    B=[0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]
        print(B)
        if T in B:

            print('count:',count)
            count += B.count(T)


    # B = [A[i] +B[i] for i in range(N)]
    #
    # count = [ count + 1 for m in range(len(B)) if B[i] - B[i-m] == 0]

        # for m in range(len(B)):
        #     if T - B[m] == 0:
        #         # print(i, m)
        #         # print(B[i],B[i-m])
        #         # print(T)
        #         # print("kore",B[i],B[i-m])
        #         count += 1
        B.append(T)


    #print(count)
    print(B)
    return print(count)

if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))

    main(N,A)

Buggy submission (verdict: Runtime Error):
def main(N,A):
    B=[0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]
        for m in range(N+1):
            if T - B[m] == 0:
                # print(i, m)
                # print(B[i],B[i-m])
                # print(T)
                # print("kore",B[i],B[i-m])
                count += 1
        B.append(T)

    #print(count)
    #print(B)
    return print(count)

if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))

    main(N,A)

Buggy submission (verdict: Runtime Error):


def main(N,A):
    B=[0]

    for i in range(int(len(A))):
        T = A[i] + B[i]
        B.append(T)
    count = 0
    for i in range(i+1)):
        for m in range(i+1):
            if i > i-m:
                T = B[i]-B[i-m]
                # print(i, m)
                # print(B[i],B[i-m])
                # print(T)
                if T == 0:
                    # print("kore",B[i],B[i-m])
                    count += 1

    #print(count)
    #print(B)
    return print(count)




if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))
    main(N,A)
Problem p02621 (python)

Fixed submission:
val = int(input())

print(val + val **2 + val **3)

Buggy submission (verdict: Runtime Error):
val = input()

res = val + val ** 2 + val ** 3

print(res.astype(int))

Buggy submission (verdict: Runtime Error):
val = input()

print(val + val ** 2 + val ** 3)
Problem p02700 (python)

Fixed submission:
arg = input()
a = int((arg.split())[0])
b = int((arg.split())[1])
c = int((arg.split())[2])
d = int((arg.split())[3])

while True:
    c -= b
    if c <= 0:
        print('Yes')
        break
    a -= d
    if a <= 0:
        print('No')
        break

Buggy submission (verdict: Runtime Error):
arg = input()
a = (int)(arg.split())[0]
b = (int)(arg.split())[1]
c = (int)(arg.split())[2]
d = (int)(arg.split())[3]

while true:
  a = a - d
  if a <= 0:
    print('No')
    break
  c = c - b
  if c <= 0:
	print('yes')
	break
Problem p02639 (python)

Fixed submission:
P = list(map(int,input().split()))
ans = 0
for i in range(5):
  if(P[i]==0):
    ans = i+1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
X, Y = map(int,input().split())
ans = "No"
for i in range(X):
  if(2*X+2*i==Y):
    ans = "Yes"
print(ans)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
if(T[:-1]==S):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int,input().split())
ans = 0
if(K<=A):
  ans = K
elif(K<=A+B):
  ans = A
else:
  ans = A-(K-A-B)
print(ans)
Problem p02600 (python)

Fixed submission:
print(8 - (int(input()) // 200 - 2))

Buggy submission (verdict: Runtime Error):
print(8 - (X // 200 - 2))
Problem p02616 (python)

Fixed submission:
def e_multiplication_4(MOD=10**9 + 7):
    from functools import reduce
    N, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    sign = {-1: 0, 0: 0, 1: 0}  # A の各要素の符号
    for a in A:
        if a == 0:
            sign[0] += 1
            continue
        sign[a // abs(a)] += 1

    if sign[1] == 0 and K % 2 == 1:
        # どうやっても解は負。絶対値の小さなものから掛けていく
        A.sort(reverse=True)
        return reduce(lambda x, y: (x * y) % MOD, A[:K])
    if sign[1] == 0 and K % 2 == 0:
        # 先程と違って絶対値の大きなものから掛けても解は正になる
        A.sort()
        return reduce(lambda x, y: (x * y) % MOD, A[:K])

    A.sort()
    ans = 1
    i, j = 0, N - 1
    while K > 0:
        # 負の絶対値が大きいものから 2 個取るか？　正の絶対値が大きいものから 1 個取るか？
        # i, j がそれぞれ負の値、非負の値を指さなくなった場合、if 文のどちらかを
        # 確実に通らなくなるので、i, j についての条件は必要ない
        if K > 1 and A[i] * A[i + 1] >= A[j] * A[j - 1]:
            ans *= A[i] * A[i + 1]
            i += 2
            K -= 2
        else:
            ans *= A[j]
            j -= 1
            K -= 1
        ans %= MOD
    return ans

print(e_multiplication_4())

Buggy submission (verdict: Runtime Error):
def e_multiplication_4(MOD=10**9 + 7):
    from functools import reduce
    N, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    sign = {-1: 0, 0: 0, 1: 0}  # A の各要素の符号
    for a in A:
        sign[a // abs(a)] += 1

    if sign[1] == 0 and K % 2 == 1:
        # どうやっても解は負。絶対値の小さなものから掛けていく
        A.sort(reverse=True)
        return reduce(lambda x, y: (x * y) % MOD, A[:K])
    if sign[1] == 0 and K % 2 == 0:
        # 先程と違って絶対値の大きなものから掛けても解は正になる
        A.sort()
        return reduce(lambda x, y: (x * y) % MOD, A[:K])

    A.sort()
    ans = 1
    i, j = 0, N - 1
    while K > 0:
        # 負の絶対値が大きいものから 2 個取るか？　正の絶対値が大きいものから 1 個取るか？
        # i, j がそれぞれ負の値、非負の値を指さなくなった場合、if 文のどちらかを
        # 確実に通らなくなるので、i, j についての条件は必要ない
        if K > 1 and A[i] * A[i + 1] >= A[j] * A[j - 1]:
            ans *= A[i] * A[i + 1]
            i += 2
            K -= 2
        else:
            ans *= A[j]
            j -= 1
            K -= 1
        ans %= MOD
    return ans

print(e_multiplication_4())
Problem p02646 (python)

Fixed submission:
A, V = [int(i) for i in input().split()]
B, W = [int(i) for i in input().split()]
T = int(input())

print('YES' if V > W and abs(A - B) <= T * (V - W) else 'NO')

Buggy submission (verdict: Runtime Error):
A, V = [int(i) for i in input().split()]
B, W = [int(i) for i in input().split()]

print('YES' if V > W and abs(A - B) <= T * (V - W) else 'NO')
Problem p02658 (python)

Fixed submission:
N = int(input())
A = sorted([int(i) for i in input().split()])
ans = 1
for a in A:
    if a == 0:
        ans = 0
        break
    ans *= a
    if ans > 10**18:
        ans = -1
        break
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
ans = reduce(mul, A)
print(ans if ans <= 10**18 else -1)
Problem p02718 (python)

Fixed submission:
N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort(reverse=True)
total = sum(A)
ans = 0
for a in A:
    if a * 4 * M >= total:
        ans += 1
print('Yes' if ans >= M else 'No')

Buggy submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
total = sum(A)
print('Yes' if len(1 for a in A if a * 4 * M >= total) >= M else 'No')
Problem p02760 (python)

Fixed submission:
A = [[int(i) for i in input().split()] for j in range(3)]
N = int(input())
B = [int(input()) for j in range(N)]

for b in B:
    for row in range(3):
        for col in range(3):
            if A[row][col] == b:
                A[row][col] = 0

cond = [
    A[0][0] == A[0][1] and A[0][1] == A[0][2],
    A[1][0] == A[1][1] and A[1][1] == A[1][2],
    A[2][0] == A[2][1] and A[2][1] == A[2][2],
    A[0][0] == A[1][0] and A[1][0] == A[2][0],
    A[0][1] == A[1][1] and A[1][1] == A[2][1],
    A[0][2] == A[1][2] and A[1][2] == A[2][2],
    A[0][0] == A[1][1] and A[1][1] == A[2][2],
    A[0][2] == A[1][1] and A[1][1] == A[2][0]
]
print('Yes' if any(cond) else 'No')

Buggy submission (verdict: Runtime Error):
def c_guess_the_number():
    N, M = [int(i) for i in input().split()]
    Conds = [[int(i) for i in input().split()] for j in range(M)]

    digit = [-1] * N
    # 同じ桁に異なる数字を割り当てている場合を検出
    for s, c in Conds:
        if digit[s - 1] not in (-1, c):
            return -1
        digit[s - 1] = c

    # N 桁目に 0 を割り当てなければならない場合
    # 基本的に N+1 桁の数となり矛盾するが、例外的に N = 1 だと 0 とすればよい。
    if digit[0] == 0:
        return -1 if N >= 2 else 0

    # 指定されなかった桁は基本的に 0 とすればよいが、N 桁目は 0 にできない。
    # 例外的に、N = 1, M = 0 だと N 桁目も 0 にできる。
    if N == 1 and M == 0:
        return 0
    for d, value in enumerate(digit):
        if value == -1:
            digit[d] = 0 if d != 0 else 1
    return ''.join(map(str, digit))

print(c_guess_the_number())
Problem p02780 (python)

Fixed submission:
def d_dice_in_line():
    N, K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]

    def experience(x):
        return (x + 1) / 2  # 1からxまで出るサイコロの出目の期待値

    ans = []
    tmp = 0
    for i in range(K):
        tmp += experience(P[i])
    ans.append(tmp)
    for i in range(K, N):
        tmp -= experience(P[i - K])
        tmp += experience(P[i])
        ans.append(tmp)
    return max(ans)

print(d_dice_in_line())

Buggy submission (verdict: Runtime Error):
def d_dice_in_line():
    from itertools import accumulate
    N, K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]

    expected_value = [(p + 1) / 2 for p in P]  # 1~p まで出るサイコロの出目の期待値
    cumsum = [0] + list(accumulate(expected_value))
    return max([cumsum[j + K] - cumsum[j] for j in range(K)])

print(d_dice_in_line())
Problem p02803 (python)

Fixed submission:
def d_maze_master(INF=float('inf')):
    from collections import deque
    H, W = [int(i) for i in input().split()]
    Maze = [list(input()) for _ in range(H)]

    def bfs(start_row, start_col):
        diff = ((-1, 0), (0, 1), (1, 0), (0, -1))

        def is_inside(row, col):
            return 0 <= row < H and 0 <= col < W

        queue = deque([(start_row, start_col)])
        dist = [[INF for _ in range(W)] for _ in range(H)]
        dist[start_row][start_col] = 0
        while queue:
            row, col = queue.pop()
            for dr, dc in diff:
                nr, nc = row + dr, col + dc
                if is_inside(nr, nc) and Maze[nr][nc] != '#' and dist[nr][nc] == INF:
                    queue.appendleft((nr, nc))
                    dist[nr][nc] = dist[row][col] + 1
        return dist

    ans = 0
    for start_row in range(H):
        for start_col in range(W):
            if Maze[start_row][start_col] == '#':
                continue
            dist = bfs(start_row, start_col)
            for row in range(H):
                for col in range(W):
                    if Maze[row][col] != '#':
                        ans = max(ans, dist[row][col])
    return ans

print(d_maze_master())

Buggy submission (verdict: Runtime Error):
def d_maze_master(INF=float('inf')):
    from collections import deque
    H, W = [int(i) for i in input().split()]
    Maze = [list(input()) for _ in range(H)]

    start_row, start_col = None, None
    for row in range(H):
        for col in range(W):
            if Maze[row][col] == '.':
                start_row, start_col = row, col
                break
        else:
            continue
        break

    diff = ((-1, 0), (0, 1), (1, 0), (0, -1))

    def is_inside(row, col):
        return 0 <= row < H and 0 <= col < W

    queue = deque([(start_row, start_col)])
    dist = [[INF for _ in range(W)] for _ in range(H)]
    dist[start_row][start_col] = 0
    while queue:
        row, col = queue.pop()
        for dr, dc in diff:
            nr, nc = row + dr, col + dc
            if is_inside(nr, nc) and Maze[nr][nc] != '#' and dist[nr][nc] == INF:
                queue.appendleft((nr, nc))
                dist[nr][nc] = dist[row][col] + 1

    start_row, start_col = None, None
    maximum = 0
    for row in range(H):
        for col in range(W):
            if Maze[row][col] != '#' and dist[row][col] > maximum:
                maximum = dist[row][col]
                start_row, start_col = row, col

    queue = deque([(start_row, start_col)])
    dist = [[INF for _ in range(W)] for _ in range(H)]
    dist[start_row][start_col] = 0
    while queue:
        row, col = queue.pop()
        for dr, dc in diff:
            nr, nc = row + dr, col + dc
            if is_inside(nr, nc) and Maze[nr][nc] != '#' and dist[nr][nc] == INF:
                queue.appendleft((nr, nc))
                dist[nr][nc] = dist[row][col] + 1

    ans = 0
    for row in range(H):
        for col in range(W):
            if Maze[row][col] != '#' and dist[row][col] > ans:
                ans = dist[row][col]
    return ans

print(c_welcome_to_atcoder())
Problem p02814 (python)

Fixed submission:
def d_semi_common_multiple():
    from fractions import gcd
    from functools import reduce
    N, M = [int(i) for i in input().split()]
    A = [int(i) // 2 for i in input().split()]  # 先に2で割っておく

    def count_divide_2(n):
        ret = 0
        while n % 2 == 0:
            ret += 1
            n //= 2
        return ret

    def lcm(a, b):
        return a * b // gcd(a, b)

    # A の全要素について、2で割れる回数は等しいか？
    tmp = count_divide_2(A[0])
    for a in A:
        if count_divide_2(a) != tmp:
            return 0

    t = reduce(lambda x, y: lcm(x, y), A)
    return M // t - M // (2 * t)

print(d_semi_common_multiple())

Buggy submission (verdict: Runtime Error):
def d_semi_common_multiple():
    from math import gcd
    from functools import reduce
    N, M = [int(i) for i in input().split()]
    A = [int(i) // 2 for i in input().split()]  # 先に2で割っておく

    def count_divide_2(n):
        """n に含まれる因数 2 の指数"""
        return (n & -n).bit_length()

    def lcm(a, b):
        return a * b // gcd(a, b)

    # A の全要素について，2で割れる回数は等しいか？
    tmp = count_divide_2(A[0])
    for a in A:
        if count_divide_2(a) != tmp:
            return 0

    t = reduce(lambda x, y: lcm(x, y), A)
    return (M // t) - (M // (2 * t))

print(d_semi_common_multiple())
Problem p02900 (python)

Fixed submission:
def d_disjoint_set_of_common_divisors():
    A, B = [int(i) for i in input().split()]
    if A == 1 or B == 1:
        return 1

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数の辞書"""
        from collections import defaultdict
        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return set(table.keys())
    a_primekey = prime_factorization_dict(A)
    b_primekey = prime_factorization_dict(B)
    ans = []
    for a in a_primekey:
        if a in b_primekey:
            ans.append(a)
    return len(ans) + 1

print(d_disjoint_set_of_common_divisors())

Buggy submission (verdict: Runtime Error):
def d_disjoint_set_of_common_divisors():
    from math import gcd
    A, B = [int(i) for i in input().split()]

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数とその指数の辞書"""
        from collections import defaultdict
        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table
    g = gcd(A, B)
    return len(prime_factorization_dict(g).keys()) + 1 if g > 1 else 1

print(d_disjoint_set_of_common_divisors())
Problem p02918 (python)

Fixed submission:
def d_face_produces_unhappiness():
    N, K = [int(i) for i in input().split()]
    S = input()
    before_char = S[0]
    t = []
    v = 0
    for s in S + '*':
        if s != before_char:
            t.append(v)
            v = 1
        else:
            v += 1
        before_char = s
    t.sort(reverse=True)
    for i in range(min(K, len(t))):
        t[i] += 2
    return min(sum([e - 1 for e in t]), N - 1)

print(d_face_produces_unhappiness())

Buggy submission (verdict: Runtime Error):
def d_face_produces_unhappiness():
    N, K = [int(i) for i in input().split()]
    S = input()
    before_char = S[0]
    t = []
    v = 0
    for s in S + '*':
        if s != before_char:
            t.append(v)
            v = 1
        else:
            v += 1
        before_char = s
    t.sort(reverse=True)
    for i in range(K):
        t[i] += 2
    return min(sum([e - 1 for e in t]), N - 1)

print(d_face_produces_unhappiness())
Problem p02936 (python)

Fixed submission:
def d_ki():
    import sys
    input = sys.stdin.readline
    N, Q = [int(i) for i in input().split()]

    tree = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = [int(i) for i in input().split()]
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    ans = [0] * N
    for _ in range(Q):
        p, x = [int(i) for i in input().split()]
        ans[p - 1] += x

    # 1次元配列だったら単純に累積和を取ればいいのだが、木なので
    # DFSをしなければならない
    q = [0]
    is_visited = [False] * N
    while q:
        current = q.pop()
        is_visited[current] = True
        for child in tree[current]:
            if is_visited[child]:
                continue
            ans[child] += ans[current]
            q.append(child)
    return ' '.join(map(str, ans))

print(d_ki())

Buggy submission (verdict: Runtime Error):
def d_ki():
    import sys
    input = sys.stdin.readline
    N, Q = [int(i) for i in input().split()]

    tree = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = [int(i) for i in input().split()]
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    ans = [0] * N
    for _ in range(Q):
        p, x = [int(i) for i in input().split()]
        ans[p - 1] += x

    # 1次元配列だったら単純に累積和を取ればいいのだが、木なので
    # DFSをしなければならない
    def dfs(current, parent=-1):
        for child in tree[current]:
            if child == parent:
                continue
            ans[child] += ans[current]
            dfs(child, current)
    dfs(0)
    return ' '.join(map(str, ans))

print(d_ki())
Problem p02958 (python)

Fixed submission:
N = int(input())
P = [int(i) for i in input().split()]
p_sorted = list(sorted(P))

if P == p_sorted:
    print('YES')
    exit()
for i in range(N):
    for j in range(i + 1, N):
        P[i], P[j] = P[j], P[i]
        if P == p_sorted:
            print('YES')
            exit()
        P[i], P[j] = P[j], P[i]
print('NO')

Buggy submission (verdict: Runtime Error):
N = int(input())
P = [int(i) for i in input().split()]

permulated = len(1 for k, p in enumerate(P, 1) if p != k)
print('YES' if permulated <= 2 else 'NO')
Problem p02972 (python)

Fixed submission:
def d_preparing_boxes(N, A):
    boxes = [0] * (N + 1)
    result = []

    for i in range(N, 0, -1):
        # N以下のiの倍数(i自身を除く)の箱に入っているボールの数を求める
        total = 0
        for j in range(1, N // i):
            total += boxes[(j + 1) * i]
        # 求めたボール数と条件の偶奇が一致しないなら、i番の箱にボールを入れる
        if total % 2 != A[i - 1]:
            boxes[i] = 1
            result.append(i)
    return '\n'.join(map(str, [len(result)] + result)) if len(result) != 0 else 0

N = int(input())
A = [int(i) for i in input().split()]
print(d_preparing_boxes(N, A))

Buggy submission (verdict: Runtime Error):
def d_preparing_boxes(N, A):
    balls = [0] * N

    for i in range(N, 0, -1):
        t = i
        while t <= N:
            if balls[i - 1] % 2 != A[i - 1]:
                balls[i - 1] += 1
            t += i
    ans = [k for k, b in enumerate(balls, 1) if b != 0]
    return '\n'.join(map(str, (len(ans), *ans))) if len(ans) != 0 else 0

N = int(input())
A = [int(i) for i in input().split()]
print(d_preparing_boxes(N, A))
Problem p02985 (python)

Fixed submission:
def e_virus_tree_2(N, K, Edges, MOD=10**9 + 7):
    import sys
    sys.setrecursionlimit(10**6)
    
    graph = [[] for _ in range(N)]
    for a, b in Edges:
        graph[b - 1].append(a - 1)
        graph[a - 1].append(b - 1)

    def dfs(color, graph, current, parent):
        can_use_color_num = K - 1 if parent == -1 else K - 2

        if color < len(graph[current]):
            return 0  # 塗らねばならない子の数に対して色が足りない

        # コンビネーションの計算はここで行っている
        case_num = 1
        for child in graph[current]:
            if child == parent:
                continue
            case_num *= can_use_color_num
            case_num %= MOD
            can_use_color_num -= 1
        for child in graph[current]:
            if child == parent:
                continue
            case_num *= dfs(color, graph, child, current)
            case_num %= MOD
        return case_num

    ans = K * dfs(K, graph, 0, -1)
    return ans % MOD

N, K = [int(i) for i in input().split()]
Edges = [[int(i) for i in input().split()] for j in range(N - 1)]
print(e_virus_tree_2(N, K, Edges))

Buggy submission (verdict: Runtime Error):
def e_virus_tree_2(N, K, Edges, MOD=10**9 + 7):
    graph = [[] for _ in range(N)]
    for a, b in Edges:
        graph[b - 1].append(a - 1)
        graph[a - 1].append(b - 1)

    def dfs(color, graph, current, parent):
        can_use_color_num = K - 1 if parent == -1 else K - 2

        if color < len(graph[current]):
            return 0  # 塗らねばならない子の数に対して色が足りない

        # コンビネーションの計算はここで行っている
        case_num = 1
        for child in graph[current]:
            if child == parent:
                continue
            case_num *= can_use_color_num
            case_num %= MOD
            can_use_color_num -= 1
        for child in graph[current]:
            if child == parent:
                continue
            case_num *= dfs(color, graph, child, current)
            case_num %= MOD
        return case_num

    ans = K * dfs(K, graph, 0, -1)
    return ans % MOD

N, K = [int(i) for i in input().split()]
Edges = [[int(i) for i in input().split()] for j in range(N - 1)]
print(e_virus_tree_2(N, K, Edges))
Problem p03006 (python)

Fixed submission:
def b_picking_up(N, Positions):
    if N == 1:
        return 1  # 最初のボールに移動するのは必ずコスト1

    from collections import defaultdict
    difference_count = defaultdict(int)  # xの差分とyの差分の組について、現れた回数

    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            # diff_x と diff_y がともに0となることは、入力の制約よりありえない
            diff_x = Positions[j][0] - Positions[i][0]
            diff_y = Positions[j][1] - Positions[i][1]
            difference_count[(diff_x, diff_y)] += 1
    return N - max(difference_count.values())  # 第2項はコスト0で移動できる座標の数

N = int(input())
Positions = [[int(i) for i in input().split()] for j in range(N)]
print(b_picking_up(N, Positions))

Buggy submission (verdict: Runtime Error):
def b_picking_up(N, Positions):
    from collections import defaultdict
    difference_count = defaultdict(int)  # xの差分とyの差分の組について、現れた回数
    before_x, before_y = Positions[0]
    for x, y in Positions[1:]:
        diff_x, diff_y = x - before_x, y - before_y
        difference_count[(diff_x, diff_y)] += 1
        before_x, before_y = x, y
    # print(difference_count)
    difference_count = sorted(difference_count.items(), key=lambda x: x[1], reverse=True)
    # print(difference_count)
    if difference_count[0][0] == (0, 0):
        if len(difference_count) == 1:
            return N
        else:
            p, q = difference_count[1][0]
    else:
        p, q = difference_count[0][0]

    ans = 1
    before_x, before_y = Positions[0]
    for x, y in Positions[1:]:
        diff_x, diff_y = x - before_x, y - before_y
        if (diff_x, diff_y) != (p, q):
            ans += 1
        before_x, before_y = x, y
    return ans

N = int(input())
Positions = [[int(i) for i in input().split()] for j in range(N)]
print(b_picking_up(N, Positions))