Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A =list(map(int, input().split()))
k = bin(K)[2:]

def add_zero(text):
    if len(text) < len(k):
        mozi = ""
        for i in range(len(k) - len(text)):
            mozi += "0"
        return mozi + text
    else:
        return text

B = [bin(i)[2:] for i in A ]
B = list(map(add_zero, B))

ans_li = []
for index, i in enumerate(k):
    if i == "1":
        str = ""
        for j in range(len(k)-index-1):
            count = 0
            for l in B:
                if l[-j-1] == "1":
                    count += 1
            if count > len(B) - count:
                str = "0" + str
            else:
                str = "1" + str
        ans_li.append(k[:index] + "0" + str)

ans_li.append(k)
ans_li2 = [int("0b"+i, 2) for i in ans_li]
max_score = 0
for i in ans_li2:
    score = 0
    for j in A:
        score += i^j
    max_score = max(score, max_score)

print(max_score)

Fixed submission:
N, K = map(int, input().split())
A =list(map(int, input().split()))
k = bin(K)[2:]

def add_zero(text):
    if len(text) < len(k):
        mozi = ""
        for i in range(len(k) - len(text)):
            mozi += "0"
        return mozi + text
    else:
        return text

B = [bin(i)[2:] for i in A ]
B = list(map(add_zero, B))

ans_li = []
for index, i in enumerate(k):
    if i == "1":
        str = ""
        for j in range(len(k)-index-1):
            count = 0
            for l in B:
                if l[-j-1] == "1":
                    count += 1
            if count > len(B) - count:
                str = "0" + str
            else:
                str = "1" + str
        ans_li.append(k[:index] + "0" + str)

ans_li.append(k)
ans_li2 = [int("0b"+i, 2) for i in ans_li]
max_score = 0
for i in ans_li2:
    score = 0
    for j in A:
        score += i^j
    max_score = max(score, max_score)

print(max_score)
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split()))

ans = 0
while max(h):
    current_hight = 0
    for i in range(len(h)):
        if not h[i]:
            if not current_hight:
                continue
            else:
                break
        elif h[i] < current_hight:
            break
        else:
            current_hight = h[i]
            h[i] -= 1
    ans += 1
    if ans == 75:

print(ans)

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

ans = 0
while max(h):
    current_hight = 0
    for i in range(len(h)):
        if not h[i]:
            if not current_hight:
                continue
            else:
                break
        elif h[i] < current_hight:
            break
        else:
            current_hight = h[i]
            h[i] -= 1
    ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

h += [float("inf")] * (K)
dp = [float("inf")] * (N+K)
dp[0] = 0
for i in range(N):
    for j in range(K):
        dp[i+j+1] = min(dp[i+j+1], dp[i]+abs(h[i] - h[i+j+1]))


print(dp[N-1])

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

h += [float("inf")] * (K)
dp = [float("inf")] * (N+K)
dp[0] = 0
for i in range(N):
    for j in range(K):
        dp[i+j+1] = min(dp[i+j+1], dp[i]+abs(h[i] - h[i+j+1]))


print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf")] * (N+K)
dp[0] = 0
for i in range(N):
    for j in range(K):
        if i+j+1 > N-1:
            break
        else:
            dp[i+j+1] = min(dp[i+j+1], dp[i]+abs(h[i] - h[i+j+1]))


print(dp[N-1])

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

h += [float("inf")] * (K)
dp = [float("inf")] * (N+K)
dp[0] = 0
for i in range(N):
    for j in range(K):
        dp[i+j+1] = min(dp[i+j+1], dp[i]+abs(h[i] - h[i+j+1]))


print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = {}
dp[0] = 0

for i in range(1, N):
    min_cost = float("inf")
    for j in range(K):
        if i - j - 1 < 0:
            break
        else:
            min_cost = min(min_cost, abs(h[i - j - 1]-h[i]) + dp[i - j - 1])
    
    dp[i] = min_cost

print(dp[N - 1])

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

h += [float("inf")] * (K)
dp = [float("inf")] * (N+K)
dp[0] = 0
for i in range(N):
    for j in range(K):
        dp[i+j+1] = min(dp[i+j+1], dp[i]+abs(h[i] - h[i+j+1]))


print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
A, N = map(int, input().split())
if (A < 9) and (B < 9):
    print("Yay!")
else:
    print(":(")


Fixed submission:
A, B = map(int, input().split())
if (A < 9) and (B < 9):
    print("Yay!")
else:
    print(":(")

Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
if (A < 9) and (B < 9):
    print("Yay!")
