


from __future__ import annotations

import pandas as pd






def  __lowerCAmelCase					(SCREAMING_SNAKE_CASE      ,      SCREAMING_SNAKE_CASE      ,      SCREAMING_SNAKE_CASE      )->						list[int]:




      """simple docstring"""

      snake_case_ =   [0] * no_of_processes
      snake_case_ =   [0] * no_of_processes
      # Copy the burst time into remaining_time[]
      for i in range(SCREAMING_SNAKE_CASE_      ):
            snake_case_ =   burst_time[i]

      snake_case_ =   0
      snake_case_ =   0
      snake_case_ =   9_9999_9999
      snake_case_ =   0
      snake_case_ =   False

      # Process until all processes are completed
      while complete != no_of_processes:
            for j in range(SCREAMING_SNAKE_CASE_      ):
                  if arrival_time[j] <= increment_time and remaining_time[j] > 0:
                        if remaining_time[j] < minm:
                              snake_case_ =   remaining_time[j]
                              snake_case_ =   j
                              snake_case_ =   True

            if not check:
                  increment_time += 1
                  continue
            remaining_time[short] -= 1

            snake_case_ =   remaining_time[short]
            if minm == 0:
                  snake_case_ =   9_9999_9999

            if remaining_time[short] == 0:
                  complete += 1
                  snake_case_ =   False

                  # Find finish time of current process
                  snake_case_ =   increment_time + 1

                  # Calculate waiting time
                  snake_case_ =   finish_time - arrival_time[short]
                  snake_case_ =   finar - burst_time[short]

                  if waiting_time[short] < 0:
                        snake_case_ =   0

        # Increment time
            increment_time += 1
      return waiting_time






def  __lowerCAmelCase					(SCREAMING_SNAKE_CASE      ,      SCREAMING_SNAKE_CASE      ,      SCREAMING_SNAKE_CASE      )->						list[int]:




      """simple docstring"""

      snake_case_ =   [0] * no_of_processes
      for i in range(SCREAMING_SNAKE_CASE_      ):
            snake_case_ =   burst_time[i] + waiting_time[i]
      return turn_around_time






def  __lowerCAmelCase					(SCREAMING_SNAKE_CASE      ,      SCREAMING_SNAKE_CASE      ,      SCREAMING_SNAKE_CASE      )->						None:




      """simple docstring"""

      snake_case_ =   0
      snake_case_ =   0
      for i in range(SCREAMING_SNAKE_CASE_      ):
            snake_case_ =   total_waiting_time + waiting_time[i]
            snake_case_ =   total_turn_around_time + turn_around_time[i]
      print(f'''Average waiting time = {total_waiting_time / no_of_processes:.5f}'''      )
      print('''Average turn around time ='''      ,      total_turn_around_time / no_of_processes      )


if __name__ == "__main__":
   print("""Enter how many process you want to analyze""")
   UpperCAmelCase     :   Optional[int]    =					int(input())
   UpperCAmelCase     :   int    =					[0] * no_of_processes
   UpperCAmelCase     :   Optional[Any]    =					[0] * no_of_processes
   UpperCAmelCase     :   Dict    =					list(range(1, no_of_processes + 1))

   for i in range(no_of_processes):
      print("""Enter the arrival time and burst time for process:--""" + str(i + 1))
      UpperCAmelCase,							UpperCAmelCase     :   Dict    =					map(int, input().split())

   UpperCAmelCase     :   Any    =					calculate_waitingtime(arrival_time, burst_time, no_of_processes)

   UpperCAmelCase     :   int    =					burst_time
   UpperCAmelCase     :   str    =					no_of_processes
   UpperCAmelCase     :   Optional[int]    =					waiting_time
   UpperCAmelCase     :   Any    =					calculate_turnaroundtime(bt, n, wt)

   calculate_average_times(waiting_time, turn_around_time, no_of_processes)

   UpperCAmelCase     :   int    =					pd.DataFrame(
       list(zip(processes, burst_time, arrival_time, waiting_time, turn_around_time)),
       columns=[
           """Process""",
           """BurstTime""",
           """ArrivalTime""",
           """WaitingTime""",
           """TurnAroundTime""",
       ],
   )

   # Printing the dataFrame
   pd.set_option("""display.max_rows""", fcfs.shape[0] + 1)
   print(fcfs)



from collections import namedtuple

UpperCAmelCase    =					namedtuple("""from_to""", """from_ to""")

UpperCAmelCase    =					{
    """cubicmeter""": from_to(1, 1),
    """litre""": from_to(0.001, 1000),
    """kilolitre""": from_to(1, 1),
    """gallon""": from_to(0.00_454, 264.172),
    """cubicyard""": from_to(0.76_455, 1.30_795),
    """cubicfoot""": from_to(0.028, 35.3_147),
    """cup""": from_to(0.000_236_588, 4_226.75),
}






def  __lowerCAmelCase					(SCREAMING_SNAKE_CASE      ,      SCREAMING_SNAKE_CASE      ,      SCREAMING_SNAKE_CASE      )->						float:




      """simple docstring"""

      if from_type not in METRIC_CONVERSION:
            raise ValueError(
                f'''Invalid \'from_type\' value: {from_type!r}  Supported values are:\n'''
                + ''', '''.join(SCREAMING_SNAKE_CASE      )      )
      if to_type not in METRIC_CONVERSION:
            raise ValueError(
                f'''Invalid \'to_type\' value: {to_type!r}.  Supported values are:\n'''
                + ''', '''.join(SCREAMING_SNAKE_CASE      )      )
      return value * METRIC_CONVERSION[from_type].from_ * METRIC_CONVERSION[to_type].to


if __name__ == "__main__":
   import doctest

   doctest.testmod()