'''simple docstring'''





from __future__ import annotations

from collections.abc import Callable
from typing import Any, Generic, TypeVar

lowerCAmelCase_	:		Any			=     TypeVar("""T""")




class 		SCREAMING_SNAKE_CASE     (					Generic[T]	):







				'''simple docstring'''





				def __init__(						self					:						Optional[int]       ,		lowercase__					:						list[T]       ,		lowercase__					:						Callable[[T, T], T]					)							->None:


										'''simple docstring'''




										_UpperCamelCase			:			Any | T   			=						None

										_UpperCamelCase			:			int   			=						len(lowercase__					)
										_UpperCamelCase			:			list[T]   			=						[any_type for _ in range(self.N					)] + arr
										_UpperCamelCase			:			List[str]   			=						fnc
										self.build()





				def  snake_case__				(						self					:						Any					)							->None:


										'''simple docstring'''




										for p in range(self.N - 1       ,		0       ,		-1					):
																_UpperCamelCase			:			Any   			=						self.fn(self.st[p * 2]       ,		self.st[p * 2 + 1]					)





				def  snake_case__				(						self					:						Tuple       ,		lowercase__					:						int       ,		lowercase__					:						T					)							->None:


										'''simple docstring'''




										p += self.N
										_UpperCamelCase			:			List[str]   			=						v
										while p > 1:
																_UpperCamelCase			:			Dict   			=						p // 2
																_UpperCamelCase			:			str   			=						self.fn(self.st[p * 2]       ,		self.st[p * 2 + 1]					)







				def  snake_case__				(						self					:						Optional[int]       ,		lowercase__					:						int       ,		lowercase__					:						int					)							->T | None:  # noqa: E741


										'''simple docstring'''




										_UpperCamelCase			,       _UpperCamelCase			:			Any   			=						l + self.N, r + self.N

										_UpperCamelCase			:			T | None   			=						None
										while l <= r:
																if l % 2 == 1:
																						_UpperCamelCase			:			Union[str, Any]   			=						self.st[l] if res is None else self.fn(lowercase__       ,		self.st[l]					)
																if r % 2 == 0:
																						_UpperCamelCase			:			Optional[Any]   			=						self.st[r] if res is None else self.fn(lowercase__       ,		self.st[r]					)
																_UpperCamelCase			,       _UpperCamelCase			:			List[str]   			=						(l + 1) // 2, (r - 1) // 2
										return res


if __name__ == "__main__":
			from functools import reduce

			lowerCAmelCase_	:		Optional[Any]			=     [1, 10, -2, 9, -3, 8, 4, -7, 5, 6, 11, -12]

			lowerCAmelCase_	:		int			=     {
			    0: 7,
			    1: 2,
			    2: 6,
			    3: -14,
			    4: 5,
			    5: 4,
			    6: 7,
			    7: -10,
			    8: 9,
			    9: 10,
			    10: 12,
			    11: 1,
			}

			lowerCAmelCase_	:		int			=     SegmentTree(test_array, min)
			lowerCAmelCase_	:		List[str]			=     SegmentTree(test_array, max)
			lowerCAmelCase_	:		Tuple			=     SegmentTree(test_array, lambda a, b: a + b)
			def 						__A							(     )     ->			None:




									'''simple docstring'''
									for i in range(len(UpperCAmelCase					)					):
															for j in range(UpperCAmelCase     ,len(UpperCAmelCase					)					):
																					_UpperCamelCase			:			Optional[int]   			=						reduce(UpperCAmelCase     ,test_array[i : j + 1]					)
																					_UpperCamelCase			:			Any   			=						reduce(UpperCAmelCase     ,test_array[i : j + 1]					)
																					_UpperCamelCase			:			Union[str, Any]   			=						reduce(lambda UpperCAmelCase     ,UpperCAmelCase					: a + b     ,test_array[i : j + 1]					)
																					assert min_range == min_segment_tree.query(UpperCAmelCase     ,UpperCAmelCase					)
																					assert max_range == max_segment_tree.query(UpperCAmelCase     ,UpperCAmelCase					)
																					assert sum_range == sum_segment_tree.query(UpperCAmelCase     ,UpperCAmelCase					)

			test_all_segments()

			for index, value in test_updates.items():
						lowerCAmelCase_	:		int			=     value
						min_segment_tree.update(index, value)
						max_segment_tree.update(index, value)
						sum_segment_tree.update(index, value)
						test_all_segments()



'''simple docstring'''





def 						__A							(     UpperCAmelCase     ,UpperCAmelCase     ,UpperCAmelCase=False					)     ->			Optional[int]:




						'''simple docstring'''

						if isinstance(UpperCAmelCase     ,UpperCAmelCase					) and isinstance(UpperCAmelCase     ,UpperCAmelCase					):
												_UpperCamelCase			:			Any   			=						len(set_a.intersection(UpperCAmelCase					)					)

												if alternative_union:
																		_UpperCamelCase			:			List[str]   			=						len(UpperCAmelCase					) + len(UpperCAmelCase					)
												else:
																		_UpperCamelCase			:			List[str]   			=						len(set_a.union(UpperCAmelCase					)					)

												return intersection / union

						if isinstance(UpperCAmelCase     ,(list, tuple)					) and isinstance(UpperCAmelCase     ,(list, tuple)					):
												_UpperCamelCase			:			List[Any]   			=						[element for element in set_a if element in set_b]

												if alternative_union:
																		_UpperCamelCase			:			str   			=						len(UpperCAmelCase					) + len(UpperCAmelCase					)
																		return len(UpperCAmelCase					) / union
												else:
																		_UpperCamelCase			:			int   			=						set_a + [element for element in set_b if element not in set_a]
																		return len(UpperCAmelCase					) / len(UpperCAmelCase					)

												return len(UpperCAmelCase					) / len(UpperCAmelCase					)
						return None


if __name__ == "__main__":
			lowerCAmelCase_	:		List[str]			=     {"""a""", """b""", """c""", """d""", """e"""}
			lowerCAmelCase_	:		Dict			=     {"""c""", """d""", """e""", """f""", """h""", """i"""}
			print(jaccard_similarity(set_a, set_b))


