






import time
from contextlib import contextmanager
from pathlib import Path

import pytest
import requests
from huggingface_hub.hf_api import HfApi, HfFolder


_a      	=  '''__DUMMY_TRANSFORMERS_USER__'''
_a      	=  '''Dummy User'''
_a      	=  '''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'''

_a      	=  '''https://hub-ci.huggingface.co'''
_a      	=  CI_HUB_ENDPOINT + '''/datasets/{repo_id}/resolve/{revision}/{path}'''
_a      	=  CI_HUB_ENDPOINT + '''/{repo_id}/resolve/{revision}/{filename}'''
_a      	=  Path('''~/.huggingface/hub_ci_token''').expanduser()


@pytest.fixture
def __A    (      __lowerCAmelCase	)->  Optional[Any]:





						"""simple docstring"""



						monkeypatch.setattr(
						    'huggingface_hub.file_download.HUGGINGFACE_CO_URL_TEMPLATE' ,		__lowerCAmelCase	)


@pytest.fixture
def __A    (      __lowerCAmelCase	)->  Union[str, Any]:





						"""simple docstring"""



						monkeypatch.setattr('datasets.config.HF_ENDPOINT' ,		__lowerCAmelCase	)
						monkeypatch.setattr('datasets.config.HUB_DATASETS_URL' ,		__lowerCAmelCase	)


@pytest.fixture
def __A    (      __lowerCAmelCase	)->  Optional[Any]:





						"""simple docstring"""



						monkeypatch.setattr('huggingface_hub.hf_api.HfFolder.path_token' ,		__lowerCAmelCase	)


@pytest.fixture
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase	)->  Tuple:





						"""simple docstring"""



						HfFolder.save_token(__lowerCAmelCase	)
						yield
						HfFolder.delete_token()


@pytest.fixture(scope='session'	)
def __A    (      )->  Tuple:





						"""simple docstring"""



						return HfApi(endpoint=__lowerCAmelCase	)


@pytest.fixture(scope='session'	)
def __A    (      __lowerCAmelCase	)->  Union[str, Any]:





						"""simple docstring"""



						_UpperCAmelCase									=			HfFolder.get_token()
						HfFolder.save_token(__lowerCAmelCase	)
						yield CI_HUB_USER_TOKEN
						if previous_token is not None:
												HfFolder.save_token(__lowerCAmelCase	)


@pytest.fixture
def __A    (      __lowerCAmelCase	)->  Optional[Any]:





						"""simple docstring"""



						def _cleanup_repo(__lowerCAmelCase	):
												hf_api.delete_repo(__lowerCAmelCase ,		token=__lowerCAmelCase ,		repo_type='dataset'	)

						return _cleanup_repo


@pytest.fixture
def __A    (      __lowerCAmelCase	)->  Union[str, Any]:





						"""simple docstring"""



						@contextmanager
						def _temporary_repo(__lowerCAmelCase	):
												try:
																		yield repo_id
												finally:
																		cleanup_repo(__lowerCAmelCase	)

						return _temporary_repo


@pytest.fixture(scope='session'	)
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)->  Dict:





						"""simple docstring"""



						_UpperCAmelCase									=			F"""repo_txt_data-{int(time.time() * 10E3	)}"""
						_UpperCAmelCase									=			F"""{CI_HUB_USER}/{repo_name}"""
						hf_api.create_repo(__lowerCAmelCase ,		token=__lowerCAmelCase ,		repo_type='dataset' ,		private=__lowerCAmelCase	)
						hf_api.upload_file(
						    token=__lowerCAmelCase ,		path_or_fileobj=str(__lowerCAmelCase	) ,		path_in_repo='data/text_data.txt' ,		repo_id=__lowerCAmelCase ,		repo_type='dataset' ,		)
						yield repo_id
						try:
												hf_api.delete_repo(__lowerCAmelCase ,		token=__lowerCAmelCase ,		repo_type='dataset'	)
						except (requests.exceptions.HTTPError, ValueError):  # catch http error and token invalid error
												pass


