from __future__ import annotations

UpperCAmelCase      		=					[2, 1, 4, 5, 6, 0, 8, 9, 1, 2, 0, 6, 4, 2, 0, 6, 5, 3, 2, 7]




class  __lowerCAmelCase	:



 '''simple docstring'''

 def __init__(      self							:		Optional[Any]							,      lowerCamelCase							:		int	)			->				None:
        _UpperCamelCase  :							int	    =	-1
        _UpperCamelCase  :							int	    =	-1
        _UpperCamelCase  :							list[int]	    =	[-1] * length
        _UpperCamelCase  :							Node | None	    =	None
        _UpperCamelCase  :							Node | None	    =	None

 def __repr__(      self							:		Optional[Any]	)			->				str:
        return f"Node(min_value={self.minn} max_value={self.maxx})"







def SCREAMING_SNAKE_CASE					(  lowercase_:						list[int]					):
       _UpperCamelCase  :							Dict	    =	Node(len(lowercase_					)					)
       _UpperCamelCase    ,   _UpperCamelCase  :							List[str]	    =	min(lowercase_					), max(lowercase_					)
       # Leaf node case where the node contains only one unique value
       if root.minn == root.maxx:
              return root
       _UpperCamelCase  :							Dict	    =	(root.minn + root.maxx) // 2

       _UpperCamelCase  :							list[int]	    =	[]
       _UpperCamelCase  :							list[int]	    =	[]

       for index, num in enumerate(lowercase_					):
              if num <= pivot:
                     left_arr.append(lowercase_					)
              else:
                     right_arr.append(lowercase_					)
              _UpperCamelCase  :							int	    =	len(lowercase_					)
       _UpperCamelCase  :							Any	    =	build_tree(lowercase_					)
       _UpperCamelCase  :							Optional[int]	    =	build_tree(lowercase_					)
       return root


def SCREAMING_SNAKE_CASE					(  lowercase_:						Node | None		,    lowercase_:						int		,    lowercase_:						int					):
       if index < 0 or node is None:
              return 0
       # Leaf node cases
       if node.minn == node.maxx:
              return index + 1 if node.minn == num else 0
       _UpperCamelCase  :							Tuple	    =	(node.minn + node.maxx) // 2
       if num <= pivot:
              # go the left subtree and map index to the left subtree
              return rank_till_index(node.left		,    lowercase_		,    node.map_left[index] - 1					)
       else:
              # go to the right subtree and map index to the right subtree
              return rank_till_index(node.right		,    lowercase_		,    index - node.map_left[index]					)


def SCREAMING_SNAKE_CASE					(  lowercase_:						Node | None		,    lowercase_:						int		,    lowercase_:						int		,    lowercase_:						int					):
       if start > end:
              return 0
       _UpperCamelCase  :							List[str]	    =	rank_till_index(lowercase_		,    lowercase_		,    lowercase_					)
       _UpperCamelCase  :							List[Any]	    =	rank_till_index(lowercase_		,    lowercase_		,    start - 1					)
       return rank_till_end - rank_before_start


def SCREAMING_SNAKE_CASE					(  lowercase_:						Node | None		,    lowercase_:						int		,    lowercase_:						int		,    lowercase_:						int					):
       if index > (end - start) or start > end or node is None:
              return -1
       # Leaf node case
       if node.minn == node.maxx:
              return node.minn
       # Number of elements in the left subtree in interval [start, end]
       _UpperCamelCase  :							Union[str, Any]	    =	node.map_left[end] - (
           node.map_left[start - 1] if start else 0
       )
       if num_elements_in_left_tree > index:
              return quantile(
                  node.left		,    lowercase_		,    (node.map_left[start - 1] if start else 0)		,    node.map_left[end] - 1		,    )
       else:
              return quantile(
                  node.right		,    index - num_elements_in_left_tree		,    start - (node.map_left[start - 1] if start else 0)		,    end - node.map_left[end]		,    )


def SCREAMING_SNAKE_CASE					(  lowercase_:						Node | None		,    lowercase_:						int		,    lowercase_:						int		,    lowercase_:						int		,    lowercase_:						int					):
       if (
           start > end
           or node is None
           or start_num > end_num
           or node.minn > end_num
           or node.maxx < start_num
       ):
              return 0
       if start_num <= node.minn and node.maxx <= end_num:
              return end - start + 1
       _UpperCamelCase  :							Optional[int]	    =	range_counting(
           node.left		,    (node.map_left[start - 1] if start else 0)		,    node.map_left[end] - 1		,    lowercase_		,    lowercase_		,    )
       _UpperCamelCase  :							int	    =	range_counting(
           node.right		,    start - (node.map_left[start - 1] if start else 0)		,    end - node.map_left[end]		,    lowercase_		,    lowercase_		,    )
       return left + right


if __name__ == "__main__":
 import doctest

 doctest.testmod()




from __future__ import annotations

from statistics import mean


def SCREAMING_SNAKE_CASE					(  lowercase_:						list[int]					):
       _UpperCamelCase  :							str	    =	2
       _UpperCamelCase  :							Optional[int]	    =	list(lowercase_					)
       _UpperCamelCase  :							Union[str, Any]	    =	[0] * len(lowercase_					)
       _UpperCamelCase  :							List[str]	    =	0
       while True:
              _UpperCamelCase  :							List[str]	    =	True
              for i, burst_time in enumerate(lowercase_					):
                     if rem_burst_times[i] > 0:
                            _UpperCamelCase  :							List[str]	    =	False
                            if rem_burst_times[i] > quantum:
                                   t += quantum
                                   rem_burst_times[i] -= quantum
                            else:
                                   t += rem_burst_times[i]
                                   _UpperCamelCase  :							str	    =	t - burst_time
                                   _UpperCamelCase  :							Union[str, Any]	    =	0
              if done is True:
                     return waiting_times


def SCREAMING_SNAKE_CASE					(  lowercase_:						list[int]		,    lowercase_:						list[int]					):
       return [burst + waiting for burst, waiting in zip(lowercase_		,    lowercase_					)]


if __name__ == "__main__":
 UpperCAmelCase      		=					[3, 5, 7]
 UpperCAmelCase      		=					calculate_waiting_times(burst_times)
 UpperCAmelCase      		=					calculate_turn_around_times(burst_times, waiting_times)
 print('''Process ID \tBurst Time \tWaiting Time \tTurnaround Time''')
 for i, burst_time in enumerate(burst_times):
  print(
      f'''  {i + 1}\t\t  {burst_time}\t\t  {waiting_times[i]}\t\t  '''
      f'''{turn_around_times[i]}'''
  )
 print(f'''\nAverage waiting time = {mean(waiting_times):.5f}''')
 print(f'''Average turn around time = {mean(turn_around_times):.5f}''')



