



"""simple docstring"""







class        __A       :







		'''simple docstring'''





		def __init__(	self						:  Tuple			,_snake_case						:  int			,_snake_case						:  Union[str, Any]=None			,_snake_case						:  List[Any]=None						)					->		Tuple:






				"""simple docstring"""



				lowercase__   :    List[Any]				=			data
				lowercase__   :    Tuple				=			previous
				lowercase__   :    Tuple				=			next_node







		def __str__(	self						:  Optional[Any]						)					->		str:






				"""simple docstring"""



				return f"""{self.data}"""







		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		int:






				"""simple docstring"""



				return self.data







		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		Any:






				"""simple docstring"""



				return self.next







		def 					UpperCAmelCase    (	self						:  Union[str, Any]						)					->		Optional[int]:






				"""simple docstring"""



				return self.previous





class        __A       :







		'''simple docstring'''





		def __init__(	self						:  Optional[Any]			,_snake_case						:  Any						)					->		int:






				"""simple docstring"""



				lowercase__   :    Union[str, Any]				=			head







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






				"""simple docstring"""



				return self







		def 					UpperCAmelCase    (	self						:  str						)					->		Any:






				"""simple docstring"""



				if not self.current:
						raise StopIteration
				else:
						lowercase__   :    str				=			self.current.get_data()
						lowercase__   :    Optional[Any]				=			self.current.get_next()
						return value





class        __A       :







		'''simple docstring'''





		def __init__(	self						:  List[Any]						)					->		Dict:






				"""simple docstring"""



				lowercase__   :    Tuple				=			None  # First node in list
				lowercase__   :    int				=			None  # Last node in list







		def __str__(	self						:  Dict						)					->		Optional[int]:






				"""simple docstring"""



				lowercase__   :    List[str]				=			self.head
				lowercase__   :    Dict				=			[]
				while current is not None:
						nodes.append(current.get_data()						)
						lowercase__   :    Dict				=			current.get_next()
				return " ".join(str(_snake_case						) for node in nodes						)







		def __contains__(	self						:  Any			,_snake_case						:  int						)					->		Any:






				"""simple docstring"""



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







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






				"""simple docstring"""



				return LinkedListIterator(self.head						)







		def 					UpperCAmelCase    (	self						:  List[str]						)					->		Optional[Any]:






				"""simple docstring"""



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







		def 					UpperCAmelCase    (	self						:  Optional[int]						)					->		Any:






				"""simple docstring"""



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







		def 					UpperCAmelCase    (	self						:  List[Any]			,_snake_case						:  Node						)					->		None:






				"""simple docstring"""



				if self.head is None:
						lowercase__   :    Dict				=			node
						lowercase__   :    Dict				=			node
				else:
						self.insert_before_node(self.head			,_snake_case						)







		def 					UpperCAmelCase    (	self						:  List[Any]			,_snake_case						:  Node						)					->		None:






				"""simple docstring"""



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







		def 					UpperCAmelCase    (	self						:  int			,_snake_case						:  int						)					->		None:






				"""simple docstring"""



				lowercase__   :    Any				=			Node(_snake_case						)
				if self.head is None:
						self.set_head(_snake_case						)
				else:
						self.set_tail(_snake_case						)







		def 					UpperCAmelCase    (	self						:  Union[str, Any]			,_snake_case						:  Node			,_snake_case						:  Node						)					->		None:






				"""simple docstring"""



				lowercase__   :    Tuple				=			node
				lowercase__   :    Optional[Any]				=			node.previous

				if node.get_previous() is None:
						lowercase__   :    Optional[int]				=			node_to_insert
				else:
						lowercase__   :    List[str]				=			node_to_insert

				lowercase__   :    Tuple				=			node_to_insert







		def 					UpperCAmelCase    (	self						:  int			,_snake_case						:  Node			,_snake_case						:  Node						)					->		None:






				"""simple docstring"""



				lowercase__   :    Dict				=			node
				lowercase__   :    str				=			node.next

				if node.get_next() is None:
						lowercase__   :    int				=			node_to_insert
				else:
						lowercase__   :    Optional[int]				=			node_to_insert

				lowercase__   :    Tuple				=			node_to_insert







		def 					UpperCAmelCase    (	self						:  Optional[int]			,_snake_case						:  int			,_snake_case						:  int						)					->		None:






				"""simple docstring"""



				lowercase__   :    Dict				=			1
				lowercase__   :    Optional[Any]				=			Node(_snake_case						)
				lowercase__   :    Any				=			self.head
				while node:
						if current_position == position:
								self.insert_before_node(_snake_case			,_snake_case						)
								return
						current_position += 1
						lowercase__   :    Optional[Any]				=			node.next
				self.insert_after_node(self.tail			,_snake_case						)







		def 					UpperCAmelCase    (	self						:  int			,_snake_case						:  int						)					->		Node:






				"""simple docstring"""



				lowercase__   :    Any				=			self.head
				while node:
						if node.get_data() == item:
								return node
						lowercase__   :    Tuple				=			node.get_next()
				raise Exception('''Node not found'''						)







		def 					UpperCAmelCase    (	self						:  Dict			,_snake_case						:  List[Any]						)					->		str:






				"""simple docstring"""



				if (node := self.get_node(_snake_case						)) is not None:
						if node == self.head:
								lowercase__   :    List[Any]				=			self.head.get_next()

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

						self.remove_node_pointers(_snake_case						)







		@staticmethod
		def 					UpperCAmelCase    (	_snake_case						:  Node						)					->		None:






				"""simple docstring"""



				if node.get_next():
						lowercase__   :    int				=			node.previous

				if node.get_previous():
						lowercase__   :    Optional[int]				=			node.next

				lowercase__   :    List[Any]				=			None
				lowercase__   :    Tuple				=			None







		def 					UpperCAmelCase    (	self						:  str						)					->		str:






				"""simple docstring"""



				return self.head is None





def      __UpperCAmelCase      (    )							->      None:
		pass


if __name__ == "__main__":
							import doctest

							doctest.testmod()





"""simple docstring"""







import os



def      __UpperCAmelCase      (    )							->      int:
		with open(os.path.dirname(__lowerCamelCase	) + '''/p022_names.txt'''	) as file:
				lowercase__   :    List[Any]				=			str(file.readlines()[0]	)
				lowercase__   :    Dict				=			names.replace('''"'''						,     ''''''	).split(''','''	)

		names.sort()

		lowercase__   :    int				=			0
		lowercase__   :    Optional[Any]				=			0

		for i, name in enumerate(__lowerCamelCase	):
				for letter in name:
						name_score += ord(__lowerCamelCase	) - 64

				total_score += (i + 1) * name_score
				lowercase__   :    List[str]				=			0
		return total_score


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