






from __future__ import annotations





def 						__UpperCAmelCase			(     a_							,     a_							,     a_							,     a_):  # noqa: E741
							while r - l > 1:
														snake_case_				=							(l + r) // 2
														if v[m] >= key:
																					snake_case_				=							m
														else:
																					snake_case_				=							m  # noqa: E741
							return r





def 						__UpperCAmelCase			(     a_):
							if len(a_) == 0:
														return 0

							snake_case_				=							[0] * len(a_)
							snake_case_				=							1

							snake_case_				=							v[0]

							for i in range(1							,     len(a_)):
														if v[i] < tail[0]:
																					snake_case_				=							v[i]
														elif v[i] > tail[length - 1]:
																					snake_case_				=							v[i]
																					length += 1
														else:
																					snake_case_				=							v[i]

							return length


if __name__ == "__main__":
	import doctest

	doctest.testmod()













class  UpperCamelCase_      :



	'''simple docstring'''




	def __init__(       self       ,			a					)       ->    None:
								snake_case_				=							set_counts
								snake_case_				=							max(a					)
								snake_case_				=							len(a					)
								snake_case_				=							[1] * num_sets
								snake_case_				=							list(range(a					)					)




	def 							_UpperCamelCase			(       self       ,			a       ,			a					)       ->    bool:
								snake_case_				=							self.get_parent(a					)
								snake_case_				=							self.get_parent(a					)

								if src_parent == dst_parent:
															return False

								if self.ranks[dst_parent] >= self.ranks[src_parent]:
															self.set_counts[dst_parent] += self.set_counts[src_parent]
															snake_case_				=							0
															snake_case_				=							dst_parent
															if self.ranks[dst_parent] == self.ranks[src_parent]:
																						self.ranks[dst_parent] += 1
															snake_case_				=							self.set_counts[dst_parent]
								else:
															self.set_counts[src_parent] += self.set_counts[dst_parent]
															snake_case_				=							0
															snake_case_				=							src_parent
															snake_case_				=							self.set_counts[src_parent]

								snake_case_				=							max(self.max_set       ,			a					)
								return True






	def 							_UpperCamelCase			(       self       ,			a					)       ->    int:
								if self.parents[disj_set] == disj_set:
															return disj_set
								snake_case_				=							self.get_parent(self.parents[disj_set]					)
								return self.parents[disj_set]





