#K54487. Balanced String Check

    ID: 29764 Type: Default 1000ms 256MiB

Balanced String Check

Balanced String Check

Problem Description:

A string is said to be balanced if the number of occurrences of the letter A is equal to the number of occurrences of the letter B. In mathematical terms, for a given string (s), let (#A) denote the count of character A and (#B) denote the count of character B. The string (s) is balanced if (#A = #B).

You are given multiple test cases. For each test case, determine whether the provided string is balanced. If it is balanced, output YES; otherwise, output NO.

inputFormat

Input is provided via standard input (stdin). The first line contains an integer (T) (the number of test cases). Each of the following (T) lines contains a non-empty string consisting solely of uppercase letters.

Constraints:
(1 \le T \le 10^5)
The total length of all strings does not exceed (10^6).

outputFormat

For each test case, print a single line to standard output (stdout) containing YES if the string is balanced, or NO otherwise.## sample

4
ABAB
AABB
AAABBB
AAAABB
YES

YES YES NO

</p>