#K14826. Formatting Mathematical Expression

    ID: 24221 Type: Default 1000ms 256MiB

Formatting Mathematical Expression

Formatting Mathematical Expression

In this problem, you are given a mathematical expression as a string which may have irregular spacing around the operators. Your task is to format the expression so that each operator ((+, -, *, /)) is surrounded by exactly one space on both sides. The output should not contain any leading or trailing spaces, and multiple consecutive spaces should be reduced to a single space.

For example, given the input:

3+ 5*2-4 /8

The correctly formatted output is:

3 + 5 * 2 - 4 / 8

Note that all operators need to have one space before and after them, regardless of the input spacing.

inputFormat

The input consists of a single line that contains a mathematical expression string. The expression may include digits, spaces, and the operators +, -, *, and /.

outputFormat

Output the mathematical expression formatted so that each operator is separated by exactly one space from its neighboring numbers, with no extra spaces at the beginning or end.## sample

3+ 5*2-4 /8
3 + 5 * 2 - 4 / 8