





import os







def       lowerCAmelCase__(	) ->    int:
  __snake_case   :				List[Any]        =       os.path.dirname(os.path.realpath(lowercase				)				)
  __snake_case   :				Dict        =       os.path.join(lowercase   ,     "triangle.txt"				)

  with open(lowercase				) as in_file:
    __snake_case   :				Dict        =       [[int(lowercase				) for i in line.split()] for line in in_file]

  while len(lowercase				) != 1:
    __snake_case   :				Optional[Any]        =       triangle.pop()
    __snake_case   :				Tuple        =       triangle[-1]
    for j in range(len(lowercase				) - 1				):
      curr_row[j] += max(last_row[j]   ,     last_row[j + 1]				)
  return triangle[0][0]


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








import torch
from torch import autograd




class 				_lowerCamelCase (    autograd.Function    ):



      """simple docstring"""






      @staticmethod
      def 						UpperCAmelCase		( UpperCAmelCase				,						UpperCAmelCase				,						UpperCAmelCase				,						UpperCAmelCase   )       ->   str:






        '''simple docstring'''






        __snake_case   :				Dict        =       inputs.numel()
        __snake_case   :				Optional[int]        =       int(0.005 * nb_elems   ) + 1
        if sigmoid:
          __snake_case   :				Any        =       (torch.sigmoid(UpperCAmelCase   ) > threshold).type(inputs.type()   )
        else:
          __snake_case   :				Optional[int]        =       (inputs > threshold).type(inputs.type()   )
        if mask.sum() < nb_min:
          # We limit the pruning so that at least 0.5% (half a percent) of the weights are remaining
          __snake_case   :				List[str]        =       inputs.flatten().kthvalue(max(nb_elems - nb_min				,						1   )   ).values
          __snake_case   :				Union[str, Any]        =       (inputs > k_threshold).type(inputs.type()   )
        return mask







      @staticmethod
      def 						UpperCAmelCase		( UpperCAmelCase				,						UpperCAmelCase   )       ->   Optional[int]:






        '''simple docstring'''






        return gradOutput, None, None




class 				_lowerCamelCase (    autograd.Function    ):



      """simple docstring"""






      @staticmethod
      def 						UpperCAmelCase		( UpperCAmelCase				,						UpperCAmelCase				,						UpperCAmelCase   )       ->   Optional[int]:






        '''simple docstring'''






        __snake_case   :				Optional[int]        =       inputs.clone()
        __snake_case    ,   __snake_case   :				int        =       inputs.flatten().sort(descending=UpperCAmelCase   )
        __snake_case   :				Tuple        =       int(threshold * inputs.numel()   )

        # flat_out and mask access the same memory.
        __snake_case   :				Optional[int]        =       mask.flatten()
        __snake_case   :				Union[str, Any]        =       0
        __snake_case   :				Any        =       1
        return mask







      @staticmethod
      def 						UpperCAmelCase		( UpperCAmelCase				,						UpperCAmelCase   )       ->   List[str]:






        '''simple docstring'''






        return gradOutput, None




class 				_lowerCamelCase (    a    ):



      """simple docstring"""






      @staticmethod
      def 						UpperCAmelCase		( UpperCAmelCase				,						UpperCAmelCase   )       ->   Any:






        '''simple docstring'''






        __snake_case   :				Union[str, Any]        =       inputs.clone()
        __snake_case    ,   __snake_case   :				Optional[Any]        =       inputs.abs().flatten().sort(descending=UpperCAmelCase   )
        __snake_case   :				List[Any]        =       int(threshold * inputs.numel()   )

        # flat_out and mask access the same memory.
        __snake_case   :				Optional[Any]        =       mask.flatten()
        __snake_case   :				Tuple        =       0
        __snake_case   :				Any        =       1
        return mask

