


'''simple docstring'''




from collections import defaultdict


def    UpperCAmelCase_  (       A		,	A      ):
   '''simple docstring'''





   _a					:  Optional[Any]						=  first_str.lower().strip()
   _a					:  Optional[int]						=  second_str.lower().strip()

   # Remove whitespace
   _a					:  Dict						=  first_str.replace(' '		,	''      )
   _a					:  Any						=  second_str.replace(' '		,	''      )

   # Strings of different lengths are not anagrams
   if len(A      ) != len(A      ):
      return False

   # Default values for count should be 0
   _a					:  defaultdict[str, int]						=  defaultdict(A      )

   # For each character in input strings,
   # increment count in the corresponding
   for i in range(len(A      )      ):
      count[first_str[i]] += 1
      count[second_str[i]] -= 1

   return all(_count == 0 for _count in count.values()      )


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

 testmod()
 UpperCAmelCase_      :		List[str]          =		input("Enter the first string ").strip()
 UpperCAmelCase_      :		Any          =		input("Enter the second string ").strip()

 UpperCAmelCase_      :		Tuple          =		check_anagrams(input_a, input_b)
 print(f'''{input_a} and {input_b} are {"" if status else "not "}anagrams.''')






'''simple docstring'''




from __future__ import annotations

from collections import namedtuple
from dataclasses import dataclass







@dataclass
class 					a			:
 '''simple docstring'''




 __lowerCAmelCase						: int
 __lowerCAmelCase						: TreeNode | None							  =		None
 __lowerCAmelCase						: TreeNode | None							  =		None





UpperCAmelCase_      :		Dict          =		namedtuple("CoinsDistribResult", "moves excess")


def    UpperCAmelCase_  (       A      ):
   '''simple docstring'''





   if root is None:
      return 0

   # Validation
   def count_nodes(A      ) -> int:
      if node is None:
         return 0

      return count_nodes(node.left      ) + count_nodes(node.right      ) + 1

   def count_coins(A      ) -> int:
      if node is None:
         return 0

      return count_coins(node.left      ) + count_coins(node.right      ) + node.data

   if count_nodes(A      ) != count_coins(A      ):
      raise ValueError('The nodes number should be same as the number of coins'      )

   # Main calculation
   def get_distrib(A      ) -> CoinsDistribResult:

      if node is None:
         return CoinsDistribResult(0		,	1      )

      _a		,						_a					:  Optional[Any]						=  get_distrib(node.left      )
      _a		,						_a					:  Tuple						=  get_distrib(node.right      )

      _a					:  List[str]						=  1 - left_distrib_excess
      _a					:  str						=  1 - right_distrib_excess

      _a					:  Any						=  (
          left_distrib_moves
          + right_distrib_moves
          + abs(A      )
          + abs(A      )
      )
      _a					:  Optional[int]						=  node.data - coins_to_left - coins_to_right

      return CoinsDistribResult(A		,	A      )

   return get_distrib(A      )[0]


if __name__ == "__main__":
 import doctest

 doctest.testmod()


