

"""simple docstring"""

import itertools





def 					__UpperCamelCase (     a__:			Optional[Any]      )					->      Dict:




					"""simple docstring"""



					return (
					    int(''''''.join(combination[0:2]      )      ) * int(''''''.join(combination[2:5]      )      )
					    == int(''''''.join(combination[5:9]      )      )
					) or (
					    int(''''''.join(combination[0]      )      ) * int(''''''.join(combination[1:5]      )      )
					    == int(''''''.join(combination[5:9]      )      )
					)





def 					__UpperCamelCase (     )					->      Optional[int]:




					"""simple docstring"""



					return sum(
					    {
					        int(''''''.join(pandigital[5:9]      )      )
					        for pandigital in itertools.permutations('''123456789'''      )
					        if is_combination_valid(a__      )
					    }      )


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





"""simple docstring"""

import os





def 					__UpperCamelCase (     )					->      int:




					"""simple docstring"""



					__lowercase        =      os.path.dirname(os.path.realpath(a__      )      )
					__lowercase        =      os.path.join(a__			,						'''triangle.txt'''      )

					with open(a__      ) as f:
										__lowercase        =      f.readlines()

					__lowercase        =      [[int(a__      ) for y in x.rstrip('''\r\n'''      ).split(''' '''      )] for x in triangle]

					for i in range(1			,						len(a__      )      ):
										for j in range(len(a[i]      )      ):
															__lowercase        =      a[i - 1][j] if j != len(a[i - 1]      ) else 0
															__lowercase        =      a[i - 1][j - 1] if j > 0 else 0
															a[i][j] += max(a__			,						a__      )
					return max(a[-1]      )


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


