





from __future__ import annotations

import typing
from collections.abc import Iterable

import numpy as np

_UpperCAmelCase             =							typing.Union[Iterable[float], Iterable[int], np.ndarray]  # noqa: UP007
_UpperCAmelCase             =							typing.Union[np.floataa, int, float]  # noqa: UP007






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:Vector   ,   SCREAMING_SNAKE_CASE		:Vector   )      ->   VectorOut:
 return np.sqrt(np.sum((np.asarray(_A   ) - np.asarray(_A   )) ** 2   )   )






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:Vector   ,   SCREAMING_SNAKE_CASE		:Vector   )      ->   VectorOut:
 return sum((va - va) ** 2 for va, va in zip(_A   ,   _A   )   ) ** (1 / 2)


if __name__ == "__main__":






      def 	_SCREAMING_SNAKE_CASE		(      )      ->   None:
       from timeit import timeit

       print("""Without Numpy"""   )
       print(
           timeit(
               """euclidean_distance_no_np([1, 2, 3], [4, 5, 6])"""   ,   number=10_000   ,   globals=globals()   ,   )   )
       print("""With Numpy"""   )
       print(
           timeit(
               """euclidean_distance([1, 2, 3], [4, 5, 6])"""   ,   number=10_000   ,   globals=globals()   ,   )   )







      benchmark()






_UpperCAmelCase             =							{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

_UpperCAmelCase             =							{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:dict[int, list[int]]   ,   SCREAMING_SNAKE_CASE		:int   ,   SCREAMING_SNAKE_CASE		:list[bool]   )      ->   list[int]:
 __lowerCAmelCase					:	str      =       True
 __lowerCAmelCase					:	str      =       []

 for neighbour in graph[vert]:
  if not visited[neighbour]:
   order += topology_sort(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )

 order.append(SCREAMING_SNAKE_CASE   )

 return order






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:dict[int, list[int]]   ,   SCREAMING_SNAKE_CASE		:int   ,   SCREAMING_SNAKE_CASE		:list[bool]   )      ->   list[int]:
 __lowerCAmelCase					:	Optional[Any]      =       True
 __lowerCAmelCase					:	Union[str, Any]      =       [vert]

 for neighbour in reversed_graph[vert]:
  if not visited[neighbour]:
   component += find_components(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )

 return component







def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:dict[int, list[int]]   )      ->   list[list[int]]:
 __lowerCAmelCase					:	Optional[Any]      =       len(SCREAMING_SNAKE_CASE   ) * [False]
 __lowerCAmelCase					:	dict[int, list[int]]      =       {vert: [] for vert in range(len(SCREAMING_SNAKE_CASE   )   )}

 for vert, neighbours in graph.items():
  for neighbour in neighbours:
   reversed_graph[neighbour].append(SCREAMING_SNAKE_CASE   )

 __lowerCAmelCase					:	Tuple      =       []
 for i, was_visited in enumerate(SCREAMING_SNAKE_CASE   ):
  if not was_visited:
   order += topology_sort(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )

 __lowerCAmelCase					:	Optional[Any]      =       []
 __lowerCAmelCase					:	Any      =       len(SCREAMING_SNAKE_CASE   ) * [False]

 for i in range(len(SCREAMING_SNAKE_CASE   )   ):
  __lowerCAmelCase					:	Optional[int]      =       order[len(SCREAMING_SNAKE_CASE   ) - i - 1]
  if not visited[vert]:
   __lowerCAmelCase					:	Any      =       find_components(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )
   components_list.append(SCREAMING_SNAKE_CASE   )

 return components_list