




"""simple docstring"""







from __future__ import annotations

from bisect import bisect_left
from functools import total_ordering
from heapq import merge




@total_ordering
class       lowerCAmelCase__       (			lowerCAmelCase_    ):


				"""simple docstring"""





				def __lt__(     self					:	str    ,   lowercase__					:	List[Any]						):
						return self[-1] < other[-1]



				def __eq__(     self					:	Optional[Any]    ,   lowercase__					:	str						):
						return self[-1] == other[-1]





def 						snake_case__       (					_lowerCamelCase				)			->list:






		"""simple docstring"""


		__lowercase				:		list[Stack]												=				[]
		# sort into stacks
		for element in collection:
				__lowercase				:		Optional[Any]												=				Stack([element]				)
				__lowercase				:		Any												=				bisect_left(_lowerCamelCase,  _lowerCamelCase				)
				if i != len(_lowerCamelCase				):
						stacks[i].append(_lowerCamelCase				)
				else:
						stacks.append(_lowerCamelCase				)

    # use a heap-based merge to merge stack efficiently
		__lowercase				:		Optional[int]												=				merge(*(reversed(_lowerCamelCase				) for stack in stacks)				)
		return collection


if __name__ == "__main__":
						__A   :  str					=      input('Enter numbers separated by a comma:\n').strip()
						__A   :  Optional[Any]					=      [int(item) for item in user_input.split(',')]
						print(patience_sort(unsorted))






"""simple docstring"""







from collections import deque

from .hash_table import HashTable




class       lowerCAmelCase__       (			lowerCAmelCase_    ):


				"""simple docstring"""





				def __init__(     self					:	Optional[int]    ,   *lowercase__					:	Any    ,   **lowercase__					:	Union[str, Any]						):
						super().__init__(*lowercase__    ,   **lowercase__						)



				def       snake_case    (     self					:	Any    ,   lowercase__					:	Dict    ,   lowercase__					:	Dict						):
						__lowercase				:		Dict												=				deque([]						) if self.values[key] is None else self.values[key]
						self.values[key].appendleft(lowercase__						)
						__lowercase				:		Union[str, Any]												=				self.values[key]



				def       snake_case    (     self					:	str						):
						return (
						    sum(self.charge_factor - len(lowercase__						) for slot in self.values						)
						    / self.size_table
						    * self.charge_factor
						)



				def       snake_case    (     self					:	Union[str, Any]    ,   lowercase__					:	List[str]    ,   lowercase__					:	str=None						):
						if not (
						    len(self.values[key]						) == self.charge_factor and self.values.count(lowercase__						) == 0
						):
								return key
						return super()._collision_resolution(lowercase__    ,   lowercase__						)
