


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

_A		       =						TypeVar('KEY')
_A		       =						TypeVar('VAL')






@dataclass(frozen=A_   ,  slots=A_		)
class     UpperCAmelCase__       (					Generic[KEY, VAL]		):



    """simple docstring"""






    UpperCAmelCase__						:		KEY
    UpperCAmelCase__						:		VAL






class     UpperCAmelCase__       (					_Item		):



    """simple docstring"""






    def __init__(			self    )  ->       None:
         super().__init__(A_					,   A_    )






    def __bool__(			self    )  ->       bool:
         return False
_A		       =						_DeletedItem()






class     UpperCAmelCase__       (					MutableMapping[KEY, VAL]		):



    """simple docstring"""






    def __init__(			self					,   A_ = 8					,   A_ = 0.75    )  ->       None:
         __UpperCamelCase    							=initial_block_size
         __UpperCamelCase    							=[None] * initial_block_size
         assert 0.0 < capacity_factor < 1.0
         __UpperCamelCase    							=capacity_factor
         __UpperCamelCase    							=0






    def _a					(			self					,   A_    )  ->       int:
         return hash(A_    ) % len(self._buckets    )






    def _a					(			self					,   A_    )  ->       int:
         return (ind + 1) % len(self._buckets    )






    def _a					(			self					,   A_					,   A_					,   A_    )  ->       bool:
         __UpperCamelCase    							=self._buckets[ind]
         if not stored:
              __UpperCamelCase    							=_Item(A_					,   A_    )
              self._len += 1
              return True
         elif stored.key == key:
              __UpperCamelCase    							=_Item(A_					,   A_    )
              return True
         else:
              return False






    def _a					(			self    )  ->       bool:
         __UpperCamelCase    							=len(self._buckets    ) * self._capacity_factor
         return len(self    ) >= int(A_    )






    def _a					(			self    )  ->       bool:
         if len(self._buckets    ) <= self._initial_block_size:
              return False
         __UpperCamelCase    							=len(self._buckets    ) * self._capacity_factor / 2
         return len(self    ) < limit






    def _a					(			self					,   A_    )  ->       None:
         __UpperCamelCase    							=self._buckets
         __UpperCamelCase    							=[None] * new_size
         __UpperCamelCase    							=0
         for item in old_buckets:
              if item:
                   self._add_item(item.key					,   item.val    )






    def _a					(			self    )  ->       None:
         self._resize(len(self._buckets    ) * 2    )






    def _a					(			self    )  ->       None:
         self._resize(len(self._buckets    ) // 2    )






    def _a					(			self					,   A_    )  ->       Iterator[int]:
         __UpperCamelCase    							=self._get_bucket_index(A_    )
         for _ in range(len(self._buckets    )    ):
              yield ind
              __UpperCamelCase    							=self._get_next_ind(A_    )






    def _a					(			self					,   A_					,   A_    )  ->       None:
         for ind in self._iterate_buckets(A_    ):
              if self._try_set(A_					,   A_					,   A_    ):
                   break






    def __setitem__(			self					,   A_					,   A_    )  ->       None:
         if self._is_full():
              self._size_up()

         self._add_item(A_					,   A_    )






    def __delitem__(			self					,   A_    )  ->       None:
         for ind in self._iterate_buckets(A_    ):
              __UpperCamelCase    							=self._buckets[ind]
              if item is None:
                   raise KeyError(A_    )
              if item is _deleted:
                   continue
              if item.key == key:
                   __UpperCamelCase    							=_deleted
                   self._len -= 1
                   break
         if self._is_sparse():
              self._size_down()






    def __getitem__(			self					,   A_    )  ->       VAL:
         for ind in self._iterate_buckets(A_    ):
              __UpperCamelCase    							=self._buckets[ind]
              if item is None:
                   break
              if item is _deleted:
                   continue
              if item.key == key:
                   return item.val
         raise KeyError(A_    )






    def __len__(			self    )  ->       int:
         return self._len






    def __iter__(			self    )  ->       Iterator[KEY]:
         yield from (item.key for item in self._buckets if item)






    def __repr__(			self    )  ->       str:
         __UpperCamelCase    							=' ,'.join(
             f'{item.key}: {item.val}' for item in self._buckets if item    )
         return f'HashMap({val_string})'






"""simple docstring"""







from __future__ import annotations



def 			lowercase__(       __SCREAMING_SNAKE_CASE							:     list      ):
     if not nums:
          raise ValueError('List is empty'      )
     return sum(__SCREAMING_SNAKE_CASE      ) / len(__SCREAMING_SNAKE_CASE      )


if __name__ == "__main__":
       import doctest

       doctest.testmod()

