



'''simple docstring'''
def A__       (	UpperCAmelCase_				):
						_UpperCamelCase   :						Any												=  current_set.copy()
						for row_index, row in enumerate(UpperCAmelCase_				):
												_UpperCamelCase   :						Any												=  row[0]
												for column_index, column in enumerate(UpperCAmelCase_				):
																		if magnitude == 0:
																								_UpperCamelCase   :						Optional[Any]												=  column
																								continue
																		_UpperCamelCase   :						int												=  column / magnitude
    # Subtract to cancel term
						_UpperCamelCase   :						Union[str, Any]												=  current_set[0]
						_UpperCamelCase   :						Tuple												=  [first_row]
						_UpperCamelCase   :						Any												=  current_set[1::]
						for row in current_set:
												_UpperCamelCase   :						Dict												=  []
												# If first term is 0, it is already in form we want, so we preserve it
												if row[0] == 0:
																		final_set.append(UpperCAmelCase_				)
																		continue
												for column_index in range(len(UpperCAmelCase_				)				):
																		temp_row.append(first_row[column_index] - row[column_index]				)
												final_set.append(UpperCAmelCase_				)
						# Create next recursion iteration set
						if len(final_set[0]				) != 3:
												_UpperCamelCase   :						Union[str, Any]												=  final_set[0]
												_UpperCamelCase   :						Optional[Any]												=  []
												_UpperCamelCase   :						Optional[int]												=  []
												for row in final_set[1::]:
																		current_first_column.append(row[0]				)
																		next_iteration.append(row[1::]				)
												_UpperCamelCase   :						Optional[Any]												=  simplify(UpperCAmelCase_				)
												for i in range(len(UpperCAmelCase_				)				):
																		resultant[i].insert(0    ,    current_first_column[i]				)
												resultant.insert(0    ,    UpperCAmelCase_				)
												_UpperCamelCase   :						List[str]												=  resultant
						return final_set






def A__       (	UpperCAmelCase_				):
						if len(UpperCAmelCase_				) == 0:
												raise IndexError('solve_simultaneous() requires n lists of length n+1'				)
						_UpperCamelCase   :						List[Any]												=  len(UpperCAmelCase_				) + 1
						if any(len(UpperCAmelCase_				) != _length for item in equations				):
												raise IndexError('solve_simultaneous() requires n lists of length n+1'				)
						for row in equations:
												if any(not isinstance(UpperCAmelCase_    ,    (int, float)				) for column in row				):
																		raise ValueError('solve_simultaneous() requires lists of integers'				)
						if len(UpperCAmelCase_				) == 1:
												return [equations[0][-1] / equations[0][0]]
						_UpperCamelCase   :						Dict												=  equations.copy()
						if any(0 in row for row in data_set				):
												_UpperCamelCase   :						str												=  data_set.copy()
												_UpperCamelCase   :						Dict												=  []
												for row_index, row in enumerate(UpperCAmelCase_				):
																		if 0 not in row:
																								_UpperCamelCase   :						Optional[Any]												=  data_set.pop(UpperCAmelCase_				)
																								break
												if not full_row:
																		raise ValueError('solve_simultaneous() requires at least 1 full equation'				)
												data_set.insert(0    ,    UpperCAmelCase_				)
						_UpperCamelCase   :						str												=  data_set.copy()
						_UpperCamelCase   :						Dict												=  simplify(UpperCAmelCase_				)
						_UpperCamelCase   :						List[str]												=  simplified[::-1]
						_UpperCamelCase   :						list												=  []
						for row in simplified:
												_UpperCamelCase   :						List[str]												=  row[-1]
												if not solutions:
																		if row[-2] == 0:
																								solutions.append(0				)
																								continue
																		solutions.append(current_solution / row[-2]				)
																		continue
												_UpperCamelCase   :						int												=  row.copy()[: len(UpperCAmelCase_				) - 1 :]
												while temp_row[0] == 0:
																		temp_row.pop(0				)
												if len(UpperCAmelCase_				) == 0:
																		solutions.append(0				)
																		continue
												_UpperCamelCase   :						str												=  temp_row[1::]
												_UpperCamelCase   :						Optional[int]												=  temp_row[::-1]
												for column_index, column in enumerate(UpperCAmelCase_				):
																		current_solution -= column * solutions[column_index]
												solutions.append(UpperCAmelCase_				)
						_UpperCamelCase   :						Any												=  []
						for item in solutions:
												final.append(float(round(UpperCAmelCase_    ,    5				)				)				)
						return final[::-1]


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					snake_case_					:      Optional[int]    			=    [
					    [2, 1, 1, 1, 1, 4],
					    [1, 2, 1, 1, 1, 5],
					    [1, 1, 2, 1, 1, 6],
					    [1, 1, 1, 2, 1, 7],
					    [1, 1, 1, 1, 2, 8],
					]
					print(solve_simultaneous(eq))
					print(solve_simultaneous([[4, 2]]))







'''simple docstring'''
from collections.abc import Iterator, MutableMapping
from dataclasses import dataclass
from typing import Generic, TypeVar

snake_case_					:      Optional[Any]    			=    TypeVar('KEY')
snake_case_					:      Dict    			=    TypeVar('VAL')






@dataclass(frozen=lowercase		,   slots=lowercase  )
class 				lowercase__      (				Generic[KEY, VAL]  ):
	lowercase__    							=     42
	lowercase__    							=     42






