

import posixpath
from pathlib import Path
from unittest.mock import patch

import pytest
from fsspec.implementations.local import AbstractFileSystem, LocalFileSystem, stringify_path
from fsspec.registry import _registry as _fsspec_registry



class     lowercase						(       _UpperCamelCase					):



 '''simple docstring'''


 __SCREAMING_SNAKE_CASE												=				"""mock"""




 def __init__(self       ,       *__a       ,       __a       ,       **__a ) ->					Tuple:






  """simple docstring"""





  super().__init__()
  UpperCAmelCase__							=				LocalFileSystem(*__a       ,       **__a )
  UpperCAmelCase__							=				Path(__a ).resolve().as_posix() + '/'




 def   UpperCamelCase__							(self       ,       __a       ,       *__a       ,       **__a ) ->					Optional[Any]:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  return self._fs.mkdir(__a       ,       *__a       ,       **__a )




 def   UpperCamelCase__							(self       ,       __a       ,       *__a       ,       **__a ) ->					Tuple:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  return self._fs.makedirs(__a       ,       *__a       ,       **__a )




 def   UpperCamelCase__							(self       ,       __a ) ->					Any:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  return self._fs.rmdir(__a )




 def   UpperCamelCase__							(self       ,       __a       ,       __a=True       ,       *__a       ,       **__a ) ->					Union[str, Any]:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  UpperCAmelCase__							=				self._fs.ls(__a       ,       detail=__a       ,       *__a       ,       **__a )
  if detail:
   return [{**info, "name": info["name"][len(self.local_root_dir ) :]} for info in out]
  else:
   return [name[len(self.local_root_dir ) :] for name in out]




 def   UpperCamelCase__							(self       ,       __a       ,       *__a       ,       **__a ) ->					Tuple:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  UpperCAmelCase__							=				dict(self._fs.info(__a       ,       *__a       ,       **__a ) )
  UpperCAmelCase__							=				out['name'][len(self.local_root_dir ) :]
  return out




 def   UpperCamelCase__							(self       ,       __a       ,       __a       ,       *__a       ,       **__a ) ->					int:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  return self._fs.cp_file(__a       ,       __a       ,       *__a       ,       **__a )




 def   UpperCamelCase__							(self       ,       __a       ,       *__a       ,       **__a ) ->					Dict:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  return self._fs.rm_file(__a       ,       *__a       ,       **__a )




 def   UpperCamelCase__							(self       ,       __a       ,       *__a       ,       **__a ) ->					List[str]:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  return self._fs.rm(__a       ,       *__a       ,       **__a )




 def   UpperCamelCase__							(self       ,       __a       ,       *__a       ,       **__a ) ->					Union[str, Any]:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  return self._fs._open(__a       ,       *__a       ,       **__a )




 def   UpperCamelCase__							(self       ,       __a ) ->					Union[str, Any]:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  return self._fs.created(__a )




 def   UpperCamelCase__							(self       ,       __a ) ->					Any:






  """simple docstring"""





  UpperCAmelCase__							=				posixpath.join(self.local_root_dir       ,       self._strip_protocol(__a ) )
  return self._fs.modified(__a )




 @classmethod
 def   UpperCamelCase__							(cls       ,       __a ) ->					Dict:






  """simple docstring"""





  UpperCAmelCase__							=				stringify_path(__a )
  if path.startswith('mock://' ):
   UpperCAmelCase__							=				path[7:]
  return path







class     lowercase						(       _UpperCamelCase					):



 '''simple docstring'''


 __SCREAMING_SNAKE_CASE												=				"""tmp"""
 __SCREAMING_SNAKE_CASE												=				None




 def __init__(self       ,       *__a       ,       **__a ) ->					int:






  """simple docstring"""





  assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
  super().__init__(*__a       ,       **__a       ,       local_root_dir=self.tmp_dir       ,       auto_mkdir=__a )




 @classmethod
 def   UpperCamelCase__							(cls       ,       __a ) ->					Optional[Any]:






  """simple docstring"""





  UpperCAmelCase__							=				stringify_path(__a )
  if path.startswith('tmp://' ):
   UpperCAmelCase__							=				path[6:]
  return path







@pytest.fixture
def 						UpperCamelCase_(			)       -> List[Any]:
 UpperCAmelCase__							=				MockFileSystem
 UpperCAmelCase__							=				TmpDirFileSystem
 yield
 del _fsspec_registry["mock"]
 del _fsspec_registry["tmp"]
@pytest.fixture
def 						UpperCamelCase_(			snake_case__:  List[str]  ,    snake_case__:  List[str]   )       -> str:
 UpperCAmelCase__							=				tmp_path_factory.mktemp('mockfs'   )
 return MockFileSystem(local_root_dir=snake_case__  ,    auto_mkdir=snake_case__   )







@pytest.fixture
def 						UpperCamelCase_(			snake_case__:  str  ,    snake_case__:  List[str]   )       -> Dict:
 UpperCAmelCase__							=				tmp_path_factory.mktemp('tmpfs'   )
 with patch.object(snake_case__  ,    'tmp_dir'  ,    snake_case__   ):
  yield TmpDirFileSystem()






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



