




'''simple docstring'''



from itertools import compress, repeat
from math import ceil, sqrt



def       UpperCAmelCase__ (     UpperCAmelCase_   :    Tuple							)					->		List[Any]:




     if num <= 2:
          return []
     if num == 3:
          return [2]

     # Odd sieve for numbers in range [3, num - 1]
     __lowerCamelCase       :     Optional[Any]        =		bytearray(B'\x01'							) * ((num >> 1) - 1)

     for i in range(3				,   int(sqrt(_UpperCamelCase							)							) + 1				,   2							):
          if sieve[(i >> 1) - 1]:
               __lowerCamelCase       :     Dict        =		i**2
               __lowerCamelCase       :     Any        =		repeat(
                   0				,   ceil((num - i_squared) / (i << 1)							)							)

     return [2] + list(compress(range(3				,   _UpperCamelCase				,   2							)				,   _UpperCamelCase							)							)


if __name__ == "__main__":
      import doctest

      doctest.testmod()










'''simple docstring'''



from typing import Literal

A__		: Tuple												=  """ABCDEFGHIJKLMNOPQRSTUVWXYZ"""



def       UpperCAmelCase__ (     UpperCAmelCase_   :    str				,   UpperCAmelCase_   :    str				,   UpperCAmelCase_   :    Literal["encrypt", "decrypt"]							)					->		str:
     __lowerCamelCase       :     Dict        =		LETTERS if mode == 'decrypt' else key
     __lowerCamelCase       :     Tuple        =		key if mode == 'decrypt' else LETTERS
     __lowerCamelCase       :     Optional[int]        =		''
     # loop through each symbol in the message
     for symbol in message:
          if symbol.upper() in chars_a:
               # encrypt/decrypt the symbol
               __lowerCamelCase       :     Optional[int]        =		chars_a.find(symbol.upper()							)
               if symbol.isupper():
                    translated += chars_b[sym_index].upper()
               else:
                    translated += chars_b[sym_index].lower()
          else:
               # symbol is not in LETTERS, just add it
               translated += symbol
     return translated



def       UpperCAmelCase__ (     UpperCAmelCase_   :    str				,   UpperCAmelCase_   :    str							)					->		str:
     return translate_message(UpperCAmelCase_				,   UpperCAmelCase_				,   'encrypt'							)



def       UpperCAmelCase__ (     UpperCAmelCase_   :    str				,   UpperCAmelCase_   :    str							)					->		str:
     return translate_message(UpperCAmelCase_				,   UpperCAmelCase_				,   'decrypt'							)



def       UpperCAmelCase__ (     )					->		None:
     __lowerCamelCase       :     Dict        =		'Hello World'
     __lowerCamelCase       :     str        =		'QWERTYUIOPASDFGHJKLZXCVBNM'
     __lowerCamelCase       :     Any        =		'decrypt'  # set to 'encrypt' or 'decrypt'

     if mode == "encrypt":
          __lowerCamelCase       :     Optional[int]        =		encrypt_message(UpperCAmelCase_				,   UpperCAmelCase_							)
     elif mode == "decrypt":
          __lowerCamelCase       :     List[str]        =		decrypt_message(UpperCAmelCase_				,   UpperCAmelCase_							)
     print(F'Using the key {key}, the {mode}ed message is: {translated}'							)


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      main()






