#C13936. Correct Parentheses Expression
Correct Parentheses Expression
Correct Parentheses Expression
This problem requires you to verify and correct misaligned parentheses in a given mathematical expression.
You are given a string expression that may contain characters and parentheses. Your task is to check whether the parentheses in the expression are properly balanced.
If the expression has perfectly balanced opening and closing parentheses, print the original expression. Otherwise, print Cannot be corrected
.
In mathematical terms, the expression is valid if every opening parenthesis \( ( \) has a matching closing parenthesis \( ) \) in the correct order.
inputFormat
The input consists of a single line containing the expression that may include spaces, letters, arithmetic operators, and parentheses.
The expression is read from standard input (stdin).
outputFormat
If the parentheses are balanced, print the original expression to standard output (stdout). Otherwise, print Cannot be corrected
.
(a + b) * (c + d)
(a + b) * (c + d)