





"""simple docstring"""






from __future__ import annotations

from sys import maxsize
from typing import Generic, TypeVar

__UpperCAmelCase						=			TypeVar('''T''')






def      lowercase__ (					lowerCAmelCase__   :			int			)    ->			int:



			'''simple docstring'''
			return (position - 1) // 2






def      lowercase__ (					lowerCAmelCase__   :			int			)    ->			int:



			'''simple docstring'''
			return (2 * position) + 1






def      lowercase__ (					lowerCAmelCase__   :			int			)    ->			int:



			'''simple docstring'''
			return (2 * position) + 2



class 					__UpperCAmelCase							(						Generic[T]  ):
				def __init__(		self    :			str    )	->	None:



							'''simple docstring'''



							a__  :	list[tuple[T, int]]		 =			[]
							a__  :	dict[T, int]		 =			{}
							a__  :	int		 =			0
				def __len__(		self    :			Optional[Any]    )	->	int:



							'''simple docstring'''



							return self.elements
				def __repr__(		self    :			List[Any]    )	->	str:



							'''simple docstring'''



							return str(self.heap    )
				def       UpperCAmelCase      (		self    :			Any    )	->	bool:



							'''simple docstring'''



							return self.elements == 0
				def       UpperCAmelCase      (		self    :			Dict	, a_    :			T	, a_    :			int    )	->	None:



							'''simple docstring'''



							self.heap.append((elem, weight)    )
							a__  :	int		 =			self.elements
							self.elements += 1
							self._bubble_up(a_    )
				def       UpperCAmelCase      (		self    :			List[str]    )	->	T:



							'''simple docstring'''



							if self.elements > 1:
										self._swap_nodes(0	, self.elements - 1    )
							a__ ,	a__  :	int		 =			self.heap.pop()
							del self.position_map[elem]
							self.elements -= 1
							if self.elements > 0:
										a__ ,	a__  :	Dict		 =			self.heap[0]
										self._bubble_down(a_    )
							return elem
				def       UpperCAmelCase      (		self    :			int	, a_    :			T	, a_    :			int    )	->	None:



							'''simple docstring'''



							a__  :	List[str]		 =			self.position_map[elem]
							a__  :	Union[str, Any]		 =			(elem, weight)
							if position > 0:
										a__  :	Union[str, Any]		 =			get_parent_position(a_    )
										a__ ,	a__  :	List[Any]		 =			self.heap[parent_position]
										if parent_weight > weight:
													self._bubble_up(a_    )
										else:
													self._bubble_down(a_    )
							else:
										self._bubble_down(a_    )
				def       UpperCAmelCase      (		self    :			Dict	, a_    :			T    )	->	None:



							'''simple docstring'''



							a__  :	List[str]		 =			self.position_map[elem]
							if curr_pos == 0:
										return None
							a__  :	Tuple		 =			get_parent_position(a_    )
							a__ ,	a__  :	Optional[Any]		 =			self.heap[curr_pos]
							a__ ,	a__  :	Tuple		 =			self.heap[parent_position]
							if parent_weight > weight:
										self._swap_nodes(a_	, a_    )
										return self._bubble_up(a_    )
							return None
				def       UpperCAmelCase      (		self    :			Any	, a_    :			T    )	->	None:



							'''simple docstring'''



							a__  :	int		 =			self.position_map[elem]
							a__ ,	a__  :	List[str]		 =			self.heap[curr_pos]
							a__  :	Any		 =			get_child_left_position(a_    )
							a__  :	List[Any]		 =			get_child_right_position(a_    )
							if child_left_position < self.elements and child_right_position < self.elements:
										a__ ,	a__  :	Optional[int]		 =			self.heap[child_left_position]
										a__ ,	a__  :	Dict		 =			self.heap[child_right_position]
										if child_right_weight < child_left_weight and child_right_weight < weight:
													self._swap_nodes(a_	, a_    )
													return self._bubble_down(a_    )
							if child_left_position < self.elements:
										a__ ,	a__  :	Any		 =			self.heap[child_left_position]
										if child_left_weight < weight:
													self._swap_nodes(a_	, a_    )
													return self._bubble_down(a_    )
							else:
										return None
							if child_right_position < self.elements:
										a__ ,	a__  :	Optional[int]		 =			self.heap[child_right_position]
										if child_right_weight < weight:
													self._swap_nodes(a_	, a_    )
													return self._bubble_down(a_    )
							return None






				def       UpperCAmelCase      (		self    :			Optional[int]	, a_    :			int	, a_    :			int    )	->	None:



							'''simple docstring'''



							a__  :	str		 =			self.heap[nodea_pos][0]
							a__  :	Dict		 =			self.heap[nodea_pos][0]
							a__ ,	a__  :	List[Any]		 =			(
							    self.heap[nodea_pos],
							    self.heap[nodea_pos],
							)
							a__  :	Optional[Any]		 =			nodea_pos
							a__  :	Optional[int]		 =			nodea_pos



