



from __future__ import annotations

import pandas as pd






def 	_lowerCAmelCase						(				__lowerCamelCase   :     list[int]		,	__lowerCamelCase   :     list[int]		,	__lowerCamelCase   :     int     ):



 """simple docstring"""





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

 __SCREAMING_SNAKE_CASE       :    Tuple       =	0
 __SCREAMING_SNAKE_CASE       :    int       =	0
 __SCREAMING_SNAKE_CASE       :    str       =	999999999
 __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	0
 __SCREAMING_SNAKE_CASE       :    int       =	False

 # Process until all processes are completed
 while complete != no_of_processes:
  for j in range(__lowerCamelCase     ):
   if arrival_time[j] <= increment_time and remaining_time[j] > 0:
    if remaining_time[j] < minm:
     __SCREAMING_SNAKE_CASE       :    Optional[int]       =	remaining_time[j]
     __SCREAMING_SNAKE_CASE       :    Dict       =	j
     __SCREAMING_SNAKE_CASE       :    List[Any]       =	True

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

  __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	remaining_time[short]
  if minm == 0:
   __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	999999999

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

   # Find finish time of current process
   __SCREAMING_SNAKE_CASE       :    Tuple       =	increment_time + 1

   # Calculate waiting time
   __SCREAMING_SNAKE_CASE       :    Optional[int]       =	finish_time - arrival_time[short]
   __SCREAMING_SNAKE_CASE       :    List[str]       =	finar - burst_time[short]

   if waiting_time[short] < 0:
    __SCREAMING_SNAKE_CASE       :    List[Any]       =	0

        # Increment time
  increment_time += 1
 return waiting_time






def 	_lowerCAmelCase						(				__lowerCamelCase   :     list[int]		,	__lowerCamelCase   :     int		,	__lowerCamelCase   :     list[int]     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	[0] * no_of_processes
 for i in range(__lowerCamelCase     ):
  __SCREAMING_SNAKE_CASE       :    Any       =	burst_time[i] + waiting_time[i]
 return turn_around_time






def 	_lowerCAmelCase						(				__lowerCamelCase   :     list[int]		,	__lowerCamelCase   :     list[int]		,	__lowerCamelCase   :     int     ):



 """simple docstring"""





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

      _lowerCamelCase						    =  calculate_waitingtime(arrival_time, burst_time, no_of_processes)

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

      calculate_average_times(waiting_time, turn_around_time, no_of_processes)

      _lowerCamelCase						    =  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 math import sqrt






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int     ):



 """simple docstring"""





 if 1 < number < 4:
  # 2 and 3 are primes
  return True
 elif number < 2 or number % 2 == 0 or number % 3 == 0:
  # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
  return False

 # All primes number are in format of 6k +/- 1
 for i in range(5		,	int(sqrt(__lowerCamelCase     ) + 1     )		,	6     ):
  if number % i == 0 or number % (i + 2) == 0:
   return False
 return True






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int = 10001     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    List[Any]       =	0
 __SCREAMING_SNAKE_CASE       :    Dict       =	1
 while count != nth and number < 3:
  number += 1
  if is_prime(__lowerCamelCase     ):
   count += 1
 while count != nth:
  number += 2
  if is_prime(__lowerCamelCase     ):
   count += 1
 return number


if __name__ == "__main__":
      print(f'''{solution() = }''')






