#K54097. Valid Parentheses Checker

    ID: 29677 Type: Default 1000ms 256MiB

Valid Parentheses Checker

Valid Parentheses Checker

Given a string consisting only of the characters '(' and ')', determine whether the string is valid. A valid string satisfies the condition that every opening parenthesis has a corresponding closing parenthesis and the pairs are properly nested.

For instance, when the input is ()(), the output should be True. Your solution should read from stdin and output the result to stdout.

The problem can be mathematically described as: A string ( s ) is valid if and only if ( \forall i, ; the; number; of; '(' ; encountered ; so ; far ; is ; always \geq ) the number of ( ')' ) and, upon completing the string, they are equal.

inputFormat

A single string ( s ), consisting solely of the characters '(' and ')'. The input is provided via stdin.

outputFormat

Print True if the input string ( s ) is valid; otherwise, print False. The output is produced to stdout.## sample

()
True