#C11842. Balanced Parentheses Checker

    ID: 41203 Type: Default 1000ms 256MiB

Balanced Parentheses Checker

Balanced Parentheses Checker

You are given a string s that may contain any characters. Your task is to determine whether the parentheses in the string are balanced. Only the characters '(' and ')' are considered when checking for balance; all other characters should be ignored.

A sequence of parentheses is considered balanced if:

  • Every opening parenthesis '(' has a corresponding closing parenthesis ')'.
  • At no point in the sequence does a closing parenthesis ')' appear before its matching opening parenthesis '('.

For example:

  • a(b)c is balanced.
  • a(b)c)d is unbalanced.
  • An empty string or a string without any parentheses is considered balanced.

Note: If any formulas are needed, present them in LaTeX format (although none are required in this problem).

inputFormat

The input consists of a single line containing the string s.

outputFormat

Output a single line: True if the parentheses in s are balanced, and False otherwise.

## sample
a(b)c
True