





'''simple docstring'''

from collections import deque







def 							UpperCAmelCase_    (	lowerCAmelCase_							):

				"""simple docstring"""






				lowercase         = len(lowerCAmelCase_							)
				lowercase         = deque()
				lowercase         = [False for _ in range(lowerCAmelCase_							)]
				lowercase         = [-1 for _ in range(lowerCAmelCase_							)]
				lowercase         = index_of[:]

				def strong_connect(lowerCAmelCase_		,							lowerCAmelCase_		,							lowerCAmelCase_							):
								lowercase         = index  # the number when this node is seen
								lowercase         = index  # lowest rank node reachable from here
								index += 1
								stack.append(lowerCAmelCase_							)
								lowercase         = True

								for w in g[v]:
												if index_of[w] == -1:
																lowercase         = strong_connect(lowerCAmelCase_		,							lowerCAmelCase_		,							lowerCAmelCase_							)
																lowercase         = (
																    lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
																)
												elif on_stack[w]:
																lowercase         = (
																    lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
																)

								if lowlink_of[v] == index_of[v]:
												lowercase         = []
												lowercase         = stack.pop()
												lowercase         = False
												component.append(lowerCAmelCase_							)
												while w != v:
																lowercase         = stack.pop()
																lowercase         = False
																component.append(lowerCAmelCase_							)
												components.append(lowerCAmelCase_							)
								return index

				lowercase         = []
				for v in range(lowerCAmelCase_							):
								if index_of[v] == -1:
												strong_connect(lowerCAmelCase_		,							0		,							lowerCAmelCase_							)

				return components







def 							UpperCAmelCase_    (	lowerCAmelCase_		,							lowerCAmelCase_							):

				"""simple docstring"""






				lowercase         = [[] for _ in range(lowerCAmelCase_							)]
				for u, v in edges:
								g[u].append(lowerCAmelCase_							)
				return g


if __name__ == "__main__":
			# Test
			__lowerCamelCase : List[Any]				=			7
			__lowerCamelCase : str				=			[0, 0, 1, 2, 3, 3, 4, 4, 6]
			__lowerCamelCase : Optional[int]				=			[1, 3, 2, 0, 1, 4, 5, 6, 5]
			__lowerCamelCase : Optional[Any]				=			[(u, v) for u, v in zip(source, target)]
			__lowerCamelCase : List[Any]				=			create_graph(n_vertices, edges)

			assert [[5], [6], [4], [3, 2, 1, 0]] == tarjan(g)











'''simple docstring'''

# Algorithm for the pigeonhole sorting









def 							UpperCAmelCase_    (	lowerCAmelCase_							):

				"""simple docstring"""






				lowercase         = min(lowerCAmelCase_							)  # min() finds the minimum value
				lowercase         = max(lowerCAmelCase_							)  # max() finds the maximum value

				lowercase         = 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
				lowercase         = [0] * size

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

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







def 							UpperCAmelCase_    (	):

				"""simple docstring"""






				lowercase         = [8, 3, 2, 7, 4, 6, 8]
				pigeonhole_sort(lowerCAmelCase_							)
				print("Sorted order is:"		,							" ".join(lowerCAmelCase_							)							)


if __name__ == "__main__":
			main()