else:
    print(":(")


Fixed submission:
A, B = map(int, input().split())
if (A < 9) and (B < 9):
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
a,b,c,d = list(map(int, input().split()))

if abs(a - c) <= d:
    print("Yes")

elif abs(a-b) <= d and ans(b-c) <= d:
    print("Yes")

else:
    print("No")


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

if abs(a - c) <= d:
    print("Yes")

elif abs(a-b) <= d and abs(b-c) <= d:
    print("Yes")

else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(int(input()) for k in range(N))

mx, mxn = sorted(A, reverse=True)[:2]

result = [mxn if x==mn else mx for x in A]
print('\n'.join(map(str, result)))

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

sort = sorted(A, reverse=True)
mx = sort[0]
mxn = sort[1]

for i in range(N):
    if A[i] == mx:
        print(mxn)
    else:
        print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    a = input()
    s.append(a)

def sort_list(st):
    arr = []
    freq = []
    for moji in st:
        exist_in_st = False
        for i in range(len(arr)):
            if moji == arr[i]:
                freq[i] += 1
                exist_in_st = True
        if exist_in_st == False:
            arr.append(moji)
            freq.append(1)
    ans = []
    for st, num in zip(arr, freq):
        ans.append([st,num])
    ans.sort(key=lambda x:x[0])
    return  ans

def compare_lists(li1, li2):
    if len(li1) != len(li2):
        return False
    if len(li1) == len(li2):        
        for a1, a2 in zip(li1, li2):
            if  a1 != a2:
                return False
    return True

sts = []
nums = []
for new_st in s:
    new_st = sort_list(new_st)
    exist_in_sts = False
    for i in range(len(sts)):
        if (new_st == sts[i]):
            nums[i] += 1
            exist_in_sts = True
    if exist_in_sts == False:
        sts.append(new_st)
        nums.append(1)

ans = sum([int(x * (x - 1) / 2) for x in nums])
print(ans)

Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(input())

dictS = {}
for new_st in s:
    new_st = "".join(sorted([x for x in new_st]))
    if new_st in dictS:
        dictS[new_st] += 1
    else:
        dictS[new_st] = 1

ans = sum([int(x * (x - 1) / 2) for x in dictS.values()])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    a = input()
    s.append(a)

sts = []
nums = []
for new_st in s:
    new_st = sorted([x for x in new_st])
    exist_in_sts = False
    for i in range(len(sts)):
        if (new_st == sts[i]):
            nums[i] += 1
            exist_in_sts = True
    if exist_in_sts == False:
        sts.append(new_st)
        nums.append(1)

print(sum([int(x * (x - 1) / 2) for x in nums]))

Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(input())

dictS = {}
for new_st in s:
    new_st = "".join(sorted([x for x in new_st]))
    if new_st in dictS:
        dictS[new_st] += 1
    else:
        dictS[new_st] = 1

ans = sum([int(x * (x - 1) / 2) for x in dictS.values()])
print(ans)
Buggy python submission (verdict: Runtime Error):
S = int(input())
# S = "SASA"
arr = []
for s in S:
    arr.append(s)
if (arr[0] == arr[1]):
    if (arr[2] == arr[3]):
        ans = "Yes"
    else:
        ans = "No"
else:
    if (arr.count(arr[0]) == 2 and arr.count(arr[1]) == 2):
        ans = "Yes"
    else:
        ans = "No"

print(ans)



Fixed submission:
S = input()
arr = []
for s in S:
    arr.append(s)
if (arr[0] == arr[1]):
    if (arr[0] != arr[2] and arr[2] == arr[3]):
        ans = "Yes"
    else:
        ans = "No"
else:
    if (arr.count(arr[0]) == 2 and arr.count(arr[1]) == 2):
        ans = "Yes"
    else:
        ans = "No"

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = [int(_) for _ in input().split()]

import math
def dvi_num(b, c):
    return math.floor(b / c)

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

def dvi_num2(b, c, d):
    return b - dvi_num(b,c) - dvi_num(b,d) + dvi_num(b, lcm(c, d))

ans = dvi_num2(B, C, D) - dvi_num2(A - 1, C, D)

print(ans)

Fixed submission:
A, B, C, D = [int(_) for _ in input().split()]

def gcd(a,b):
    while b != 0:
        a, b = b, a%b
    return a

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

def dvi_num2(b, c, d):
    return b - b // c - b //d + b // lcm(c, d)

ans = dvi_num2(B, C, D) - dvi_num2(A - 1, C, D)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
A, B, C, D = [int(_) for _ in input().split()]

