


"""simple docstring"""



from __future__ import annotations

import pandas as pd







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


    """simple docstring"""





    snake_case   :				Optional[Any]				 =   [0] * no_of_processes
    snake_case   :				List[Any]				 =   [0] * no_of_processes
    # Copy the burst time into remaining_time[]
    for i in range(lowercase			):
        snake_case   :				Optional[int]				 =   burst_time[i]

    snake_case   :				Optional[int]				 =   0
    snake_case   :				List[str]				 =   0
    snake_case   :				int				 =   9_9999_9999
    snake_case   :				Tuple				 =   0
    snake_case   :				Union[str, Any]				 =   False

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

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

        snake_case   :				Any				 =   remaining_time[short]
        if minm == 0:
            snake_case   :				List[Any]				 =   9_9999_9999

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

            # Find finish time of current process
            snake_case   :				str				 =   increment_time + 1

            # Calculate waiting time
            snake_case   :				Optional[Any]				 =   finish_time - arrival_time[short]
            snake_case   :				Any				 =   finar - burst_time[short]

            if waiting_time[short] < 0:
                snake_case   :				Tuple				 =   0

        # Increment time
        increment_time += 1
    return waiting_time







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


    """simple docstring"""





    snake_case   :				Optional[int]				 =   [0] * no_of_processes
    for i in range(lowercase			):
        snake_case   :				int				 =   burst_time[i] + waiting_time[i]
    return turn_around_time







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


    """simple docstring"""





    snake_case   :				Any				 =   0
    snake_case   :				Union[str, Any]				 =   0
    for i in range(lowercase			):
        snake_case   :				List[str]				 =   total_waiting_time + waiting_time[i]
        snake_case   :				str				 =   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""")
  __snake_case             =   int(input())
  __snake_case             =   [0] * no_of_processes
  __snake_case             =   [0] * no_of_processes
  __snake_case             =   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))
    __snake_case      ,		__snake_case             =   map(int, input().split())

  __snake_case             =   calculate_waitingtime(arrival_time, burst_time, no_of_processes)

  __snake_case             =   burst_time
  __snake_case             =   no_of_processes
  __snake_case             =   waiting_time
  __snake_case             =   calculate_turnaroundtime(bt, n, wt)

  calculate_average_times(waiting_time, turn_around_time, no_of_processes)

  __snake_case             =   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)









"""simple docstring"""



import math
import sys







def   __lowerCAmelCase						(						lowercase  :  int			)     ->						int:


    """simple docstring"""





    if number != int(lowercase			):
        raise ValueError("the value of input must be a natural number"			)
    if number < 0:
        raise ValueError("the value of input must not be a negative number"			)
    if number == 0:
        return 1
    snake_case   :				Optional[Any]				 =   [-1] * (number + 1)
    snake_case   :				str				 =   0
    for i in range(1						,							number + 1			):
        snake_case   :				List[Any]				 =   sys.maxsize
        snake_case   :				Union[str, Any]				 =   int(math.sqrt(lowercase			)			)
        for j in range(1						,							root + 1			):
            snake_case   :				List[str]				 =   1 + answers[i - (j**2)]
            snake_case   :				Optional[Any]				 =   min(lowercase						,							lowercase			)
        snake_case   :				Any				 =   answer
    return answers[number]


if __name__ == "__main__":
  import doctest

  doctest.testmod()





