




'''simple docstring'''





from __future__ import annotations





def 			__a			(     _UpperCamelCase:					Optional[Any]      ,		_UpperCamelCase:					Any					)		->				List[str]:

     """simple docstring"""




     _snake_case							=   0
     _snake_case							=   len(_UpperCamelCase					) - 1
     while left <= right:
          _snake_case							=   (left + right) // 2
          if left == right:
               if sorted_list[middle] < item:
                    _snake_case							=   middle + 1
               break
          elif sorted_list[middle] < item:
               _snake_case							=   middle + 1
          else:
               _snake_case							=   middle - 1
     sorted_list.insert(_UpperCamelCase      ,		_UpperCamelCase					)
     return sorted_list





def 			__a			(     _UpperCamelCase:					Union[str, Any]      ,		_UpperCamelCase:					Any					)		->				Optional[int]:

     """simple docstring"""




     _snake_case							=   []
     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 			__a			(     _UpperCamelCase:					Union[str, Any]					)		->				Union[str, Any]:

     """simple docstring"""




     _snake_case							=   len(_UpperCamelCase					)
     if length <= 1:
          return list_ad
     _snake_case							=   length // 2
     return merge(sortlist_ad(list_ad[:middle]					)      ,		sortlist_ad(list_ad[middle:]					)					)





def 			__a			(     _UpperCamelCase:					list[int]					)		->				list[int]:

     """simple docstring"""




     if len(_UpperCamelCase					) <= 1:
          return collection
     _snake_case							=   []
     _snake_case							=   False
     for i in range(0      ,		len(_UpperCamelCase					)      ,		2					):
          if i == len(_UpperCamelCase					) - 1:
               _snake_case							=   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]]					)
     _snake_case							=   sortlist_ad(_UpperCamelCase					)
     _snake_case							=   [i[0] for i in sorted_list_ad]
     result.append(sorted_list_ad[-1][1]					)
     if has_last_odd_item:
          _snake_case							=   collection[-1]
          _snake_case							=   binary_search_insertion(_UpperCamelCase      ,		_UpperCamelCase					)
     _snake_case							=   False
     for i in range(len(_UpperCamelCase					) - 1					):
          if result[i] == collection[-1] and has_last_odd_item:
               _snake_case							=   True
          _snake_case							=   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:
               _snake_case							=   result[: i + 2] + binary_search_insertion(result[i + 2 :]      ,		_UpperCamelCase					)
          else:
               _snake_case							=   result[: i + 1] + binary_search_insertion(result[i + 1 :]      ,		_UpperCamelCase					)

     return result


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








'''simple docstring'''





import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


UpperCamelCase_		:    List[str]									=		500000

UpperCamelCase_			,			UpperCamelCase_		:    Dict									=		os.path.split(__file__)
UpperCamelCase_		:    int									=		os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))





@get_duration
def 			__a			(     _UpperCamelCase:					datasets.Dataset					)		->				List[Any]:

     """simple docstring"""




     _snake_case							=   dataset.select(range(0      ,		len(_UpperCamelCase					)      ,		2					)					)





@get_duration
def 			__a			(     _UpperCamelCase:					datasets.Dataset					)		->				List[Any]:

     """simple docstring"""




     _snake_case							=   dataset.sort("numbers"					)





@get_duration
def 			__a			(     _UpperCamelCase:					datasets.Dataset					)		->				List[Any]:

     """simple docstring"""




     _snake_case							=   dataset.shuffle()





@get_duration
def 			__a			(     _UpperCamelCase:					datasets.Dataset					)		->				Any:

     """simple docstring"""




     _snake_case							=   dataset.train_test_split(0.1					)





@get_duration
def 			__a			(     _UpperCamelCase:					datasets.Dataset      ,		_UpperCamelCase:					int=10					)		->				List[str]:

     """simple docstring"""




     for shard_id in range(_UpperCamelCase					):
          _snake_case							=   dataset.shard(_UpperCamelCase      ,		_UpperCamelCase					)





def 			__a			(     )		->				int:

     """simple docstring"""




     _snake_case							=   {"num examples": SPEED_TEST_N_EXAMPLES}
     _snake_case							=   (select, sort, shuffle, train_test_split, shard)
     with tempfile.TemporaryDirectory() as tmp_dir:
          print("generating dataset"					)
          _snake_case							=   datasets.Features({"text": datasets.Value("string"					), "numbers": datasets.Value("float32"					)}					)
          _snake_case							=   generate_example_dataset(
              os.path.join(_UpperCamelCase      ,		"dataset.arrow"					)      ,		_UpperCamelCase      ,		num_examples=_UpperCamelCase					)
          print("Functions"					)
          for func in functions:
               print(func.__name__					)
               _snake_case							=   func(_UpperCamelCase					)

     with open(_UpperCamelCase      ,		"wb"					) as f:
          f.write(json.dumps(_UpperCamelCase					).encode("utf-8"					)					)


if __name__ == "__main__":  # useful to run the profiler
   benchmark_indices_mapping()


