

# Lint as: python3

import hashlib
from typing import Union
def 						UpperCamelCase_(			snake_case__:  Union[str, int, bytes]   )       -> bytes:
 if isinstance(snake_case__  ,    snake_case__   ):
  # Data already in bytes, returns as it as
  return hash_data
 elif isinstance(snake_case__  ,    snake_case__   ):
  # We keep the data as it as for it ot be later encoded to UTF-8
  # However replace `\\` with `/` for Windows compatibility
  UpperCAmelCase__							=				hash_data.replace('\\'  ,    '/'   )
 elif isinstance(snake_case__  ,    snake_case__   ):
  UpperCAmelCase__							=				str(snake_case__   )
 else:
  # If data is not of the required type, raise error
  raise InvalidKeyError(snake_case__   )

 return hash_data.encode('utf-8'   )



class     lowercase						(       _UpperCamelCase					):



 '''simple docstring'''


 def __init__(self       ,       __a ) ->					Optional[Any]:






  """simple docstring"""





  UpperCAmelCase__							=				'\nFAILURE TO GENERATE DATASET: Invalid key type detected'
  UpperCAmelCase__							=				F"\nFound Key {hash_data} of type {type(__a )}"
  UpperCAmelCase__							=				'\nKeys should be either str, int or bytes type'
  super().__init__(F"{self.prefix}{self.err_msg}{self.suffix}" )







class     lowercase						(       _UpperCamelCase					):



 '''simple docstring'''


 def __init__(self       ,       __a       ,       __a       ,       __a="" ) ->					Tuple:






  """simple docstring"""





  UpperCAmelCase__							=				key
  UpperCAmelCase__							=				duplicate_key_indices
  UpperCAmelCase__							=				fix_msg
  UpperCAmelCase__							=				'Found multiple examples generated with the same key'
  if len(__a ) <= 20:
   UpperCAmelCase__							=				F"\nThe examples at index {', '.join(__a )} have the key {key}"
  else:
   UpperCAmelCase__							=				F"\nThe examples at index {', '.join(duplicate_key_indices[:20] )}... ({len(__a ) - 20} more) have the key {key}"
  UpperCAmelCase__							=				'\n' + fix_msg if fix_msg else ''
  super().__init__(F"{self.prefix}{self.err_msg}{self.suffix}" )







class     lowercase						:



 '''simple docstring'''


 def __init__(self       ,       __a ) ->					Tuple:






  """simple docstring"""





  UpperCAmelCase__							=				hashlib.mda(_as_bytes(__a ) )




 def   UpperCamelCase__							(self       ,       __a ) ->					int:






  """simple docstring"""





  UpperCAmelCase__							=				self._split_mda.copy()
  UpperCAmelCase__							=				_as_bytes(__a )
  mda.update(__a )
  # Convert to integer with hexadecimal conversion
  return int(mda.hexdigest()       ,       16 )






import os
def 						UpperCamelCase_(			)       -> int:
 UpperCAmelCase__							=				os.path.dirname(os.path.realpath(snake_case__   )   )
 UpperCAmelCase__							=				os.path.join(snake_case__  ,    'triangle.txt'   )

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

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


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



