"""simple docstring"""


from timeit import timeit






def 			__UpperCAmelCase    (	lowercase						):







  """simple docstring"""
  if number < 0:
    raise ValueError("""the value of input must not be negative"""						)
  _UpperCAmelCase         =					0
  while number:
    number &= number - 1
    result += 1
  return result






def 			__UpperCAmelCase    (	lowercase						):







  """simple docstring"""
  if number < 0:
    raise ValueError("""the value of input must not be negative"""						)
  _UpperCAmelCase         =					0
  while number:
    if number % 2 == 1:
      result += 1
    number >>= 1
  return result






def 			__UpperCAmelCase    (	):







  """simple docstring"""

  def do_benchmark(lowercase						) -> None:
    _UpperCAmelCase         =					"""import __main__ as z"""
    print(f'''Benchmark when {number = }:'''						)
    print(f'''{get_set_bits_count_using_modulo_operator(lowercase						) = }'''						)
    _UpperCAmelCase         =					timeit("""z.get_set_bits_count_using_modulo_operator(25)"""      ,setup=lowercase						)
    print(f'''timeit() runs in {timing} seconds'''						)
    print(f'''{get_set_bits_count_using_brian_kernighans_algorithm(lowercase						) = }'''						)
    _UpperCAmelCase         =					timeit(
        """z.get_set_bits_count_using_brian_kernighans_algorithm(25)"""      ,setup=lowercase      ,)
    print(f'''timeit() runs in {timing} seconds'''						)

  for number in (25, 37, 58, 0):
    do_benchmark(lowercase						)
    print()


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()

"""simple docstring"""


from __future__ import annotations

from collections import Counter
from random import random


class 				a :


    def __init__(    self		:     Union[str, Any]    ):
      _UpperCAmelCase         =					{}


    def    lowerCAmelCase_     (    self		:     Optional[int]      , __lowerCAmelCase		:     str    ):
      _UpperCAmelCase         =					{}


    def    lowerCAmelCase_     (    self		:     str      , __lowerCAmelCase		:     str      , __lowerCAmelCase		:     str      , __lowerCAmelCase		:     float    ):
      if nodea not in self.connections:
        self.add_node(__lowerCAmelCase    )
      if nodea not in self.connections:
        self.add_node(__lowerCAmelCase    )
      _UpperCAmelCase         =					probability


    def    lowerCAmelCase_     (    self		:     Optional[Any]    ):
      return list(self.connections    )


    def    lowerCAmelCase_     (    self		:     List[Any]      , __lowerCAmelCase		:     str    ):
      _UpperCAmelCase         =					0
      _UpperCAmelCase         =					random()

      for dest in self.connections[node]:
        current_probability += self.connections[node][dest]
        if current_probability > random_value:
          return dest
      return ""






def 			__UpperCAmelCase    (	lowercase      ,lowercase      ,lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					MarkovChainGraphUndirectedUnweighted()

  for nodea, nodea, probability in transitions:
    graph.add_transition_probability(lowercase      ,lowercase      ,lowercase						)

  _UpperCAmelCase         =					Counter(graph.get_nodes()						)
  _UpperCAmelCase         =					start

  for _ in range(lowercase						):
    _UpperCAmelCase         =					graph.transition(lowercase						)
    visited[node] += 1

  return visited


if __name__ == "__main__":
    import doctest

    doctest.testmod()
