





from __future__ import annotations

import pandas as pd






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:list[int]   ,   SCREAMING_SNAKE_CASE		:list[int]   ,   SCREAMING_SNAKE_CASE		:int   )      ->   list[int]:
 __lowerCAmelCase					:	int      =       [0] * no_of_processes
 __lowerCAmelCase					:	List[Any]      =       [0] * no_of_processes
 # Copy the burst time into remaining_time[]
 for i in range(SCREAMING_SNAKE_CASE   ):
  __lowerCAmelCase					:	Any      =       burst_time[i]

 __lowerCAmelCase					:	Tuple      =       0
 __lowerCAmelCase					:	Optional[int]      =       0
 __lowerCAmelCase					:	str      =       999_999_999
 __lowerCAmelCase					:	Union[str, Any]      =       0
 __lowerCAmelCase					:	int      =       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:
     __lowerCAmelCase					:	Dict      =       remaining_time[j]
     __lowerCAmelCase					:	List[str]      =       j
     __lowerCAmelCase					:	List[Any]      =       True

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

  __lowerCAmelCase					:	Optional[int]      =       remaining_time[short]
  if minm == 0:
   __lowerCAmelCase					:	Dict      =       999_999_999

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

   # Find finish time of current process
   __lowerCAmelCase					:	Optional[int]      =       increment_time + 1

   # Calculate waiting time
   __lowerCAmelCase					:	Any      =       finish_time - arrival_time[short]
   __lowerCAmelCase					:	Dict      =       finar - burst_time[short]

   if waiting_time[short] < 0:
    __lowerCAmelCase					:	str      =       0

        # Increment time
  increment_time += 1
 return waiting_time






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:list[int]   ,   SCREAMING_SNAKE_CASE		:int   ,   SCREAMING_SNAKE_CASE		:list[int]   )      ->   list[int]:
 __lowerCAmelCase					:	Any      =       [0] * no_of_processes
 for i in range(SCREAMING_SNAKE_CASE   ):
  __lowerCAmelCase					:	List[Any]      =       burst_time[i] + waiting_time[i]
 return turn_around_time






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:list[int]   ,   SCREAMING_SNAKE_CASE		:list[int]   ,   SCREAMING_SNAKE_CASE		:int   )      ->   None:
 __lowerCAmelCase					:	str      =       0
 __lowerCAmelCase					:	Optional[Any]      =       0
 for i in range(SCREAMING_SNAKE_CASE   ):
  __lowerCAmelCase					:	int      =       total_waiting_time + waiting_time[i]
  __lowerCAmelCase					:	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')
      _UpperCAmelCase             =							int(input())
      _UpperCAmelCase             =							[0] * no_of_processes
      _UpperCAmelCase             =							[0] * no_of_processes
      _UpperCAmelCase             =							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             =							map(int, input().split())

      _UpperCAmelCase             =							calculate_waitingtime(arrival_time, burst_time, no_of_processes)

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

      calculate_average_times(waiting_time, turn_around_time, no_of_processes)

      _UpperCAmelCase             =							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 isqrt






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:int   )      ->   list[int]:
 __lowerCAmelCase					:	Tuple      =       [True] * max_number
 for i in range(2   ,   isqrt(max_number - 1   ) + 1   ):
  if is_prime[i]:
   for j in range(i**2   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ):
    __lowerCAmelCase					:	Tuple      =       False

 return [i for i in range(2   ,   SCREAMING_SNAKE_CASE   ) if is_prime[i]]






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:int = 10**8   )      ->   int:
 __lowerCAmelCase					:	int      =       calculate_prime_numbers(max_number // 2   )

 __lowerCAmelCase					:	List[Any]      =       0
 __lowerCAmelCase					:	List[str]      =       0
 __lowerCAmelCase					:	List[Any]      =       len(SCREAMING_SNAKE_CASE   ) - 1
 while left <= right:
  while prime_numbers[left] * prime_numbers[right] >= max_number:
   right -= 1
  semiprimes_count += right - left + 1
  left += 1

 return semiprimes_count


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