@pytest.fixture()
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)->  List[Any]:





						"""simple docstring"""



						return hf_private_dataset_repo_txt_data_


@pytest.fixture(scope='session'	)
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)->  int:





						"""simple docstring"""



						_UpperCAmelCase									=			F"""repo_zipped_txt_data-{int(time.time() * 10E3	)}"""
						_UpperCAmelCase									=			F"""{CI_HUB_USER}/{repo_name}"""
						hf_api.create_repo(__lowerCAmelCase ,		token=__lowerCAmelCase ,		repo_type='dataset' ,		private=__lowerCAmelCase	)
						hf_api.upload_file(
						    token=__lowerCAmelCase ,		path_or_fileobj=str(__lowerCAmelCase	) ,		path_in_repo='data.zip' ,		repo_id=__lowerCAmelCase ,		repo_type='dataset' ,		)
						yield repo_id
						try:
												hf_api.delete_repo(__lowerCAmelCase ,		token=__lowerCAmelCase ,		repo_type='dataset'	)
						except (requests.exceptions.HTTPError, ValueError):  # catch http error and token invalid error
												pass


@pytest.fixture()
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)->  List[Any]:





						"""simple docstring"""



						return hf_private_dataset_repo_zipped_txt_data_


@pytest.fixture(scope='session'	)
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)->  Dict:





						"""simple docstring"""



						_UpperCAmelCase									=			F"""repo_zipped_img_data-{int(time.time() * 10E3	)}"""
						_UpperCAmelCase									=			F"""{CI_HUB_USER}/{repo_name}"""
						hf_api.create_repo(__lowerCAmelCase ,		token=__lowerCAmelCase ,		repo_type='dataset' ,		private=__lowerCAmelCase	)
						hf_api.upload_file(
						    token=__lowerCAmelCase ,		path_or_fileobj=str(__lowerCAmelCase	) ,		path_in_repo='data.zip' ,		repo_id=__lowerCAmelCase ,		repo_type='dataset' ,		)
						yield repo_id
						try:
												hf_api.delete_repo(__lowerCAmelCase ,		token=__lowerCAmelCase ,		repo_type='dataset'	)
						except (requests.exceptions.HTTPError, ValueError):  # catch http error and token invalid error
												pass


@pytest.fixture()
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)->  int:





						"""simple docstring"""



						return hf_private_dataset_repo_zipped_img_data_








def __A    (      __lowerCAmelCase	)->  list:





						"""simple docstring"""



						if len(__lowerCAmelCase	) < 2:
												return collection

						def circle_sort_util(__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	) -> bool:
												_UpperCAmelCase									=			False

												if low == high:
																		return swapped

												_UpperCAmelCase									=			low
												_UpperCAmelCase									=			high

												while left < right:
																		if collection[left] > collection[right]:
																								_UpperCAmelCase					, _UpperCAmelCase									=			(
																								    collection[right],
																								    collection[left],
																								)
																								_UpperCAmelCase									=			True

																		left += 1
																		right -= 1

												if left == right and collection[left] > collection[right + 1]:
																		_UpperCAmelCase					, _UpperCAmelCase									=			(
																		    collection[right + 1],
																		    collection[left],
																		)

																		_UpperCAmelCase									=			True

												_UpperCAmelCase									=			low + int((high - low) / 2	)
												_UpperCAmelCase									=			circle_sort_util(__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)
												_UpperCAmelCase									=			circle_sort_util(__lowerCAmelCase ,		mid + 1 ,		__lowerCAmelCase	)

												return swapped or left_swap or right_swap

						_UpperCAmelCase									=			True

						while is_not_sorted is True:
												_UpperCAmelCase									=			circle_sort_util(__lowerCAmelCase ,		0 ,		len(__lowerCAmelCase	) - 1	)

						return collection


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