Go: package main

import "fmt"

func main() {
	for {
		var a, b, n int
		fmt.Scanf("%d", &n)

		if n == 0 {
			return
		}

		for i := 0; i < n; i++ {
			var cardA, cardB int
			fmt.Scanf("%d %d", &cardA, &cardB)

			if cardA > cardB {
				a += cardA + cardB
			} else if cardB > cardA {
				b += cardA + cardB
			} else {
				a += cardA
				b += cardB
			}
		}

		fmt.Println(a, b)
	}
}

C++: #include <stdio.h>
int main(void)
{
	int a[100], i, j, m, n, b[100], A = 0, B = 0;
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		for (i = 0; i < n; i++) {
			scanf("%d %d", &a[i], &b[i]);
		}
		for (i = 0; i < n; i++) {
			if (a[i] > b[i]) {
				A = A + a[i] + b[i];
			}
			else if (a[i] == b[i]) {
				A = A + a[i];
				B = B + b[i];
			}
			else {
				B = B + a[i] + b[i];
			}
		}
		printf("%d %d \n", A, B);
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>
using namespace std;
int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int a=0,b=0;
		int x,y;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			if(x>y)a+=x+y;
			if(x==y)a+=x,b+=y;
			if(x<y)b+=x+y;
			
		}
		
		cout<<a<<" "<<b<<endl;
		
	}
	
	return 0;
	
}

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

int main(){
	int n, a, b, at, bt;
	
loop:
	scanf("%d\n", &n);		// 各人のカード枚数
	if(n == 0) goto end_scope;
	at = 0;
	bt = 0;
	
labl_testloop:
	scanf("%d %d\n", a, b);
	if(a > b) at += a + b; else if(a == b){at += a; bt += b;}else bt += a + b;
	n--;
	if(n > 0) goto labl_testloop;
	
	printf("%d %d\n", at, bt);
	goto loop;
end_scope:
    return 0;
}

C++: #include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, a, b;
    while (cin >> n && n) {
        int apt = 0, bpt = 0;
        rep(i, n) {
            cin >> a >> b;
            if (a > b) {
                apt += a + b;
            }
            else if (a < b) {
                bpt += a + b;
            }
            else {
                apt += a;
                bpt += b;
            }
        }
        cout << apt << " " << bpt << endl;
    }
    return 0;
}

C++: #include <stdio.h>

void main() {
	int n, a, b;
	int suma = 0;
	int sumb = 0;
	bool endflg = false;
	while (1) {
		scanf_s("%d", &n);
		if (n == 0) {
			return;
		}
		int i;
		for (i = n; i > 0; i--) {
			scanf_s("%d %d", &a, &b);
			if (a > b) {
				suma = suma + a + b;
			}
			else if (b > a) {
				sumb = sumb + a + b;
			}
			else {
				suma = suma + a;
				sumb = sumb + b;
			}
		}
		printf("%d %d\n", suma, sumb);
		suma = 0;
		sumb = 0;
	}
	
}

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

using namespace std;

class Player
{	friend class Batler;
	vector<int> card;
	long long int point;
public:
	Player():point(0){}
};
class Batler
{
	Player *p1, *p2;
public:
	Batler(Player *P1, Player *P2):p1(P1),p2(P2){}

