




lowerCamelCase__				:     List[Any]			       =							float('inf')





class  lowerCamelCase_							:


 '''simple docstring'''







 def __init__(							self						:	Tuple       ,       _lowerCAmelCase						:	Union[str, Any]		):
       SCREAMING_SNAKE_CASE_					=    [0] * n
       SCREAMING_SNAKE_CASE_					=    [0] * n
       SCREAMING_SNAKE_CASE_					=    [0] * n
       SCREAMING_SNAKE_CASE_					=    [[] for _ in range(_lowerCAmelCase		)]



 def    lowerCAmelCase_						(							self						:	str       ,       _lowerCAmelCase						:	str       ,       _lowerCAmelCase						:	Optional[int]       ,       _lowerCAmelCase						:	Optional[Any]       ,       _lowerCAmelCase						:	Tuple=0		):
       self.adj[a].append([b, len(self.adj[b]		), c, 0]		)
       self.adj[b].append([a, len(self.adj[a]		) - 1, rcap, 0]		)



 def    lowerCAmelCase_						(							self						:	Optional[Any]       ,       _lowerCAmelCase						:	Optional[int]       ,       _lowerCAmelCase						:	Optional[Any]       ,       _lowerCAmelCase						:	List[str]		):
       if vertex == sink or not flow:
             return flow

       for i in range(self.ptr[vertex]       ,       len(self.adj[vertex]		)		):
             SCREAMING_SNAKE_CASE_					=    self.adj[vertex][i]
             if self.lvl[e[0]] == self.lvl[vertex] + 1:
                   SCREAMING_SNAKE_CASE_					=    self.depth_first_search(e[0]       ,       _lowerCAmelCase       ,       min(_lowerCAmelCase       ,       e[2] - e[3]		)		)
                   if p:
                         self.adj[vertex][i][3] += p
                         self.adj[e[0]][e[1]][3] -= p
                         return p
             SCREAMING_SNAKE_CASE_					=    self.ptr[vertex] + 1
       return 0




 def    lowerCAmelCase_						(							self						:	Dict       ,       _lowerCAmelCase						:	Dict       ,       _lowerCAmelCase						:	Union[str, Any]		):
       SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_					=    0, source
       for l in range(31		):  # noqa: E741  l = 30 maybe faster for random data
             while True:
                   SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_					=    [0] * len(self.q		), [0] * len(self.q		)
                   SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_					=    0, 1, 1
                   while qi < qe and not self.lvl[sink]:
                         SCREAMING_SNAKE_CASE_					=    self.q[qi]
                         qi += 1
                         for e in self.adj[v]:
                               if not self.lvl[e[0]] and (e[2] - e[3]) >> (30 - l):
                                     SCREAMING_SNAKE_CASE_					=    e[0]
                                     qe += 1
                                     SCREAMING_SNAKE_CASE_					=    self.lvl[v] + 1

                   SCREAMING_SNAKE_CASE_					=    self.depth_first_search(_lowerCAmelCase       ,       _lowerCAmelCase       ,       _lowerCAmelCase		)
                   while p:
                         flow += p
                         SCREAMING_SNAKE_CASE_					=    self.depth_first_search(_lowerCAmelCase       ,       _lowerCAmelCase       ,       _lowerCAmelCase		)

                   if not self.lvl[sink]:
                         break

       return flow
lowerCamelCase__				:     List[Any]			       =							Dinic(10)
lowerCamelCase__				:     Optional[Any]			       =							0
lowerCamelCase__				:     List[Any]			       =							9
for vertex in range(1, 5):
   graph.add_edge(source, vertex, 1)
for vertex in range(5, 9):
   graph.add_edge(vertex, sink, 1)
for vertex in range(1, 5):
   graph.add_edge(vertex, vertex + 4, 1)

# Now we can know that is the maximum flow(source -> sink)
print(graph.max_flow(source, sink))





from __future__ import annotations

def       UpperCAmelCase_							(   __UpperCAmelCase		:			list[int]							)      ->				list[int]:
      SCREAMING_SNAKE_CASE_					=    [0] * len(__UpperCAmelCase							)
      for i in range(1    ,    len(__UpperCAmelCase							)							):
            SCREAMING_SNAKE_CASE_					=    duration_times[i - 1] + waiting_times[i - 1]
      return waiting_times

def       UpperCAmelCase_							(   __UpperCAmelCase		:			list[int]    ,    __UpperCAmelCase		:			list[int]							)      ->				list[int]:
      return [
          duration_time + waiting_times[i]
          for i, duration_time in enumerate(__UpperCAmelCase							)
      ]

def       UpperCAmelCase_							(   __UpperCAmelCase		:			list[int]							)      ->				float:
      return sum(__UpperCAmelCase							) / len(__UpperCAmelCase							)

def       UpperCAmelCase_							(   __UpperCAmelCase		:			list[int]							)      ->				float:
      return sum(__UpperCAmelCase							) / len(__UpperCAmelCase							)


if __name__ == "__main__":
   # process id's
   lowerCamelCase__				:     Union[str, Any]			       =							[1, 2, 3]

   # ensure that we actually have processes
   if len(processes) == 0:
      print('Zero amount of processes')
      raise SystemExit(0)

   # duration time of all processes
   lowerCamelCase__				:     Optional[Any]			       =							[19, 8, 9]

   # ensure we can match each id to a duration time
   if len(duration_times) != len(processes):
      print('Unable to match all id\'s with their duration time')
      raise SystemExit(0)

   # get the waiting times and the turnaround times
   lowerCamelCase__				:     Dict			       =							calculate_waiting_times(duration_times)
   lowerCamelCase__				:     int			       =							calculate_turnaround_times(duration_times, waiting_times)

   # get the average times
   lowerCamelCase__				:     Any			       =							calculate_average_waiting_time(waiting_times)
   lowerCamelCase__				:     Tuple			       =							calculate_average_turnaround_time(turnaround_times)

   # print all the results
   print('Process ID\tDuration Time\tWaiting Time\tTurnaround Time')
   for i, process in enumerate(processes):
      print(
          f'''{process}\t\t{duration_times[i]}\t\t{waiting_times[i]}\t\t'''
          f'''{turnaround_times[i]}'''
      )
   print(f'''Average waiting time = {average_waiting_time}''')
   print(f'''Average turn around time = {average_turnaround_time}''')