class 					__UpperCAmelCase							(						Generic[T]  ):
				def __init__(		self    :			List[str]    )	->	None:



							'''simple docstring'''



							a__  :	dict[T, dict[T, int]]		 =			{}
							a__  :	int		 =			0
				def __repr__(		self    :			List[str]    )	->	str:



							'''simple docstring'''



							return str(self.connections    )
				def __len__(		self    :			List[Any]    )	->	int:



							'''simple docstring'''



							return self.nodes
				def       UpperCAmelCase      (		self    :			List[Any]	, a_    :			T    )	->	None:



							'''simple docstring'''



							if node not in self.connections:
										a__  :	Dict		 =			{}
										self.nodes += 1






				def       UpperCAmelCase      (		self    :			Dict	, a_    :			T	, a_    :			T	, a_    :			int    )	->	None:



							'''simple docstring'''



							self.add_node(a_    )
							self.add_node(a_    )
							a__  :	Optional[Any]		 =			weight
							a__  :	Any		 =			weight






def      lowercase__ (					lowerCAmelCase__   :			GraphUndirectedWeighted[T]							,			)    ->			tuple[dict[T, int], dict[T, T | None]]:



			'''simple docstring'''
			a__  :	dict[T, int]		 =			{node: maxsize for node in graph.connections}
			a__  :	dict[T, T | None]		 =			{node: None for node in graph.connections}

			a__  :	MinPriorityQueue[T]		 =			MinPriorityQueue()
			for node, weight in dist.items():
						priority_queue.push(lowerCAmelCase__							,			lowerCAmelCase__			)

			if priority_queue.is_empty():
						return dist, parent

			# initialization
			a__  :	Tuple		 =			priority_queue.extract_min()
			a__  :	List[Any]		 =			0
			for neighbour in graph.connections[node]:
						if dist[neighbour] > dist[node] + graph.connections[node][neighbour]:
									a__  :	Union[str, Any]		 =			dist[node] + graph.connections[node][neighbour]
									priority_queue.update_key(lowerCAmelCase__							,			dist[neighbour]			)
									a__  :	str		 =			node

    # running prim's algorithm
			while not priority_queue.is_empty():
						a__  :	List[Any]		 =			priority_queue.extract_min()
						for neighbour in graph.connections[node]:
									if dist[neighbour] > dist[node] + graph.connections[node][neighbour]:
												a__  :	Any		 =			dist[node] + graph.connections[node][neighbour]
												priority_queue.update_key(lowerCAmelCase__							,			dist[neighbour]			)
												a__  :	Tuple		 =			node
			return dist, parent






"""simple docstring"""






from __future__ import annotations






def      lowercase__ (					lowerCAmelCase__   :			int			)    ->			list[int]:



			'''simple docstring'''
			a__  :	Tuple		 =			[True] * limit
			a__  :	Tuple		 =			False
			a__  :	int		 =			False
			a__  :	Tuple		 =			True

			for i in range(3							,			int(limit**0.5 + 1			)							,			2			):
						a__  :	int		 =			i * 2
						while index < limit:
									a__  :	Union[str, Any]		 =			False
									a__  :	int		 =			index + i

			a__  :	str		 =			[2]

			for i in range(3							,			lowerCAmelCase__							,			2			):
						if is_prime[i]:
									primes.append(lowerCAmelCase__			)

			return primes






def      lowercase__ (					lowerCAmelCase__   :			int = 1_0_0_0_0_0_0			)    ->			int:



			'''simple docstring'''
			a__  :	List[Any]		 =			prime_sieve(lowerCAmelCase__			)
			a__  :	int		 =			0
			a__  :	str		 =			0

			for i in range(len(lowerCAmelCase__			)			):
						for j in range(i + length							,			len(lowerCAmelCase__			)			):
									a__  :	List[str]		 =			sum(primes[i:j]			)
									if sol >= ceiling:
												break

									if sol in primes:
												a__  :	Tuple		 =			j - i
												a__  :	Union[str, Any]		 =			sol

			return largest


if __name__ == "__main__":
		print(f"{solution() = }")