





from __future__ import annotations

from collections import namedtuple
from dataclasses import dataclass

@dataclass
class 		SCREAMING_SNAKE_CASE__				:
      A_						:				int
      A_						:				TreeNode | None							=    None
      A_						:				TreeNode | None							=    None






snake_case_				=			namedtuple('CoinsDistribResult', 'moves excess')






def lowerCamelCase__    (							snake_case_	:  TreeNode | None       )      ->				int:

   if root is None:
      return 0

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

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

   def count_coins(snake_case_	:  TreeNode | None       ) -> int:
      if node is None:
         return 0

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

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

   # Main calculation
   def get_distrib(snake_case_	:  TreeNode | None       ) -> CoinsDistribResult:

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

      __snake_case       ,	__snake_case							       =   get_distrib(node.left       )
      __snake_case       ,	__snake_case							       =   get_distrib(node.right       )

      __snake_case							       =   1 - left_distrib_excess
      __snake_case							       =   1 - right_distrib_excess

      __snake_case							       =   (
          left_distrib_moves
          + right_distrib_moves
          + abs(snake_case_       )
          + abs(snake_case_       )
      )
      __snake_case							       =   node.data - coins_to_left - coins_to_right

      return CoinsDistribResult(snake_case_       ,      snake_case_       )

   return get_distrib(snake_case_       )[0]


if __name__ == "__main__":
    import doctest

    doctest.testmod()



'''simple docstring'''







def 				SCREAMING_SNAKE_CASE__	(   __A = 1_000_000	)       ->	int:
	_snake_case   						=		limit + 1
	_snake_case   						=		[0] * limit
	for first_term in range(1			,				__A	):
		for n in range(__A			,				__A			,				__A	):
			_snake_case   						=		first_term + n / first_term
			if common_difference % 4:  # d must be divisble by 4
				continue
			else:
				common_difference /= 4
				if (
				    first_term > common_difference
				    and first_term < 4 * common_difference
				):  # since x,y,z are positive integers
					frequency[n] += 1  # so z>0 and a>d ,also 4d<a

	_snake_case   						=		sum(1 for x in frequency[1:limit] if x == 10	)

	return count


if __name__ == "__main__":
					print(F'''{solution() = }''')

