




'''simple docstring'''




from __future__ import annotations




def     snake_case__     (			lowerCamelCase__					: int      ,		lowerCamelCase__					: int      ,		lowerCamelCase__					: int      ) -> int:
					assert n > 1 and a > 0 and greatest_common_divisor(lowerCamelCase__      ,		lowerCamelCase__      ) == 1
					((A_)			,(A_)			,(A_))			:  Optional[int]			=				extended_gcd(lowerCamelCase__      ,		lowerCamelCase__      )  # Implemented below
					A_			:  Dict			=				(b * s) % n
					return x




def     snake_case__     (			lowerCamelCase__					: int      ,		lowerCamelCase__					: int      ) -> int:
					((A_)			,(A_))			:  List[str]			=				extended_euclid(lowerCamelCase__      ,		lowerCamelCase__      )  # Implemented below
					if b < 0:
										A_			:  int			=				(b % n + n) % n
					return b




def     snake_case__     (			lowerCamelCase__					: int      ,		lowerCamelCase__					: int      ,		lowerCamelCase__					: int      ) -> int:
					A_			:  Union[str, Any]			=				invert_modulo(lowerCamelCase__      ,		lowerCamelCase__      )
					A_			:  str			=				(b * s) % n
					return x




def     snake_case__     (			lowerCamelCase__					: int      ,		lowerCamelCase__					: int      ) -> tuple[int, int, int]:
					assert a >= 0 and b >= 0

					if b == 0:
										A_			,A_			,A_			:  Any			=				a, 1, 0
					else:
										((A_)			,(A_)			,(A_))			:  List[str]			=				extended_gcd(lowerCamelCase__      ,		a % b      )
										A_			:  Tuple			=				q
										A_			:  Any			=				p - q * (a // b)

					assert a % d == 0 and b % d == 0
					assert d == a * x + b * y

					return (d, x, y)




def     snake_case__     (			lowerCamelCase__					: int      ,		lowerCamelCase__					: int      ) -> tuple[int, int]:
					if b == 0:
										return (1, 0)
					((A_)			,(A_))			:  Tuple			=				extended_euclid(lowerCamelCase__      ,		a % b      )
					A_			:  Optional[int]			=				a // b
					return (y, x - k * y)




def     snake_case__     (			lowerCamelCase__					: int      ,		lowerCamelCase__					: int      ) -> int:
					if a < b:
										A_			,A_			:  int			=				b, a

					while a % b != 0:
										A_			,A_			:  Optional[int]			=				b, a % b

					return b


if __name__ == "__main__":
							from doctest import testmod

							testmod(name="""modular_division""", verbose=True)
							testmod(name="""modular_division2""", verbose=True)
							testmod(name="""invert_modulo""", verbose=True)
							testmod(name="""extended_gcd""", verbose=True)
							testmod(name="""extended_euclid""", verbose=True)
							testmod(name="""greatest_common_divisor""", verbose=True)









'''simple docstring'''




import os




def     snake_case__     (			) -> int:
					A_			:  List[str]			=				os.path.dirname(os.path.realpath(lowerCamelCase__      )      )
					A_			:  str			=				os.path.join(lowerCamelCase__      ,		'''triangle.txt'''      )

					with open(lowerCamelCase__      ) as in_file:
										A_			:  List[str]			=				[[int(lowerCamelCase__      ) for i in line.split()] for line in in_file]

					while len(lowerCamelCase__      ) != 1:
										A_			:  List[str]			=				triangle.pop()
										A_			:  Optional[Any]			=				triangle[-1]
										for j in range(len(lowerCamelCase__      ) - 1      ):
															curr_row[j] += max(last_row[j]      ,		last_row[j + 1]      )
					return triangle[0][0]


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



