
"""simple docstring"""







import math
def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE )  ->     bool:







							"""simple docstring"""


							if 1 < number < 4:
														# 2 and 3 are primes
														return True
							elif number < 2 or number % 2 == 0 or number % 3 == 0:
														# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
														return False

							# All primes number are in format of 6k +/- 1
							for i in range(5							,    int(math.sqrt(SCREAMING_SNAKE_CASE ) + 1 )							,    6 ):
														if number % i == 0 or number % (i + 2) == 0:
																					return False
							return True
def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE = 0.1 )  ->     int:







							"""simple docstring"""


							__snake_case     			=       3
							__snake_case     			=       3

							while primes / (2 * j - 1) >= ratio:
														for i in range(j * j + j + 1							,    (j + 2) * (j + 2)							,    j + 1 ):
																					primes += is_prime(SCREAMING_SNAKE_CASE )
														j += 2
							return j


if __name__ == "__main__":
		import doctest

		doctest.testmod()


"""simple docstring"""







from heapq import heappop, heappush

import numpy as np
def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    )  ->     tuple[float | int, list[tuple[int, int]]]:







							"""simple docstring"""


							__snake_case			,   __snake_case     			=       grid.shape
							__snake_case     			=       [-1, 1, 0, 0]
							__snake_case     			=       [0, 0, -1, 1]
							if allow_diagonal:
														dx += [-1, -1, 1, 1]
														dy += [-1, 1, -1, 1]

							__snake_case			,   __snake_case     			=       [(0, source)], set()
							__snake_case     			=       np.full((rows, cols)							,    np.inf )
							__snake_case     			=       0
							__snake_case     			=       np.empty((rows, cols)							,    dtype=SCREAMING_SNAKE_CASE )
							__snake_case     			=       None

							while queue:
														((__snake_case)			,   (__snake_case))     			=       heappop(SCREAMING_SNAKE_CASE )
														if (x, y) in visited:
																					continue
														visited.add((x, y) )

														if (x, y) == destination:
																					__snake_case     			=       []
																					while (x, y) != source:
																												path.append((x, y) )
																												__snake_case			,   __snake_case     			=       predecessors[x, y]
																					path.append(SCREAMING_SNAKE_CASE )  # add the source manually
																					path.reverse()
																					return matrix[destination], path

														for i in range(len(SCREAMING_SNAKE_CASE ) ):
																					__snake_case			,   __snake_case     			=       x + dx[i], y + dy[i]
																					if 0 <= nx < rows and 0 <= ny < cols:
																												__snake_case     			=       grid[nx][ny]
																												if next_node == 1 and matrix[nx, ny] > dist + 1:
																																			heappush(SCREAMING_SNAKE_CASE							,    (dist + 1, (nx, ny)) )
																																			__snake_case     			=       dist + 1
																																			__snake_case     			=       (x, y)

							return np.inf, []


if __name__ == "__main__":
		import doctest

		doctest.testmod()