import math
def dvi_num(b, c):
    return math.floor(b / c)

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

def dvi_num2(b, c, d):
    return b - dvi_num(b,c) - dvi_num(b,d) + dvi_num(b, lcm(c, d))

ans = dvi_num2(B, C, D) - dvi_num2(A - 1, C, D)
print([dvi_num2(B, C, D), dvi_num2(A - 1, C, D)])

print(ans)

Fixed submission:
A, B, C, D = [int(_) for _ in input().split()]

def gcd(a,b):
    while b != 0:
        a, b = b, a%b
    return a

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

def dvi_num2(b, c, d):
    return b - b // c - b //d + b // lcm(c, d)

ans = dvi_num2(B, C, D) - dvi_num2(A - 1, C, D)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N = list(input())
m = list(map(int,N))
a = 10*m[0] + m[1]
b = 10*m[2] + m[3]
 
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")
N = list(input())
m = list(map(int,N))
a = 10*m[0] + m[1]
b = 10*m[2] + m[3]
 
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")

Fixed submission:
N = list(input())
m = list(map(int,N))
a = 10*m[0] + m[1]
b = 10*m[2] + m[3]
 
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
ans = [0] * n
for i in range(n):
    t = 0
    p = i
    c = s[p]
    while c == s[p]:
        p += 1 if c == 'R' else -1
        t += 1
    if t % 2 == 1:
        p -= 1 if c == 'R' else -1
    ans[p] += 1
print(' '.join([str(x) for x in ans]))

Fixed submission:
import math
s = input()
n = len(s)
ans = [0] * n
i = 0
while i < n:
    r = 0
    while s[i] == 'R':
        r += 1
        i += 1
    ans[i-1] += math.ceil(r / 2)
    ans[i] += math.floor(r / 2)
    l = 0
    while i < n and s[i] == 'L':
        l += 1
        i += 1
    ans[i-l-1] += math.floor(l / 2)
    ans[i-l] += math.ceil(l / 2)
print(' '.join([str(x) for x in ans]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
k = n if n % 2 == 0 else n + 1
ans = [0] * n
for i in range(n):
    p = i
    for _ in range(k):
        if s[p] == 'R':
            p += 1
        else:
            p -= 1
    ans[p] += 1
print(' '.join([str(x) for x in ans]))

Fixed submission:
import math
s = input()
n = len(s)
ans = [0] * n
i = 0
while i < n:
    r = 0
    while s[i] == 'R':
        r += 1
        i += 1
    ans[i-1] += math.ceil(r / 2)
    ans[i] += math.floor(r / 2)
    l = 0
    while i < n and s[i] == 'L':
        l += 1
        i += 1
    ans[i-l-1] += math.floor(l / 2)
    ans[i-l] += math.ceil(l / 2)
print(' '.join([str(x) for x in ans]))
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
s = [input() for _ in range(h)]

l = [[0 for _ in range(w)] for _ in range(h)]
r = [[0 for _ in range(w)] for _ in range(h)]
u = [[0 for _ in range(w)] for _ in range(h)]
d = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w):
        l[i][j] = 0 if s[i][j] == '#' else (1 if j == 0 else l[i][j-1] + 1)
    for j in range(w-1, -1, -1):
        r[i][j] = 0 if s[i][j] == '#' else (1 if j == w-1 else r[i][j+1] + 1)
for j in range(w):
    for i in range(h):
        u[i][j] = 0 if s[i][j] == '#' else (1 if i == 0 else u[i-1][j] + 1)
    for i in range(h-1, -1, -1):
        d[i][j] = 0 if s[i][j] == '#' else (1 if i == h-1 else d[i+1][j] + 1)

m = 0
for i in range(h):
    for j in range(w):
        k = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
        if k > m:
            m = k

print(m)

Fixed submission:
h, w = map(int, input().split())
s = [input() for _ in range(h)]

l = [[0 for _ in range(w)] for _ in range(h)]
r = [[0 for _ in range(w)] for _ in range(h)]
u = [[0 for _ in range(w)] for _ in range(h)]
d = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w):
        l[i][j] = 0 if s[i][j] == '#' else (1 if j == 0 else l[i][j-1] + 1)
    for j in range(w-1, -1, -1):
        r[i][j] = 0 if s[i][j] == '#' else (1 if j == w-1 else r[i][j+1] + 1)