class 				lowercase__      (				_Item  ):





	def __init__(					self   :							Union[str, Any]					):







							'''simple docstring'''
							super().__init__(lowerCamelCase__					,lowerCamelCase__					)





	def __bool__(					self   :							Tuple					):







							'''simple docstring'''
							return False
snake_case_					:      int    			=    _DeletedItem()






class 				lowercase__      (				MutableMapping[KEY, VAL]  ):





	def __init__(					self   :							Any					,lowerCamelCase__   :							int = 8					,lowerCamelCase__   :							float = 0.7_5					):







							'''simple docstring'''
							_UpperCamelCase   :						Union[str, Any]												=  initial_block_size
							_UpperCamelCase   :						list[_Item | None]												=  [None] * initial_block_size
							assert 0.0 < capacity_factor < 1.0
							_UpperCamelCase   :						Optional[int]												=  capacity_factor
							_UpperCamelCase   :						List[Any]												=  0





	def       UpperCamelCase_    (					self   :							Optional[int]					,lowerCamelCase__   :							KEY					):







							'''simple docstring'''
							return hash(lowerCamelCase__					) % len(self._buckets					)





	def       UpperCamelCase_    (					self   :							List[Any]					,lowerCamelCase__   :							int					):







							'''simple docstring'''
							return (ind + 1) % len(self._buckets					)





	def       UpperCamelCase_    (					self   :							Union[str, Any]					,lowerCamelCase__   :							int					,lowerCamelCase__   :							KEY					,lowerCamelCase__   :							VAL					):







							'''simple docstring'''
							_UpperCamelCase   :						str												=  self._buckets[ind]
							if not stored:
													_UpperCamelCase   :						str												=  _Item(lowerCamelCase__					,lowerCamelCase__					)
													self._len += 1
													return True
							elif stored.key == key:
													_UpperCamelCase   :						Union[str, Any]												=  _Item(lowerCamelCase__					,lowerCamelCase__					)
													return True
							else:
													return False





	def       UpperCamelCase_    (					self   :							Optional[int]					):







							'''simple docstring'''
							_UpperCamelCase   :						Dict												=  len(self._buckets					) * self._capacity_factor
							return len(self					) >= int(lowerCamelCase__					)





	def       UpperCamelCase_    (					self   :							Dict					):







							'''simple docstring'''
							if len(self._buckets					) <= self._initial_block_size:
													return False
							_UpperCamelCase   :						str												=  len(self._buckets					) * self._capacity_factor / 2
							return len(self					) < limit





	def       UpperCamelCase_    (					self   :							int					,lowerCamelCase__   :							int					):







							'''simple docstring'''
							_UpperCamelCase   :						int												=  self._buckets
							_UpperCamelCase   :						Dict												=  [None] * new_size
							_UpperCamelCase   :						str												=  0
							for item in old_buckets:
													if item:
																			self._add_item(item.key					,item.val					)





	def       UpperCamelCase_    (					self   :							int					):







							'''simple docstring'''
							self._resize(len(self._buckets					) * 2					)





	def       UpperCamelCase_    (					self   :							List[str]					):







							'''simple docstring'''
							self._resize(len(self._buckets					) // 2					)





	def       UpperCamelCase_    (					self   :							Union[str, Any]					,lowerCamelCase__   :							KEY					):







							'''simple docstring'''
							_UpperCamelCase   :						List[str]												=  self._get_bucket_index(lowerCamelCase__					)
							for _ in range(len(self._buckets					)					):
													yield ind
													_UpperCamelCase   :						Optional[int]												=  self._get_next_ind(lowerCamelCase__					)





	def       UpperCamelCase_    (					self   :							str					,lowerCamelCase__   :							KEY					,lowerCamelCase__   :							VAL					):







							'''simple docstring'''
							for ind in self._iterate_buckets(lowerCamelCase__					):
													if self._try_set(lowerCamelCase__					,lowerCamelCase__					,lowerCamelCase__					):
																			break





	def __setitem__(					self   :							Dict					,lowerCamelCase__   :							KEY					,lowerCamelCase__   :							VAL					):







							'''simple docstring'''
							if self._is_full():
													self._size_up()

							self._add_item(lowerCamelCase__					,lowerCamelCase__					)





	def __delitem__(					self   :							Optional[Any]					,lowerCamelCase__   :							KEY					):







							'''simple docstring'''
							for ind in self._iterate_buckets(lowerCamelCase__					):
													_UpperCamelCase   :						Any												=  self._buckets[ind]
													if item is None:
																			raise KeyError(lowerCamelCase__					)
													if item is _deleted:
																			continue
													if item.key == key:
																			_UpperCamelCase   :						Optional[Any]												=  _deleted
																			self._len -= 1
																			break
							if self._is_sparse():
													self._size_down()





	def __getitem__(					self   :							Dict					,lowerCamelCase__   :							KEY					):







							'''simple docstring'''
							for ind in self._iterate_buckets(lowerCamelCase__					):
													_UpperCamelCase   :						Any												=  self._buckets[ind]
													if item is None:
																			break
													if item is _deleted:
																			continue
													if item.key == key:
																			return item.val
							raise KeyError(lowerCamelCase__					)





	def __len__(					self   :							Dict					):







							'''simple docstring'''
							return self._len





	def __iter__(					self   :							List[str]					):







							'''simple docstring'''
							yield from (item.key for item in self._buckets if item)





	def __repr__(					self   :							Union[str, Any]					):







							'''simple docstring'''
							_UpperCamelCase   :						Tuple												=  ' ,'.join(
							    F'{item.key}: {item.val}' for item in self._buckets if item					)
							return F'HashMap({val_string})'


