




"""simple docstring"""


from __future__ import annotations


def       UpperCAmelCase__ (snake_case__							:      dict	,     snake_case__							:      str					):
  """simple docstring"""

  _snake_case	,      _snake_case							:	List[str]			=						set(snake_case__					), [start]

  while stack:
    _snake_case							:	Dict			=						stack.pop()
    explored.add(snake_case__					)
    # Differences from BFS:
    # 1) pop last element instead of first one
    # 2) add adjacent elements to stack without exploring them
    for adj in reversed(graph[v]					):
      if adj not in explored:
        stack.append(snake_case__					)
  return explored


A_      			=       {
    '''A''': ['''B''', '''C''', '''D'''],
    '''B''': ['''A''', '''D''', '''E'''],
    '''C''': ['''A''', '''F'''],
    '''D''': ['''B''', '''D'''],
    '''E''': ['''B''', '''F'''],
    '''F''': ['''C''', '''E''', '''G'''],
    '''G''': ['''F'''],
}

if __name__ == "__main__":
     import doctest

     doctest.testmod()
     print(depth_first_search(G, '''A'''))








"""simple docstring"""


def       UpperCAmelCase__ (snake_case__							:      int					):
  """simple docstring"""

  if not isinstance(snake_case__	,     snake_case__					) or number < 0:
    raise ValueError("""Input must be a non-negative integer"""					)

  _snake_case							:	Dict			=						0
  while number:
    # This way we arrive at next set bit (next 1) instead of looping
    # through each bit and checking for 1s hence the
    # loop won't run 32 times it will only run the number of `1` times
    number &= number - 1
    count += 1
  return count


if __name__ == "__main__":
     import doctest

     doctest.testmod()