for j in range(w):
    for i in range(h):
        u[i][j] = 0 if s[i][j] == '#' else (1 if i == 0 else u[i-1][j] + 1)
    for i in range(h-1, -1, -1):
        d[i][j] = 0 if s[i][j] == '#' else (1 if i == h-1 else d[i+1][j] + 1)

m = 0
for i in range(h):
    for j in range(w):
        k = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
        if k > m:
            m = k

print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
g = [0] * n
for i in range(m):
    l, r = map(int, input().split())
    for j in range(l-1, r):
        g[j] += 1
ans = 0
for i in range(n):
    if g[i] == m:
        ans += 1
print(ans)


Fixed submission:
n, m = map(int, input().split())
a = 1
b = n
for i in range(m):
    l, r = map(int, input().split())
    if a < l:
        a = l
    if b > r:
        b = r
if a > b:
    print(0)
else:
    print(b - a + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
a = sorted(a)
d = []
for i in range(m):
    b, c = map(int, input().split())
    d.extend([c] * b)
d = sorted(d)
k = d.pop()
for i in range(n):
    if k > a[i]:
        a[i] = k
        if len(d) == 0:
            break
        k = d.pop()
    else:
        break
print(sum(a))

Fixed submission:
n, m = map(int, input().split())
a = [[1, int(x)] for x in input().split()]
bc = [list(map(int, input().split())) for x in range(m)]
a.extend(bc)
a = sorted(a, key=lambda x: x[1], reverse=True)
d = []
ans = 0
cnt = 0
for x in a:
    if cnt > n:
        break
    k = x[0]
    if cnt + k > n:
        k = n - cnt
    ans += x[1] * k
    cnt += k
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = map(int, input().split())
q = []
for i in a:
    q.append(i)
for i in range(m):
    b, c = map(int, input().split())
    for j in range(b):
        q.append(c)
print(sum(sorted(q)[-n:]))


Fixed submission:
n, m = map(int, input().split())
a = [[1, int(x)] for x in input().split()]
bc = [list(map(int, input().split())) for x in range(m)]
a.extend(bc)
a = sorted(a, key=lambda x: x[1], reverse=True)
d = []
ans = 0
cnt = 0
for x in a:
    if cnt > n:
        break
    k = x[0]
    if cnt + k > n:
        k = n - cnt
    ans += x[1] * k
    cnt += k
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, nlargest
n, m = map(int, input().split())
a = map(int, input().split())
q = []
for i in a:
    heappush(q, i)
for i in range(m):
    b, c = map(int, input().split())
    for j in range(b):
        heappush(q, c)
print(sum(nlargest(n, q)))

Fixed submission:
n, m = map(int, input().split())
a = [[1, int(x)] for x in input().split()]
bc = [list(map(int, input().split())) for x in range(m)]
a.extend(bc)
a = sorted(a, key=lambda x: x[1], reverse=True)
d = []
ans = 0
cnt = 0
for x in a:
    if cnt > n:
        break
    k = x[0]
    if cnt + k > n:
        k = n - cnt
    ans += x[1] * k
    cnt += k
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd

n = int(input())
a = [int(i) for i in input().split()]

l = [0 for i in range(n)]
for i in range(1, n):
    l[i] = gcd(a[i-1], l[i-1])

r = [0 for i in range(n)]
for i in range(n-1)[::-1]:
    r[i] = gcd(a[i+1], r[i+1])

m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))


