Balanced Expressions
Let us consider expressions formed by nonnegative integers, the
unary operator "-", the binary operators "+", "-", "*" and "/" and the symbols
"( " and ")".
Two expressions E and F are isomorphic if E can be obtained from F by replacing
some nonnegative integers by others. The expressions (2+3) * 6 - (-4) and (7+0) * 6 - (-8)
are isomorphic, but neither of them is isomorphic to (-2 +3) * 6 - (-4).
An expression E is balanced if every binary operation in it is applied to two
isomorphic expressions. The expressions -5, (1+2) * (3+5) and ((-3)/( -4))/(( -1)/( -100))
are balanced, while 12 + (3-2) is not.
Given an expression E, check whether it is balanced.
The input consists of several lines with the expressions to be tested, one per line.
The output consists of a separated line for each expression with a single word, either YES or NO.
Sample Input
(1+2) * (3+5)
Sample Output
YES