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

Fixed submission:
import math

def is_prime(x):
  if x <= 0 or x%1 != 0:
    return False
  elif x == 1:
    return False
  elif x == 2:
    return True
  elif x%2 == 0:
    return False
  else:
    for i in range(3, int(math.sqrt(x)//1)+1, 2):
      if x%i == 0:
        return False
    return True

S = [0] * (10**5+1)
for i in range(1, 10**5+1):
  if is_prime(i) and is_prime((i+1)/2):
    S[i] += 1
  S[i] += S[i-1]

Q = int(input())
for _ in range(Q):
  l, r = map(int, input().split())
  print(S[r] - S[l-1])

Buggy submission (verdict: Runtime Error):
import math

def is_prime(x):
  if x == 1:
    return False
  elif x == 2:
    return True
  else:
    for i in range(3, math.sqrt(x)//1+1):
      if x%i == 0:
        return False
    return True

print(is_prime(3))
Problem p02556 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())
d1 = [] * n
d2 = [] * n

for i in range(n):
    x, y = map(int, input().split())
    d1.append(x+y)
    d2.append(x-y)

print(max(max(d1) - min(d1), max(d2)-min(d2)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
import numpy as np
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())
d1 = [] * n
d2 = [] * n

for i in range(n):
    x, y = map(int, input().split())
    d1.append(x+y)
    d2.append(x-y)

print(max(max(d1) - min(d1), max(d2)-min(d2)))
Problem p02909 (python)

Fixed submission:
S = input()

if S == 'Sunny':
    print('Cloudy')
elif S =='Cloudy':
    print('Rainy')
else:
    print('Sunny')

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [ int(a) for a in input().split() ]
A.sort(reverse=True)
 
for m in range(M):
    A[0] = A[0] // 2
    A.sort(reverse=True)
 
print(sum(A))

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

if S == 'Sunny':
    print('Cloudy')
elif S =='Cloudy':
    print('Rainy')
else:
    print('Sunny')
Problem p02945 (python)

Fixed submission:
A, B = map(int, input().split())

print(max(A+B, A-B, A*B))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max([a+b, a-b, a*b])
Problem p02957 (python)

Fixed submission:
A, B = map(int, input().split())
K = int((A+B)//2)
if abs(A-K) == abs(B-K):
  print(K)
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())
K = int((A+B)//2)
if abs(A-K) == abs(B-K):
  print(K)
else:
  print('IMPOSSIBLE')
Problem p02993 (python)

Fixed submission:
S = input()

for i in range(len(S) - 1):
    if S[i] == S[i+1]:
        print('Bad')
        exit()
print('Good')

Buggy submission (verdict: Runtime Error):
import fractions

A, B, C, D = map(int, input().split())

count = B - A + 1
lcd_of_CD = C * D // fractions.gcd(C, D)

count -= B // C
count += (A - 1) // C
count -= B // D
count += (A - 1) // D
count += B // lcd_of_CD
count -= (A - 1) // lcd_of_CD

print(count)

Buggy submission (verdict: Runtime Error):
import fractions

A, B, C, D = map(int, input().split())

count = B - A + 1
lcd_of_CD = C * D // math.gcd(C, D)

count -= B // C
count += (A - 1) // C
count -= B // D
count += (A - 1) // D
count += B // lcd_of_CD
count -= (A - 1) // lcd_of_CD

print(count)
Problem p02995 (python)

Fixed submission:
import fractions

A, B, C, D = map(int, input().split())

count = B - A + 1
lcd_of_CD = C * D // fractions.gcd(C, D)

count -= B // C
count += (A - 1) // C
count -= B // D
count += (A - 1) // D
count += B // lcd_of_CD
count -= (A - 1) // lcd_of_CD

print(count)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())

count = B - A + 1
lcd_of_CD = C * D // math.gcd(C, D)

count -= B // C
count += (A - 1) // C
count -= B // D
count += (A - 1) // D
count += B // lcd_of_CD
count -= (A - 1) // lcd_of_CD

print(count)
Problem p03076 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

minutes = 0
items = [A, B, C, D, E]
rems = [item % 10 for item in items if item % 10 != 0]
cnt = len(rems)


for item in items:
    minutes += (item//10)*10
 
if cnt > 0:
    minutes += (cnt-1)*10
    minutes += min(rems)

print(minutes)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

minutes = 0
items = [A, B, C, D, E]
rems = [item % 10 for item in items if item % 10 != 0]
cnt = len(rems)
minutes += min(rems)

for item in items:
    minutes += (item//10)*10
 
if cnt > 0:
    minutes += (cnt-1)*10

print(minutes)
Problem p03085 (python)

Fixed submission:
b = input()

if b == 'A': print('T')
elif b == 'T': print('A')
elif b == 'G': print('C')
else: print('G')

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

if s == 'A':
  print('T')
elfi s == 'T':
  print('A')
elif s == 'C':
  print('G')
else:
  print('C')
Problem p03101 (python)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())


print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input())
h, w = map(int, input())
print((H-h)*(W-w))
Problem p03160 (python)

Fixed submission:
def min_cost(n, hs):
    costs = [0 for _ in range(n)]
    costs[1] = abs(hs[1] - hs[0])
    for i in range(2, n):
        costs[i] = min(costs[i-1] + abs(hs[i]-hs[i-1]), costs[i-2] + abs(hs[i] - hs[i-2]))
    
    return costs[n-1]

N = int(input())
Hn = list(map(int, input().split(' ')))

print(min_cost(N, Hn))

Buggy submission (verdict: Runtime Error):
def min_cost(N, K, Hn):
    costs = [[0 for k in range(K+1)] for n in range(N+1)]
    
    # N = 2 または K = 1 のとき
    for k in range(1, K+1):
        costs[2][k] = abs(Hn[1] - Hn[0])
    for n in range(3, N+1):
        costs[n][1] = costs[n-1][1] + abs(Hn[n-1] - Hn[n-2])
    
    # その他
    for n in range(3, N+1):
        for k in range(2, K+1):
            if k >= n:
                costs[n][k] = costs[n][k-1]
            else:
                costs[n][k] = min(costs[n][k-1], min([costs[n-l][k] + abs(Hn[n-1] - Hn[n-1-l]) for l in range(1, k+1)]))

    return costs[N][K]

N, K = map(int, input().split(' '))
Hn = list(map(int, input().split(' ')))

print(min_cost(N, K, Hn))

Buggy submission (verdict: Runtime Error):
def min_cost(n, hs):
    if (n == 2):
        return abs(hs[1] - hs[0])
    if (n == 3):
        return min(abs(hs[1] - hs[0]) + abs(hs[2] - hs[1]), abs(hs[2] - hs[0]))
    else:
        return min(min_cost(n-1, hs[:n-1:]) + abs(hs[n-1] - hs[n-2]), min_cost(n-2, hs[:n-2:]) + abs(hs[n-1] - hs[n-3]))

N = int(input())
Hn = list(map(int, input().split(' ')))

print(min_cost(N, Hn))
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
 
if a * b % 2 == 0:
    print("No")
else:
    print("Yes")

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

if a * b % 2 == 0:
    print("No")
else:
    print("Yes")
Problem p03282 (python)

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

def func(N, K):
    for n in range(len(N)):
        if N[n] != 1:
            if K > n:
                return N[n]
    
    return 1

print(func(N, K))

Buggy submission (verdict: Runtime Error):
S = list(input().split())

if S[0] == '1':
  print(S[1])
else:
  print(S[0])
Problem p03309 (python)

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

for n in range(N):
    An[n] -= (n+1)

An.sort()

if (N-1) % 2 != 0:
    m = N//2 - 1
else:
    m = (N-1)//2

bf = -sum(An[0:m+1:]) + (m+1)*An[m]
af = sum(An[m+1::]) - (N-m-1)*An[m]
ans = bf + af
print(ans)

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

for n in range(N):
    An[n] -= (n+1)

An.sort()

m = N-1
if (m % 2 == 0):
    m = m//2
    cent = (An[m] + An[m + 1]) // 2
else:
    cent = An[(m+1)//2]

ans = 0
for n in range(N):
    ans += abs(An[n] - cent)

print(ans)

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

for n in range(N):
    An[n] -= (n+1)

An.sort()

m = N-1
if (m % 2 == 0):
    cent = (An[m//2] + An[m//2 + 1]) // 2
else:
    cent = An[(m+1)//2]

ans = 0
for n in range(N):
    ans += abs(An[n] - cent)

print(ans)

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

for n in range(N):
    An[n] -= (n+1)

An.sort()

m = N-1
if (m % 2 == 0):
    cent = (An[m/2] + An[m/2 + 1]) // 2
else:
    cent = An[(m+1)/2]

ans = 0
for n in range(N):
    ans += abs(An[n] - cent)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
An = list(map(int, input().split()))
for n in range(N):
    An[n] -= (n+1)

An.sort()

m = N-1
if (m % 2 == 0):
    cent = (An[m//2] + An[m//2 + 1]) // 2
else:
    cent = An[(m+1)//2]

ans = 0
for n in range(N):
    ans += abs(An[n] - cent)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
An = list(map(int, input().split()))
for n in range(N):
    An[n] -= (n+1)

An.sort()

m = N-1
if (m % 2 == 0):
    cent = (An[m//2] + An[m//2 + 1]) // 2
else:
    cent = An[(m+1)//2]

ans = sum(An) - N * cent

print(ans)

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

sum = 0
for n in range(N):
    sum += An[n] - (n+1)
    
a, b, c = sum//N, sum//N + 1

ans = [0]*3
for n in range(N):
    ans[0] += abs(An[n] - (a+n+1))
    ans[0] += abs(An[n] - (b+n+1))
    ans[1] += abs(An[n] - (c+n+1))

print(min(ans))
Problem p03328 (python)

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

print( ((b-a) * (b-a) - b - a) // 2)

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

print( ((b-a) * (b-a) - b - a) / 2)
Problem p03469 (python)

Fixed submission:
print(input().replace('2017', '2018'))

Buggy submission (verdict: Runtime Error):
N = int(input())
print(len(set([input() for n in range(N)])))

Buggy submission (verdict: Runtime Error):
N = int(input())
print(len(set([input() for n in range(N)])))

Buggy submission (verdict: Runtime Error):
print(date = input().replace('2017', '2018'))
Problem p03477 (python)

Fixed submission:
A, B, C, D = map(int, input().split())

if A + B > C + D:
    print('Left')
elif A + B == C + D:
    print('Balanced')
else:
    print('Right')

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input())

if A + B > C + D:
    print('Left')
elif A + B == C + D:
    print('Balanced')
else:
    print('Right')
Problem p03657 (python)

Fixed submission:
A, B = map(int, input().split())

if A % 3 == 0:
    print('Possible')
elif B % 3 == 0:
    print('Possible')
elif (A+B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
L = [int(l) for l in input().split()]
L.sort(reverse=True)

print(sum(L[0:K:]))
Problem p03658 (python)

Fixed submission:
N, K = map(int, input().split())
L = [int(l) for l in input().split()]
L.sort(reverse=True)

print(sum(L[0:K:]))

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

L.sort(reverse=True))
print(L[0:K+1])
Problem p03737 (python)

Fixed submission:
s1, s2, s3 = input().split()
print(s1[0].upper() + s2[0].upper() + s3[0].upper())

Buggy submission (verdict: Runtime Error):
s1, s2, s3 = input().split()

print(s1[0].upper() + s2[0].uppter() + s3[0].upper())
Problem p03844 (python)

Fixed submission:
A, op, B = input().split()

num_A = int(A)
num_B = int(B)
if op == '+':
    print(num_A + num_B)
else:
    print(num_A - num_B)

Buggy submission (verdict: Runtime Error):
A, op, B = input().split()

num_A = int(A)
num_B = int(B)
if op == '+':
    print(num_A + numb_B)
else:
    print(num_A - num_B)
Problem p03852 (python)

Fixed submission:
c = input()

vowel = ['a', 'i', 'u', 'e', 'o']
if c in vowel:
    print('vowel')
else:
    print('consonant')

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

vowel = ['a', 'i', 'u', 'e', 'o']
if c in boin:
    print('vowel')
else:
    print('consonant')
Problem p02687 (python)

Fixed submission:
S = input()
if S == 'ABC':
  print('ARC')
else:
  print('ABC')

Buggy submission (verdict: Runtime Error):
 print('ABC') if input() == 'ARC' else print('ARC')
Problem p02694 (python)

Fixed submission:
x = int(input())
depo = 100
count = 0
while depo < x:
  depo += int(depo / 100)
  count += 1
  
print(count)

Buggy submission (verdict: Runtime Error):
x = int(input())
depo = 100
count = 0
while True:
  depo += int(depo / 100)
  count += 1
  if x == depo:
    break;
    
print(count)
Problem p02713 (python)

Fixed submission:
from math import gcd

def gcd_3(a, b, c):
    return gcd(gcd(a, b), c)
sum_gcd = 0
K = int(input())
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for l in range(1, K + 1):
            sum_gcd += gcd_3(i, j, l)

print(sum_gcd)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
worker_list = [0] * N

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

for i in range(N):
    print(worker_list[i])
Problem p02573 (python)

Fixed submission:
N, M = map(int, input().split())
F = [list(map(int, input().split())) for i in range(M)]

d = [-1]*N


def find(x):
    if d[x] < 0:
        return x
    d[x] = find(d[x])
    return d[x]


def union(x, y):
    x, y = find(x), find(y)
    if x == y:
        return
    if (d[x] > d[y]):
        x, y = y, x
    d[x] += d[y]
    d[y] = x


for f in F:
    union(f[0]-1, f[1]-1)
print(-min(d))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
F = [list(map(int, input().split())) for i in range(M)]

G = []

for i, f in enumerate(F):
    new_grp = True
    for j, g in enumerate(G):
        if f[0] in g:
            if f[1] not in g:
                G[j].append(f[1])
                new_grp = False
        if f[1] in g:
            if f[0] not in g:
                G[j].append(f[0])
                new_grp = False
    if new_grp:
        G.append(f)

print(max(map(len, G)))
Problem p02582 (python)

Fixed submission:
S = input()

print(S.count("R") if S != "RSR" else 1)

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

s_max = None
for n in range(N):
    s = 0
    p = n + 1
    for k in range(K):

        p = P[p-1]
        s += C[p-1]

        if not s_max:
            s_max = s
        if s > s_max:
            s_max = s


print(s_max)
Problem p02618 (python)

Fixed submission:
import random

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]


def calc(T):
  L = [0 for i in range(26)]
  score=0
  for d in range(D):
    score += S[d][T[d]-1]

    L[T[d]-1] = d+1
    down = 0
    for i in range(26):
      down+=C[i] * ((d+1) - L[i])

    score -=down
  return score

max_score=0
bestT=[]

for i in range(10):
  T = [random.randrange(1,26) for i in range(D)] 
  score = calc(T)

  if score > max_score:
    bestT = T
    max_score = score

for t in T:
  print(t)

Buggy submission (verdict: Runtime Error):
import random

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
L = [0 for i in range(26)]
T = [int(input()) for i in range(D)]

def calc(T):
  score=0
  for d in range(D):
    score += S[d][T[d]-1]

    L[T[d]-1] = d+1
    down = 0
    for i in range(26):
      down+=C[i] * ((d+1) - L[i])

    score -=down
  return score

max_score=0
bestT=[]

for i in range(10):
  T = [random.randrange(1,26) for i in range(D)] 
  score = calc(T)
  if score > max_score:
    bestT = T
    max_score = score

for t in T:
  print(t)
Problem p02640 (python)

Fixed submission:
X, Y = map(int, input().split())

if Y < X*2 :
  print("No")
  exit()

elif Y > X*4:
  print("No")
  exit()
    
if Y % 2 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

if Y < X*2 :
  print("No")
  eit()
  
if Y % 2 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

if Y < X*2 :
  print("NO")
  eit()
  
if Y % 2 == 0:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

if Y < X*2 :
  print("NO")
  eit()
  
if Y % 2 == 0:
  print("YES")
else:
  print("NO")
Problem p02645 (python)

Fixed submission:
S = input()

print(S[:3])

Buggy submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

for t in range(T):
  A += V
  B += W
  if A >= B:
    print("YES")
    exit()
  
print("NO")
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

print("Yes" if S == T[:len(S)] else "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 p02582 (python)

Fixed submission:
S = input().strip()

if S == "RRR":
    print(3)
elif "RR" in S:
    print(2)
elif "R" in S:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
X, K, D = [int(x) for x in input().strip().split(" ")]

k, x = divmod(X, D)
if K >= k:
    X = x
    K -= k
    if k % 2 == 0:
        print(abs(X))
    elif X < 0:
        print(abs(X + D))
    else:
        print(abs(X - D))
elif X < 0:
    print(abs(X + D * K))
else:
    print(abs(X - D * K))
Problem p02646 (python)

Fixed submission:
import sys
 
A, V = [int(x) for x in input().strip().split(" ")]
B, W = [int(x) for x in input().strip().split(" ")]
T = int(input().strip())
 
if V <= W:
    print("NO")
    sys.exit(0)
 
distance = abs(A - B)
diff = abs(V - W)
 
t, distance = divmod(distance, diff)
T -= t
if distance == 0 and T >= 0:
    print("YES")
    sys.exit(0)
elif T > 0:
    print("YES")
    sys.exit(0)
print("NO")
sys.exit(0)

Buggy submission (verdict: Runtime Error):
import sys

A, V = [int(x) for x in input().strip().split(" ")]
B, W = [int(x) for x in input().strip().split(" ")]
T = int(input().strip())

if V <= W:
    print("NO")
    sys.exit(0)

distance = abs(A - B)
diff = abs(V - W)

t, distance = divmod(df, diff)
if t > T:
    print("NO")
    sys.exit(0)
if distance == 0:
    print("YES")
    sys.exit(0)

distance = abs(distance - V - W)
T -= t
t, distance = divmod(df, diff)
if distance == 0 and t <= T:
    print("YES")
    sys.exit(0)
print("NO")
sys.exit(0)
Problem p02732 (python)

Fixed submission:
from functools import lru_cache

N = int(input().strip())
A = [int(v) for v in input().strip().split()]
C = {}


@lru_cache(maxsize=None)
def pair(k):
    return k * (k - 1) // 2

@lru_cache(maxsize=None)
def calc(s, a):
    return s - pair(C[a]) + pair(C[a] - 1)

for a in A:
    C.setdefault(a, 0)
    C[a] += 1

S = sum([pair(v) for v in C.values()])

for a in A:
    print(calc(S, a))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

N = int(input().strip())
A = [int(v) for v in input().strip().split()]
C = {}


@lru_cache
def calc(a):
    C[a] -= 1
    sum_ = sum([n * (n - 1) // 2 for n in C.values() if n > 1])
    C[a] += 1
    return sum_

for a in A:
    C.setdefault(a, 0)
    C[a] += 1

for i, a in enumerate(A):
    print(calc(a))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

N = int(input().strip())
A = [int(v) for v in input().strip().split()]
C = {}
S = {}


@lru_cache
def calc(C, a):
    C[a] -= 1
    sum_ = sum([S[n] for n in C.values() if n > 1])
    C[a] += 1
    return sum_

for a in A:
    C.setdefault(a, 0)
    C[a] += 1


for i, a in enumerate(A):
    print(calc(C, a))

Buggy submission (verdict: Runtime Error):
N = int(input().strip())
A = [int(v) for v in input().strip().split()]
C = {}
S = {}

for a in A:
    C.setdefault(a, 0)
    C[a] += 1

for c in C.values():
    if c < 1:
        continue
    C.setdefault(c, c * (c - 1) // 2)
    if c < 2:
        continue
    C.setdefault(c - 1, c * (c - 1) // 2)

for i, a in enumerate(A):
    C[a] -= 1
    sum_ = sum([S[n] for n in C.values() if n > 1])
    C[a] += 1
    print(sum_)
Problem p03006 (python)

Fixed submission:

def solve2():
    N = int(raw_input())
    xy = [None] * N
    for i in range(N):
        xi, yi = [int(_) for _ in raw_input().split()]
        xy[i] = (xi, yi)
    if N == 1:
        print N
        return
    xy.sort()
    dist = []
    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]
            dist.append((p,q))
    dist.sort()
    max_cnt = 0
    cnt = 1
    save = dist[0]
    for i in range(1, len(dist)):
        if dist[i] == save:
            cnt += 1
        else:
            max_cnt = max(cnt, max_cnt)
            cnt = 1
            save = dist[i]
    max_cnt = max(cnt, max_cnt)
    print N - max_cnt

if __name__ == '__main__':
    solve2()

Buggy submission (verdict: Runtime Error):
def solve2():
    N = int(raw_input())
    xy = [None] * N
    for i in range(N):
        xi, yi = [int(_) for _ in raw_input().split()]
        xy[i] = (xi, yi)
    xy.sort()
    dist = []
    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]
            dist.append((p,q))
    dist.sort()
    max_cnt = 0
    cnt = 1
    save = dist[0]
    for i in range(1, len(dist)):
        if dist[i] == save:
            cnt += 1
        else:
            max_cnt = max(cnt, max_cnt)
            cnt = 1
            save = dist[i]
    max_cnt = max(cnt, max_cnt)
    print N - max_cnt

if __name__ == '__main__':
    solve2()