




from __future__ import annotations

# This is the precision for this function which can be altered.
# It is recommended for users to keep this number greater than or equal to 10.
UpperCamelCase__         =      10







def      _a				(						SCREAMING_SNAKE_CASE_							:    int				,				SCREAMING_SNAKE_CASE_							:    int				,				SCREAMING_SNAKE_CASE_							:    list[int]				,				SCREAMING_SNAKE_CASE_							:    int					):
					for i in range(SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_					):
										if array[i] == target:
															return i
					return -1







def      _a				(						SCREAMING_SNAKE_CASE_							:    list[int]				,				SCREAMING_SNAKE_CASE_							:    int					):
					__lowerCAmelCase           =	0
					__lowerCAmelCase           =	len(SCREAMING_SNAKE_CASE_					)
					while left <= right:
										if right - left < precision:
															return lin_search(SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_					)

										__lowerCAmelCase           =	(left + right) // 3 + 1
										__lowerCAmelCase           =	2 * (left + right) // 3 + 1

										if array[one_third] == target:
															return one_third
										elif array[two_third] == target:
															return two_third

										elif target < array[one_third]:
															__lowerCAmelCase           =	one_third - 1
										elif array[two_third] < target:
															__lowerCAmelCase           =	two_third + 1

										else:
															__lowerCAmelCase           =	one_third + 1
															__lowerCAmelCase           =	two_third - 1
					else:
										return -1







def      _a				(						SCREAMING_SNAKE_CASE_							:    int				,				SCREAMING_SNAKE_CASE_							:    int				,				SCREAMING_SNAKE_CASE_							:    list[int]				,				SCREAMING_SNAKE_CASE_							:    int					):
					if left < right:
										if right - left < precision:
															return lin_search(SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_					)
										__lowerCAmelCase           =	(left + right) // 3 + 1
										__lowerCAmelCase           =	2 * (left + right) // 3 + 1

										if array[one_third] == target:
															return one_third
										elif array[two_third] == target:
															return two_third

										elif target < array[one_third]:
															return rec_ternary_search(SCREAMING_SNAKE_CASE_				,				one_third - 1				,				SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_					)
										elif array[two_third] < target:
															return rec_ternary_search(two_third + 1				,				SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_					)
										else:
															return rec_ternary_search(one_third + 1				,				two_third - 1				,				SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_					)
					else:
										return -1


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					UpperCamelCase__         =      input("""Enter numbers separated by comma:\n""").strip()
					UpperCamelCase__         =      [int(item.strip()) for item in user_input.split(""",""")]
					assert collection == sorted(collection), f"List must be ordered.\n{collection}."
					UpperCamelCase__         =      int(input("""Enter the number to be found in the list:\n""").strip())
					UpperCamelCase__         =      ite_ternary_search(collection, target)
					UpperCamelCase__         =      rec_ternary_search(0, len(collection) - 1, collection, target)
					if resulta != -1:
										print(f'''Iterative search: {target} found at positions: {resulta}''')
										print(f'''Recursive search: {target} found at positions: {resulta}''')
					else:
										print("""Not found""")










def      _a				(						SCREAMING_SNAKE_CASE_							:    List[Any]					):
					__lowerCAmelCase       ,							__lowerCAmelCase           =	[], []
					while len(SCREAMING_SNAKE_CASE_					) > 1:
										__lowerCAmelCase       ,							__lowerCAmelCase           =	min(SCREAMING_SNAKE_CASE_					), max(SCREAMING_SNAKE_CASE_					)
										start.append(SCREAMING_SNAKE_CASE_					)
										end.append(SCREAMING_SNAKE_CASE_					)
										collection.remove(SCREAMING_SNAKE_CASE_					)
										collection.remove(SCREAMING_SNAKE_CASE_					)
					end.reverse()
					return start + collection + end


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




