
from __future__ import annotations





def        lowerCAmelCase       (				snake_case__   :      Any				,					snake_case__   :      List[str] )->			Any:
    A_								=					0
    A_								=					len(snake_case__ ) - 1
    while left <= right:
        A_								=					(left + right) // 2
        if left == right:
            if sorted_list[middle] < item:
                A_								=					middle + 1
            break
        elif sorted_list[middle] < item:
            A_								=					middle + 1
        else:
            A_								=					middle - 1
    sorted_list.insert(snake_case__				,					snake_case__ )
    return sorted_list





def        lowerCAmelCase       (				snake_case__   :      List[str]				,					snake_case__   :      Optional[int] )->			str:
    A_								=					[]
    while left and right:
        if left[0][0] < right[0][0]:
            result.append(left.pop(0 ) )
        else:
            result.append(right.pop(0 ) )
    return result + left + right





def        lowerCAmelCase       (				snake_case__   :      Union[str, Any] )->			List[Any]:
    A_								=					len(snake_case__ )
    if length <= 1:
        return list_ad
    A_								=					length // 2
    return merge(sortlist_ad(list_ad[:middle] )				,					sortlist_ad(list_ad[middle:] ) )





def        lowerCAmelCase       (				snake_case__   :      str )->			list[int]:

    if len(snake_case__ ) <= 1:
        return collection
    A_								=					[]
    A_								=					False
    for i in range(0				,					len(snake_case__ )				,					2 ):
        if i == len(snake_case__ ) - 1:
            A_								=					True
        else:
            if collection[i] < collection[i + 1]:
                two_paired_list.append([collection[i], collection[i + 1]] )
            else:
                two_paired_list.append([collection[i + 1], collection[i]] )
    A_								=					sortlist_ad(snake_case__ )
    A_								=					[i[0] for i in sorted_list_ad]
    result.append(sorted_list_ad[-1][1] )
    if has_last_odd_item:
        A_								=					collection[-1]
        A_								=					binary_search_insertion(snake_case__				,					snake_case__ )
    A_								=					False
    for i in range(len(snake_case__ ) - 1 ):
        if result[i] == collection[-1] and has_last_odd_item:
            A_								=					True
        A_								=					sorted_list_ad[i][1]
        # If last_odd_item is inserted before the item's index,
        # you should forward index one more.
        if is_last_odd_item_inserted_before_this_index:
            A_								=					result[: i + 2] + binary_search_insertion(result[i + 2 :]				,					snake_case__ )
        else:
            A_								=					result[: i + 1] + binary_search_insertion(result[i + 1 :]				,					snake_case__ )

    return result


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









'''simple docstring'''


from __future__ import annotations

from collections.abc import Iterable, Iterator
from typing import Any, Generic, TypeVar

lowerCAmelCase__      				=			TypeVar("T", bound=bool)



class        lowercase    (	Generic[T]			):


							def __init__(      self     ,      _snake_case)				->					None:
								UpperCAmelCase_		:   T													=       value
								UpperCAmelCase_		:   SkewNode[T] | None													=       None
								UpperCAmelCase_		:   SkewNode[T] | None													=       None


							@property
							def     _snake_case				(      self)				->					T:
								return self._value





							@staticmethod
							def     _snake_case				(      _snake_case     ,      _snake_case)				->					SkewNode[T] | None:
								if not roota:
									return roota

								if not roota:
									return roota

								if roota.value > roota.value:
									UpperCAmelCase_						,     UpperCAmelCase_		:   Union[str, Any]													=       roota, roota

								UpperCAmelCase_		:   Dict													=       roota
								UpperCAmelCase_		:   Dict													=       roota.right
								UpperCAmelCase_		:   Optional[int]													=       roota.left
								UpperCAmelCase_		:   Dict													=       SkewNode.merge(_snake_case     ,      _snake_case)

								return result



class        lowercase    (	Generic[T]			):


							def __init__(      self     ,      _snake_case = ())				->					None:
								UpperCAmelCase_		:   SkewNode[T] | None													=       None
								if data:
									for item in data:
										self.insert(_snake_case)


							def __bool__(      self)				->					bool:
								return self._root is not None


							def __iter__(      self)				->					Iterator[T]:
								UpperCAmelCase_		:   list[Any]													=       []
								while self:
									result.append(self.pop())

								# Pushing items back to the heap not to clear it.
								for item in result:
									self.insert(_snake_case)

								return iter(_snake_case)


							def     _snake_case				(      self     ,      _snake_case)				->					None:
								UpperCAmelCase_		:   Any													=       SkewNode.merge(self._root     ,      SkewNode(_snake_case))


							def     _snake_case				(      self)				->					T | None:
								UpperCAmelCase_		:   Union[str, Any]													=       self.top()
								UpperCAmelCase_		:   Tuple													=       (
								    SkewNode.merge(self._root.left     ,      self._root.right) if self._root else None
								)

								return result


							def     _snake_case				(      self)				->					T:
								if not self._root:
									raise IndexError('Can\'t get top element for the empty heap.')
								return self._root.value





							def     _snake_case				(      self)				->					None:
								UpperCAmelCase_		:   Union[str, Any]													=       None


if __name__ == "__main__":
						import doctest

						doctest.testmod()






