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<cstdio>
#include<cstring>

using namespace std;

char ch[110];

int A,B;

void solve()
{
	A=0,B=0;
	int N=strlen(ch);
	for(int i=1;i<N;i++)
	{
		if(ch[i]=='A') A++;
		else if(ch[i]=='B') B++;
	}
	if(A>B) A++;
	else B++;
}

int main()
{
	while(true)
	{
		scanf("%s",ch);
		if(ch[0]=='0') break;
		solve();
		printf("%d %d\n",A,B);
	}
	return 0;
}

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

int main(){
	char ta[1000];
	int a,b;

	while(true){
	for(int i=0;i<3;i++){
	cin>>ta;
	if(strcmp(ta,"0")==0)return 0;
	a=b=0;
		for(int j=1;ta[j]!='\0';j++){
		(ta[j]=='A')?a++:b++;
		}
		(a>b)?a++:b++;
		cout<<a<<" "<<b<<endl;
	}
	}


	return 0;
}

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

int main(){
  while(1){
    int h=0,b=0;
    string r,a;
    cin >> r >> a;
    if(r=="0"&&a=="0")
      break;
    for(int i=0;i<r.size();i++){
      for(int j=0;j<r.size();j++){
        if(r[i]==a[j])
          (i==j)?h++:b++;
      }
    }
    cout << h << " " << b << endl;
  }
  return 0;
}

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

int main()
{
	string s;
	while( cin >> s && s != "0" ){
		int point[ 'Z' ] = { 0 };
		for( int i = 1; i < (int)s.size(); ++i ){
			++point[ s[ i ] ];
		}
		point[ 'A' ] > point[ 'B' ] ? ++point[ 'A' ] : ++point[ 'B' ];
		cout << point[ 'A' ] << " " << point[ 'B' ] << endl;
	}

	return 0;
}

C++: #include<iostream>

char service[3][101];
int point[2];

void solve(int n){
	point[0]=0;
	point[1]=0;
	for(int i=1; service[n][i]!='\0'; i++){
		if(service[n][i]=='A')
			point[0]++;
		else
			point[1]++;
	}
	if(n==2){
		if(point[0]>point[1])
			point[0]++;
		else
			point[1]++;
	}
	else{
		if(service[n+1][0]=='A')
			point[0]++;
		else
			point[1]++;
	}
}

int main(){
	while(true){
		for(int i=0; i<3; i++){
			std::cin >> service[i];
			if(service[0][0] == '0')
				return 0;
		}
		for(int i=0; i<3; i++){
			solve(i);
			std::cout << point[0] << ' ' << point[1] << std::endl;
		}
	}
}

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

main(){
	while(true){
		char r[1000];

		cin>>r;

		// 入力の終わりはゼロひとつの行で示されます
		if( strcmp(r,"0") == 0 ){
			return 0;
		}

		cin>>(r+strlen(r));

		cin>>(r+strlen(r));

		int a=0, b=0;
		for(int i=1; r[i]!='\0'; ++i){

			if( r[i] == 'A'){
				a++;
			}else{
				b++;
			}

			if( (min(a,b)<10&&10<max(a,b)) || (10<=min(a,b) && 1<abs(a-b))){
				cout<<a<<" "<<b<<endl;
				a=0, b=0;
			}
		}
		
		(a>b?a:b)++;
		
		cout<<a<<" "<<b<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main() {

  while( 1 ) {
    string s[3];
    cin >> s[0];
    if( s[0] == "0" ) break;
    cin >> s[1] >> s[2];

    for(int i=0; i<3; i++) {
      int p[2] = {0};
      for(int j=1; j<s[i].size(); j++) {
	if( s[i][j] == 'A' ) p[0]++;
	else p[1]++;
      }
      if( p[0] > p[1] ) p[0]++;
      else p[1]++;
      cout << p[0] << ' ' << p[1] << endl;
    }
  }
}

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

int main()
{
  string s;
  int a, b;
  while(true)
  {
    for(int i = 0; i < 3; i++)
    {
      a = b = 0;
      cin >> s;
      if(s[0] == '0')
        break;

      for(int j = 1; j < s.length(); j++)
      {
        if(s[j] == 'A')
          a++;
        else
          b++;
      }
      if(a > b)
        a++;
      else
        b++;
      cout << a << " " << b << endl;
    }
  }
}

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

int main(void){
	string a;
	while(1)
	{
		cin>>a;
		if(a=="0")break;
		a[0]='z';
		string::iterator str = a.begin();
		int A=0,B=0;
		for( str = a.begin(); str != a.end(); ++str )
		{
			if( 'A' == *str ) ++A;
			if( 'B' == *str ) ++B; 
		}
		if(A<B) ++B;
		else ++A;
		cout<<A<<" "<<B<<endl;
		a.clear();
	}
	return 0;
}

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




main(){

  char ab[13][102];
  
  int i=0,j=0;
  int sumA[13],sumB[13], game=0;
  
  for(i=0;i<13;i++){
    sumA[i]=0;
    sumB[i]=0;
    
  }
  i=0;
  j=0;

  while(1){
    
    scanf("%c",&ab[i][j]);
    
    if( ab[i][j]== '0'){
      break;
    }
    
    //Ã£ÂÂÃ£ÂÂÃ£ÂÂÃ£ÂÂ¯Ã§ÂÂ¨
    // cout << ab[i][j] <<" "<< i <<" " <<j<< " "<< sumA[i]<< " " << sumB[i]<< endl;
     //cout << game <<  " " << i<< endl;
    
    if(ab[i][j]=='A' && j!=0)sumA[i]++;
    if(ab[i][j]=='B' && j!=0)sumB[i]++;
    
    j++;
    
    
    
    if(ab[i][j-1]== '\n' || ab[i][j-1]=='\0'){
      i++;
      j=0;
      game++;
      //cout << "OK";
    }
    
    
    /*
    if(ab[i][j-1] != 'A' && ab[i][j-1]!= 'B'){
      i++;
      j=0;
      game++;
    }
    */
  }
  
  
  for(i=0;i<game;i++){

    //AÃ£ÂÂBÃ£ÂÂÃ£ÂÂÃ£ÂÂ§Ã£ÂÂÃ£ÂÂÃ¦ÂÂ
    if(sumA[i]>sumB[i]){
      if(sumB[i]>=10){
	sumA[i] = sumB[i]+2;
      }
      if(sumB[i]<10){
	sumA[i] += 11 - sumA[i];
      }
    }
    
    //BÃ¯Â¼ÂAÃ£ÂÂ®Ã¦ÂÂ
    if(sumB[i]>sumA[i]){
      if(sumA[i]>=10){
	sumB[i] = sumA[i]+2;
      }
      if(sumA[i]<10){
	sumB[i] += 11 - sumB[i];
      }
    }
    
  }
  
  for(i=0;i<game;i++){
    
    cout << sumA[i]<< " " << sumB[i]<< endl;

  }
  


  return 0;

}

C++: #include<stdio.h>
#include<string.h>
int main(void)
{
	int x,X,i;
	char c[1001];
	while(1){
		scanf("%s",c);
		if(c[0]=='0') break;
		X=0; x=0;
		for(i=1;i<strlen(c);i++){
			if(c[i]=='A'){
				x++;
			}
			else{
				X++;
			}
		}
		if(x<X){
			X++;
		}
		else{
			x++;
		}
		printf("%d %d\n",x,X);
	}
	return 0;
}