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 <iostream>
using namespace std;
int main()
{
	int n, a, b, pa, pb, i;

	while (cin >> n && n)
	{
		for (i = 0, pa = pb = 0; i < n; i++)
		{
			cin >> a >> b;
			if (a > b)	pa += a + b;
			if (a == b)	pa += a, pb += b;
			if (a < b)	pb += a + b;
		}
		cout << pa << " " << pb << endl;
	}
	return 0;
}

C++: #include<cstdio>
int main(){
    int ai,bi,as=0,bs=0,n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",ai,bi);
        if(ai>bi) as+=ai+bi;
        else if(ai<bi) bs+=ai+bi;
        else{
            as+=ai;
            bs+=bi;
        }
    }
    printf("%d %d\n",as,bs);
}

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

using namespace std;

int main() {

	int n, a=0, b=0, c, d;

	cin >> n;
	while(n!=0) {
		cin >> c >> d;
		if(c>d)
			a+=c+d;
		else if(c<d)
			b+=c+d;
		else {
			a+=c;
			b+=d;
		}

		n--;
	}

	cout << a << " " << b << endl;

	return 0;

}

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

int main(){
	int z;
	int a=0;
	int b=0;
	while(1){
		std::cin>>z;
		if(z==0)break;
		std::vector<int> vec1(z);
		std::vector<int> vec2(z);
		for(int i=0;i<z;i++){
			std::cin>>vec1[i];
			std::cin>>vec2[i];
		}
		for(int i=0;i<z;i++){
			if(vec1[i]>vec2[i])a=a+vec1[i]+vec2[i];
			if(vec2[i]>vec1[i])b=b+vec1[i]+vec2[i];
			if(vec1[i]==vec2[i]){
				a=a+vec1[i];
				b=b+vec2[i];
			}
		}
		std::cout<<a<<" "<<b<<std::endl;
		a=0;
		b=0;
	}
	
	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	int N; cin >> N;
	int as=0, bs=0;
	for (int i = 0; i < N; ++i) {
		int a, b; cin >> a >> b;
		if (a > b) {
			as += a + b;

		}
		else if (b > a) {
			bs += a + b;
		}
		else {
			as += a;
			bs += b;
		}

	}
	cout << as <<" "<< bs << endl;
	return 0;
}

C++: #include <stdio.h>
 
int main(){
int n,a=0,b=0;
scanf("%d",&n);
while(n){
int aa,bb;
for(int i=n;i>0;i--){
scanf("%d %d",&aa,&bb);
if(aa>bb){
a+=aa+bb;
}else if(aa<bb){
b+=aa+bb;
}else{
a+=aa;
b+=bb:
}
}
scand("%d",&n);
}
}

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

