






from queue import PriorityQueue
from typing import Any

import numpy as np


def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		)->  float | int:





						"""simple docstring"""



						for nxt, d in graph[v]:
												if nxt in visited_forward:
																		continue
												_UpperCAmelCase									=			cst_fwd.get(__lowerCAmelCase ,		np.inf	)
												_UpperCAmelCase									=			cst_fwd[v] + d
												if new_cost_f < old_cost_f:
																		queue.put((new_cost_f, nxt)	)
																		_UpperCAmelCase									=			new_cost_f
																		_UpperCAmelCase									=			v
												if nxt in visited_backward:
																		if cst_fwd[v] + d + cst_bwd[nxt] < shortest_distance:
																								_UpperCAmelCase									=			cst_fwd[v] + d + cst_bwd[nxt]
						return shortest_distance


def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)->  int:





						"""simple docstring"""



						_UpperCAmelCase									=			-1

						_UpperCAmelCase									=			set()
						_UpperCAmelCase									=			set()
						_UpperCAmelCase									=			{source: 0}
						_UpperCAmelCase									=			{destination: 0}
						_UpperCAmelCase									=			{source: None}
						_UpperCAmelCase									=			{destination: None}
						_UpperCAmelCase									=			PriorityQueue()
						_UpperCAmelCase									=			PriorityQueue()

						_UpperCAmelCase									=			np.inf

						queue_forward.put((0, source)	)
						queue_backward.put((0, destination)	)

						if source == destination:
												return 0

						while not queue_forward.empty() and not queue_backward.empty():
												_UpperCAmelCase					, _UpperCAmelCase									=			queue_forward.get()
												visited_forward.add(__lowerCAmelCase	)

												_UpperCAmelCase					, _UpperCAmelCase									=			queue_backward.get()
												visited_backward.add(__lowerCAmelCase	)

												_UpperCAmelCase									=			pass_and_relaxation(
												    __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		)

												_UpperCAmelCase									=			pass_and_relaxation(
												    __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		)

												if cst_fwd[v_fwd] + cst_bwd[v_bwd] >= shortest_distance:
																		break

						if shortest_distance != np.inf:
												_UpperCAmelCase									=			shortest_distance
						return shortest_path_distance


_a      	=  {
    '''B''': [['''C''', 1]],
    '''C''': [['''D''', 1]],
    '''D''': [['''F''', 1]],
    '''E''': [['''B''', 1], ['''G''', 2]],
    '''F''': [],
    '''G''': [['''F''', 1]],
}
_a      	=  {
    '''B''': [['''E''', 1]],
    '''C''': [['''B''', 1]],
    '''D''': [['''C''', 1]],
    '''F''': [['''D''', 1], ['''G''', 1]],
    '''E''': [[None, np.inf]],
    '''G''': [['''E''', 2]],
}

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