#C3918. Balanced Parentheses, Brackets, and Braces Checker

    ID: 47398 Type: Default 1000ms 256MiB

Balanced Parentheses, Brackets, and Braces Checker

Balanced Parentheses, Brackets, and Braces Checker

You are given a string that consists of various characters including parentheses, brackets, and braces. Your task is to determine whether the string is balanced. A string is considered balanced if each opening symbol has a corresponding closing symbol in the correct order. More formally, if we let ( S ) be the given string, it is balanced if for every opening bracket ( ( ), ( { ), or ( [ ) there is a matching closing bracket ( ) ), ( } ), or ( ] ) respectively, and they are correctly nested. Note: Any character other than these brackets should be treated as invalid and result in a "False" output.

Input is provided via standard input (stdin) and the result should be printed to standard output (stdout).

inputFormat

The input consists of a single line containing a string ( S ) which may include parentheses, brackets, and braces. Any character other than these symbols is considered invalid.

outputFormat

Output a single line: "True" if the string is balanced, and "False" otherwise.## sample

(){}[]
True