	void init();
	void input();
	void start();
};
void Batler::init()
{
	if(!p1->card.empty()){
		p1->card.clear();
		p2->card.clear();
	}
	p1->point = 0;
	p2->point = 0;
}
void Batler::input()
{
	int buf;
	cin>>buf;
	p1->card.push_back(buf);
	cin>>buf;
	p2->card.push_back(buf);
}
void Batler::start()
{
	for(unsigned int i = 0; i < p1->card.size(); i++){
		if( p1->card[i] > p2->card[i]){
			p1->point += p1->card[i] + p2->card[i];
		}else if( p1->card[i] < p2->card[i] ){
			p2->point += p1->card[i] + p2->card[i];
		}else{
			p1->point += p1->card[i];
			p2->point += p2->card[i];
		}
	}
	cout<<p1->point<<" "<<p2->point<<endl;
}
int main()
{
	int n;
	Player p1, p2;
	Batler batle(&p1,&p2);

	while(1){
		batle.init();
		cin>>n;
		if(n == 0) return 0;

		//üÍ
		for(int i = 0; i < n; i++){
			batle.input();
		}
		//ð
		batle.start();
	}
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,a,b,ap,bp,i;
  while(1){
    cin >> n;
    if(n==0) break;
    ap=bp=0;
    for(i=0;i<n;i++){
      cin >> a >> b;
      if(a>b) ap+=a+b;
      else if(b>a) bp+=a+b;
      else ap+=a,bp+=b;
    }
    cout << ap << ' ' << bp << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
int main() {
	int i = 0;
	std::cin >> i;
	int A = 0, B = 0;
	std::vector<int> a{ 100000 }, b{ 100000 };
	for (int j = 0; j < i; ++j) {
		std::cin >> a[j] >> b[j];
	}
	for (int j = 0; j < i; ++j) {
		if (a[j] > b[j]) {
			A += (a[j] + b[j]);
		}
		else if (a[j] < b[j]) {
			B += (a[j] + b[j]);
		}
		else {
			A += a[j];
			B += b[j];
		}
	}
	std::cout << A << " " << B << std::endl;
}

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

int main(void)
{
    int n;
    int ans1, ans2;
    while(1) {
        scanf("%d", &n);
        if(n == 0) break;
        ans1 = ans2 = 0;
        for(int i=0; i<n; i++) {
            int a, b;
            scanf("%d %d", &a, &b);
            if(a > b) {
                ans1 += a + b;
            } else if(a < b) {
                ans2 += a + b;
            } else {
                ans1 += a;
                ans2 += a;
            }
        }
        printf("%d %d\n", ans1, ans2);
    }
    return 0;
}

C++: #include <stdio.h>

int i;
int a, b;
int n;

int main() {
    while (1) { 
        a = 0;
        b = 0;

        scanf("%d", &n);
        if (n == 0) return 0;

        for (i=0; i<n; i++) {
            int l, r;
    
            scanf("%d %d", &l, &r);
            if (l > r) {
                a += l + r;
            } else if (l < r) {
                b += l + r;
            } else {
                a += l;
                b += r;
            }
        }
    
        printf("%d %d\n", a, b);
   }
}

C++: #include <iostream>
using namespace std;
       
int main()
{
  while(1){ 
  int i, n, x, y;
  cin >>n;
     
  if(n==0){break;}
  else
  {
  x=0; 
  y=0;
       
  int a[n], b[n];
         
  for(i=1;i<=n;i++)
  {
    cin >>a[i]>>b[i];
    if(a[i]>b[i])
    {
      x += a[i]+b[i];
    }
    else if(a[i]<b[i])
    {
      y += a[i]+b[i];
    }
    else
    {
      x += a[i];
      y += b[i];
    }
   } cout <<x<<" "<<y<<"\n";
  }}
       
      
       
  return 0;
}

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

int main()
{
 int a,b,n,x=0,y=0;
 cin>>n;
 while(n--)
 {
   cin>>a>>b;
   if(a<b) {y+=a+b;}
   else if(a>b) {x+=a+b;}
   else {x+=a; y+=b;}
  }
 cout<<x<<" "<<b<<endl;
 return 0;
}

C++: #include<iostream>
using namespace std;
 
int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;

	while (true){
		cin >> a;
		if (a == 0){ break; }
		else{
			for (int i; i < a; i++){
				cin >> b;
				cin >> c;
				if (b>c){
					uma = uma + b + c;
				}
				if (b == c){
					uma = uma + b;
					ushi = ushi + c;
				}
				else{
					ushi = ushi + b + c;
				}
			}
		}
		cout << uma << " " << ushi;
	}
}

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

int main()
{
	int n;
	int a[10000];
	int b[10000];
	while (cin >> n, n)
	{
		for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
		int A = 0;
		int B = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i] > b[i])
			{
				A += a[i] + b[i];
			}
			else if (a[i] < b[i])
			{
				B += a[i] + b[i];
			}
			else
			{
				A += a[i];
				B += b[i];
			}
		}
		cout << A << ' ' << B << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){

	int n, a, b, ap = 0, bp = 0, i;

	cin >> n;
	for (i = 0; i < n; i++){
		cin >> a >> b;

		//?????°?????´??°
		if (a > b)
			ap += a + b;
		else if (a < b)
			bp += a + b;
		else{
			ap += a;
			bp += b;
		}
	}

	cout << ap << ' ' << bp << endl;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int n,a,b,asum,bsum;

int main(){
	while(1){
		cin>>n;
		if( n == 0 ) break;
		for(int i=0;i<n;i++){
			cin >> a >> b ;
			if( a > b ){
				asum+=(a+b);
			}else if( a == b ){
				asum+=a;
				bsum+=b;
			}else{
				bsum+=(a+b);
			}
		}
		cout<<asum<<" "<<bsum<<endl;
		asum=0;bsum=0;
	}
	return 0;
}