





import random
import sys

SCREAMING_SNAKE_CASE_		  =			"""ABCDEFGHIJKLMNOPQRSTUVWXYZ"""



def   __lowercase  ( )					->  None:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE						=		input("""Enter message: """      )
      SCREAMING_SNAKE_CASE						=		"""LFWOAYUISVKMNXPBDCRJTQEGHZ"""
      SCREAMING_SNAKE_CASE						=		input("""Encrypt/Decrypt [e/d]: """      )

      check_valid_key(_SCREAMING_SNAKE_CASE      )

      if resp.lower().startswith("""e"""      ):
            SCREAMING_SNAKE_CASE						=		"""encrypt"""
            SCREAMING_SNAKE_CASE						=		encrypt_message(_SCREAMING_SNAKE_CASE					,		_SCREAMING_SNAKE_CASE      )
      elif resp.lower().startswith("""d"""      ):
            SCREAMING_SNAKE_CASE						=		"""decrypt"""
            SCREAMING_SNAKE_CASE						=		decrypt_message(_SCREAMING_SNAKE_CASE					,		_SCREAMING_SNAKE_CASE      )

      print(F"""\n{mode.title()}ion: \n{translated}"""      )



def   __lowercase  ( _SCREAMING_SNAKE_CASE      )					->  None:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE						=		list(_SCREAMING_SNAKE_CASE      )
      SCREAMING_SNAKE_CASE						=		list(_SCREAMING_SNAKE_CASE      )
      key_list.sort()
      letters_list.sort()

      if key_list != letters_list:
            sys.exit("""Error in the key or symbol set."""      )



def   __lowercase  ( _SCREAMING_SNAKE_CASE					,		_SCREAMING_SNAKE_CASE      )					->  str:


      '''simple docstring'''


      return translate_message(_SCREAMING_SNAKE_CASE					,		_SCREAMING_SNAKE_CASE					,		"""encrypt"""      )



def   __lowercase  ( _SCREAMING_SNAKE_CASE					,		_SCREAMING_SNAKE_CASE      )					->  str:


      '''simple docstring'''


      return translate_message(_SCREAMING_SNAKE_CASE					,		_SCREAMING_SNAKE_CASE					,		"""decrypt"""      )



def   __lowercase  ( _SCREAMING_SNAKE_CASE					,		_SCREAMING_SNAKE_CASE					,		_SCREAMING_SNAKE_CASE      )					->  str:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE						=		""""""
      SCREAMING_SNAKE_CASE						=		LETTERS
      SCREAMING_SNAKE_CASE						=		key

      if mode == "decrypt":
            SCREAMING_SNAKE_CASE,   SCREAMING_SNAKE_CASE						=		chars_b, chars_a

      for symbol in message:
            if symbol.upper() in chars_a:
                  SCREAMING_SNAKE_CASE						=		chars_a.find(symbol.upper()      )
                  if symbol.isupper():
                        translated += chars_b[sym_index].upper()
                  else:
                        translated += chars_b[sym_index].lower()
            else:
                  translated += symbol

      return translated



def   __lowercase  ( )					->  str:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE						=		list(_SCREAMING_SNAKE_CASE      )
      random.shuffle(_SCREAMING_SNAKE_CASE      )
      return "".join(_SCREAMING_SNAKE_CASE      )


if __name__ == "__main__":
      main()









import os



def   __lowercase  ( )					->  int:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE						=		os.path.dirname(os.path.realpath(_SCREAMING_SNAKE_CASE      )      )
      SCREAMING_SNAKE_CASE						=		os.path.join(_SCREAMING_SNAKE_CASE					,		"""triangle.txt"""      )

      with open(_SCREAMING_SNAKE_CASE      ) as in_file:
            SCREAMING_SNAKE_CASE						=		[[int(_SCREAMING_SNAKE_CASE      ) for i in line.split()] for line in in_file]

      while len(_SCREAMING_SNAKE_CASE      ) != 1:
            SCREAMING_SNAKE_CASE						=		triangle.pop()
            SCREAMING_SNAKE_CASE						=		triangle[-1]
            for j in range(len(_SCREAMING_SNAKE_CASE      ) - 1      ):
                  curr_row[j] += max(last_row[j]					,		last_row[j + 1]      )
      return triangle[0][0]


if __name__ == "__main__":
      print(solution())


