"""simple docstring"""




import json
import sys
import tempfile
import unittest
from pathlib import Path

import transformers
from transformers import (
    CONFIG_MAPPING,
    FEATURE_EXTRACTOR_MAPPING,
    AutoConfig,
    AutoFeatureExtractor,
    WavaVecaConfig,
    WavaVecaFeatureExtractor,
)
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, get_tests_dir


sys.path.append(str(Path(__file__).parent.parent.parent.parent / "utils"))

from test_module.custom_configuration import CustomConfig  # noqa E402
from test_module.custom_feature_extraction import CustomFeatureExtractor  # noqa E402


__lowerCAmelCase    :							List[str]													=						get_tests_dir("fixtures")
__lowerCAmelCase    :							str													=						get_tests_dir("fixtures/dummy_feature_extractor_config.json")
__lowerCAmelCase    :							Union[str, Any]													=						get_tests_dir("fixtures/dummy-config.json")

class       a_      (     unittest.TestCase			):




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[Any]     ):
							lowerCAmelCase__        =   0




					def 						_SCREAMING_SNAKE_CASE						(	self						:     str     ):
							lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained("""facebook/wav2vec2-base-960h"""     )
							self.assertIsInstance(__A  ,						__A     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     int     ):
							lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(__A     )
							self.assertIsInstance(__A  ,						__A     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[int]     ):



							with tempfile.TemporaryDirectory() as tmpdirname:
									lowerCAmelCase__        =   WavaVecaConfig()

									# remove feature_extractor_type to make sure config.json alone is enough to load feature processor locally
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(__A     ).to_dict()

									config_dict.pop("""feature_extractor_type"""     )
									lowerCAmelCase__        =   WavaVecaFeatureExtractor(**__A     )

									# save in new folder
									model_config.save_pretrained(__A     )
									config.save_pretrained(__A     )

									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(__A     )

									# make sure private variable is not incorrectly saved
									lowerCAmelCase__        =   json.loads(config.to_json_string()     )
									self.assertTrue("""_processor_class""" not in dict_as_saved     )

							self.assertIsInstance(__A  ,						__A     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]     ):
							lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(__A     )
							self.assertIsInstance(__A  ,						__A     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Dict     ):



							with self.assertRaisesRegex(
							    __A  ,						"""bert-base is not a local folder and is not a valid model identifier"""     ):
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained("""bert-base"""     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Any     ):



							with self.assertRaisesRegex(
							    __A  ,						R"""aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)"""     ):
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(__A  ,						revision="""aaaaaa"""     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]     ):



							with self.assertRaisesRegex(
							    __A  ,						"""hf-internal-testing/config-no-model does not appear to have a file named preprocessor_config.json."""  ,						):
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained("""hf-internal-testing/config-no-model"""     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[Any]     ):



							with self.assertRaises(__A     ):
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(
									    """hf-internal-testing/test_dynamic_feature_extractor"""     )
							# If remote code is disabled, we can't load this config.
							with self.assertRaises(__A     ):
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(
									    """hf-internal-testing/test_dynamic_feature_extractor"""  ,						trust_remote_code=__A     )

							lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(
							    """hf-internal-testing/test_dynamic_feature_extractor"""  ,						trust_remote_code=__A     )
							self.assertEqual(feature_extractor.__class__.__name__  ,						"""NewFeatureExtractor"""     )

							# Test feature extractor can be reloaded.
							with tempfile.TemporaryDirectory() as tmp_dir:
									feature_extractor.save_pretrained(__A     )
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(__A  ,						trust_remote_code=__A     )
							self.assertEqual(reloaded_feature_extractor.__class__.__name__  ,						"""NewFeatureExtractor"""     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[Any]     ):



							try:
									AutoConfig.register("""custom"""  ,						__A     )
									AutoFeatureExtractor.register(__A  ,						__A     )
									# Trying to register something existing in the Transformers library will raise an error
									with self.assertRaises(__A     ):
											AutoFeatureExtractor.register(__A  ,						__A     )

									# Now that the config is registered, it can be used as any other config with the auto-API
									lowerCAmelCase__        =   CustomFeatureExtractor.from_pretrained(__A     )
									with tempfile.TemporaryDirectory() as tmp_dir:
											feature_extractor.save_pretrained(__A     )
											lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(__A     )
											self.assertIsInstance(__A  ,						__A     )

							finally:
									if "custom" in CONFIG_MAPPING._extra_content:
											del CONFIG_MAPPING._extra_content["custom"]
									if CustomConfig in FEATURE_EXTRACTOR_MAPPING._extra_content:
											del FEATURE_EXTRACTOR_MAPPING._extra_content[CustomConfig]




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Any     ):

							class       a_      (     UpperCamelCase__			):
												UpperCamelCase_ :	Dict			=    True

							try:
									AutoConfig.register("""custom"""  ,						__A     )
									AutoFeatureExtractor.register(__A  ,						__A     )
									# If remote code is not set, the default is to use local
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(
									    """hf-internal-testing/test_dynamic_feature_extractor"""     )
									self.assertEqual(feature_extractor.__class__.__name__  ,						"""NewFeatureExtractor"""     )
									self.assertTrue(feature_extractor.is_local     )

									# If remote code is disabled, we load the local one.
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(
									    """hf-internal-testing/test_dynamic_feature_extractor"""  ,						trust_remote_code=__A     )
									self.assertEqual(feature_extractor.__class__.__name__  ,						"""NewFeatureExtractor"""     )
									self.assertTrue(feature_extractor.is_local     )

									# If remote is enabled, we load from the Hub
									lowerCAmelCase__        =   AutoFeatureExtractor.from_pretrained(
									    """hf-internal-testing/test_dynamic_feature_extractor"""  ,						trust_remote_code=__A     )
									self.assertEqual(feature_extractor.__class__.__name__  ,						"""NewFeatureExtractor"""     )
									self.assertTrue(not hasattr(__A  ,						"""is_local"""     )     )

							finally:
									if "custom" in CONFIG_MAPPING._extra_content:
											del CONFIG_MAPPING._extra_content["custom"]
									if CustomConfig in FEATURE_EXTRACTOR_MAPPING._extra_content:
											del FEATURE_EXTRACTOR_MAPPING._extra_content[CustomConfig]





"""simple docstring"""




import os







def 							_UpperCAmelCase		(       ):





		"""simple docstring"""




		lowerCAmelCase__        =   os.path.dirname(os.path.realpath(lowerCamelCase__     )     )
		lowerCAmelCase__        =   os.path.join(lowerCamelCase__			,  """triangle.txt"""     )

		with open(lowerCamelCase__     ) as f:
				lowerCAmelCase__        =   f.readlines()

		lowerCAmelCase__        =   []
		for line in triangle:
				lowerCAmelCase__        =   []
				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]     )     ):
						lowerCAmelCase__        =   a[i - 1][j] if j != len(a[i - 1]     ) else 0
						lowerCAmelCase__        =   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())




