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 <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    cin.ignore();

    int a, b;

    for(;;){
        a = 0;
        b = 0;

        char c;
        for(;;){
            cin >> c;
            if(c == 'A')
                ++ a;
            else if(c == 'B')
                ++ b;
            else if(a > b)
                ++ a;
            else
                ++ b;

            if((a >= 11 || b >= 11) && abs(a-b) >= 2)
                break;
        }

        cout << a << ' ' << b << endl;
        if(c == '0')
            break;
    }
}

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

int main(){

	while(1){
		string str[3];
		int a[3] = {0}, b[3] = {0};

		cin>>str[0];
		if(str[0] == "0")
			break;

		cin>>str[1];
		cin>>str[2];

		for(int i=0;i<3;i++){
			for(int j=1;j<str[i].length();j++)
				if(str[i][j] == 'A')
					a[i]++;
				else if(str[i][j] == 'B')
					b[i]++;

			if(i != 2){
				if(str[i+1][0] == 'A')
					a[i]++;
				else if(str[i+1][0] == 'B')
					b[i]++;
			}else{
				if(a[i] > b[i])
					a[i]++;
				else
					b[i]++;
			}
		}

		for(int i=0;i<3;i++)
			cout<<a[i]<<" "<<b[i]<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	while(cin >> str, str != "0")
	{
		int size = str.size();
		int countA = 0;
		int countB = 0;
		for(int i = 1; i < size; ++i)
		{
			str[i] == 'A' ? countA++ : countB++;
		}
		countA > countB ? countA++ : countB++;
		cout << countA << " " << countB << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

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

C++: // 2011/06/30 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		string srv;
		cin >> srv;
		if(srv=="0")
			break;

		int pntA = 0;
		int pntB = 0;
		for(int i=1; i<srv.size(); i++)
			if(srv[i]=='A')
				pntA++;
			else
				pntB++;

		if(pntA>pntB)
			pntA++;
		else
			pntB++;

		cout << pntA << ' ' << pntB << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cstring>

using namespace std;

int main(){

char p[101];
cin>>p;
int a,b;
while(p[0]!=0&&p[1]!='\0'){
	a=0;
	b=0;
	for(int i=1;i<101;i++){
		if(p[i]=='A'){
			a++;
		}else if(p[i]=='B'){
			b++;
		}
	}
	if(p[0]=='A'){
		a++;
	}else if(p[0]=='B'){
		b++;
	}
	cout<<a<<' '<<b<<endl;
	for(int k=0;k<101;k++){
		p[k]='\0';
	}
	cin>>p;
}

	return 0;
}

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

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

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

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

C++: #include<cstdio>
#include<cstring>
using namespace std;
int main(){
	char str[1024];
	int cnt = -1;
	int a = 0,b = 0;
	while(scanf("%s",str),true){
		if(str[0] == '0'){
			if(a > b)a++;
			else b++;
			printf("%d %d",a,b);
			break;
		}
		if(++cnt % 3 != 0){
			(str[0] == 'A') ? a++ : b++;
			printf("%d %d\n",a,b);
			a = 0,b = 0;
		}
		else if(cnt != 0){
			printf("%d %d",a,b);
			a = 0,b = 0;
		}
		int len = strlen(str);
		for(int i = 1; i < len; i++){
			(str[i] == 'A') ? a++ : b++;
		}
	}
	return 0;
}

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

int main() {
  string str;
  while(cin >> str) {
    if(str == "0") break;
    int a = 0,b = 0;
    string s = str.substr(1);
    for(int i=0;i<s.size();i++) {
      if(s.substr(i,1) == "A") {
        a++;
      }
      else if(s.substr(i,1) == "B") {
        b++;
      }
    }
    if(a<b) {
      cout << a << " " << b+1 << endl;
      continue;
    }
    else {
      cout << a+1 << " " << b << endl;
      continue;
    }
  }
}

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

int main() {
	int a,b;
	string s;
	while(cin>>s,s!="0"){
		a=b=0;
		for(int i=0;i<s.size();i++){
			if(s[i]=='A')a++;
			if(s[i]=='B')b++;
		}
		if(a!=11||b!=11){
			if(a==10){a++;b--;}
			if(b==10){a--;b++;}
		}
		if(a==11&&b==11){
			if(s[s.size()]=='A'){a++;b--;}
			else{a--;b++;}
		}
		cout<<a<<" "<<b<<endl;
			
	}
	return 0;
}

C++: #include<iostream>
#include<string>

using namespace std;

int main(){
  int i, j, Awin[3], Bwin[3];
  string game;

  while(1){
    for(i=0; i<3; ++i){
      cin >> game;
      if(game == "0") break;

      Awin[i] = 0;
      Bwin[i] = 0;
      for(j=1; j<game.size(); ++j){
	if(game[j] == 'A')
	  ++Awin[i];
	else
	  ++Bwin[i];
      }
      if(game[game.size()-1] == 'A')
	++Awin[i];
      else
	++Bwin[i];
    }

    if(game == "0") break;
    for(i=0; i<3; ++i)
      cout << Awin[i] << " " << Bwin[i] << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

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

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

int main() {
  string record;
  int a_score, b_score;

  while(1) {
    a_score = 0;
    b_score = 0;
    cin >> record;
    if(record == "0") break; 
    
    for(int i = 1; i < 10; i++) {
      if(record[i] == 'A')
	a_score += 1;
      else
	b_score += 1;
    }
    for(int i = 10; i < record.length(); i++) {
      if(record[i] == 'A')
	a_score += 1;
      else
	b_score += 1;
      }
    if(a_score > b_score)
      cout << a_score+1 << ' ' << b_score << endl;
    else
      cout << a_score << ' ' << b_score+1 << endl;
  }
  return 0;
}