





"""simple docstring"""




from __future__ import annotations

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




@total_ordering
class 			_a						(				_A    ):






				def __lt__(			self		:   Union[str, Any],			lowerCAmelCase__		:   Any							)     ->				Any:




										'''simple docstring'''



										return self[-1] < other[-1]






				def __eq__(			self		:   Union[str, Any],			lowerCAmelCase__		:   int							)     ->				str:




										'''simple docstring'''



										return self[-1] == other[-1]





def 	a_    (							_lowercase       ):
						_UpperCamelCase      : List[Any]         =   []
						# sort into stacks
						for element in collection:
												_UpperCamelCase      : List[Any]         =   Stack([element]       )
												_UpperCamelCase      : Tuple         =   bisect_left(lowercase__	,						lowercase__       )
												if i != len(lowercase__       ):
																		stacks[i].append(lowercase__       )
												else:
																		stacks.append(lowercase__       )

    # use a heap-based merge to merge stack efficiently
						_UpperCamelCase      : int         =   merge(*(reversed(lowercase__       ) for stack in stacks)       )
						return collection


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












"""simple docstring"""




from functools import lru_cache





@lru_cache
def 	a_    (							_lowercase       ):
						if num < 0:
												raise ValueError('''Number should not be negative.'''       )

						return 1 if num in (0, 1) else num * factorial(num - 1       )


if __name__ == "__main__":
						import doctest

						doctest.testmod()



