




def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__   )     ->     str:







				'''simple docstring'''


				if not isinstance(UpperCamelCase__						,			UpperCamelCase__   ):
								raise TypeError("""plaintext must be a string"""   )
				if not isinstance(UpperCamelCase__						,			UpperCamelCase__   ):
								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
				__lowerCAmelCase					=  plaintext.lower()
				__lowerCAmelCase					=  key.lower()
				__lowerCAmelCase					=  0
				__lowerCAmelCase					=  0
				__lowerCAmelCase					=  """"""
				while plaintext_iterator < len(UpperCamelCase__   ):
								if (
								    ord(plaintext[plaintext_iterator]   ) < 97
								    or ord(plaintext[plaintext_iterator]   ) > 1_22
								):
												ciphertext += plaintext[plaintext_iterator]
												plaintext_iterator += 1
								elif ord(key[key_iterator]   ) < 97 or ord(key[key_iterator]   ) > 1_22:
												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      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__   )     ->     str:







				'''simple docstring'''


				if not isinstance(UpperCamelCase__						,			UpperCamelCase__   ):
								raise TypeError("""ciphertext must be a string"""   )
				if not isinstance(UpperCamelCase__						,			UpperCamelCase__   ):
								raise TypeError("""key must be a string"""   )

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

				__lowerCAmelCase					=  key.lower()
				__lowerCAmelCase					=  0
				__lowerCAmelCase					=  0
				__lowerCAmelCase					=  """"""
				while ciphertext_iterator < len(UpperCamelCase__   ):
								if (
								    ord(ciphertext[ciphertext_iterator]   ) < 97
								    or ord(ciphertext[ciphertext_iterator]   ) > 1_22
								):
												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()
	__A						:		Tuple          =						int(input("Type 1 to encrypt or 2 to decrypt:"))
	if operation == 1:
		__A						:		Tuple          =						input("Typeplaintext to be encrypted:\n")
		__A						:		Tuple          =						input("Type the key:\n")
		print(encrypt(plaintext, key))
	elif operation == 2:
		__A						:		List[str]          =						input("Type the ciphertext to be decrypted:\n")
		__A						:		Optional[Any]          =						input("Type the key:\n")
		print(decrypt(ciphertext, key))
	decrypt("jsqqs avvwo", "coffee")






"""simple docstring"""







def 						_lowercase				(  _SCREAMING_SNAKE_CASE				:				list[int]						)    ->     tuple[int, int]:







     '''simple docstring'''


     if len(_SCREAMING_SNAKE_CASE						) == 1:
          return a[0], a[0]
     else:
          # split A into half.
          __A					:					List[str]								=		a[: len(_SCREAMING_SNAKE_CASE						) // 2]
          __A					:					Optional[Any]								=		a[len(_SCREAMING_SNAKE_CASE						) // 2 :]

          # 2 sub problems, 1/2 of original size.
          __A						,		__A					:					int								=		max_difference(_SCREAMING_SNAKE_CASE						)
          __A						,		__A					:					str								=		max_difference(_SCREAMING_SNAKE_CASE						)

          # get min of first and max of second
          # linear time
          __A					:					str								=		min(_SCREAMING_SNAKE_CASE						)
          __A					:					Optional[int]								=		max(_SCREAMING_SNAKE_CASE						)

          # 3 cases, either (small1, big1),
          # (min_first, max_second), (small2, big2)
          # constant comparisons
          if biga - smalla > max_second - min_first and biga - smalla > biga - smalla:
               return smalla, biga
          elif biga - smalla > max_second - min_first:
               return smalla, biga
          else:
               return min_first, max_second


if __name__ == "__main__":
       import doctest

       doctest.testmod()



