#K49367. Balanced Parentheses Checker
Balanced Parentheses Checker
Balanced Parentheses Checker
Problem Statement: You are given a string composed solely of the characters '(' and ')'. The string is said to be balanced if every opening parenthesis has a corresponding closing parenthesis and the parentheses are properly nested.
In formal terms, a string \( S \) is balanced if for every prefix of \( S \), the number of '(' is at least as many as the number of ')', and the total number of '(' equals the total number of ')'.
Your task is to determine whether the given string of parentheses is balanced.
inputFormat
Input: A single line containing a non-empty string consisting only of the characters '(' and ')'.
outputFormat
Output: Print a single line containing Balanced
if the given string is balanced, or Unbalanced
otherwise.
Note: Use LaTeX formatting for any formulas, e.g., \(S\) for the string.
## sample(())
Balanced