Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
XY = [ [int(j) for j in input().split()] for _ in range(N)]

xlst = []
ylst = []

for x,y in XY:
    x += 10**9 + 1
    y += 10**9 + 1
    xlst.append(x)
    ylst.append(y)

xset = sorted(list(set(xlst)))
yset = sorted(list(set(ylst)))

# print(xset, yset)

S = [ [0]*(N+1) for _ in range(N+1)]

for x,y in zip(xlst,ylst):
    x=xset.index(x)+1
    y=yset.index(y)+1
    S[y][x] = 1

for y in range(N+1):
    for x in range(1, N+1):
        S[y][x] += S[y][x-1]
for x in range(N+1):
    for y in range(1,N+1):
        S[y][x] += S[y-1][x]


ans = float("inf")
for i in range(N):
    for j in range(N):
        for k in range(N):
            for ll in range(N):

                left     = xlst[i]
                right    = xlst[j]
                top      = ylst[k]
                bottom   = ylst[ll]

                if right <= left: continue
                if bottom <= top: continue

                left = xset.index(left)+1
                right = xset.index(right)+1
                top = yset.index(top)+1
                bottom=yset.index(bottom)+1


                cnt = 0
                cnt += S[bottom][right]
                # print(cnt)
                cnt += S[top-1][left-1]
                # print(cnt)
                cnt -= S[top-1][right]
                # print(cnt)
                cnt -= S[bottom][left-1]
                # print(cnt)
                if cnt >= K:
                    left = xset[left    -1 ]
                    right = xset[right  -1 ]
                    top = yset[top      -1 ]
                    bottom = yset[bottom-1 ]
                    rect_area = (right-left)*(bottom-top)
                    ans = min(ans, rect_area)
                
print(ans)


                


Fixed submission:
N,K = map(int, input().split())
XY = [ [int(j) for j in input().split()] for _ in range(N)]

xlst = []
ylst = []

for x,y in XY:
    x += 10**9 + 1
    y += 10**9 + 1
    xlst.append(x)
    ylst.append(y)

xset = sorted(list(set(xlst)))
yset = sorted(list(set(ylst)))

# print(xset, yset)

S = [ [0]*(N+1) for _ in range(N+1)]

for x,y in zip(xlst,ylst):
    x=xset.index(x)+1
    y=yset.index(y)+1
    S[y][x] = 1

for y in range(N+1):
    for x in range(1, N+1):
        S[y][x] += S[y][x-1]
for x in range(N+1):
    for y in range(1,N+1):
        S[y][x] += S[y-1][x]


ans = float("inf")
for i in range(N):
    for j in range(N):
        for k in range(N):
            for ll in range(N):

                left     = xlst[i]
                right    = xlst[j]
                top      = ylst[k]
                bottom   = ylst[ll]

                if right <= left: continue
                if bottom <= top: continue

                left = xset.index(left)+1
                right = xset.index(right)+1
                top = yset.index(top)+1
                bottom=yset.index(bottom)+1


                cnt = 0
                cnt += S[bottom][right]
                # print(cnt)
                cnt += S[top-1][left-1]
                # print(cnt)
                cnt -= S[top-1][right]
                # print(cnt)
                cnt -= S[bottom][left-1]
                # print(cnt)
                if cnt >= K:
                    left = xset[left    -1 ]
                    right = xset[right  -1 ]
                    top = yset[top      -1 ]
                    bottom = yset[bottom-1 ]
                    rect_area = (right-left)*(bottom-top)
                    ans = min(ans, rect_area)
                
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
X = []; Y = []
oriX  = []; oriY = []


for i in range(N):
    x,y = map(int,input().split())
    oriX.append(x)
    oriY.append(y)
    X.append(x)
    Y.append(y)

X = sorted(list(set(X)))
Y = sorted(list(set(Y)))

for i in range(len( oriX)) :
    oriX[i] = X.index(oriX[i] )
    oriY[i] = Y.index( oriY[i] )  

MAP = [ [0] * len(oriX) for _ in (oriY)]
for i in range(len(oriX)):
    MAP[ oriY[i] ][ oriX[i] ] = 1


ans = float("inf")

for i in range(len(oriX)):
    for j in range(len(oriX)):
        if i == j : continue

        for p in range(len(oriY)):
            for q in range(len(oriY)):
                if p == q: continue


                npoints = 0
                for c in range(N):
                    if  oriX[i] <= oriX[c] <= oriX[j]:
                        if oriY[p] <= oriY[c] <= oriY[q]:
                            npoints += 1
                        
                # for h in range(oriY[p], oriY[q]+1):
                #     for w in range(oriX[i], oriX[j]+1):
                #         if MAP[h][w] == 1: 
                #             npoints += 1

                if npoints >= K:
                    tmp = (X[oriX[j]] - X[oriX[i]]) * (Y[oriY[q]] - Y[oriY[p]])
                    ans = min(tmp, ans)

