


'''simple docstring'''







from __future__ import annotations

from collections.abc import Iterable






class 		_snake_case    :






						'''simple docstring'''







						def __init__(  self:	str      ,							__UpperCamelCase:	Optional[int]      ,							__UpperCamelCase:	List[str]     )							->	Optional[Any]:
										__magic_name__       ,     __magic_name__				:					List[str]						       =       float(__UpperCamelCase     ), float(__UpperCamelCase     )







						def __eq__(  self:	List[Any]      ,							__UpperCamelCase:	str     )							->	int:
										return self.x == other.x and self.y == other.y







						def __ne__(  self:	Any      ,							__UpperCamelCase:	Any     )							->	Any:
										return not self == other







						def __gt__(  self:	Tuple      ,							__UpperCamelCase:	int     )							->	Union[str, Any]:
										if self.x > other.x:
														return True
										elif self.x == other.x:
														return self.y > other.y
										return False







						def __lt__(  self:	Optional[Any]      ,							__UpperCamelCase:	Any     )							->	Optional[Any]:
										return not self > other







						def __ge__(  self:	List[Any]      ,							__UpperCamelCase:	Optional[Any]     )							->	Optional[Any]:
										if self.x > other.x:
														return True
										elif self.x == other.x:
														return self.y >= other.y
										return False







						def __le__(  self:	Tuple      ,							__UpperCamelCase:	str     )							->	Dict:
										if self.x < other.x:
														return True
										elif self.x == other.x:
														return self.y <= other.y
										return False







						def __repr__(  self:	int     )							->	Optional[Any]:
										return f"""({self.x}, {self.y})"""







						def __hash__(  self:	Optional[Any]     )							->	int:
										return hash(self.x     )






def 						_UpperCamelCase							( UpperCamelCase__     ,   ):






				"""simple docstring"""



				__magic_name__				:					list[Point]						       =       []
				if list_of_tuples:
								for p in list_of_tuples:
												if isinstance(UpperCamelCase__     ,   UpperCamelCase__		):
																points.append(UpperCamelCase__		)
												else:
																try:
																				points.append(Point(p[0]     ,   p[1]		)		)
																except (IndexError, TypeError):
																				print(
																				    F"""Ignoring deformed point {p}. All points"""
																				    " must have at least 2 coordinates."		)
				return points



def 						_UpperCamelCase							( UpperCamelCase__		):






				"""simple docstring"""



				if not hasattr(UpperCamelCase__     ,   "__iter__"		):
								__magic_name__				:					Any						       =       F"""Expecting an iterable object but got an non-iterable type {points}"""
								raise ValueError(UpperCamelCase__		)

				if not points:
								__magic_name__				:					Any						       =       F"""Expecting a list of points but got {points}"""
								raise ValueError(UpperCamelCase__		)

				return _construct_points(UpperCamelCase__		)



def 						_UpperCamelCase							( UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__		):






				"""simple docstring"""



				__magic_name__				:					Optional[Any]						       =       (a.x * b.y + b.x * c.y + c.x * a.y) - (a.y * b.x + b.y * c.x + c.y * a.x)
				return det



def 						_UpperCamelCase							( UpperCamelCase__		):






				"""simple docstring"""



				__magic_name__				:					Optional[Any]						       =       sorted(_validate_input(UpperCamelCase__		)		)
				__magic_name__				:					Union[str, Any]						       =       len(UpperCamelCase__		)
				__magic_name__				:					Dict						       =       set()

				for i in range(n - 1		):
								for j in range(i + 1     ,   UpperCamelCase__		):
												__magic_name__				:					Optional[Any]						       =       False
												__magic_name__				:					Dict						       =       True
												for k in range(UpperCamelCase__		):
																if k != i and k != j:
																				__magic_name__				:					Optional[int]						       =       _det(points[i]     ,   points[j]     ,   points[k]		)

																				if det_k > 0:
																								__magic_name__				:					str						       =       True
																				elif det_k < 0:
																								__magic_name__				:					Union[str, Any]						       =       True
																				else:
																								# point[i], point[j], point[k] all lie on a straight line
																								# if point[k] is to the left of point[i] or it's to the
																								# right of point[j], then point[i], point[j] cannot be
																								# part of the convex hull of A
																								if points[k] < points[i] or points[k] > points[j]:
																												__magic_name__				:					Dict						       =       False
																												break

																if points_left_of_ij and points_right_of_ij:
																				__magic_name__				:					Union[str, Any]						       =       False
																				break

												if ij_part_of_convex_hull:
																convex_set.update([points[i], points[j]]		)

				return sorted(UpperCamelCase__		)



