






# Lint as: python3

import hashlib
from typing import Union

def   snake_case					(UpperCAmelCase__  )       ->				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_:					Dict          =				hash_data.replace('\\'	,    '/'  )
  elif isinstance(snake_case__	,    snake_case__  ):
    UpperCamelCase_:					Tuple          =				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 				_lowerCAmelCase(       _UpperCamelCase					):





       """simple docstring"""







       def __init__(					self  ,			_lowerCamelCase							):
         UpperCamelCase_:					Union[str, Any]          =				'\nFAILURE TO GENERATE DATASET: Invalid key type detected'
         UpperCamelCase_:					Optional[int]          =				f'''\nFound Key {hash_data} of type {type(__a							)}'''
         UpperCamelCase_:					Optional[Any]          =				'\nKeys should be either str, int or bytes type'
         super().__init__(f'''{self.prefix}{self.err_msg}{self.suffix}'''							)







class 				_lowerCAmelCase(       _UpperCamelCase					):





       """simple docstring"""







       def __init__(					self  ,			_lowerCamelCase  ,			_lowerCamelCase  ,			_lowerCamelCase=""							):
         UpperCamelCase_:					Dict          =				key
         UpperCamelCase_:					int          =				duplicate_key_indices
         UpperCamelCase_:					int          =				fix_msg
         UpperCamelCase_:					List[str]          =				'Found multiple examples generated with the same key'
         if len(__a							) <= 2_0:
           UpperCamelCase_:					Optional[int]          =				f'''\nThe examples at index {', '.join(__a							)} have the key {key}'''
         else:
           UpperCamelCase_:					Optional[int]          =				f'''\nThe examples at index {', '.join(duplicate_key_indices[:2_0]							)}... ({len(__a							) - 2_0} more) have the key {key}'''
         UpperCamelCase_:					int          =				'\n' + fix_msg if fix_msg else ''
         super().__init__(f'''{self.prefix}{self.err_msg}{self.suffix}'''							)







class 				_lowerCAmelCase:





       """simple docstring"""







       def __init__(					self  ,			_lowerCamelCase							):
         UpperCamelCase_:					Any          =				hashlib.mda(_as_bytes(__a							)							)





       def 			_a    (					self  ,			_lowerCamelCase							):
         UpperCamelCase_:					Optional[int]          =				self._split_mda.copy()
         UpperCamelCase_:					str          =				_as_bytes(__a							)
         mda.update(__a							)
         # Convert to integer with hexadecimal conversion
         return int(mda.hexdigest()  ,			1_6							)


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())



