'''simple docstring'''


def    _lowerCamelCase       ( lowerCamelCase_   :				str      ,	lowerCamelCase_   :				str  ):



     """simple docstring"""





     if not isinstance(lowerCamelCase_      ,	lowerCamelCase_  ):
          raise TypeError('plaintext must be a string'  )
     if not isinstance(lowerCamelCase_      ,	lowerCamelCase_  ):
          raise TypeError('key must be a string'  )

     if not plaintext:
          raise ValueError('plaintext is empty'  )
     if not key:
          raise ValueError('key is empty'  )

     key += plaintext
     UpperCAmelCase_				:  Optional[Any]  = plaintext.lower()
     UpperCAmelCase_				:  List[str]  = key.lower()
     UpperCAmelCase_				:  List[Any]  = 0
     UpperCAmelCase_				:  Optional[int]  = 0
     UpperCAmelCase_				:  List[Any]  = ''
     while plaintext_iterator < len(lowerCamelCase_  ):
          if (
              ord(plaintext[plaintext_iterator]  ) < 97
              or ord(plaintext[plaintext_iterator]  ) > 122
          ):
               ciphertext += plaintext[plaintext_iterator]
               plaintext_iterator += 1
          elif ord(key[key_iterator]  ) < 97 or ord(key[key_iterator]  ) > 122:
               key_iterator += 1
          else:
               ciphertext += chr(
                   (
                       (ord(plaintext[plaintext_iterator]  ) - 97 + ord(key[key_iterator]  ))
                       - 97
                   )
                   % 26
                   + 97  )
               key_iterator += 1
               plaintext_iterator += 1
     return ciphertext


def    _lowerCamelCase       ( lowerCamelCase_   :				str      ,	lowerCamelCase_   :				str  ):



     """simple docstring"""





     if not isinstance(lowerCamelCase_      ,	lowerCamelCase_  ):
          raise TypeError('ciphertext must be a string'  )
     if not isinstance(lowerCamelCase_      ,	lowerCamelCase_  ):
          raise TypeError('key must be a string'  )

     if not ciphertext:
          raise ValueError('ciphertext is empty'  )
     if not key:
          raise ValueError('key is empty'  )

     UpperCAmelCase_				:  Optional[Any]  = key.lower()
     UpperCAmelCase_				:  int  = 0
     UpperCAmelCase_				:  Optional[Any]  = 0
     UpperCAmelCase_				:  Tuple  = ''
     while ciphertext_iterator < len(lowerCamelCase_  ):
          if (
              ord(ciphertext[ciphertext_iterator]  ) < 97
              or ord(ciphertext[ciphertext_iterator]  ) > 122
          ):
               plaintext += ciphertext[ciphertext_iterator]
          else:
               plaintext += chr(
                   (ord(ciphertext[ciphertext_iterator]  ) - ord(key[key_iterator]  )) % 26
                   + 97  )
               key += chr(
                   (ord(ciphertext[ciphertext_iterator]  ) - ord(key[key_iterator]  )) % 26
                   + 97  )
               key_iterator += 1
          ciphertext_iterator += 1
     return plaintext


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 snake_case__	:     Union[str, Any]      =    int(input('''Type 1 to encrypt or 2 to decrypt:'''))
 if operation == 1:
  snake_case__	:     Dict      =    input('''Typeplaintext to be encrypted:\n''')
  snake_case__	:     List[Any]      =    input('''Type the key:\n''')
  print(encrypt(plaintext, key))
 elif operation == 2:
  snake_case__	:     List[str]      =    input('''Type the ciphertext to be decrypted:\n''')
  snake_case__	:     Optional[int]      =    input('''Type the key:\n''')
  print(decrypt(ciphertext, key))
 decrypt('''jsqqs avvwo''', '''coffee''')







'''simple docstring'''


from __future__ import annotations

snake_case__	:     str      =    [2, 1, 4, 5, 6, 0, 8, 9, 1, 2, 0, 6, 4, 2, 0, 6, 5, 3, 2, 7]






class 	__SCREAMING_SNAKE_CASE		:







  '''simple docstring'''






  def __init__(					self ,						snake_case_		):




       '''simple docstring'''

       UpperCAmelCase_				:  int  = -1
       UpperCAmelCase_				:  int  = -1
       UpperCAmelCase_				:  list[int]  = [-1] * length
       UpperCAmelCase_				:  Node | None  = None
       UpperCAmelCase_				:  Node | None  = None






  def __repr__(					self		):




       '''simple docstring'''

       return F'''Node(min_value={self.minn} max_value={self.maxx})'''







