



import operator as op
def        a__     (				lowerCAmelCase__				):
      UpperCAmelCase_      			=							[]
      UpperCAmelCase_      			=							lambda lowerCAmelCase__     ,      lowerCAmelCase__				: int(x / y				)  # noqa: E731 integer division operation
      UpperCAmelCase_      			=							{
          "^": op.pow,
          "*": op.mul,
          "/": div,
          "+": op.add,
          "-": op.sub,
      }  # operators & their respective operation

      # print table header
      print("Symbol".center(8				)     ,      "Action".center(12				)     ,      "Stack"     ,      sep=" | "				)
      print("-" * (30 + len(lowerCAmelCase__				))				)

      for x in post_fix:
            if x.isdigit():  # if x in digit
                  stack.append(lowerCAmelCase__				)  # append x to stack
                  # output in tabular format
                  print(x.rjust(8				)     ,      ("push(" + x + ")").ljust(12				)     ,      ",".join(lowerCAmelCase__				)     ,      sep=" | "				)
            else:
                  UpperCAmelCase_      			=							stack.pop()  # pop stack
                  # output in tabular format
                  print("".rjust(8				)     ,      ("pop(" + b + ")").ljust(12				)     ,      ",".join(lowerCAmelCase__				)     ,      sep=" | "				)

                  UpperCAmelCase_      			=							stack.pop()  # pop stack
                  # output in tabular format
                  print("".rjust(8				)     ,      ("pop(" + a + ")").ljust(12				)     ,      ",".join(lowerCAmelCase__				)     ,      sep=" | "				)

                  stack.append(
                      str(opr[x](int(lowerCAmelCase__				)     ,      int(lowerCAmelCase__				)				)				)				)  # evaluate the 2 values popped from stack & push result to stack
                  # output in tabular format
                  print(
                      x.rjust(8				)     ,      ("push(" + a + x + b + ")").ljust(12				)     ,      ",".join(lowerCAmelCase__				)     ,      sep=" | "     ,      )

      return int(stack[0]				)


if __name__ == "__main__":
  lowerCamelCase       	=						input("""\n\nEnter a Postfix Equation (space separated) = """).split(""" """)
  print("""\n\tResult = """, solve(Postfix))









"""simple docstring"""





from __future__ import annotations

from collections import namedtuple
from dataclasses import dataclass
@dataclass
class 				lowercase__       :







       '''simple docstring'''


       UpperCamelCase						=					42
       UpperCamelCase						=					None
       UpperCamelCase						=					None



lowerCamelCase       	=						namedtuple("""CoinsDistribResult""", """moves excess""")
def        a__     (				lowerCAmelCase__				):

      if root is None:
            return 0

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

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

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

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

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

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

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

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

            UpperCAmelCase_      			=							1 - left_distrib_excess
            UpperCAmelCase_      			=							1 - right_distrib_excess

            UpperCAmelCase_      			=							(
                left_distrib_moves
                + right_distrib_moves
                + abs(lowerCAmelCase__				)
                + abs(lowerCAmelCase__				)
            )
            UpperCAmelCase_      			=							node.data - coins_to_left - coins_to_right

            return CoinsDistribResult(lowerCAmelCase__     ,      lowerCAmelCase__				)

      return get_distrib(lowerCAmelCase__				)[0]


if __name__ == "__main__":
  import doctest

  doctest.testmod()




