



'''simple docstring'''





class     UpperCAmelCase_       :
    """simple docstring"""







    def __init__(    self					:     List[str] ,     snake_case_					:     Dict						):
          snake_case__  :    Tuple    						=      len(_A						)
          snake_case__  :    List[str]    						=      [0] * len_array

          if len_array > 0:
                snake_case__  :    int    						=      array[0]

          for i in range(1 ,     _A						):
                snake_case__  :    Union[str, Any]    						=      self.prefix_sum[i - 1] + array[i]




    def lowerCamelCase       (    self					:     Any ,     snake_case_					:     List[str] ,     snake_case_					:     Optional[int]						):



          if start == 0:
                return self.prefix_sum[end]

          return self.prefix_sum[end] - self.prefix_sum[start - 1]




    def lowerCamelCase       (    self					:     Dict ,     snake_case_					:     Optional[Any]						):
          snake_case__  :    Any    						=      {0}
          for sum_item in self.prefix_sum:
                if sum_item - target_sum in sums:
                      return True

                sums.add(_A						)

          return False


if __name__ == "__main__":
       import doctest

       doctest.testmod()






class 			a__    (					snake_case__      ):
						pass






class 			a__    (					snake_case__      ):
						pass






class 			a__    :






						def __init__(   self			):




											"""simple docstring"""



											__lowerCAmelCase				   =       [
											    [],
											    [],
											    [],
											]






						def 				__SCREAMING_SNAKE_CASE(   self		,			_A		,			_A			):




											"""simple docstring"""



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






						def 				__SCREAMING_SNAKE_CASE(   self			):




											"""simple docstring"""



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






						def __str__(   self			):




											"""simple docstring"""



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






class 			a__    :






						def __init__(   self			):




											"""simple docstring"""



											__lowerCAmelCase				   =       []






						def 				__SCREAMING_SNAKE_CASE(   self		,			_A			):




											"""simple docstring"""



											if len(self.queue			) == 1_0_0:
																raise OverFlowError("Maximum queue size is 100"			)
											self.queue.append(_A			)






						def 				__SCREAMING_SNAKE_CASE(   self			):




											"""simple docstring"""



											if not self.queue:
																raise UnderFlowError("The queue is empty"			)
											else:
																__lowerCAmelCase				   =       min(self.queue			)
																self.queue.remove(_A			)
																return data






						def __str__(   self			):




											"""simple docstring"""



											return str(self.queue			)







def 	_a      (						):
					__lowerCAmelCase				   =       FixedPriorityQueue()
					fpq.enqueue(0      ,      10     )
					fpq.enqueue(1      ,      70     )
					fpq.enqueue(0      ,      1_00     )
					fpq.enqueue(2      ,      1     )
					fpq.enqueue(2      ,      5     )
					fpq.enqueue(1      ,      7     )
					fpq.enqueue(2      ,      4     )
					fpq.enqueue(1      ,      64     )
					fpq.enqueue(0      ,      1_28     )
					print(SCREAMING_SNAKE_CASE_     )
					print(fpq.dequeue()     )
					print(fpq.dequeue()     )
					print(fpq.dequeue()     )
					print(fpq.dequeue()     )
					print(fpq.dequeue()     )
					print(SCREAMING_SNAKE_CASE_     )
					print(fpq.dequeue()     )
					print(fpq.dequeue()     )
					print(fpq.dequeue()     )
					print(fpq.dequeue()     )
					print(fpq.dequeue()     )







def 	_a      (						):
					__lowerCAmelCase				   =       ElementPriorityQueue()
					epq.enqueue(10     )
					epq.enqueue(70     )
					epq.enqueue(1_00     )
					epq.enqueue(1     )
					epq.enqueue(5     )
					epq.enqueue(7     )
					epq.enqueue(4     )
					epq.enqueue(64     )
					epq.enqueue(1_28     )
					print(SCREAMING_SNAKE_CASE_     )
					print(epq.dequeue()     )
					print(epq.dequeue()     )
					print(epq.dequeue()     )
					print(epq.dequeue()     )
					print(epq.dequeue()     )
					print(SCREAMING_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()




