Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n, k = map(int, input().split())
xlist, ylist, xy = [], [], []
for _ in range(n):
  x, y = map(int, input().split())
  xlist.append(x)
  ylist.append(y)
  xy.append((x, y))

xlist.sort()
ylist.sort()
ans = (xlist[-1] - xlist[0]) * (ylist[-1] - ylist[0])
for x1, x2 in combinations(xlist, r=2):
  for y1, y2 in combinations(ylist, r=2):
    tmpk = 0
    for i in range(n):
      if x1 <= xy[i][0] <= x2 and y1 <= xy[i][1] <= y2:
        tmpk += 1

      if tmpk >= k:
        tmp_ans = (x2 - x1) * (y2 - y1)
        if ans > tmp_ans:
          ans = tmp_ans

print(ans)


Fixed submission:
from itertools import combinations

n, k = map(int, input().split())
xlist, ylist, xy = [], [], []
for _ in range(n):
  x, y = map(int, input().split())
  xlist.append(x)
  ylist.append(y)
  xy.append((x, y))

xlist.sort()
ylist.sort()
ans = (xlist[-1] - xlist[0]) * (ylist[-1] - ylist[0])
for x1, x2 in combinations(xlist, r=2):
  for y1, y2 in combinations(ylist, r=2):
    tmpk = 0
    for i in range(n):
      if x1 <= xy[i][0] <= x2 and y1 <= xy[i][1] <= y2:
        tmpk += 1

      if tmpk >= k:
        tmp_ans = (x2 - x1) * (y2 - y1)
        if ans > tmp_ans:
          ans = tmp_ans

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
xlist, ylist, xy = [], [], []
for _ in range(n):
  x, y = map(int, input().split())
  xlist.append(x)
  ylist.append(y)
  xy.append((x, y))

xlist.sort()
ylist.sort()
ans = (xlist[-1] - xlist[0]) * (ylist[-1] - ylist[0])
for i, x1 in enumerate(xlist):
  for x2 in xlist[i+1:]:
    for j, y1 in enumerate(ylist):
      for y2 in ylist[j+1:]:
        tmpk = 0
        for i in range(n):
          if x1 <= xy[i][0] <= x2 and y1 <= xy[i][1] <= y2:
            tmpk += 1

          if tmpk >= k:
            tmp_ans = (x2 - x1) * (y2 - y1)
            if ans > tmp_ans:
              ans = tmp_ans

print(ans)


Fixed submission:
from itertools import combinations

n, k = map(int, input().split())
xlist, ylist, xy = [], [], []
for _ in range(n):
  x, y = map(int, input().split())
  xlist.append(x)
  ylist.append(y)
  xy.append((x, y))

xlist.sort()
ylist.sort()
ans = (xlist[-1] - xlist[0]) * (ylist[-1] - ylist[0])
for x1, x2 in combinations(xlist, r=2):
  for y1, y2 in combinations(ylist, r=2):
    tmpk = 0
    for i in range(n):
      if x1 <= xy[i][0] <= x2 and y1 <= xy[i][1] <= y2:
        tmpk += 1

      if tmpk >= k:
        tmp_ans = (x2 - x1) * (y2 - y1)
        if ans > tmp_ans:
          ans = tmp_ans

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
xy = []
for _ in range(n):
  xy.append(tuple(map(int, input().split())))

mins = None
for i, _xl in enumerate(xy):
  for _xr in xy[i:]:
    for j, _yu in enumerate(xy):
      for _yd in xy[j:]:
        c = 0
        for _xy in xy:
          if min(_xl[0], _xr[0]) <= _xy[0] <= max(_xl[0], _xr[0]) and min(_yd[1], _yu[1]) <= _xy[1] <= max(_yd[1], _yu[1]):
            c += 1
        if c >= k:
          if mins is None:
            mins = abs(_xl[0] - _xr[0]) * abs(_yu[1] - _yd[1])
          elif mins > abs(_xl[0] - _xr[0]) * abs(_yu[1] - _yd[1]):
            mins = abs(_xl[0] - _xr[0]) * abs(_yu[1] - _yd[1])
print(mins)


Fixed submission:
from itertools import combinations

n, k = map(int, input().split())
xlist, ylist, xy = [], [], []
for _ in range(n):
  x, y = map(int, input().split())
  xlist.append(x)
  ylist.append(y)
  xy.append((x, y))

xlist.sort()
ylist.sort()
ans = (xlist[-1] - xlist[0]) * (ylist[-1] - ylist[0])
for x1, x2 in combinations(xlist, r=2):
  for y1, y2 in combinations(ylist, r=2):
    tmpk = 0
    for i in range(n):
      if x1 <= xy[i][0] <= x2 and y1 <= xy[i][1] <= y2:
        tmpk += 1

      if tmpk >= k:
        tmp_ans = (x2 - x1) * (y2 - y1)
        if ans > tmp_ans:
          ans = tmp_ans

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
xy = []
for _ in range(n):
  xy.append(tuple(map(int, input().split())))

mins = None
for i, _xl in enumerate(xy):
  for _xr in xy[i:]:
    for j, _yu in enumerate(xy):
      for _yd in xy[j:]:
        c = 0
        for _xy in xy:
          if min(_xl[0], _xr[0]) <= _xy[0] <= max(_xl[0], _xr[0]) and min(_yd[1], _yu[1]) <= _xy[1] <= max(_yd[1], _yu[1]):
            c += 1
        if c >= k:
          if mins is None:
            mins = abs(_xl[0] - _xr[0]) * abs(_yu[1] - _yd[1])
          elif mins > abs(_xl[0] - _xr[0]) * abs(_yu[1] - _yd[1]):
            mins = abs(_xl[0] - _xr[0]) * abs(_yu[1] - _yd[1])
print(mins)

Fixed submission:
from itertools import combinations

n, k = map(int, input().split())
xlist, ylist, xy = [], [], []
for _ in range(n):
  x, y = map(int, input().split())
  xlist.append(x)
  ylist.append(y)
  xy.append((x, y))

xlist.sort()
ylist.sort()
ans = (xlist[-1] - xlist[0]) * (ylist[-1] - ylist[0])
for x1, x2 in combinations(xlist, r=2):
  for y1, y2 in combinations(ylist, r=2):
    tmpk = 0
    for i in range(n):
      if x1 <= xy[i][0] <= x2 and y1 <= xy[i][1] <= y2:
        tmpk += 1

      if tmpk >= k:
        tmp_ans = (x2 - x1) * (y2 - y1)
        if ans > tmp_ans:
          ans = tmp_ans

print(ans)