Fixed submission:
def gcd(a, b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a < b:
        return gcd(b, a)
    r = a % b
    return b if r == 0 else gcd(b, r)


n = int(input())
a = [int(i) for i in input().split()]

l = [0 for i in range(n)]
for i in range(1, n):
    l[i] = gcd(a[i-1], l[i-1])

r = [0 for i in range(n)]
for i in range(n-1)[::-1]:
    r[i] = gcd(a[i+1], r[i+1])

m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
import numpy as np

a = int(input())
a_list = []
b_list = []

for i in range(a):
  a_list.append(input())
a_list.append('null')

b = int(input())

for i in range(b):
  b_list.append(input())
a_count = Counter(a_list)
b_count = Counter(b_list)
a_list_no_overlap = set(a_list)
print(a_count)

point = []
for i in a_list_no_overlap:
    point.append(a_count[i]-b_count[i])

point_max = np.argmax(point)
print(point_max)


Fixed submission:
a, b, c= map(int, input().split())
if a+b<c:
  print("No")
else :
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N = input()
a = []
for i in range(N):
    a.append(input())
b = list(set(a))
If length(b) ==3 :
  print(3)
elso :
  print(4)

Fixed submission:
N = int(input())
Num_of_Group = int(N/3)
print(Num_of_Group)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
int s = a*b
if s%2==0:
  print('Even')
else:
  print('Odd')


Fixed submission:
a, b = map(int, input().split())
s = a*b
if s%2==0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from collections import defaultdict
n = int(input())
a = [0 for _ in range(n)]
for i in range(n):
    a[i] = int(input())


colors = defaultdict(int)
colors[a[0]] += 1
for num in a[1:]:
    for cnum in sorted(set(colors.keys()), reverse=True):
        if num > cnum:
            if colors[cnum] == 1:
                colors.pop(cnum)
            else:
                colors[cnum] -= 1
            break
    colors[num] += 1
print(sum(colors.values()))

Fixed submission:
# -*- coding: utf-8 -*-
import bisect

n = int(input())
a = [0 for _ in range(n)]
for i in range(n):
    a[i] = -int(input())


LIS = list()
for i in a:
    j = bisect.bisect_right(LIS, i)
    if len(LIS) == j:
        LIS.append(i)
    else:
        LIS[j] = i

print(len(LIS))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from collections import deque
n = int(input())
a = [0 for _ in range(n)]
for i in range(n):
    a[i] = int(input())


colors = deque()
colors.append(a[0])
for num in a[1:]:
    exchange = False
    for i in range(len(colors)):
        if num > colors[i]:
            colors[i] = num
            exchange = True
            break
    if not exchange:
        colors.append(num)
print(len(colors))

Fixed submission:
# -*- coding: utf-8 -*-
import bisect

n = int(input())
a = [0 for _ in range(n)]
for i in range(n):
    a[i] = -int(input())


LIS = list()
for i in a:
    j = bisect.bisect_right(LIS, i)
    if len(LIS) == j:
        LIS.append(i)
    else:
        LIS[j] = i

print(len(LIS))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
n, k = map(int, input().split())
k_max = int((n - 2) * (n - 1) / 2)
k_min =

if k > k_max:
    print(-1)
    sys.exit()

edges = list()

for i in range(2, n + 1):
    edges.append((1, i))

cnt = k_max
exit_flag = False
for i in range(2, n):
    for j in range(i + 1, n + 1):
        edges.append((i, j))
        cnt -= 1
        if cnt == k:
            exit_flag = True
            break
    if exit_flag:
        break

print(len(edges))
for u, v in edges:
    print(u, v)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
n, k = map(int, input().split())
k_max = (n - 2) * (n - 1) // 2

if k > k_max:
    print(-1)
    sys.exit()

m = n - 1 + k_max - k

print(m)
cnt = 0
exit_flag = False
for i in range(1, n):
    for j in range(i + 1, n + 1):
        print(i, j)
        cnt += 1
        if cnt == m:
            exit_flag = True
            break
    if exit_flag:
        break
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import defaultdict

n = int(input())
pairs = list()
patterns = defaultdict(int)

for _ in range(n):
    pairs.append(tuple((map(int, input().split()))))

for i in range(n):
    for j in range(n):
        if i != j:
            patterns[(pairs[i][0] - pairs[j][0], pairs[i][1] - pairs[j][1])] += 1

print(n - max(patterns.values()))

Fixed submission:
# -*- coding: utf-8 -*-
from collections import defaultdict

n = int(input())
pairs = list()
patterns = defaultdict(int)

for _ in range(n):
    pairs.append(tuple((map(int, input().split()))))

for i in range(n):
    for j in range(n):
        if i != j:
            patterns[(pairs[i][0] - pairs[j][0], pairs[i][1] - pairs[j][1])] += 1

ans = 1
if n > 1:
    ans = n - max(patterns.values())

print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import defaultdict

n = int(input())
patterns = defaultdict(int)

last_x, last_y = map(int, input().split())
for _ in range(1, n):
    x, y = map(int, input().split())
    diff_x = x - last_x
    diff_y = y - last_y
    last_x, last_y = x, y
    pattern = '{0}, {1}'.format(diff_x, diff_y)
    patterns[pattern] += 1

ans = n - max(patterns.values())

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
from collections import defaultdict

n = int(input())
pairs = list()
patterns = defaultdict(int)

for _ in range(n):
    pairs.append(tuple((map(int, input().split()))))

for i in range(n):
    for j in range(n):
        if i != j:
            patterns[(pairs[i][0] - pairs[j][0], pairs[i][1] - pairs[j][1])] += 1

ans = 1
if n > 1:
    ans = n - max(patterns.values())

print(ans)