





from __future__ import annotations






def 							__lowercase       (			__lowerCAmelCase							:    list ,   __lowerCAmelCase							:    int ,   __lowerCAmelCase							:    int ,   __lowerCAmelCase							:    int       ):
							a__					=					[]
							a__				, a__					=					input_list[low:mid], input_list[mid : high + 1]
							while left and right:
														result.append((left if left[0] <= right[0] else right).pop(0       )       )
							a__					=					result + left + right
							return input_list






def 							__lowercase       (			__lowerCAmelCase							:    list       ):
							if len(__lowerCAmelCase       ) <= 1:
														return input_list
							a__					=					list(__lowerCAmelCase       )

							# iteration for two-way merging
							a__					=					2
							while p <= len(__lowerCAmelCase       ):
														# getting low, high and middle value for merge-sort of single list
														for i in range(0 ,   len(__lowerCAmelCase       ) ,   __lowerCAmelCase       ):
																					a__					=					i
																					a__					=					i + p - 1
																					a__					=					(low + high + 1) // 2
																					a__					=					merge(__lowerCAmelCase ,   __lowerCAmelCase ,   __lowerCAmelCase ,   __lowerCAmelCase       )
														# final merge of last two parts
														if p * 2 >= len(__lowerCAmelCase       ):
																					a__					=					i
																					a__					=					merge(__lowerCAmelCase ,   0 ,   __lowerCAmelCase ,   len(__lowerCAmelCase       ) - 1       )
																					break
														p *= 2

							return input_list


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








from __future__ import annotations






def 							__lowercase       (			__lowerCAmelCase							:    List[Any] ,   __lowerCAmelCase							:    Optional[Any] ,   __lowerCAmelCase							:    str ,   __lowerCAmelCase							:    List[str]       ):  # noqa: E741
							while r - l > 1:
														a__					=					(l + r) // 2
														if v[m] >= key:
																					a__					=					m
														else:
																					a__					=					m  # noqa: E741
							return r






def 							__lowercase       (			__lowerCAmelCase							:    list[int]       ):
							if len(__lowerCAmelCase       ) == 0:
														return 0

							a__					=					[0] * len(__lowerCAmelCase       )
							a__					=					1

							a__					=					v[0]

							for i in range(1 ,   len(__lowerCAmelCase       )       ):
														if v[i] < tail[0]:
																					a__					=					v[i]
														elif v[i] > tail[length - 1]:
																					a__					=					v[i]
																					length += 1
														else:
																					a__					=					v[i]

							return length


if __name__ == "__main__":
						import doctest

						doctest.testmod()