def    _lowerCamelCase       ( lowerCamelCase_   :				list[int]  ):



     """simple docstring"""





     UpperCAmelCase_				:  List[str]  = Node(len(lowerCamelCase_  )  )
     UpperCAmelCase_  ,     UpperCAmelCase_				:  Any  = min(lowerCamelCase_  ), max(lowerCamelCase_  )
     # Leaf node case where the node contains only one unique value
     if root.minn == root.maxx:
          return root
     UpperCAmelCase_				:  str  = (root.minn + root.maxx) // 2

     UpperCAmelCase_				:  list[int]  = []
     UpperCAmelCase_				:  list[int]  = []

     for index, num in enumerate(lowerCamelCase_  ):
          if num <= pivot:
               left_arr.append(lowerCamelCase_  )
          else:
               right_arr.append(lowerCamelCase_  )
          UpperCAmelCase_				:  Tuple  = len(lowerCamelCase_  )
     UpperCAmelCase_				:  Optional[Any]  = build_tree(lowerCamelCase_  )
     UpperCAmelCase_				:  Optional[Any]  = build_tree(lowerCamelCase_  )
     return root


def    _lowerCamelCase       ( lowerCamelCase_   :				Node | None      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int  ):



     """simple docstring"""





     if index < 0 or node is None:
          return 0
     # Leaf node cases
     if node.minn == node.maxx:
          return index + 1 if node.minn == num else 0
     UpperCAmelCase_				:  Any  = (node.minn + node.maxx) // 2
     if num <= pivot:
          # go the left subtree and map index to the left subtree
          return rank_till_index(node.left      ,	lowerCamelCase_      ,	node.map_left[index] - 1  )
     else:
          # go to the right subtree and map index to the right subtree
          return rank_till_index(node.right      ,	lowerCamelCase_      ,	index - node.map_left[index]  )


def    _lowerCamelCase       ( lowerCamelCase_   :				Node | None      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int  ):



     """simple docstring"""





     if start > end:
          return 0
     UpperCAmelCase_				:  int  = rank_till_index(lowerCamelCase_      ,	lowerCamelCase_      ,	lowerCamelCase_  )
     UpperCAmelCase_				:  List[Any]  = rank_till_index(lowerCamelCase_      ,	lowerCamelCase_      ,	start - 1  )
     return rank_till_end - rank_before_start


def    _lowerCamelCase       ( lowerCamelCase_   :				Node | None      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int  ):



     """simple docstring"""





     if index > (end - start) or start > end or node is None:
          return -1
     # Leaf node case
     if node.minn == node.maxx:
          return node.minn
     # Number of elements in the left subtree in interval [start, end]
     UpperCAmelCase_				:  Tuple  = node.map_left[end] - (
         node.map_left[start - 1] if start else 0
     )
     if num_elements_in_left_tree > index:
          return quantile(
              node.left      ,	lowerCamelCase_      ,	(node.map_left[start - 1] if start else 0)      ,	node.map_left[end] - 1      ,	)
     else:
          return quantile(
              node.right      ,	index - num_elements_in_left_tree      ,	start - (node.map_left[start - 1] if start else 0)      ,	end - node.map_left[end]      ,	)


def    _lowerCamelCase       ( lowerCamelCase_   :				Node | None      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int  ):



     """simple docstring"""





     if (
         start > end
         or node is None
         or start_num > end_num
         or node.minn > end_num
         or node.maxx < start_num
     ):
          return 0
     if start_num <= node.minn and node.maxx <= end_num:
          return end - start + 1
     UpperCAmelCase_				:  Any  = range_counting(
         node.left      ,	(node.map_left[start - 1] if start else 0)      ,	node.map_left[end] - 1      ,	lowerCamelCase_      ,	lowerCamelCase_      ,	)
     UpperCAmelCase_				:  List[str]  = range_counting(
         node.right      ,	start - (node.map_left[start - 1] if start else 0)      ,	end - node.map_left[end]      ,	lowerCamelCase_      ,	lowerCamelCase_      ,	)
     return left + right


if __name__ == "__main__":
 import doctest

 doctest.testmod()






