Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x = I()
ans = (x // 500) * 1000
x %= 500
ans += x // 5 * 5
print(ans)

Fixed submission:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k,n = LI()
a = LI()
ans = a[-1] - a[0]
for i in range(1,n-1):
    ans = min(ans, a[i] + (k - a[i+1]))
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x, y, a, b, c = LI()
p = LI()
q = LI()
r = LI()

p.sort(reverse=1)
q.sort(reverse=1)
r.sort(reverse=1)
r = list(accumulate(r))
ans = 0
h = []
s = sum(p[:x])
s += sum(q[:y])
for i in p[:x]:
    heappush(h, i)
for i in q[:y]:
    heappush(h, i)
ans = s
for i in range(c):
    f = heappop(h)
    s -= f
    tmp = s + r[i]
    ans = max(ans, tmp)
print(ans)


Fixed submission:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x, y, a, b, c = LI()
p = LI()
q = LI()
r = LI()

p.sort(reverse=1)
q.sort(reverse=1)
r.sort(reverse=1)
r = list(accumulate(r))
ans = 0
h = []
s = sum(p[:x])
s += sum(q[:y])
for i in p[:x]:
    heappush(h, i)
for i in q[:y]:
    heappush(h, i)
ans = s
for i in range(c):
    if len(h) > 0:
        f = heappop(h)
    else:
        break
    s -= f
    tmp = s + r[i]
    ans = max(ans, tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = list(input())
q = I()
for _ in range(q):
    query = input().split()
    if query[0] == "1":
        s = s[::-1]
    else:
        if query[1] == "1":
            s = [query[2]] + s
        else:
            s.append(query[2])
ans = ''
for i in s:
    ans += i
print(ans)


Fixed submission:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = list(input())
q = I()
front = []
back = []
cnt = 0
for _ in range(q):
    query = input().split()
    if query[0] == "1":
        cnt += 1
    else:
        if query[1] == "1":
            if cnt % 2 == 0:
                front.append(query[2])
            else:
                back.append(query[2])
        else:
            if cnt % 2 == 0:
                back.append(query[2])
            else:
                front.append(query[2])

if cnt % 2 == 0:
    print(''.join(front[::-1])+''.join(s)+''.join(back))
else:
    print(''.join(back[::-1])+''.join(s[::-1])+''.join(front))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
c = LI()
c.sort(reverse=True)
dp = [0]*n
dp[0] = c[0]
p = 1
for i in range(n-1):
    dp[i+1] = (2*dp[i] + p*(2+i+1)*c[i+1]) % mod
    p *= 2
print(dp[-1]*(2*p) % mod)

Fixed submission:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
S,T
"""

n = I()
c = LI()
c.sort(reverse=True)
dp = [0]*n
dp[0] = c[0]
p = 1
for i in range(n-1):
    dp[i+1] = (2*dp[i] + p*(2+i+1)*c[i+1]) % mod
    p *= 2
    p %= mod
p *= 2
p %= mod
print(dp[-1]*p % mod)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
c = LI()
c.sort(reverse=True)
dp = [0]*n
dp[0] = c[0]
p = 1
for i in range(n-1):
    dp[i+1] = (2*dp[i] + p*(2+i+1)*c[i+1]) % mod
    p *= 2
print(dp[-1]*(2**n) % mod)

Fixed submission:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
S,T
"""

n = I()
c = LI()
c.sort(reverse=True)
dp = [0]*n
dp[0] = c[0]
p = 1
for i in range(n-1):
    dp[i+1] = (2*dp[i] + p*(2+i+1)*c[i+1]) % mod
    p *= 2
    p %= mod
p *= 2
p %= mod
print(dp[-1]*p % mod)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

lst = get_sieve_of_eratosthenes(10**6+1)
x = I()
for i in lst:
    if x <= i:
        print(i)
        quit()


Fixed submission:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

lst = get_sieve_of_eratosthenes(2*10**5)
x = I()
for i in lst:
    if x <= i:
        print(i)
        quit()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#AGC39 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
k = I()
n = len(s)
res = 0
i = 0
flg,flg2 = False,False
if s[i] == s[-1]:
    flg = True
while i < n:
    tmp = s[i]
    i += 1
    cnt = 1
    while i < n and tmp == s[i]:
        cnt += 1
        i += 1
    res += cnt//2
if s[-1] != s[-2]:
    flg2 = True 
print((res+(flg and flg2))*k)

Fixed submission:
#!/usr/bin/env python3
#AGC39 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
k = I()
n = len(s)
res = 0
i = 0
lst = deque()
while i < n:
    tmp = s[i]
    i += 1
    cnt = 1
    while i < n and tmp == s[i]:
        cnt += 1
        i += 1
    lst.append(cnt)
if len(lst) >= 2:
    if s[0] == s[-1] and k >= 2:
        x = lst.popleft()
        y = lst.pop()
        res = 0
        for i in lst:
            res += (i//2)*k
        res += (x//2) + (y//2)
        res += ((x+y)//2)*(k-1)
        print(res)
    else:
        res = 0
        for i in lst:
            res += (i//2)*k
        print(res)
else:
    print((n*k)//2)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#AGC37 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop,heapify
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
b = LI()
h = []
for i,v in enumerate(b):
    heappush(h,(-v,i))
ans = 0
while h:
    v,i = heappop(h)
    v = -v
    tmp = b[(i+1) % n] + b[i-1]
    if v == a[i]:
        continue
    s = (v - a[i])//tmp

    if s <= 0:
        print(-1)
        quit()

    ans += s
    v -= s*tmp
    b[i] = v
    if v != a[i]:
        heappush(h,(-v,i))
print(ans)


Fixed submission:
#!/usr/bin/env python3
#AGC37 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop,heapify
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
b = LI()
h = []
V = [0]*n
for i,v in enumerate(b):
    heappush(h,(-v,i))
    V[i] = v
ans = 0
while h:
    v,i = heappop(h)
    v = -v
    tmp = V[(i+1) % n] + V[i-1]
    if v == a[i]:
        continue
    s = (v - a[i])//tmp

    if s <= 0:
        print(-1)
        quit()

    ans += s
    v -= s*tmp
    V[i] = v
    if v != a[i]:
        heappush(h,(-v,i))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC136 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

s = input()
n = len(s)
x = []
for i in range(n-1):
    if s[i] == 'R' and s[i+1] == 'L':
        x.append(i)

ans = [0]*n
for i in range(n):
    if s[i] == 'R':
        for j in x:
            if j >= i:
                tmp = j
                break
        #print((10**100 - (tmp-i)) % 2)
        ans[(10**100 - (tmp-i)) % 2 + tmp] += 1
    else:
        for j in x[::-1]:
            if j <= i:
                tmp = j
                break
        #print((10**100 - (i-tmp+1)) % 2)
        ans[(10**100 - (i-tmp)) % 2 + tmp] += 1
print(*ans)


Fixed submission:
#!/usr/bin/env python3
#ABC136 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

s = input()
n = len(s)
x = []
for i in range(n-1):
    if s[i] == 'R' and s[i+1] == 'L':
        x.append(i)

ans = [0]*n
for i in range(n):
    if s[i] == 'R':
        tmp = bisect.bisect_left(x,i)
        tmp = x[tmp]
        #print((10**100 - (tmp-i)) % 2)
        ans[(10**100 - (tmp-i)) % 2 + tmp] += 1
    else:
        tmp = bisect.bisect_right(x,i)
        tmp = x[tmp-1]
        #print((10**100 - (i-tmp+1)) % 2)
        ans[(10**100 - (i-tmp)) % 2 + tmp] += 1
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
a = [int(input()) for _ in range(n)]
dp = [0]*n
ans = 0
for i in range(n):
    dp[i] = 1
    for j in range(i):
        if -a[j] <= -a[i]:
            dp[i] = max(dp[i],dp[j]+1)
    ans = max(ans,dp[i])
print(ans)


Fixed submission:
#!/usr/bin/env python3
#ABC134 E

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())
a = [int(input()) for _ in range(n)]
m = []
for i in range(n):
    r = bisect.bisect_right(m,-a[i])
    if r == len(m):
        m.append(-a[i])
    else:
        m[r] = -a[i]
print(len(m))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC134 E

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())
a = [int(input()) for _ in range(n)]
x = [False]*(n)
ans = 0
for i in range(n):
    if x[i] == False:
        ans += 1
        x[i] = True
    for j in range(i+1,n):
        if a[i] < a[j] and x[j] == False:
            x[j] = True

print(ans)


Fixed submission:
#!/usr/bin/env python3
#ABC134 E

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())
a = [int(input()) for _ in range(n)]
m = []
for i in range(n):
    r = bisect.bisect_right(m,-a[i])
    if r == len(m):
        m.append(-a[i])
    else:
        m[r] = -a[i]
print(len(m))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC132 C

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

ans = 0
for i in range(min(d),max(d)):
    s = 0
    t = 0
    for j in range(N):
        if d[j] <= i:
            s += 1
        else:
            t += 1
        if s > N//2:
            break
        if t > N//2:
            break
    if s == t:
        ans += 1
print(ans)


Fixed submission:
#!/usr/bin/env python3
#ABC132 C
import sys
sys.setrecursionlimit(1000000)
from collections import deque

N = int(input())
d = list(map(int,input().split()))
d.sort()
if N % 2 == 0:
    print(d[N//2]-d[N//2-1])
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#ABC132 D
import sys
sys.setrecursionlimit(1000000)
from collections import deque

inf = 10**9+7
N,K = map(int,input().split())

fact = [1]*10000
for i in range(1,10000):
    fact[i] = fact[i-1]*i

for i in range(1,K+1):
    if N - K + 1 < i:
        print(0)
    else:
        ans = (fact[N-K+1]/(fact[i]*fact[N-K-i+1])) % inf
        ans *= (fact[K-1]/(fact[i-1]*fact[K-i])) % inf
        print(int(ans))


Fixed submission:
#!/usr/bin/env python3
#ABC132 D
import sys
sys.setrecursionlimit(1000000)
from collections import deque

inf = 10**9+7
N,K = map(int,input().split())

fact = [1]*10000
for i in range(1,10000):
    fact[i] = fact[i-1]*i

for i in range(1,K+1):
    if N - K + 1 < i:
        print(0)
    else:
        ans = (fact[N-K+1]//fact[i]//fact[N-K-i+1])
        ans *= (fact[K-1]//fact[i-1]//fact[K-i])
        print(ans%inf)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#ABC132 D
import sys
sys.setrecursionlimit(1000000)
from collections import deque

inf = 10**9+7
N,K = map(int,input().split())

def fact(n):
    if n == 0:
        return 1
    return n*fact(n-1)

for i in range(1,K+1):
    if N - K + 1 < i:
        print(0)
    else:
        ans = (fact(N-K+1)/(fact(i)*fact(N-K-i+1)))*(fact(K-1)/(fact(i-1)*fact(K-i)))
        print(int(ans%inf))


Fixed submission:
#!/usr/bin/env python3
#ABC132 D
import sys
sys.setrecursionlimit(1000000)
from collections import deque

inf = 10**9+7
N,K = map(int,input().split())

fact = [1]*10000
for i in range(1,10000):
    fact[i] = fact[i-1]*i

for i in range(1,K+1):
    if N - K + 1 < i:
        print(0)
    else:
        ans = (fact[N-K+1]//fact[i]//fact[N-K-i+1])
        ans *= (fact[K-1]//fact[i-1]//fact[K-i])
        print(ans%inf)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#ABC132 D
import sys
sys.setrecursionlimit(1000000)
from collections import deque

inf = 10**9+7
N,K = map(int,input().split())

def fact(n):
    if n == 0:
        return 1
    return n*fact(n-1)

for i in range(1,K+1):
    ans = (fact(N-K+1)/(fact(i)*fact(N-K-i+1)))*(fact(K-1)/(fact(i-1)*fact(K-i)))
    print(int(ans%inf))


Fixed submission:
#!/usr/bin/env python3
#ABC132 D
import sys
sys.setrecursionlimit(1000000)
from collections import deque

inf = 10**9+7
N,K = map(int,input().split())

fact = [1]*10000
for i in range(1,10000):
    fact[i] = fact[i-1]*i

for i in range(1,K+1):
    if N - K + 1 < i:
        print(0)
    else:
        ans = (fact[N-K+1]//fact[i]//fact[N-K-i+1])
        ans *= (fact[K-1]//fact[i-1]//fact[K-i])
        print(ans%inf)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#ABC131 E
import sys
import math
import networkx as nx

N, K = map(int,input().split())

if K > (N - 1)*(N - 2) // 2:
    print(-1)
    exit()

print((N - 1)*(N - 2) // 2 + (N - 1) - K)
for i in range(N - 1):
    print(1,i+2)
k = 2
for i in range(N,2,-1):
    if (i - 1)*(i - 2)//2 == K:
        break
    for j in range(k,N):
        print(k,j+1)
    k += 1

Fixed submission:
#!/usr/bin/env python3
#ABC131 E
import sys
import math

N, K = map(int,input().split())

if K > (N - 1)*(N - 2) // 2:
    print(-1)
    exit()

print((N - 1)*(N - 2) // 2 + (N - 1) - K)
for i in range(N - 1):
    print(1,i+2)
s = 2
t = 3
for i in range((N - 1)*(N - 2) // 2 - K):
    print(s,t)
    t += 1
    if t > N:
        s += 1
        t = s + 1
Buggy python submission (verdict: Runtime Error):
N = int(input())

a = [list(map(int,input().split())) for _ in range(N)]
def count(a1,a2,n,a):
    count = [0 for i in range(len(a) - n)]
    #print(count)
    x1 = a1[0]
    y1 = a1[1]
    x2 = a2[0]
    y2 = a2[1]
    if x1 != x2:
        #print(1)
        for j in range(len(a)-n):
            #print(a[j][1] - ((y1 - y2)/(x1 - x2))*(a[j][0] - x1) - y1)
            if (a[j][1] - ((y1 - y2)/(x1 - x2))*(a[j][0] - x1) - y1) == 0:
                count[j] += 1
    else:
        for j in range(n,len(a)):
            if a[j][0] == x1:
                count[j] += 1
    if len(count) != 0:
        return max(count)
    else:
        return 0
if N == 1 or N == 2:
    print(1)
    exit()
ans = []
for i in range(N):
    for j in range(i+1,N):
        ans.append(count(a[i],a[j],j+1,a))
        #print(count(a[i],a[j],j+1,a))
print(int(N//2) + 1 - max(ans))

Fixed submission:
#!/usr/bin/env python3
#diverta B

import sys

def main():
	N = int(input())
	xy = []
	for i in range(N):
		x, y = map(int, input().split(" "))
		xy.append((x, y))

	if N == 1:
		print(1)
		sys.exit()

	re = {}
	for i, val in enumerate(xy):
		x, y = val
		for j, vol in enumerate(xy):
			if i == j:
				continue
			nx, ny = vol
			p = nx - x
			q = ny -y
			if (p, q) in re:
				re[(p, q)] += 1
			else:
				re[(p, q)] = 1


	ans = N - max(re.values())

	print(ans)


if __name__ == "__main__":
	main()