






"""simple docstring"""
from __future__ import annotations





def 				lowercase__		(					lowerCamelCase,						lowerCamelCase,						lowerCamelCase,						lowerCamelCase       ):
				if (direction == 1 and array[indexa] > array[indexa]) or (
				    direction == 0 and array[indexa] < array[indexa]
				):
								_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    array[indexa], array[indexa]





def 				lowercase__		(					lowerCamelCase,						lowerCamelCase,						lowerCamelCase,						lowerCamelCase       ):
				if length > 1:
								_SCREAMING_SNAKE_CASE   :		Any       		=    int(length / 2       )
								for i in range(lowerCamelCase,						low + middle       ):
												comp_and_swap(lowerCamelCase,						lowerCamelCase,						i + middle,						lowerCamelCase       )
								bitonic_merge(lowerCamelCase,						lowerCamelCase,						lowerCamelCase,						lowerCamelCase       )
								bitonic_merge(lowerCamelCase,						low + middle,						lowerCamelCase,						lowerCamelCase       )





def 				lowercase__		(					lowerCamelCase,						lowerCamelCase,						lowerCamelCase,						lowerCamelCase       ):
				if length > 1:
								_SCREAMING_SNAKE_CASE   :		Dict       		=    int(length / 2       )
								bitonic_sort(lowerCamelCase,						lowerCamelCase,						lowerCamelCase,						1       )
								bitonic_sort(lowerCamelCase,						low + middle,						lowerCamelCase,						0       )
								bitonic_merge(lowerCamelCase,						lowerCamelCase,						lowerCamelCase,						lowerCamelCase       )


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

			bitonic_sort(unsorted, 0, len(unsorted), 1)
			print('\nSorted array in ascending order is: ', end='')
			print(*unsorted, sep=', ')

			bitonic_merge(unsorted, 0, len(unsorted), 0)
			print('Sorted array in descending order is: ', end='')
			print(*unsorted, sep=', ')









"""simple docstring"""
class _lowerCAmelCase						:







						def __init__(    self   ,				lowerCAmelCase_							)		->							None:
										_SCREAMING_SNAKE_CASE   :		Dict       		=    size
										_SCREAMING_SNAKE_CASE   :		str       		=    [0] * size
										_SCREAMING_SNAKE_CASE   :		Any       		=    [0] * size







						@staticmethod
						def 			A      (    lowerCAmelCase_							)		->							int:
										return index | (index + 1)







						@staticmethod
						def 			A      (    lowerCAmelCase_							)		->							int:
										return (index & (index + 1)) - 1







						def 			A      (    self   ,				lowerCAmelCase_   ,				lowerCAmelCase_							)		->							None:
										_SCREAMING_SNAKE_CASE   :		str       		=    value
										while index < self.size:
														_SCREAMING_SNAKE_CASE   :		List[str]       		=    self.get_prev(lowerCAmelCase_							) + 1
														if current_left_border == index:
																		_SCREAMING_SNAKE_CASE   :		List[str]       		=    value
														else:
																		_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    max(lowerCAmelCase_   ,				lowerCAmelCase_   ,				lowerCAmelCase_							)
														_SCREAMING_SNAKE_CASE   :		str       		=    self.get_next(lowerCAmelCase_							)







						def 			A      (    self   ,				lowerCAmelCase_   ,				lowerCAmelCase_							)		->							int:
										right -= 1  # Because of right is exclusive
										_SCREAMING_SNAKE_CASE   :		List[Any]       		=    0
										while left <= right:
														_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    self.get_prev(lowerCAmelCase_							)
														if left <= current_left:
																		_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    max(lowerCAmelCase_   ,				self.tree[right]							)
																		_SCREAMING_SNAKE_CASE   :		List[Any]       		=    current_left
														else:
																		_SCREAMING_SNAKE_CASE   :		List[str]       		=    max(lowerCAmelCase_   ,				self.arr[right]							)
																		right -= 1
										return result


if __name__ == "__main__":
			import doctest

			doctest.testmod()