print(ans)


Fixed submission:
N,K = map(int, input().split())
XY = [ [int(j) for j in input().split()] for _ in range(N)]

xlst = []
ylst = []

for x,y in XY:
    x += 10**9 + 1
    y += 10**9 + 1
    xlst.append(x)
    ylst.append(y)

xset = sorted(list(set(xlst)))
yset = sorted(list(set(ylst)))

# print(xset, yset)

S = [ [0]*(N+1) for _ in range(N+1)]

for x,y in zip(xlst,ylst):
    x=xset.index(x)+1
    y=yset.index(y)+1
    S[y][x] = 1

for y in range(N+1):
    for x in range(1, N+1):
        S[y][x] += S[y][x-1]
for x in range(N+1):
    for y in range(1,N+1):
        S[y][x] += S[y-1][x]


ans = float("inf")
for i in range(N):
    for j in range(N):
        for k in range(N):
            for ll in range(N):

                left     = xlst[i]
                right    = xlst[j]
                top      = ylst[k]
                bottom   = ylst[ll]

                if right <= left: continue
                if bottom <= top: continue

                left = xset.index(left)+1
                right = xset.index(right)+1
                top = yset.index(top)+1
                bottom=yset.index(bottom)+1


                cnt = 0
                cnt += S[bottom][right]
                # print(cnt)
                cnt += S[top-1][left-1]
                # print(cnt)
                cnt -= S[top-1][right]
                # print(cnt)
                cnt -= S[bottom][left-1]
                # print(cnt)
                if cnt >= K:
                    left = xset[left    -1 ]
                    right = xset[right  -1 ]
                    top = yset[top      -1 ]
                    bottom = yset[bottom-1 ]
                    rect_area = (right-left)*(bottom-top)
                    ans = min(ans, rect_area)
                
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
X = []; Y = []
oriX  = []; oriY = []


for i in range(N):
    x,y = map(int,input().split())
    oriX.append(x)
    oriY.append(y)
    X.append(x)
    Y.append(y)

X = sorted(list(set(X)))
Y = sorted(list(set(Y)))

for i in range(len( oriX)) :
    oriX[i] = X.index(oriX[i] )
    oriY[i] = Y.index( oriY[i] )  

MAP = [ [0] * len(oriX) for _ in (oriY)]
for i in range(len(oriX)):
    MAP[ oriY[i] ][ oriX[i] ] = 1


ans = float("inf")

for i in range(len(oriX)):
    for j in range(len(oriX)):
        if i == j : continue

        for p in range(len(oriY)):
            for q in range(len(oriY)):
                if p == q: continue


                npoints = 0
                for h in range(oriY[p], oriY[q]+1):
                    for w in range(oriX[i], oriX[j]+1):
                        if MAP[h][w] == 1: 
                            npoints += 1

                if npoints >= K:
                    tmp = (X[oriX[j]] - X[oriX[i]]) * (Y[oriY[q]] - Y[oriY[p]])
                    ans = min(tmp, ans)

print(ans)


Fixed submission:
N,K = map(int, input().split())
XY = [ [int(j) for j in input().split()] for _ in range(N)]

xlst = []
ylst = []

for x,y in XY:
    x += 10**9 + 1
    y += 10**9 + 1
    xlst.append(x)
    ylst.append(y)

xset = sorted(list(set(xlst)))
yset = sorted(list(set(ylst)))

# print(xset, yset)

S = [ [0]*(N+1) for _ in range(N+1)]

for x,y in zip(xlst,ylst):
    x=xset.index(x)+1
    y=yset.index(y)+1
    S[y][x] = 1

for y in range(N+1):
    for x in range(1, N+1):
        S[y][x] += S[y][x-1]
for x in range(N+1):
    for y in range(1,N+1):
        S[y][x] += S[y-1][x]


ans = float("inf")
for i in range(N):
    for j in range(N):
        for k in range(N):
            for ll in range(N):

                left     = xlst[i]
                right    = xlst[j]
                top      = ylst[k]
                bottom   = ylst[ll]

                if right <= left: continue
                if bottom <= top: continue

                left = xset.index(left)+1
                right = xset.index(right)+1
                top = yset.index(top)+1
                bottom=yset.index(bottom)+1


                cnt = 0
                cnt += S[bottom][right]
                # print(cnt)
                cnt += S[top-1][left-1]
                # print(cnt)
                cnt -= S[top-1][right]
                # print(cnt)
                cnt -= S[bottom][left-1]
                # print(cnt)
                if cnt >= K:
                    left = xset[left    -1 ]
                    right = xset[right  -1 ]
                    top = yset[top      -1 ]
                    bottom = yset[bottom-1 ]
                    rect_area = (right-left)*(bottom-top)
                    ans = min(ans, rect_area)
                
print(ans)