

'''simple docstring'''






from __future__ import annotations


def 						_A	(       A__	,							A__ ):






 """simple docstring"""



 if b == 0:
  return (1, 0)
 ((__lowercase)    ,      (__lowercase))				    =					extended_euclid(A__	,							a % b )
 __lowercase				    =					a // b
 return (y, x - k * y)


def 						_A	(       A__	,							A__	,							A__	,							A__ ):






 """simple docstring"""



 ((__lowercase)    ,      (__lowercase))				    =					extended_euclid(A__	,							A__ )
 __lowercase				    =					na * na
 __lowercase				    =					ra * x * na + ra * y * na
 return (n % m + m) % m


def 						_A	(       A__	,							A__ ):






 """simple docstring"""



 ((__lowercase)    ,      (__lowercase))				    =					extended_euclid(A__	,							A__ )
 if b < 0:
  __lowercase				    =					(b % n + n) % n
 return b


def 						_A	(       A__	,							A__	,							A__	,							A__ ):






 """simple docstring"""



 __lowercase    ,      __lowercase				    =					invert_modulo(A__	,							A__ ), invert_modulo(A__	,							A__ )
 __lowercase				    =					na * na
 __lowercase				    =					ra * x * na + ra * y * na
 return (n % m + m) % m


if __name__ == "__main__":
 from doctest import testmod

 testmod(name='''chinese_remainder_theorem''', verbose=True)
 testmod(name='''chinese_remainder_theorem2''', verbose=True)
 testmod(name='''invert_modulo''', verbose=True)
 testmod(name='''extended_euclid''', verbose=True)





from collections import deque

from .hash_table import HashTable


class      __lowerCAmelCase  (			a       ):






  """simple docstring"""





  def __init__(  self							:							int     ,					*_lowerCAmelCase							:							List[Any]     ,					**_lowerCAmelCase							:							Any	) ->			Union[str, Any]:




     """simple docstring"""
     super().__init__(*_lowerCAmelCase     ,					**_lowerCAmelCase	)



  def        lowerCAmelCase__	(  self							:							Tuple     ,					_lowerCAmelCase							:							Optional[int]     ,					_lowerCAmelCase							:							List[Any]	) ->			List[Any]:




     """simple docstring"""
     snake_case_            =       deque([]	) if self.values[key] is None else self.values[key]
     self.values[key].appendleft(_lowerCAmelCase	)
     snake_case_            =       self.values[key]



  def        lowerCAmelCase__	(  self							:							List[str]	) ->			List[Any]:




     """simple docstring"""
     return (
         sum(self.charge_factor - len(_lowerCAmelCase	) for slot in self.values	)
         / self.size_table
         * self.charge_factor
     )



  def        lowerCAmelCase__	(  self							:							List[str]     ,					_lowerCAmelCase							:							Any     ,					_lowerCAmelCase							:							List[str]=None	) ->			int:




     """simple docstring"""
     if not (
         len(self.values[key]	) == self.charge_factor and self.values.count(_lowerCAmelCase	) == 0
     ):
        return key
     return super()._collision_resolution(_lowerCAmelCase     ,					_lowerCAmelCase	)




