






"""simple docstring"""



class 			lowerCAmelCase__			(    __magic_name__   ):
   pass




class 			lowerCAmelCase__			(    __magic_name__   ):
   pass




class 			lowerCAmelCase__			:
   def __init__(		self      :	Dict							):


        '''simple docstring'''
        UpperCAmelCase__						:    Union[str, Any]							=							[
            [],
            [],
            [],
        ]
   def       __a							(		self      :	str							,			snake_case__      :	int							,			snake_case__      :	int							):


        '''simple docstring'''
        try:
             if len(self.queues[priority]							) >= 1_0_0:
                  raise OverflowError("Maximum queue size is 100"							)
             self.queues[priority].append(snake_case__							)
        except IndexError:
             raise ValueError("Valid priorities are 0, 1, and 2"							)
   def       __a							(		self      :	int							):


        '''simple docstring'''
        for queue in self.queues:
             if queue:
                  return queue.pop(0							)
        raise UnderFlowError("All queues are empty"							)




   def __str__(		self      :	List[Any]							):


        '''simple docstring'''
        return "\n".join(f'Priority {i}: {q}' for i, q in enumerate(self.queues							)							)




class 			lowerCAmelCase__			:
   def __init__(		self      :	Tuple							):


        '''simple docstring'''
        UpperCAmelCase__						:    Union[str, Any]							=							[]
   def       __a							(		self      :	Dict							,			snake_case__      :	int							):


        '''simple docstring'''
        if len(self.queue							) == 1_0_0:
             raise OverFlowError("Maximum queue size is 100"							)
        self.queue.append(snake_case__							)
   def       __a							(		self      :	Dict							):


        '''simple docstring'''
        if not self.queue:
             raise UnderFlowError("The queue is empty"							)
        else:
             UpperCAmelCase__						:    Dict							=							min(self.queue							)
             self.queue.remove(snake_case__							)
             return data




   def __str__(		self      :	Tuple							):


        '''simple docstring'''
        return str(self.queue							)




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






     '''simple docstring'''



     UpperCAmelCase__						:    List[Any]							=							FixedPriorityQueue()
     fpq.enqueue(0			,					10				)
     fpq.enqueue(1			,					70				)
     fpq.enqueue(0			,					100				)
     fpq.enqueue(2			,					1				)
     fpq.enqueue(2			,					5				)
     fpq.enqueue(1			,					7				)
     fpq.enqueue(2			,					4				)
     fpq.enqueue(1			,					64				)
     fpq.enqueue(0			,					128				)
     print(snake_case				)
     print(fpq.dequeue()				)
     print(fpq.dequeue()				)
     print(fpq.dequeue()				)
     print(fpq.dequeue()				)
     print(fpq.dequeue()				)
     print(snake_case				)
     print(fpq.dequeue()				)
     print(fpq.dequeue()				)
     print(fpq.dequeue()				)
     print(fpq.dequeue()				)
     print(fpq.dequeue()				)


def 	SCREAMING_SNAKE_CASE__       (  )->		Optional[Any]:






     '''simple docstring'''



     UpperCAmelCase__						:    Optional[Any]							=							ElementPriorityQueue()
     epq.enqueue(10				)
     epq.enqueue(70				)
     epq.enqueue(100				)
     epq.enqueue(1				)
     epq.enqueue(5				)
     epq.enqueue(7				)
     epq.enqueue(4				)
     epq.enqueue(64				)
     epq.enqueue(128				)
     print(snake_case				)
     print(epq.dequeue()				)
     print(epq.dequeue()				)
     print(epq.dequeue()				)
     print(epq.dequeue()				)
     print(epq.dequeue()				)
     print(snake_case				)
     print(epq.dequeue()				)
     print(epq.dequeue()				)
     print(epq.dequeue()				)
     print(epq.dequeue()				)
     print(epq.dequeue()				)


if __name__ == "__main__":
 fixed_priority_queue()
 element_priority_queue()










"""simple docstring"""



import os


def 	SCREAMING_SNAKE_CASE__       (  )->		Optional[Any]:






     '''simple docstring'''



     with open(os.path.dirname(snake_case				) + "/p022_names.txt"				) as file:
          UpperCAmelCase__						:    Tuple							=							str(file.readlines()[0]				)
          UpperCAmelCase__						:    str							=							names.replace("\""			,					""				).split(","				)

     names.sort()

     UpperCAmelCase__						:    Optional[int]							=							0
     UpperCAmelCase__						:    List[str]							=							0

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

          total_score += (i + 1) * name_score
          UpperCAmelCase__						:    Optional[int]							=							0
     return total_score


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


