





'''simple docstring'''






from __future__ import annotations

import pandas as pd






def      __A						(							a_						:  list[int]      ,a_						:  list[int]      ,a_						:  int	):
		lowerCAmelCase     :    List[str]						=   [0] * no_of_processes
		lowerCAmelCase     :    Union[str, Any]						=   [0] * no_of_processes
		# Copy the burst time into remaining_time[]
		for i in range(a_	):
				lowerCAmelCase     :    str						=   burst_time[i]

		lowerCAmelCase     :    Tuple						=   0
		lowerCAmelCase     :    Optional[Any]						=   0
		lowerCAmelCase     :    List[Any]						=   9_9_9_9_9_9_9_9_9
		lowerCAmelCase     :    List[Any]						=   0
		lowerCAmelCase     :    Tuple						=   False

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

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

				lowerCAmelCase     :    Dict						=   remaining_time[short]
				if minm == 0:
						lowerCAmelCase     :    List[str]						=   9_9_9_9_9_9_9_9_9

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

						# Find finish time of current process
						lowerCAmelCase     :    Union[str, Any]						=   increment_time + 1

						# Calculate waiting time
						lowerCAmelCase     :    Union[str, Any]						=   finish_time - arrival_time[short]
						lowerCAmelCase     :    Any						=   finar - burst_time[short]

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

        # Increment time
				increment_time += 1
		return waiting_time






def      __A						(							a_						:  list[int]      ,a_						:  int      ,a_						:  list[int]	):
		lowerCAmelCase     :    Optional[int]						=   [0] * no_of_processes
		for i in range(a_	):
				lowerCAmelCase     :    Union[str, Any]						=   burst_time[i] + waiting_time[i]
		return turn_around_time






def      __A						(							a_						:  list[int]      ,a_						:  list[int]      ,a_						:  int	):
		lowerCAmelCase     :    List[Any]						=   0
		lowerCAmelCase     :    List[str]						=   0
		for i in range(a_	):
				lowerCAmelCase     :    List[str]						=   total_waiting_time + waiting_time[i]
				lowerCAmelCase     :    int						=   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)










'''simple docstring'''






def      __A						(							a_						:  int      ,a_						:  int	):
		return abs(a_	) if a == 0 else greatest_common_divisor(b % a      ,a_	)






def      __A						(							a_						:  int      ,a_						:  int	):
		while y:  # --> when y=0 then loop will terminate and return x as final GCD.
				lowerCAmelCase	,		lowerCAmelCase     :    Tuple						=   y, x % y
		return abs(a_	)






def      __A						(							):
		try:
				lowerCAmelCase     :    Tuple						=   input("Enter two integers separated by comma (,): "	).split(","	)
				lowerCAmelCase     :    Tuple						=   int(nums[0]	)
				lowerCAmelCase     :    Tuple						=   int(nums[1]	)
				print(
				    f'''greatest_common_divisor({num_a}, {num_a}) = '''
				    f'''{greatest_common_divisor(a_      ,a_	)}'''	)
				print(f'''By iterative gcd({num_a}, {num_a}) = {gcd_by_iterative(a_      ,a_	)}'''	)
		except (IndexError, UnboundLocalError, ValueError):
				print("Wrong input"	)


if __name__ == "__main__":
					main()



