Problem p03576 (python)

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
dots = XY[:]

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            if ans > area:
                ans = area
            
print(ans)

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

XY = [tuple(map(int,input().split())) for i in range(N)]

dots = XY[:]

import sys
INT_MAX = sys.maxsize


def sub_f(x):
    right_x, left_x = x[0], x[1]
    ans = INT_MAX
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1

        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            ans = min(ans, area)
    return ans

import itertools
multiprocessing_inputs = []
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    
    multiprocessing_inputs.append((right_x, left_x))
    #ans_list.append(sub_f(right_x, left_x))


from multiprocessing import Pool
with Pool(5) as p:
    ans_list = p.map(sub_f, multiprocessing_inputs)

ans = min(ans_list)
print(ans)

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
    
import numpy as np
dots = np.asarray(XY[:])

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            if ans > area:
                ans = area
            
print(ans)

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

XY = []
for _ in range(N):
    x, y = map(int, input().spålit())
    XY.append((x, y))
    

dots = XY[:]

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for left_d, right_d in itertools.permutations(dots, 2):
    if left_d[0] < right_d[0]:
        left_x = left_d[0]
        right_x = right_d[0]
    else:
        left_x = right_d[0]
        right_x =  left_d[0]
    
    for under_d, top_d in itertools.permutations(dots, 2):
        c += 1
        if under_d[1] < top_d[1]:
            under_y = under_d[1]
            top_y = top_d[1]
        else:
            under_y = top_d[1]
            top_y = under_d[1]
            
        counter = 0
        for d in dots:
            if  (left_x <= d[0]) and (d[0] <= right_x) and (under_y <= d[1]) and (d[1] <= top_y):
                counter += 1
            if counter >= K:
                break
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            ans = min(ans, area)
            
print(ans)

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    

dots = XY[:]

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for left_d, right_d in itertools.permutations(dots, 2):
    if left_d[0] < right_d[0]:
        left_x = left_d[0]
        right_x = right_d[0]
    else:
        left_x = right_d[0]
        right_x =  left_d[0]
    
    for under_d, top_d in itertools.permutations(dots, 2):
        c += 1
        if under_d[1] < top_d[1]:
            under_y = under_d[1]
            top_y = top_d[1]
        else:
            under_y = top_d[1]
            top_y = under_d[1]
            
        counter = 0
        for d in dots:
            if  (left_x <= d[0]) and (d[0] <= right_x) and (under_y <= d[1]) and (d[1] <= top_y):
                counter += 1
                if counter >= K:
                    break
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            ans = min(ans, area)
            
print(ans)

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    

dots = XY[:]

import sys
INT_MAX = sys.maxsize

x_dots = [(x, y) for x, y in dots]
x_dots = sorted(x_dots)
y_dots = [(x, y) for x, y in dots]
y_dots = sorted(y_dots, key=lambda x: x[1])

ans = INT_MAX
for l in range(N):
    for r in range(l+1, N+1):
        for u in range(N):
            for t in range(u+1, N+1):
                xy_dots =  set(x_dots[l:r]) & set(y_dots[u:t])
                if len(xy_dots) >= K:
                    #print("---")
                    #print(l, r, x_dots[l:r])
                    #print(u, t, y_dots[u:t])
                    l = x_dots[l:r][0][0]
                    r = x_dots[l:r][-1][0]
                    u = y_dots[u:t][0][1]
                    t = y_dots[u:t][-1][1]
                    #print((r-l)*(t-u))
                    ans = min(ans, (r-l)*(t-u))
print(ans)


#y_dots = sorted(y_dots, key=lambda x: x[1])
#ans = INT_MAX

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    

dots = XY[:]

import sys
INT_MAX = sys.maxsize

x_dots = [(x, y) for x, y in dots]
x_dots = sorted(x_dots)
y_dots = [(x, y) for x, y in dots]
y_dots = sorted(x_dots, key=lambda x: x[1])

ans = INT_MAX
for l in range(N):
    for r in range(l+1, N+1):
        for u in range(N):
            for t in range(u+1, N+1):
                xy_dots =  set(x_dots[l:r]) & set(y_dots[u:t])
                if len(xy_dots) >= K:
                    #print("---")
                    #print(l, r, x_dots[l:r])
                    #print(u, t, y_dots[u:t])
                    l = x_dots[l:r][0][0]
                    r = x_dots[l:r][-1][0]
                    u = y_dots[u:t][0][1]
                    t = y_dots[u:t][-1][1]
                    #print((r-l)*(t-u))
                    ans = min(ans, (r-l)*(t-u))
print(ans)


#y_dots = sorted(y_dots, key=lambda x: x[1])
#ans = INT_MAX

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))

if name == 'main':
    dots = XY[:]

    import sys
    INT_MAX = sys.maxsize

    x_dots = [(x, y) for x, y in dots]
    x_dots = sorted(x_dots)
    y_dots = [(x, y) for x, y in dots]
    y_dots = sorted(y_dots, key=lambda x: x[1])

    ans = INT_MAX
    for i in range(N):
        for j in range(i+1, N):
            sub_x_dots = set(x_dots[i:j+1])
            xl = x_dots[i:j+1][0][0]
            xr = x_dots[i:j+1][-1][0]
            for k in range(N):
                for l in range(k+1, N):
                    sub_y_dots = set(y_dots[k:l+1])
                    #print("----")
                    #print(x_dots[i:j+1])
                    #print(y_dots[k:l+1])
                    intersection = sub_x_dots & sub_y_dots
                    if len(intersection) >= K:
                        yl = y_dots[k:l+1][0][1]
                        yr = y_dots[k:l+1][-1][1]
                        area = (xl-xr) * (yl-yr)

                        ans = min(ans, area)
    print(ans)

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
if name == 'main':
    dots = XY[:]

    import sys
    INT_MAX = sys.maxsize

    x_dots = [(x, y) for x, y in dots]
    x_dots = sorted(x_dots)
    y_dots = [(x, y) for x, y in dots]
    y_dots = sorted(y_dots, key=lambda x: x[1])

    ans = INT_MAX
    for i in range(N):
        for j in range(i+1, N):
            sub_x_dots = set(x_dots[i:j+1])
            xl = x_dots[i:j+1][0][0]
            xr = x_dots[i:j+1][-1][0]
            for k in range(N):
                for l in range(k+1, N):
                    sub_y_dots = set(y_dots[k:l+1])
                    #print("----")
                    #print(x_dots[i:j+1])
                    #print(y_dots[k:l+1])
                    intersection = sub_x_dots & sub_y_dots
                    if len(intersection) >= K:
                        yl = y_dots[k:l+1][0][1]
                        yr = y_dots[k:l+1][-1][1]
                        area = (xl-xr) * (yl-yr)

                        ans = min(ans, area)
    print(ans)