def 						_UpperCamelCase							( UpperCamelCase__		):






				"""simple docstring"""



				__magic_name__				:					List[str]						       =       sorted(_validate_input(UpperCamelCase__		)		)
				__magic_name__				:					Optional[Any]						       =       len(UpperCamelCase__		)

				# divide all the points into an upper hull and a lower hull
				# the left most point and the right most point are definitely
				# members of the convex hull by definition.
				# use these two anchors to divide all the points into two hulls,
				# an upper hull and a lower hull.

				# all points to the left (above) the line joining the extreme points belong to the
				# upper hull
				# all points to the right (below) the line joining the extreme points below to the
				# lower hull
				# ignore all points on the line joining the extreme points since they cannot be
				# part of the convex hull

				__magic_name__				:					int						       =       points[0]
				__magic_name__				:					Optional[int]						       =       points[n - 1]

				__magic_name__				:					Any						       =       {left_most_point, right_most_point}
				__magic_name__				:					Optional[Any]						       =       []
				__magic_name__				:					str						       =       []

				for i in range(1     ,   n - 1		):
								__magic_name__				:					List[Any]						       =       _det(UpperCamelCase__     ,   UpperCamelCase__     ,   points[i]		)

								if det > 0:
												upper_hull.append(points[i]		)
								elif det < 0:
												lower_hull.append(points[i]		)

				_construct_hull(UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__		)
				_construct_hull(UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__		)

				return sorted(UpperCamelCase__		)



def 						_UpperCamelCase							( UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__		):






				"""simple docstring"""



				if points:
								__magic_name__				:					Optional[int]						       =       None
								__magic_name__				:					Optional[Any]						       =       float("-inf"		)
								__magic_name__				:					str						       =       []

								for p in points:
												__magic_name__				:					List[Any]						       =       _det(UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__		)

												if det > 0:
																candidate_points.append(UpperCamelCase__		)

																if det > extreme_point_distance:
																				__magic_name__				:					Any						       =       det
																				__magic_name__				:					Optional[Any]						       =       p

								if extreme_point:
												_construct_hull(UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__		)
												convex_set.add(UpperCamelCase__		)
												_construct_hull(UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__		)



def 						_UpperCamelCase							( UpperCamelCase__		):






				"""simple docstring"""



				__magic_name__				:					Union[str, Any]						       =       sorted(_validate_input(UpperCamelCase__		)		)
				__magic_name__				:					Optional[Any]						       =       len(UpperCamelCase__		)

				__magic_name__				:					Tuple						       =       points[:2]
				for i in range(2     ,   UpperCamelCase__		):
								__magic_name__				:					List[str]						       =       _det(convex_hull[1]     ,   convex_hull[0]     ,   points[i]		)
								if det > 0:
												convex_hull.insert(0     ,   points[i]		)
												break
								elif det < 0:
												convex_hull.append(points[i]		)
												break
								else:
												__magic_name__				:					Tuple						       =       points[i]
				i += 1

				for j in range(UpperCamelCase__     ,   UpperCamelCase__		):
								if (
								    _det(convex_hull[0]     ,   convex_hull[-1]     ,   points[j]		) > 0
								    and _det(convex_hull[-1]     ,   convex_hull[0]     ,   points[1]		) < 0
								):
												# The point lies within the convex hull
												continue

								convex_hull.insert(0     ,   points[j]		)
								convex_hull.append(points[j]		)
								while _det(convex_hull[0]     ,   convex_hull[1]     ,   convex_hull[2]		) >= 0:
												del convex_hull[1]
								while _det(convex_hull[-1]     ,   convex_hull[-2]     ,   convex_hull[-3]		) <= 0:
												del convex_hull[-2]

    # `convex_hull` is contains the convex hull in circular order
				return sorted(convex_hull[1:] if len(UpperCamelCase__		) > 3 else convex_hull		)



def 						_UpperCamelCase							( ):






				"""simple docstring"""



				__magic_name__				:					Union[str, Any]						       =       [
				    (0, 3),
				    (2, 2),
				    (1, 1),
				    (2, 1),
				    (3, 0),
				    (0, 0),
				    (3, 3),
				    (2, -1),
				    (2, -4),
				    (1, -3),
				]
				# the convex set of points is
				# [(0, 0), (0, 3), (1, -3), (2, -4), (3, 0), (3, 3)]
				__magic_name__				:					List[str]						       =       convex_hull_bf(UpperCamelCase__		)

				__magic_name__				:					List[Any]						       =       convex_hull_recursive(UpperCamelCase__		)
				assert results_bf == results_recursive

				__magic_name__				:					int						       =       convex_hull_melkman(UpperCamelCase__		)
				assert results_bf == results_melkman

				print(UpperCamelCase__		)


if __name__ == "__main__":
		main()



'''simple docstring'''







import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput






@dataclass
class 		_snake_case    (				snake_case_		):






						'''simple docstring'''







						__snake_case   =      42
						__snake_case   =      None
						__snake_case   =      None






