#C13815. Well-Formed Parentheses Checker

    ID: 43395 Type: Default 1000ms 256MiB

Well-Formed Parentheses Checker

Well-Formed Parentheses Checker

You are given a string S consisting solely of the characters '(' and ')'. Your task is to determine whether the given string is well-formed. A string is well-formed if every opening parenthesis '(' has a corresponding closing parenthesis ')' and the pairs of parentheses are properly nested.

The well-formed condition can be defined as follows: Let \(balance\) be initialized to zero. As you traverse the string from left to right, increase \(balance\) by 1 for every '(' and decrease it by 1 for every ')'. The string is well-formed if and only if:

  • \(balance \ge 0\) at every step, and
  • \(balance = 0\) at the end of the traversal.

Input is read from stdin and the result should be printed to stdout as the string True if the input is well-formed, or False otherwise.

inputFormat

The input consists of a single line that contains a string S composed only of the characters '(' and ')'.

outputFormat

Output a single line containing True if the parentheses string is well-formed. Otherwise, output False.

## sample
()
True