#K34772. Balanced Parentheses Checker

    ID: 25384 Type: Default 1000ms 256MiB

Balanced Parentheses Checker

Balanced Parentheses Checker

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

More formally, let count('(') and count(')') denote the number of '(' and ')' respectively. A string s is balanced if and only if:

$$\forall i, \; count('(') \ge count(')')$$

and

$$count('(') = count(')')$$

inputFormat

The input consists of a single line containing a string of parentheses.

outputFormat

Output "True" if the string of parentheses is balanced, otherwise output "False".## sample

()()
True