class 		_snake_case    (				unittest.TestCase		):






						'''simple docstring'''







						def lowerCAmelCase__ (  self:	List[str]     )							->	str:
										__magic_name__				:					List[Any]						       =       ModelOutputTest(a=30     )
										self.assertEqual(x.a      ,							30     )
										self.assertIsNone(x.b     )
										self.assertIsNone(x.c     )
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					Optional[int]						       =       x.d







						def lowerCAmelCase__ (  self:	Dict     )							->	Dict:
										__magic_name__				:					List[Any]						       =       ModelOutputTest(a=30      ,							b=10     )
										self.assertEqual(x[0]      ,							30     )
										self.assertEqual(x[1]      ,							10     )
										self.assertEqual(x[:2]      ,							(30, 10)     )
										self.assertEqual(x[:]      ,							(30, 10)     )

										__magic_name__				:					str						       =       ModelOutputTest(a=30      ,							c=10     )
										self.assertEqual(x[0]      ,							30     )
										self.assertEqual(x[1]      ,							10     )
										self.assertEqual(x[:2]      ,							(30, 10)     )
										self.assertEqual(x[:]      ,							(30, 10)     )







						def lowerCAmelCase__ (  self:	List[Any]     )							->	Optional[int]:
										__magic_name__				:					Optional[Any]						       =       ModelOutputTest(a=30      ,							b=10     )
										self.assertEqual(x["a"]      ,							30     )
										self.assertEqual(x["b"]      ,							10     )
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					str						       =       x["c"]

										__magic_name__				:					Optional[Any]						       =       ModelOutputTest(a=30      ,							c=10     )
										self.assertEqual(x["a"]      ,							30     )
										self.assertEqual(x["c"]      ,							10     )
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					Union[str, Any]						       =       x["b"]







						def lowerCAmelCase__ (  self:	Optional[Any]     )							->	Any:
										__magic_name__				:					Any						       =       ModelOutputTest(a=30     )
										self.assertEqual(list(x.keys()     )      ,							["a"]     )
										self.assertEqual(list(x.values()     )      ,							[30]     )
										self.assertEqual(list(x.items()     )      ,							[("a", 30)]     )
										self.assertEqual(list(__UpperCamelCase     )      ,							["a"]     )

										__magic_name__				:					Dict						       =       ModelOutputTest(a=30      ,							b=10     )
										self.assertEqual(list(x.keys()     )      ,							["a", "b"]     )
										self.assertEqual(list(x.values()     )      ,							[30, 10]     )
										self.assertEqual(list(x.items()     )      ,							[("a", 30), ("b", 10)]     )
										self.assertEqual(list(__UpperCamelCase     )      ,							["a", "b"]     )

										__magic_name__				:					int						       =       ModelOutputTest(a=30      ,							c=10     )
										self.assertEqual(list(x.keys()     )      ,							["a", "c"]     )
										self.assertEqual(list(x.values()     )      ,							[30, 10]     )
										self.assertEqual(list(x.items()     )      ,							[("a", 30), ("c", 10)]     )
										self.assertEqual(list(__UpperCamelCase     )      ,							["a", "c"]     )

										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					str						       =       x.update({"d": 20}     )
										with self.assertRaises(__UpperCamelCase     ):
														del x["a"]
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					List[str]						       =       x.pop("a"     )
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					Optional[Any]						       =       x.setdefault("d"      ,							32     )







						def lowerCAmelCase__ (  self:	Dict     )							->	int:
										__magic_name__				:					Any						       =       ModelOutputTest(a=30     )
										__magic_name__				:					Tuple						       =       10
										self.assertEqual(x.a      ,							10     )
										self.assertEqual(x["a"]      ,							10     )







						def lowerCAmelCase__ (  self:	Dict     )							->	Union[str, Any]:
										__magic_name__				:					Tuple						       =       ModelOutputTest(a=30     )
										__magic_name__				:					Union[str, Any]						       =       10
										self.assertEqual(x.a      ,							10     )
										self.assertEqual(x["a"]      ,							10     )







						def lowerCAmelCase__ (  self:	Optional[int]     )							->	Optional[int]:
										__magic_name__				:					Tuple						       =       ModelOutputTest({"a": 30, "b": 10}     )
										self.assertEqual(list(x.keys()     )      ,							["a", "b"]     )
										self.assertEqual(x.a      ,							30     )
										self.assertEqual(x.b      ,							10     )







						def lowerCAmelCase__ (  self:	Optional[int]     )							->	Optional[Any]:
										__magic_name__				:					List[str]						       =       ModelOutputTest([("a", 30), ("b", 10)]     )
										self.assertEqual(list(x.keys()     )      ,							["a", "b"]     )
										self.assertEqual(x.a      ,							30     )
										self.assertEqual(x.b      ,							10     )

										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					Any						       =       ModelOutputTest([("a", 30), (10, 10)]     )

										__magic_name__				:					Any						       =       ModelOutputTest(a=(30, 30)     )
										self.assertEqual(list(x.keys()     )      ,							["a"]     )
										self.assertEqual(x.a      ,							(30, 30)     )