int main()
{
    int n;
    int A;
    int B;
    int sum_A = 0;
    int sum_B = 0;

    while (n != 0){
        cin >> n;
        
        for (int i = 0; i < n; i++){
            cin >> A;
            cin >> B;
            
            if (A > B){
                sum_A += A + B;
            }
            else {
                sum_B += A + B;
            }
        }
        cout << sum_A << " " << sum_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>

using namespace std;

int main(){
	int n,a,b,pa = 0,pb = 0;

	cin >> n;
	if(n != 0){
		for(; n > 0; n--){
			cin >> a;
			cin >> b;

			if(a > b){
				pa += a + b;
			}else if(a < b){
				pb += a + b;
			}else{
				pa += a;
				pb += b;
			}
		}

		cout << pa << " " << pb << endl;
	}

	return 0;
}

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

class game{
	int length;
	int cur;
	int *r,*l;
	int r_score,l_score;
public:
	game(int _l){
		length = _l;
		r = new int [length];
		l = new int [length];
		r_score = 0;
		l_score = 0;
		cur = 0;
	}
	~game(){
		delete [] r;
		delete [] l;
	}
	void run();
	void insert(int,int);
};

void game::run(){
	for(int i = 0;i < length;i++){
		if(r[i] < l[i]){
			l_score += r[i] + l[i];
		}else if(r[i] > l[i]){
			r_score += r[i] + l[i];
		}else{
			l_score += l[i];
			r_score += r[i];
		}
	}
	cout<<l_score<<" "<<r_score<<endl;
}

void game::insert(int l_card,int r_card){
	r[cur] = r_card;
	l[cur] = l_card;
	cur++;
}

int main(){
	list<game*> lst;
	while(1){
		int read;
		cin>>read;
		if(read == 0){
			break;
		}
		game *g = new game(read);
		for(int i = 0; i < read;i++){
			int r_card,l_card;
			cin>>l_card>>r_card;
			//cout<<l_card<<","<<r_card<<endl;
			g->insert(l_card,r_card);
		}
		lst.push_back(g);
	}

	for(auto it = lst.begin();it != lst.end();it++){
		(*it)->run();
		delete (*it);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int N,suma=0,sumb=0;
    cin >> N;
    while(N--){
        cin >> x >> y;
        if(x>y) suma=suma+x+y;
        else    sumb=sumb+x+y;
    }
    cout << suma << " " << sumb << "\n";
    return 0;
}

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

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

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

int main()
{
	int n;
	while(cin>>n){
		if(n==0) break;
		int p1=0,p2=0;
		for(int i=0;i<n;i++){
			int t1,t2;
			cin>>t1>>t2;
			if(t1==t2){
				p1+=t1;
				p2+=t2;
			}
			else if(t1>t2)
				p1+=t1+t2;
			else p2+=t1+t2;
		}
		cout<<p1<<" "<<p2<<endl;
	}
	return 0;
}

C++: #include <cstdio>
int main(){
  int n;
  int data[2],sum[2]={0,0};

  for(;;){
    scanf("%d",&n);
    if(n==0)
       break;
    for(int i=0;i<n;i++){
      scanf("%d%d",&data[0],&data[1]);
      if(data[0]>data[1])
	sum[0]+=data[0]+data[1];
      else if(data[0]<data[1])
	sum[1]+=data[0]+data[1];
      else{
	sum[0]+=data[0];
	sum[1]+=data[1];
      }
    }
    printf("%d %d\n",sum[0],sum[1]);
    sum[0]=0;
    sum[1]=0;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
main(){
	int n;
	while(cin>>n,n){
		int data[2];
		int ans[2]={0,0};
		for(int i=0;i<n;++i){
			cin>>data[0]>>data[1];
			if(data[0]>data[1]){
				ans[0]+=data[0]+data[1];
			}else if(data[0]<data[1]){
				ans[1]+=data[0]+data[1];
			}else if(data[0]==data[1]){
				ans[0]+=data[0];
				ans[1]+=data[1];
			}
		}
		cout<<ans[0]<<" "<<ans[1]<<endl;
	}
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cmath>
#include <string>

using namespace std;





int main()
{
	int n;
	int a, b;
	int A, B;
	
	while (1)
	{
		cin >> n;
		if (n == 0) break;
		
		A = 0;
		B = 0;
		
		for (int i=0; i<n; i++)
		{
			cin >> a >> b;
			
			//cout << "a = " << a << " : b = " << b << "\n";
			
			if (a > b)
			{
				A += a + b;
			} else if (a < b) {
				B += a + b;
			} else if (a == b) {
				A += a;
				B += b;
			}
		}
		
		cout << A << " " << B << "\n";
	}
	
	
}

C++: #include <iostream>
using namespace std;
int main(){
    int n, scoreA, scoreB;
    while(cin >> n, n != 0){
        scoreA = 0; scoreB = 0;
        int a,b;
        for (int i = 0; i < n; i++){
            cin >> a >> b;
            if (a > b){
                scoreA += (a+b);
            }else if (b > a){
                scoreB += (a+b);
            }else{
                scoreA += a; scoreB += b;
            }
        }
        cout << scoreA << " " << scoreB << endl;
    }
}