


from __future__ import annotations



def     __lowerCAmelCase						(							snake_case	:    list						,      snake_case	:    int						,      snake_case	:    int						,      snake_case	:    int )       ->							list:
   __lowerCamelCase:				Optional[Any]     =	[]
   __lowerCamelCase:				Any     =	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 ) )
   __lowerCamelCase:				Any     =	result + left + right
   return input_list



def     __lowerCAmelCase						(							snake_case	:    list )       ->							list:
   if len(snake_case ) <= 1:
      return input_list
   __lowerCamelCase:				Tuple     =	list(snake_case )

   # iteration for two-way merging
   __lowerCamelCase:				List[str]     =	2
   while p <= len(snake_case ):
      # getting low, high and middle value for merge-sort of single list
      for i in range(0						,      len(snake_case )						,      snake_case ):
         __lowerCamelCase:				Optional[Any]     =	i
         __lowerCamelCase:				Optional[int]     =	i + p - 1
         __lowerCamelCase:				List[str]     =	(low + high + 1) // 2
         __lowerCamelCase:				List[str]     =	merge(snake_case						,      snake_case						,      snake_case						,      snake_case )
      # final merge of last two parts
      if p * 2 >= len(snake_case ):
         __lowerCamelCase:				str     =	i
         __lowerCamelCase:				Dict     =	merge(snake_case						,      0						,      snake_case						,      len(snake_case ) - 1 )
         break
      p *= 2

   return input_list


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






_A		:				Tuple									=       '''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''



def     __lowerCAmelCase						(							)       ->							None:
   __lowerCamelCase:				Optional[int]     =	input("""Enter message: """ )
   __lowerCamelCase:				Dict     =	input("""Enter key [alphanumeric]: """ )
   __lowerCamelCase:				List[Any]     =	input("""Encrypt/Decrypt [e/d]: """ )

   if mode.lower().startswith("""e""" ):
      __lowerCamelCase:				Optional[int]     =	"""encrypt"""
      __lowerCamelCase:				Optional[int]     =	encrypt_message(snake_case						,      snake_case )
   elif mode.lower().startswith("""d""" ):
      __lowerCamelCase:				Union[str, Any]     =	"""decrypt"""
      __lowerCamelCase:				Optional[Any]     =	decrypt_message(snake_case						,      snake_case )

   print(f'\n{mode.title()}ed message:' )
   print(snake_case )



def     __lowerCAmelCase						(							snake_case	:    str						,      snake_case	:    str )       ->							str:
   return translate_message(snake_case						,      snake_case						,      """encrypt""" )



def     __lowerCAmelCase						(							snake_case	:    str						,      snake_case	:    str )       ->							str:
   return translate_message(snake_case						,      snake_case						,      """decrypt""" )



def     __lowerCAmelCase						(							snake_case	:    str						,      snake_case	:    str						,      snake_case	:    str )       ->							str:
   __lowerCamelCase:				Any     =	[]
   __lowerCamelCase:				Optional[int]     =	0
   __lowerCamelCase:				Any     =	key.upper()

   for symbol in message:
      __lowerCamelCase:				int     =	LETTERS.find(symbol.upper() )
      if num != -1:
         if mode == "encrypt":
            num += LETTERS.find(key[key_index] )
         elif mode == "decrypt":
            num -= LETTERS.find(key[key_index] )

         num %= len(snake_case )

         if symbol.isupper():
            translated.append(LETTERS[num] )
         elif symbol.islower():
            translated.append(LETTERS[num].lower() )

         key_index += 1
         if key_index == len(snake_case ):
            __lowerCamelCase:				Union[str, Any]     =	0
      else:
         translated.append(snake_case )
   return "".join(snake_case )


if __name__ == "__main__":
   main()


