In this question, the task is to debug the existing code to successfully execute all provided test files.
Ana loves playing with binary strings(a string which contains only characters '0' and '1' are called binary strings) and associating it with some special qualities.
She discovers a property “Power” of binary strings which is denoted as the total number of pairs (i,j) in the given string such that the Substring S(i),S(i+1),S(i+2)….S(j-1),S(j) is magical. (1<= i <= j <= |S|)
Let’s say the frequency of characters ‘0’ and ‘1’ in a given binary string be f0 and f1 respectively. It is said to be magical if f0 is equal to the square of f1.
Help Ana find the “Power” of each binary string she has.
For each test case, print a single line containing one integer — the Power of the string S.
1 ≤ T ≤ 10
1 ≤ |S| ≤ 10^5
Each character of S is '0' or '1'
For the sample test case:
1) 100100
The special substrings correspond to: (1,2) , (2,3) , (4,5) , (1,6)
So, Power of the string =4
2) 101
The special substrings correspond to: (1,2) , (2,3)
So,Power of the string = 2