Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int T;
- cin >> T;
- while (T--) {
- string s;
- cin >> s;
- int a = count(s.begin(), s.end(), '0');
- int b = count(s.begin(), s.end(), '1');
- if (a == b) {
- cout << a - 1 << endl;
- } else{
- cout << min(a, b) << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement