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

Fixed submission:
H, W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]

ans = []

for i in range(H-1):
    for j in range(W):
        if a[i][j] % 2:
            a[i][j] -= 1
            a[i+1][j] += 1
            ans.append((i+1, j+1, i+2, j+1))

for i in range(W-1):
    if a[-1][i] % 2:
        a[-1][i] -= 1
        a[-1][i+1] += 1
        ans.append((H, i+1, H, i+2))

print(len(ans))
for row in ans:
    print(*row)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
field = []
for i in range(H):
    field.append(list(map(int, input().split())))

tmp = []
cnt = 0 
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            if j == W-1 and field[i][j] % 2 == 1:
                field[i][j] -= 1
                filed[i+1][j] += 1
                tmp.append(list((j, i, j, i+1)))
                cnt += 1
            elif field[i][j] % 2 == 1:
                field[i][j] -= 1
                field[i][j+1] += 1
                tmp.append(list((j, i, j+1, i)))
                cnt += 1
    else:
        for j in range(W)[::-1]:
            if j == 0 and field[i][j] % 2 == 1:
                field[i][j] -= 1
                field[i+1][j] += 1
                tmp.append(list((j, i, j, i+1)))
                cnt += 1
            elif field[i][j] % 2 == 1:
                field[i][j] -= 1
                field[i][j-1] += 1
                tmp.append(list((j, i, j-1, i)))
                cnt += 1

print(cnt)
for i in range(cnt):
    print(tmp[i])
Problem p03274 (python)

Fixed submission:
N, K = map(int, input().split())
x = list(map(int, input().split()))

dist = []
for i in range(N-K+1): 
    l, r = x[i], x[i+K-1]
    t = min(abs(l)+abs(l-r), abs(r)+abs(r-l))
    dist.append(t)

print(min(dist))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
x = list(map(int, input().split()))

dist = []
for i in range(N-K+1): 
    l, r = x[i], x[i+k-1]
    t = min(abs(l)+abs(l-r), abs(r)+abs(r-l))
    dist.append(t)

print(min(dist))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
x = list(map(int, input().split()))

dist = []
for i in range(N-K+1):
    a = 0
    tmp = x[i:i+K]
    mini, maxi = tmp[0], tmp[-1]
    if (mini >= 0 and maxi >= 0):
        a = maxi
    elif (mini < 0 and maxi < 0):
        a = abs(mixi)
    if mini < 0 and maxi >= 0:
        a = abs(mixi) + maxi + min(abs(mixi), maxi)
    dist.append(a)

print(min(dist))
Problem p03309 (python)

Fixed submission:
import numpy as np

N = int(input())
a = list(map(int, input().split()))

b = [a[i] - i for i in range(N)]
median = np.median(b)

ans = 0
for i in range(N):
    ans += abs(b[i] - int(median))

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
a = list(map(int, input().split()))

b = [a[i] - i for i in range(N)]
median = np.median(b)

ans = 0
for i in range(N):
    ans += abs(b[i] - int(median))

print(ans)

Buggy submission (verdict: Runtime Error):
import statistics

N = int(input())
a = list(map(int, input().split()))

b = [a[i] - i for i in range(N)]
median = statistics.median(b)

ans = 0
for i in range(N):
    ans += abs(b[i] - int(median))

print(ans)
Problem p03353 (python)

Fixed submission:
s = input()
K = int(input())

substr = []
for i in range(len(s)):
    for j in range(i+1, i+K+1):
        if len(s) >= K:
            substr.append(s[i:j])
        else:
            if j == len(s)+1:
                break
            substr.append(s[i:j])

substr = list(set(substr))
substr.sort()

print(substr[K-1])

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())

substr = []
for i in range(len(s)):
    for j in range(i+1, K):
        if len(s) >= K:
            substr.append(s[i:j])
        else:
            if j == len(s)+1:
                break
            substr.append(s[i:j])

substr = list(set(substr))
substr.sort()
print(substr[K-1])
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
s = [input() for i in range(H)]

dx = [-1, 0, 0, 1]
dy = [0, 1, -1, 0]
for i in range(H):
    for j in range(W):
        flag = False
        for k in range(4):
            if s[i][j] == '#':
                nx = j + dx[k]
                ny = i + dy[k]
                if nx < 0 or nx >= W or ny < 0 or ny >= H:
                    continue
                if s[ny][nx] == '#':
                    flag = True
            else:
                flag = True
        if flag == False:
            print('No')
            exit()        

print('Yes')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [input() for i in range(H)]

dx = [-1, 0, 0, 1]
dy = [0, 1, -1, 0]
for i in range(H):
    for j in range(W):
        flag = False
        for k in range(4):
            if s[i][j] == '#':
                nx = j + dx[k]
                ny = i + dy[k]
                if nx < 0 or nx >= W or ny < 0 or ny >= H:
                    continue
                if s[nx][ny] == '#':
                    flag = True
            else:
                flag = True
        if flag == False:
            print('No')
            exit()        

print('Yes')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [input() for i in range(H)]

dx = [-1, 0, 0, 1]
dy = [0, 1, -1, 0]
for i in range(H):
    for j in range(W):
        flag = False
        for k in range(4):
            if s[i][j] == '#':
                nx = i + dx[k]
                ny = j + dy[k]
                if nx < 0 or nx >= W or ny < 0 or ny >= H:
                    continue
                if s[nx][ny] == '#':
                    flag = True
            else:
                flag = True
        if flag == False:
            print('No')
            exit()        

print('Yes')
Problem p03418 (python)

Fixed submission:
N, K = map(int, input().split())

if K == 0:
    print(N*N)
    exit()

ans = 0
for b in range(1, N+1):
    ans += max(0, b-K)*(N//b) + max(0, N%b-K+1)
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

if K == 0:
    print(N*N)
    exit()

ans = 0
for b in range(N+1):
    ans += max(0, b-K)*(N//b) + max(0, N%b-K+1)
print(ans)
Problem p03425 (python)

Fixed submission:
from itertools import combinations

N = int(input())
S = [input() for i in range(N)]

m = []
a = []
r = []
c = []
h = []
for i in range(N):
    if S[i][0] == 'M':
        m.append(S[i])
    elif S[i][0] == 'A':
        a.append(S[i])
    elif S[i][0] == 'R':
        r.append(S[i])
    elif S[i][0] == 'C':
        c.append(S[i])
    elif S[i][0] == 'H':
        h.append(S[i])

cnt = []
cnt.append(len(m))
cnt.append(len(a))
cnt.append(len(r))
cnt.append(len(c))
cnt.append(len(h))

com = list(combinations(range(5), 3))

ans = 0
for i in com:
    ans += cnt[i[0]]*cnt[i[1]]*cnt[i[2]]
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

N = int(input())
S = [input() for i in range(N)]

m = []
a = []
r = []
c = []
h = []
for i in range(N):
    if S[i][0] == 'M':
        m.append(S[i])
    elif S[i][0] == 'A':
        a.append(S[i])
    elif S[i][0] == 'R':
        r.append(S[i])
    elif S[i][0] == 'C':
        c.append(S[i])
    elif S[i][0] == 'H':
        h.append(S[i])

cnt = []
cnt.append(m.count)
cnt.append(a.count)
cnt.append(r.count)
cnt.append(c.count)
cnt.append(h.count)

com = list(combinations(range(5), 3))

ans = 0
for i in com:
    ans += cnt[i[0]]*cnt[i[1]]*cnt[i[2]]
print(ans)
Problem p03457 (python)

Fixed submission:
N = int(input())
T = [0]
coo = [(0, 0)]
for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    coo.append((x, y))

for i in range(N):
    dxdy = coo[i+1][0] - coo[i][0] + coo[i+1][1] - coo[i][1]
    rt = (T[i+1] - T[i]) % 2
    rdxdy = dxdy % 2
    if dxdy <= T[i+1] - T[i] and rt == rdxdy:
        pass
    else:
        print('No')
        exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
T = []
coo = [(0, 0)]
for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    coo.append((x, y))

for i in range(N):
    dxdy = coo[i+1][0] - coo[i][0] + coo[i+1][1] - coo[i][1]
    if dxdy <= t[i+1] - t[i]:
        pass
    else:
        print('No')
        exit()
print('Yes')
Problem p03611 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))

b = [0]*(10**5+1)
for i in a:
    if i == 10**5:
        b[i-1] += 1
        b[i] += 1
    elif i == 0:
        b[i] += 1
        b[i+1] += 1
    else:
        b[i-1] += 1
        b[i] += 1
        b[i+1] += 1

print(max(b))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

b = [0]*(10**5)
for i in a:
    if i == 10**5:
        b[i-1] += 1
        b[i] += 1
    elif i == 0:
        b[i] += 1
        b[i+1] += 1
    else:
        b[i-1] += 1
        b[i] += 1
        b[i+1] += 1

print(max(b))
Problem p03638 (python)

Fixed submission:
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

x = 0
for i in range(H):
    ans = []
    for j in range(W):
        ans.append(x+1)
        A[x] -= 1
        if A[x] == 0:
            x += 1
    if i % 2 == 0:
        print(*ans)
    else:
        print(*ans[::-1])

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

x = 0
for i in range(H):
    ans = []
    for j in range(W):
        ans.append(x+1)
        A[i] -= 1
        if A[i] == 0:
            x += 1
    if i % 2 == 0:
        print(*ans)
    else:
        print(*ans[::-1])
Problem p03697 (python)

Fixed submission:
a, b = map(int, input().split())

if a + b < 10:
    print(a + b)
else:
    print('error')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input(),split())

if a + b < 10:
    print(a + b)
else:
    print('error')
Problem p03836 (python)

Fixed submission:
sx, sy, tx, ty = map(int, input().split())

dx, dy = tx-sx, ty-sy
ans = ''
ans += 'U'*dy
ans += 'R'*dx
ans += 'D'*dy
ans += 'L'*dx
ans += 'L'
ans += 'U'*(dy+1)
ans += 'R'*(dx+1)
ans += 'DR'
ans += 'D'*(dy+1)
ans += 'L'*(dx+1)
ans += 'U'

print(ans)

Buggy submission (verdict: Runtime Error):
K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                cnt += 1

print(cnt)
Problem p03962 (python)

Fixed submission:
a = input().split()
s = {a[0]}
for i in a:
    s |= {i}
print(len(s))

Buggy submission (verdict: Runtime Error):
a = input().split()
s = {}
for i in a:
    s |= i
print(len(s))
Problem p02609 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    X = input()
    pcnt = 0
    ans = []
    for x in X:
        if x == '1': pcnt += 1
    if pcnt == 0:
        for _ in range(N):
            print(1)
            return
    Xinv = X[::-1]
    ex1 = ex2 = 1
    num1 = num2 = 0
    for x in Xinv:
        num1 += (ex1 * int(x)) % (pcnt + 1)
        num1 %= (pcnt + 1)
        if pcnt > 1:
            num2 += (ex2 * int(x)) % (pcnt - 1)
            num2 %= (pcnt - 1)
        ex1 *= 2
        ex1 %= (pcnt + 1)
        ex2 *= 2
        if pcnt > 1: ex2 %= (pcnt - 1)

    def solve(n, p, s):
        if n == 0 and s > 0: return s
        n %= p
        p = bin(n).count('1')
        return solve(n, p, s+1)

    for i in range(N):
        if X[i] == '1':
            p = pcnt - 1
            if p == 0:
                ans.append(0)
                continue
            num = num2 - pow(2, N-i-1, p)
            ans.append(solve(num, p, 0))
        else:
            p = pcnt + 1
            num = num1 + pow(2, N-i-1, p)
            ans.append(solve(num, p, 0))

    for i in range(N):
        print(ans[i])

    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    X = input()
    pcnt = 0
    ans = []
    for x in X:
        if x == '1': pcnt += 1
    if pcnt == 0:
        for _ in range(N):
            print(0)
            return
    Xinv = X[::-1]
    ex1 = ex2 = 1
    num1 = num2 = 0
    for x in Xinv:
        num1 += (ex1 * int(x)) % (pcnt + 1)
        num1 %= (pcnt + 1)
        if pcnt > 0:
            num2 += (ex2 * int(x)) % (pcnt - 1)
            num2 %= (pcnt - 1)
        ex1 *= 2
        ex1 %= (pcnt + 1)
        ex2 *= 2
        if pcnt > 0: ex2 %= (pcnt - 1)

    def solve(n, p, s):
        if n == 0 and s > 0: return s
        n %= p
        p = bin(n).count('1')
        return solve(n, p, s+1)

    for i in range(N):
        if X[i] == '1':
            p = pcnt - 1
            if p == 0:
                ans.append(0)
                continue
            num = num2 - pow(2, N-i-1, p)
            ans.append(solve(num, p, 0))
        else:
            p = pcnt + 1
            num = num1 + pow(2, N-i-1, p)
            ans.append(solve(num, p, 0))

    for i in range(N):
        print(ans[i])

    return

if __name__ == '__main__':
    main()
Problem p02639 (python)

Fixed submission:
a = [int(_) for _ in input().split()]
print(a.index(0)+1)

Buggy submission (verdict: Runtime Error):
a = [int(_) for _ in inpur().split()]
print(a.index(0)+1)
Problem p02642 (python)

Fixed submission:
import collections

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = sorted(ZZ())
    cA = collections.Counter(A)
    MAX_A = 10 ** 6
    is_ok = [True] * (MAX_A + 1)

    if 1 in cA.keys():
        if cA[1] == 1: print(1)
        elif cA[1] >= 2: print(0)
        return

    for a in cA.keys():
        if not is_ok[a]: continue
        if cA[a] >= 2: is_ok[a] = False
        for i in range(2, MAX_A + 1):
            if a * i > MAX_A: break
            is_ok[a * i] = False

    ans = 0
    for a in cA.keys():
        if is_ok[a]: ans += 1

    print(ans)

    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = collections.Counter(ZZ())
    e = collections.defaultdict(list)
    l = [False] * (10 ** 6 + 5)

    def yakusu(num):
        ret = []
        lim = (num ** 0.5) + 5
        for i in range(1, lim):
            if i * i > num: break
            if num%i != 0: continue
            ret.append(i)
            if i != num//i: ret.append(num//i)
        return ret

    if 1 in A.keys():
        if A[1] == 1: print(1)
        elif A[1] >= 2: print(0)
        return

    ans = 0
    for n in A.keys():
        l[n] = True
        e[n] = yakusu(n)

    for n in A.keys():
        if A[n] >= 2: continue
        if len(e[n]) == 2:
            ans += 1
            continue
        for p in e[n]:
            if p in {1, n}: continue
            if l[p]: break
        else: ans += 1
    print(ans)

    return

if __name__ == '__main__':
    main()
Problem p02647 (python)

Fixed submission:
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n, k = ZZ()
    A = ZZ()+[0]

    for _ in range(k):
        if all([A[i] >= n for i in range(n)]): break
        nA = [0] * (n+1)
        for i in range(n):
            nA[max(0, i-A[i])] += 1
            nA[min(n, i+1+A[i])] -= 1
        for i in range(1, n+1): nA[i] += nA[i-1]
        A = nA
    print(*A[:-1])

    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n, k = ZZ()
    A = ZZ() + [0]

    for _ in range(k):
        nA = [0] * (n+1)
        for i in range(n):
            nA[max(0, i-A[i])] += 1
            nA[min(n, i+1+A[i])] -= 1
        for i in range(1, n+1): nA[i] += nA[i-1]
        print(nA)
        A = nA
    print(*A[:-1])

    return

if __name__ == '__main__':
    main()
Problem p02787 (python)

Fixed submission:
def main():
  H, N = (int(_) for _ in input().split())
  A = [[int(_) for _ in input().split()] for __ in range(N)]
  INF = 10 ** 15
  dp = [[INF] * (H + 1) for _ in range(N+1)]
  dp[0][0] = 0
  for i in range(N):
    for j in range(H+1):
      dp[i+1][j] = min(dp[i+1][j], dp[i][j])
      if A[i][0] <= j < H:
        dp[i+1][j] = min(dp[i+1][j], A[i][1] + dp[i+1][j-A[i][0]])
      elif j == H:
        for k in range(max(j - A[i][0], 0), j):
          dp[i+1][j] = min(dp[i+1][j], A[i][1] + dp[i+1][k])
  print(dp[N][H])
  return

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  H, N = (int(_) for _ in input().split())
  A = [[int(_) for _ in input().split()] for __ in range(N)]
  INF = 10 ** 15
  dp = [[INF] * (H + 1) for _ in range(N+1)]
  dp[0][0] = 0
  for i in range(N):
    for j in range(H+1):
      dp[i+1][j] = min(dp[i+1][j], dp[i][j])
      if A[i][0] <= j < H:
        dp[i+1][j] = min(dp[i+1][j], A[i][1] + dp[i+1][j-A[i][0]])
      elif j == H:
        for k in range(j - A[i][0], j):
          dp[i+1][j] = min(dp[i+1][j], A[i][1] + dp[i+1][k])
  print(dp[N][H])
  return

if __name__ == '__main__':
  main()
Problem p02850 (python)

Fixed submission:
import collections
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

class edge:
    def __init__(self, to, id): self.to, self.id = to, id

