Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	flag := true
	for {
		for i := 0; i < 3; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), "")
			if buf[0] == "0" {
				flag = false
				break
			}
			a, b := 0, 0
			buf = buf[1:]
			for _, v := range buf {
				if string(v) == "A" {
					a++
				} else {
					b++
				}
			}
			if a > b {
				a++
			} else {
				b++
			}
			fmt.Println(a, b)
		}
		if !flag {
			break
		}
	}
}

C++: #include<iostream>
#include<string>
using namespace std;

#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)

int main(){
	int a,b;
	string input;
	while(getline(cin,input),input!="0"){
		a=b=0;
		rep(i,input.size())	{
			if(input[i]=='A')a++;
			if(input[i]=='B')b++;
		}
		if(a<11 || b<11){
			if(a==10){a++;b--;}
			else if(b==10){b++;a--;} 
			cout<<a<<" "<<b;
		}
		else if(input[input.size()-1]=='A')cout<<a+1<<" "<<b-1;
		else cout<<a-1<<" "<<b+1;
		
		cout<<endl;
		
	}

}

C++: 
#include <iostream>
using namespace std;
int main(){
 char S[100];
 int a,b; 
 while(1){
  cin>>S;
  if(S[0]=='0') break;
  for(int i=1;S[i]!='\0';i++){
   if(S[i]=='A') a++;
   if(S[i]=='B') b++; 
   }
  if(a>b) a++;
  else b++;
  cout<<a<<' '<<b<<endl;
  a=0; b=0;

 }  

 return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    string inp;

    while (cin >> inp, inp != "0") {
        int a, b;

        a = b = 0;
        for (int i = 1; i < inp.size(); i++) 
            inp[i] == 'A' ? a++ : b++;

        (a > b) ? a++ : b++;
        cout << a << " " << b << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int a,b,ss;
	string s;
	
	while(cin>>s){
		if(s[0]=='0')break;
		ss=s.size();
		if(ss>=22){
			
			if(s[s.size()-1]=='A'){
				cout<<ss/2+1<<" "<<ss/2-1<<endl;
			}else{
				cout<<ss/2-1<<" "<<ss/2+1<<endl;
			}
			
		}else{
			
			if(s[s.size()-1]=='A'){
				cout<<11<<" "<<ss-11<<endl;
			}else{
				cout<<ss-11<<" "<<11<<endl;
			}
			
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
    while (1) {
        string s1, s2, s3;
        cin >> s1;
        if (s1 == "0") break;
        cin >> s2 >> s3;
        int a = 0, b = 0;
        for (int i = 1; i < s1.size(); i++) {
            if (s1[i] == 'A') a++;
            else b++;
        }
        if (s2[0] == 'A') a++;
        else b++;
        cout << a << " " << b << endl;
        a = 0, b = 0;
        for (int i = 1; i < s2.size(); i++) {
            if (s2[i] == 'A') a++;
            else b++;
        }
        if (s3[0] == 'A') a++;
        else b++;
        cout << a << " " << b << endl;
        a = 0, b = 0;
        for (int i = 1; i < s3.size(); i++) {
            if (s3[i] == 'A') a++;
            else b++;
        }
        if (a < b) b++;
        else a++;
        cout << a << " " << b << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
  int as,bs;
  char s[101],sf;
  cin >> sf;
  while(cin>>s){
    if(s[0]=='0') break;
    as = 0;
    bs = 0;
    for(int i=1;i<strlen(s);i++){
      if(s[i]=='A') as++;
      else bs++;
    }
    if(as>bs) as++;
    else bs++;
    cout << as << ' ' << bs << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
long i,l,a,b;
string s;
while(cin>>s){
if(s=="0")break;
l=s.size();a=b=0;
for(i=1;i<l;i++)if(s[i]=='A')a++;else b++;
if(a>b)cout<<a+1<<" "<<b<<endl;
else cout<<a<<" "<<b+1<<endl;
}
return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
string bad;
int a,b;
while(true){
 a=0;b=0;
 cin >> bad;
 if(bad=="0"){
      break;
 }
 for(int i=1;i<bad.size();i++){
       if(bad[i]=='A'){
              a++;
        }else{
              b++;
         }
 }
 if(a>b){
       a++;
 }else{
       b++;
 }
 cout << a << ' ' << b << endl;
 }
 return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
    char ser[102];
    int a=0,b=0;
    while(1){
        scanf("%s",ser);
        if(ser[0]=='0')break;
        for(int i=1;;i++){
            if(ser[i]=='\0'&&(a==10||ser[i-1]=='A'))ser[i]='A';
            else if(ser[i]=='\0')ser[i]='B';
            if(i==21)i++;
            if(ser[i]=='A')a++;
            else b++;
            if((a==11||b==11)&&(a<10||b<10))break;
            else if((a-b==2||a-b==-2)&&(a>=10&&b>=10))break;
        }
        cout<<a<<" "<<b<<endl;
        a=0;b=0;
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
string S; int a, b;
int main() {
	while (cin >> S) {
		a = 0; b = 0;
		for (int i = 1; i < S.size(); i++) {
			if (S[i] == 'A') {
				a++;
			}
			else {
				b++;
			}
		}
		if (a > b) {
			a++;
		}
		else {
			b++;
		}
		cout << a << ' ' << b << endl;
	}
}

C++: #include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	string s[3];
	while(1) {
		cin >> s[0];
		if(s[0] == "0") break;
		rep2(i,1,3) {
			cin >> s[i];
		}
		rep(i,3) {
			int a = 0, b = 0;
			rep2(j,1,s[i].size()) {
				if(s[i][j] == 'A') a++;
				else b++;
			}
			if(a>b) a++;
			else b++;
			cout << a << " " << b << endl;
		}
	}
   return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
  string s;
  while(std::cin >> s, s != "0"){
    int a = 0, b = 0;
    for (int i = 1; i < s.length(); i++) {
      if(s[i] == 'A')a++;
      else b++;
    }
    std::cout << (a + (a > b)) << " " << (b + (b > a)) << std::endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int black[3] = {0};
    int blue[] = { 0,0,255 };
    int lime[] = {0,255,0};
    int aqua[] = {0,255,255};
    int red[] = {255,0,0};
    int fuchsia[] = {255,0,255};
    int yellow[] = {255,255,0};
    int white[] = {255,255,255};
    while(true){
	string s;
	cin >> s;
	if(s == "0") break;
	int rgb[3];
	rgb[0] = stoi(s.substr(1,2),nullptr,16);
	rgb[1] = stoi(s.substr(3,2),nullptr,16);
	rgb[2] = stoi(s.substr(5,2),nullptr,16);
	string ans;
	int m = 10000000;
	int sum = 0;
	REP(j,3) sum += (rgb[j]-black[j])*(rgb[j]-black[j]);
	if(m > sum){
	    m = sum;
	    ans = "black";
	}
	sum = 0;
	REP(j,3) sum += (rgb[j]-blue[j])*(rgb[j]-blue[j]);
	if(m > sum){
	    m = sum;
	    ans = "blue";
	}
	sum = 0;
	REP(j,3) sum += (rgb[j]-lime[j])*(rgb[j]-lime[j]);
	if(m > sum){
	    m = sum;
	    ans = "lime";
	}
	sum = 0;
	REP(j,3) sum += (rgb[j]-aqua[j])*(rgb[j]-aqua[j]);
	if(m > sum){
	    m = sum;
	    ans = "aqua";
	}
	sum = 0;
	REP(j,3) sum += (rgb[j]-red[j])*(rgb[j]-red[j]);
	if(m > sum){
	    m = sum;
	    ans = "red";
	}
	sum = 0;
	REP(j,3) sum += (rgb[j]-fuchsia[j])*(rgb[j]-fuchsia[j]);
	if(m > sum){
	m = sum;
	ans = "fuchsia";
	}
	sum = 0;
	REP(j,3) sum += (rgb[j]-yellow[j])*(rgb[j]-yellow[j]);
	if(m > sum){
	    m = sum;
	    ans = "yellow";
	}
	sum = 0;
	REP(j,3) sum += (rgb[j]-white[j])*(rgb[j]-white[j]);
	if(m > sum){
	    m = sum;
	    ans = "white";
	}
	cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;

int main(){
  string str;
  
  for(;;){
    int cntA = 0,cntB = 0;
  
    cin >> str;
    if(str == "0") break;
    
    for(int i = 1 ; i < str.size() ; i++){
      if(str[i] == 'A') cntA++;
      else cntB++;    
    }
    
    if(cntA > cntB) cntA++;
    else cntB++;
    
    cout << cntA << ' ' << cntB << endl;
  }

  return 0;
}