





class  A__       :





      def __init__(			self	,							A_	,							A_=None	,							A_=None       ):
       '''simple docstring'''




       UpperCamelCase     : List[str]	     =       data
       UpperCamelCase     : Tuple	     =       previous
       UpperCamelCase     : Union[str, Any]	     =       next_node





      def __str__(			self       ):
       '''simple docstring'''




       return F"""{self.data}"""





      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       return self.data





      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       return self.next





      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       return self.previous



class  A__       :





      def __init__(			self	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Optional[Any]	     =       head





      def __iter__(			self       ):
       '''simple docstring'''




       return self





      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       if not self.current:
        raise StopIteration
       else:
        UpperCamelCase     : List[Any]	     =       self.current.get_data()
        UpperCamelCase     : Any	     =       self.current.get_next()
        return value



class  A__       :





      def __init__(			self       ):
       '''simple docstring'''




       UpperCamelCase     : int	     =       None  # First node in list
       UpperCamelCase     : Optional[int]	     =       None  # Last node in list





      def __str__(			self       ):
       '''simple docstring'''




       UpperCamelCase     : Optional[Any]	     =       self.head
       UpperCamelCase     : Union[str, Any]	     =       []
       while current is not None:
        nodes.append(current.get_data()       )
        UpperCamelCase     : Optional[int]	     =       current.get_next()
       return " ".join(str(A_       ) for node in nodes       )





      def __contains__(			self	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Any	     =       self.head
       while current:
        if current.get_data() == value:
         return True
        UpperCamelCase     : List[str]	     =       current.get_next()
       return False





      def __iter__(			self       ):
       '''simple docstring'''




       return LinkedListIterator(self.head       )





      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       if self.head:
        return self.head.get_data()
       return None





      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       if self.tail:
        return self.tail.get_data()
       return None





      def 	__UpperCamelCase(			self	,							A_       ):
       '''simple docstring'''




       if self.head is None:
        UpperCamelCase     : Dict	     =       node
        UpperCamelCase     : Union[str, Any]	     =       node
       else:
        self.insert_before_node(self.head	,							A_       )





      def 	__UpperCamelCase(			self	,							A_       ):
       '''simple docstring'''




       if self.head is None:
        self.set_head(A_       )
       else:
        self.insert_after_node(self.tail	,							A_       )





      def 	__UpperCamelCase(			self	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Any	     =       Node(A_       )
       if self.head is None:
        self.set_head(A_       )
       else:
        self.set_tail(A_       )





      def 	__UpperCamelCase(			self	,							A_	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Union[str, Any]	     =       node
       UpperCamelCase     : int	     =       node.previous

       if node.get_previous() is None:
        UpperCamelCase     : List[Any]	     =       node_to_insert
       else:
        UpperCamelCase     : Union[str, Any]	     =       node_to_insert

       UpperCamelCase     : Union[str, Any]	     =       node_to_insert





      def 	__UpperCamelCase(			self	,							A_	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Optional[int]	     =       node
       UpperCamelCase     : List[str]	     =       node.next

       if node.get_next() is None:
        UpperCamelCase     : Union[str, Any]	     =       node_to_insert
       else:
        UpperCamelCase     : Tuple	     =       node_to_insert

       UpperCamelCase     : Optional[Any]	     =       node_to_insert





      def 	__UpperCamelCase(			self	,							A_	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Dict	     =       1
       UpperCamelCase     : List[Any]	     =       Node(A_       )
       UpperCamelCase     : Any	     =       self.head
       while node:
        if current_position == position:
         self.insert_before_node(A_	,							A_       )
         return
        current_position += 1
        UpperCamelCase     : List[str]	     =       node.next
       self.insert_after_node(self.tail	,							A_       )





      def 	__UpperCamelCase(			self	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Optional[int]	     =       self.head
       while node:
        if node.get_data() == item:
         return node
        UpperCamelCase     : Tuple	     =       node.get_next()
       raise Exception("Node not found"       )





      def 	__UpperCamelCase(			self	,							A_       ):
       '''simple docstring'''




       if (node := self.get_node(A_       )) is not None:
        if node == self.head:
         UpperCamelCase     : Optional[int]	     =       self.head.get_next()

        if node == self.tail:
         UpperCamelCase     : List[Any]	     =       self.tail.get_previous()

        self.remove_node_pointers(A_       )





      @staticmethod
      def 	__UpperCamelCase(			A_       ):
       '''simple docstring'''




       if node.get_next():
        UpperCamelCase     : List[Any]	     =       node.previous

       if node.get_previous():
        UpperCamelCase     : Dict	     =       node.next

       UpperCamelCase     : Any	     =       None
       UpperCamelCase     : Any	     =       None





      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       return self.head is None



def 		A_    (					)						->			None:
 pass


if __name__ == "__main__":
    import doctest

    doctest.testmod()







import os



def 		A_    (					)						->			int:
 UpperCamelCase     : List[str]	     =       os.path.dirname(os.path.realpath(_lowerCAmelCase					)					)
 UpperCamelCase     : Any	     =       os.path.join(_lowerCAmelCase							,       "triangle.txt"					)

 with open(_lowerCAmelCase					) as f:
  UpperCamelCase     : Optional[Any]	     =       f.readlines()

 UpperCamelCase     : Tuple	     =       []
 for line in triangle:
  UpperCamelCase     : List[str]	     =       []
  for number in line.strip().split(" "					):
   numbers_from_line.append(int(_lowerCAmelCase					)					)
  a.append(_lowerCAmelCase					)

 for i in range(1							,       len(_lowerCAmelCase					)					):
  for j in range(len(a[i]					)					):
   UpperCamelCase     : List[Any]	     =       a[i - 1][j] if j != len(a[i - 1]					) else 0
   UpperCamelCase     : Dict	     =       a[i - 1][j - 1] if j > 0 else 0
   a[i][j] += max(_lowerCAmelCase							,       _lowerCAmelCase					)
 return max(a[-1]					)


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