





'''simple docstring'''


from __future__ import annotations

from collections import namedtuple
from dataclasses import dataclass

@dataclass
class    lowerCAmelCase_		:

 '''simple docstring'''





 __lowerCamelCase						:							str         =					42
 __lowerCamelCase						:							Optional[int]         =					None
 __lowerCamelCase						:							Optional[int]         =					None







_SCREAMING_SNAKE_CASE	 =							namedtuple("CoinsDistribResult", "moves excess")


def 	__a(SCREAMING_SNAKE_CASE_  :					str    ):



    '''simple docstring'''





    if root is None:
        return 0

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

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

    def count_coins(SCREAMING_SNAKE_CASE_  :					str    ) -> 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(SCREAMING_SNAKE_CASE_  :					Union[str, Any]    ) -> CoinsDistribResult:

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

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

        _lowerCAmelCase				=      1 - left_distrib_excess
        _lowerCAmelCase				=      1 - right_distrib_excess

        _lowerCAmelCase				=      (
            left_distrib_moves
            + right_distrib_moves
            + abs(__snake_case    )
            + abs(__snake_case    )
        )
        _lowerCAmelCase				=      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'''


from __future__ import annotations


def 	__a(SCREAMING_SNAKE_CASE_  :					list[float]		,       SCREAMING_SNAKE_CASE_  :					list[float]    ):



    '''simple docstring'''





    _lowerCAmelCase				=      sorted(numsa + numsa    )
    _lowerCAmelCase			,			_lowerCAmelCase				=      divmod(len(SCREAMING_SNAKE_CASE_    )		,       2    )
    if mod == 1:
        return all_numbers[div]
    else:
        return (all_numbers[div] + all_numbers[div - 1]) / 2


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       _SCREAMING_SNAKE_CASE	 =							[float(x) for x in input("Enter the elements of first array: ").split()]
       _SCREAMING_SNAKE_CASE	 =							[float(x) for x in input("Enter the elements of second array: ").split()]
       print(f'''The median of two arrays is: {median_of_two_arrays(array_a, array_a)}''')


