






"""simple docstring"""
from __future__ import annotations

import pandas as pd

def 							snake_case (  A__      ,A__      ,A__		):
			UpperCAmelCase_	:					Optional[Any]     	=   [0] * no_of_processes
			UpperCAmelCase_	:					Optional[Any]     	=   [0] * no_of_processes
			# Copy the burst time into remaining_time[]
			for i in range(A__		):
						UpperCAmelCase_	:					Optional[Any]     	=   burst_time[i]

			UpperCAmelCase_	:					Tuple     	=   0
			UpperCAmelCase_	:					Optional[int]     	=   0
			UpperCAmelCase_	:					List[Any]     	=   9_99_99_99_99
			UpperCAmelCase_	:					str     	=   0
			UpperCAmelCase_	:					List[str]     	=   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:
															UpperCAmelCase_	:					Any     	=   remaining_time[j]
															UpperCAmelCase_	:					Optional[int]     	=   j
															UpperCAmelCase_	:					Union[str, Any]     	=   True

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

						UpperCAmelCase_	:					Union[str, Any]     	=   remaining_time[short]
						if minm == 0:
									UpperCAmelCase_	:					List[str]     	=   9_99_99_99_99

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

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

									# Calculate waiting time
									UpperCAmelCase_	:					List[str]     	=   finish_time - arrival_time[short]
									UpperCAmelCase_	:					Tuple     	=   finar - burst_time[short]

									if waiting_time[short] < 0:
												UpperCAmelCase_	:					Any     	=   0

        # Increment time
						increment_time += 1
			return waiting_time

def 							snake_case (  A__      ,A__      ,A__		):
			UpperCAmelCase_	:					str     	=   [0] * no_of_processes
			for i in range(A__		):
						UpperCAmelCase_	:					List[Any]     	=   burst_time[i] + waiting_time[i]
			return turn_around_time

def 							snake_case (  A__      ,A__      ,A__		):
			UpperCAmelCase_	:					Any     	=   0
			UpperCAmelCase_	:					Optional[Any]     	=   0
			for i in range(A__		):
						UpperCAmelCase_	:					Dict     	=   total_waiting_time + waiting_time[i]
						UpperCAmelCase_	:					Optional[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)











"""simple docstring"""
def 							snake_case (  A__		):
			UpperCAmelCase_	:					int     	=   [0 for i in range(len(A__		)		)]

			# initialize interval's left pointer and right pointer
			UpperCAmelCase_	,      UpperCAmelCase_	:					Optional[int]     	=   0, 0

			for i in range(1      ,len(A__		)		):
						# case when current index is inside the interval
						if i <= right_pointer:
									UpperCAmelCase_	:					Any     	=   min(right_pointer - i + 1      ,z_result[i - left_pointer]		)
									UpperCAmelCase_	:					Union[str, Any]     	=   min_edge

						while go_next(A__      ,A__      ,A__		):
									z_result[i] += 1

						# if new index's result gives us more right interval,
						# we've to update left_pointer and right_pointer
						if i + z_result[i] - 1 > right_pointer:
									UpperCAmelCase_	,      UpperCAmelCase_	:					Union[str, Any]     	=   i, i + z_result[i] - 1

			return z_result

def 							snake_case (  A__      ,A__      ,A__		):
			return i + z_result[i] < len(A__		) and s[z_result[i]] == s[i + z_result[i]]

def 							snake_case (  A__      ,A__		):
			UpperCAmelCase_	:					Optional[int]     	=   0
			# concatenate 'pattern' and 'input_str' and call z_function
			# with concatenated string
			UpperCAmelCase_	:					Tuple     	=   z_function(pattern + input_str		)

			for val in z_result:
						# if value is greater then length of the pattern string
						# that means this index is starting position of substring
						# which is equal to pattern string
						if val >= len(A__		):
									answer += 1

			return answer


if __name__ == "__main__":
			import doctest

			doctest.testmod()



