#K44217. Valid Parentheses Checker

    ID: 27483 Type: Default 1000ms 256MiB

Valid Parentheses Checker

Valid Parentheses Checker

Given a string (S) that may contain letters, digits, and other characters including parentheses, determine whether the parentheses in the string are balanced. A string is said to have balanced parentheses if every opening parenthesis '(' has a corresponding closing parenthesis ')' and the pairs are correctly nested.

Formally, let (S) be a string. We define that the parentheses are balanced if for every prefix of (S), the number of '(' is at least as many as the number of ')', and in the entire string they are equal.

inputFormat

The input consists of a single line, which is the string (S) to be checked. Read the input from standard input (stdin).

outputFormat

Output a single line to standard output (stdout) containing either "Yes" if the parentheses are balanced, or "No" otherwise.## sample

((a+b)/c)
Yes