






'''simple docstring'''




def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_)							->     int:
  return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2







def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_=0)							->     Optional[Any]:
  return sorted(__snake_case     ,      key=lambda lowerCamelCase_: x[column])







def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_     ,      lowerCamelCase_=float('inf'))							->     int:







  for i in range(points_counts - 1):
    for j in range(i + 1     ,      __snake_case):
      UpperCamelCase__				:					int					=					euclidean_distance_sqr(points[i]     ,      points[j])
      if current_dis < min_dis:
        UpperCamelCase__				:					Union[str, Any]					=					current_dis
  return min_dis







def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_     ,      lowerCamelCase_=float('inf'))							->     Dict:







  for i in range(min(6     ,      points_counts - 1)     ,      __snake_case):
    for j in range(max(0     ,      i - 6)     ,      __snake_case):
      UpperCamelCase__				:					Optional[Any]					=					euclidean_distance_sqr(points[i]     ,      points[j])
      if current_dis < min_dis:
        UpperCamelCase__				:					int					=					current_dis
  return min_dis







def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_     ,      lowerCamelCase_)							->     Union[str, Any]:







  if points_counts <= 3:
    return dis_between_closest_pair(__snake_case     ,      __snake_case)

  # recursion
  UpperCamelCase__				:					str					=					points_counts // 2
  UpperCamelCase__				:					List[Any]					=					closest_pair_of_points_sqr(
      __snake_case     ,      points_sorted_on_y[:mid]     ,      __snake_case)
  UpperCamelCase__				:					Dict					=					closest_pair_of_points_sqr(
      __snake_case     ,      points_sorted_on_y[mid:]     ,      points_counts - mid)
  UpperCamelCase__				:					Dict					=					min(__snake_case     ,      __snake_case)
  UpperCamelCase__				:					Optional[int]					=					[]
  for point in points_sorted_on_x:
    if abs(point[0] - points_sorted_on_x[mid][0]) < closest_pair_dis:
      cross_strip.append(__snake_case)

  UpperCamelCase__				:					Optional[Any]					=					dis_between_closest_in_strip(
      __snake_case     ,      len(__snake_case)     ,      __snake_case)
  return min(__snake_case     ,      __snake_case)







def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_)							->     int:
  UpperCamelCase__				:					List[str]					=					column_based_sort(__snake_case     ,      column=0)
  UpperCamelCase__				:					Optional[Any]					=					column_based_sort(__snake_case     ,      column=1)
  return (
      closest_pair_of_points_sqr(
          __snake_case     ,      __snake_case     ,      __snake_case)
  ) ** 0.5


if __name__ == "__main__":
  lowerCAmelCase__          =						[(2, 3), (12, 30), (40, 50), (5, 1), (12, 10), (3, 4)]
  print('Distance:', closest_pair_of_points(points, len(points)))












'''simple docstring'''




from ..utils import DummyObject, requires_backends







class       __lowercase					(metaclass=__lowerCamelCase    ):
	_lowerCamelCase              =  ['''torch''', '''scipy''']

	def __init__(      self   :						List[Any]  ,					*UpperCAmelCase_   :						Any  ,					**UpperCAmelCase_   :						int):
			requires_backends(self  ,					['torch', 'scipy'])

	@classmethod
	def      __UpperCamelCase							(      cls   :						Union[str, Any]  ,					*UpperCAmelCase_   :						Any  ,					**UpperCAmelCase_   :						List[Any]):
			requires_backends(cls  ,					['torch', 'scipy'])





	@classmethod
	def      __UpperCamelCase							(      cls   :						Union[str, Any]  ,					*UpperCAmelCase_   :						Optional[Any]  ,					**UpperCAmelCase_   :						Any):
			requires_backends(cls  ,					['torch', 'scipy'])




