


"""simple docstring"""
class        __A       :





							'''simple docstring'''

							def __init__(			self							: Union[str, Any]						,    UpperCAmelCase_							: list[int]    )   ->None:



														"""simple docstring"""



														snake_case_          =						len(UpperCAmelCase_    )
														snake_case_          =						[0] * len_array

														if len_array > 0:
																					snake_case_          =						array[0]

														for i in range(1						,    UpperCAmelCase_    ):
																					snake_case_          =						self.prefix_sum[i - 1] + array[i]



							def 						lowerCAmelCase    (			self							: Optional[int]						,    UpperCAmelCase_							: int						,    UpperCAmelCase_							: int    )   ->int:



														"""simple docstring"""



														if start == 0:
																					return self.prefix_sum[end]

														return self.prefix_sum[end] - self.prefix_sum[start - 1]



							def 						lowerCAmelCase    (			self							: List[str]						,    UpperCAmelCase_							: int    )   ->bool:



														"""simple docstring"""



														snake_case_          =						{0}
														for sum_item in self.prefix_sum:
																					if sum_item - target_sum in sums:
																												return True

																					sums.add(UpperCAmelCase_    )

														return False


if __name__ == "__main__":
				import doctest

				doctest.testmod()







"""simple docstring"""
import math





class        __A       :





							'''simple docstring'''

							def __init__(			self							: List[str]						,    UpperCAmelCase_							: Tuple=0    )   ->Optional[int]:  # a graph with Node 0,1,...,N-1



														"""simple docstring"""



														snake_case_          =						n
														snake_case_          =						[
														    [math.inf for j in range(0						,    UpperCAmelCase_    )] for i in range(0						,    UpperCAmelCase_    )
														]  # adjacency matrix for weight
														snake_case_          =						[
														    [math.inf for j in range(0						,    UpperCAmelCase_    )] for i in range(0						,    UpperCAmelCase_    )
														]  # dp[i][j] stores minimum distance from i to j



							def 						lowerCAmelCase    (			self							: List[str]						,    UpperCAmelCase_							: Any						,    UpperCAmelCase_							: List[str]						,    UpperCAmelCase_							: Optional[Any]    )   ->Optional[int]:



														"""simple docstring"""



														snake_case_          =						w



							def 						lowerCAmelCase    (			self							: Optional[int]    )   ->Any:



														"""simple docstring"""



														for k in range(0						,    self.n    ):
																					for i in range(0						,    self.n    ):
																												for j in range(0						,    self.n    ):
																																			snake_case_          =						min(self.dp[i][j]						,    self.dp[i][k] + self.dp[k][j]    )



							def 						lowerCAmelCase    (			self							: Optional[int]						,    UpperCAmelCase_							: Dict						,    UpperCAmelCase_							: Optional[Any]    )   ->Union[str, Any]:



														"""simple docstring"""



														return self.dp[u][v]


if __name__ == "__main__":
				__SCREAMING_SNAKE_CASE							:      Optional[int]						=      Graph(5)
				graph.add_edge(0, 2, 9)
				graph.add_edge(0, 4, 10)
				graph.add_edge(1, 3, 5)
				graph.add_edge(2, 3, 7)
				graph.add_edge(3, 0, 10)
				graph.add_edge(3, 1, 2)
				graph.add_edge(3, 2, 1)
				graph.add_edge(3, 4, 6)
				graph.add_edge(4, 1, 3)
				graph.add_edge(4, 2, 4)
				graph.add_edge(4, 3, 9)
				graph.floyd_warshall()
				graph.show_min(1, 4)
				graph.show_min(0, 3)