def main():
    N = Z()
    col = [0] * (N-1)
    G = collections.defaultdict(list)
    for i in range(N-1):
        a, b = ZZ()
        G[a].append(edge(b, i))
        G[b].append(edge(a, i))
    numCol = 0
    for i in range(1, N+1): numCol = max(numCol, len(G[i]))

    def dfs(v):
        colSet = set()
        for ed in G[v]:
            if col[ed.id] != 0: colSet.add(col[ed.id])
        c = 1
        for ed in G[v]:
            if col[ed.id] != 0: continue
            while c in colSet: c += 1
            col[ed.id] = c
            c += 1
            dfs(ed.to)

    dfs(1)
    print(numCol)
    for i in range(N-1): print(col[i])

    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

class edge:
    def __init__(self, to, id): self.to, self.id = to, id

def main():
    N = Z()
    col = [0] * (N-1)
    G = collections.defaultdict(list)
    for i in range(N-1):
        a, b = ZZ()
        G[a].append(edge(b, i))
        G[b].append(edge(a, i))
    numCol = 0
    for i in range(1, N+1): numCol = max(numCol, len(G[i]))

    def dfs(v):
        colSet = set()
        for ed in G[v]:
            if col[ed.id] != 0: colSet.add(col[ed.id])
        c = 1
        for ed in G[v]:
            if col[ed.id] != 0: continue
            while c in colSet: c += 1
            col[ed.id] = c
            c += 1
            dfs(ed.to)

    dfs(1)
    print(numCol)
    for i in range(N-1): print(col[i])

    return

if __name__ == '__main__':
    main()
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, -1)
print(*ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
sys.setlimitrecursion(100000000)
def main():
    #入力
    N, Q = (int(_) for _ in input().split())
    edge = [[int(_) for _ in input().split()] for __ in range(N-1)]
    query = [[int(_) for _ in input().split()] for __ in range(Q)]

    tree = defaultdict(list)
    for a, b in edge:
        tree[a].append(b)
        tree[b].append(a)

    cc = [0] * (N+1)
    seen = [False] * (N+1)

    for p, x in query:
        cc[p] += x

    def dfs(x):
        for p in tree[x]:
            if seen[p] == False:
                seen[p] = True
                cc[p] += cc[x]
                dfs(p)
        return

    seen[1] = True
    dfs(1)

    print(*cc[1:])
    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def main():
    #入力
    N, Q = (int(_) for _ in input().split())
    edge = [[int(_) for _ in input().split()] for __ in range(N-1)]
    query = [[int(_) for _ in input().split()] for __ in range(Q)]

    tree = defaultdict(list)
    for a, b in edge:
        tree[a].append(b)
        tree[b].append(a)

    cc = [0] * (N+1)
    seen = [False] * (N+1)

    for p, x in query:
        cc[p] += x

    def dfs(x):
        for p in tree[x]:
            if seen[p] == False:
                seen[p] = True
                cc[p] += cc[x]
                dfs(p)
        return

    seen[1] = True
    dfs(1)

    print(*cc[1:])
    return

if __name__ == '__main__':
    main()
Problem p03006 (python)

Fixed submission:
import collections
import itertools

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    P = [ZZ() for _ in range(N)]
    vecs = set()
    d = collections.defaultdict(int)
    output = 1
    if N == 1:
        print(output)
        return

    for i, j in itertools.combinations(range(N), 2):
        dx, dy = P[i][0] - P[j][0], P[i][1] - P[j][1]
        if dx < 0: dx, dy = -dx, -dy
        vecs.add((dx, dy))

    c = 0
    for v in list(vecs):
        cc = 0
        for i, j in itertools.combinations(range(N), 2):
            if (P[i][0] - P[j][0] == v[0] and P[i][1] - P[j][1] == v[1]) or (P[i][0] - P[j][0] == -v[0] and P[i][1] - P[j][1] == -v[1]):
                cc += 1
        c = max(c, cc)
    output = (N - c)
    print(output)
    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections
import itertools

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    P = [ZZ() for _ in range(N)]
    d = collections.defaultdict(int)
    output = 0
    for i, j in itertools.combinations(range(N), 2):
        dx, dy = P[i][0] - P[j][0], P[i][1] - P[j][1]
        if dx < 0: dx, dy = -dx, -dy
        d[(dx, dy)] += 1
    output += (N - max(d.values()))
    print(output)

    return

if __name__ == '__main__':
    main()