

# Algorithm for the pigeonhole sorting









def 			A_      (    _UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: Optional[Any]  		=       min(_UpperCAmelCase    )  # min() finds the minimum value
						SCREAMING_SNAKE_CASE_: Tuple  		=       max(_UpperCAmelCase    )  # max() finds the maximum value

						SCREAMING_SNAKE_CASE_: str  		=       max_val - min_val + 1  # size is difference of max and min values plus one

						# list of pigeonholes of size equal to the variable size
						SCREAMING_SNAKE_CASE_: List[Any]  		=       [0] * size

						# Populate the pigeonholes.
						for x in a:
												assert isinstance(_UpperCAmelCase				,	_UpperCAmelCase    ), "integers only please"
												holes[x - min_val] += 1

						# Putting the elements back into the array in an order.
						SCREAMING_SNAKE_CASE_: int  		=       0
						for count in range(_UpperCAmelCase    ):
												while holes[count] > 0:
																		holes[count] -= 1
																		SCREAMING_SNAKE_CASE_: str  		=       count + min_val
																		i += 1







def 			A_      (    ):
						SCREAMING_SNAKE_CASE_: List[str]  		=       [8, 3, 2, 7, 4, 6, 8]
						pigeonhole_sort(_UpperCAmelCase    )
						print("Sorted order is:"				,	" ".join(_UpperCAmelCase    )    )


if __name__ == "__main__":
						main()









def 			A_      (    _UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: List[str]  		=       [0] * len(_UpperCAmelCase    )
						SCREAMING_SNAKE_CASE_: List[Any]  		=       []
						SCREAMING_SNAKE_CASE_: str  		=       []
						SCREAMING_SNAKE_CASE_: List[str]  		=       0

						for values in graph.values():
												for i in values:
																		indegree[i] += 1

						for i in range(len(_UpperCAmelCase    )    ):
												if indegree[i] == 0:
																		queue.append(_UpperCAmelCase    )

						while queue:
												SCREAMING_SNAKE_CASE_: Optional[int]  		=       queue.pop(0    )
												cnt += 1
												topo.append(_UpperCAmelCase    )
												for x in graph[vertex]:
																		indegree[x] -= 1
																		if indegree[x] == 0:
																								queue.append(_UpperCAmelCase    )

						if cnt != len(_UpperCAmelCase    ):
												print("Cycle exists"    )
						else:
												print(_UpperCAmelCase    )


# Adjacency List of Graph
lowerCAmelCase							:  Any   	=						{0: [1, 2], 1: [3], 2: [3], 3: [4, 5], 4: [], 5: []}



topological_sort(graph)






