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 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<<" "<<y<<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 <iostream>
using namespace std;

int main(void) {
	int a = 0, b = 0;
	int count = 0;
	cin >> count;
	while ( count != 0) {
		int sumA = 0, sumB = 0;
		for (int i = 0; i < count; i++) {
			cin >> a >> b;
			if (a > b) sumA += a + b;
			else if (a < b) sumB += a + b;
			else {
				sumA += a;
				sumB += b;
			}
		}
		cout << sumA << " " << sumB << endl;
		cin >> count;
	}
	return 0;
}

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

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

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

int main(void) {
	int a=0,b=0,n=1;
	vector<string> r;
	while (n!=0)
	{
	long ra = 0,rb = 0;
	cin >> n;
	if (n == 0){break;}
	for (int i=0; i<n; i++)
	{
		scanf("%d %d",&a,&b);
		if (a>b)
		{
			ra+=a+b;
		} else if(a<b)
		{
			rb+=a+b;
		} else {
			ra+=a;
			rb+=b;
		}
	}
	ostringstream os;
	os << ra << " " << rb;
	r.push_back(os.str());
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){int n,a,b,c,d;for(;cin>>n,n;cout<<c<<' '<<d<<endl)for(c=d=0;n--;){cin>>a>>b;(a>=b?c:d)+=a;(b>=a?d:c)+=b;}}

C++: #include<iostream>
using namespace std;
int main(){
int n;
int a,b,ap,bp;
while(cin>>n&&n){
ap=0;
bp=0;
	for(int 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;
}

return 0;
}

C++: #include<stdio.h>

int main(){
	int i=0,w=0,x,a[10000],b[10000],aP[100],bP[100];
	while(i<10000){
		aP[i]=bP[i]=0;
	++i;
	}
	i=0;
	while(1){
	scanf("%d",&x);
	if(x==0){
	goto hata;
	}
	while(i<x){
scanf("%d%d",&a[i],&b[i]);
	++i;
	}
	i=0;
	while(i<x){
		if(a[i]==b[i]){
			aP[w]=aP[w]+a[i];
			bP[w]=bP[w]+b[i];
		}else if(a[i]>b[i]){
		aP[w]=aP[w]+a[i]+b[i];
		}else{
		bP[w]=bP[w]+a[i]+b[i];
		}
		++i;
	}
	++w;
	}
hata:
	i=0;
	while(i<w){
	printf("%d %d\n",aP[w],bP[w]);
	}
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int num;
    while(1){
        a_score=0;b_score=0;
        scanf( "%d", &num );
        if(num==0)break;
        for(int i=0;i<num;i++){
            int a_card,b_card;
            scanf("%d %d",&a_card,&b_card);
            if(a_card>b_card){a_score+=a_card+b_card;}
            else if(a_card==b_card){a_score+=a_card;b_score+=b_card;}
            else b_score+=a_card+b_card;
        } 
        cout<<a_score<<" "<<b_score<<endl;
    }
    
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll n, a, b, suma = 0, sumb = 0;

int main(){
	cin >> n;
	REP(i, n){
		cin >> a >> b;
		if (a > b){
			suma += a + b;
		}
		else if (a < b){
			sumb += a + b;
		}
		else {
			sumb += b;
			suma += a;
		}
	}
	cout << suma << " " << sumb << endl;
}

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

using namespace std;


int main() {
	int n, ka, kb;
	int a, b;
	vector<pair<int, int>> dst;
	while (cin >> n && n != 0) {
		a = b = 0;
		while (n-->0 && cin >> ka >> kb) {
			if (ka > kb)
				a += (ka + kb);
			else if (ka < kb)
				b += (ka + kb);
			else {
				a += ka;
				b += kb;
			}
		}
		dst.push_back(pair<int, int>(a, b));
	}
	for (vector<pair<int, int>>::iterator it = dst.begin(); it < dst.end(); it++)
		cout << (*it).first << " " << (*it).second << endl;
	return 0;
}

C++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0500
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (true) {
		int n; cin >> n;
		if (!n) break;
		int ans[2] = { 0 };
		for (int i = 0; i < n;i++) {
			int a, b; cin >> a >> b;
			if (a == b) { ans[0] += a, ans[1] += b; continue; }
			ans[a < b] += (a + b);
		}
		cout << ans[0] << " " << ans[1] << endl;
	}
}

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

using namespace std;

int n,a,b,asum,bsum;

int main(){
	while(TRUE){
		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;
}

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

int main(void) {
	int n;

	while (1) {
		cin >> n;
		if (n == 0) break;

		int sumA = 0, sumB = 0;
		int pointA, pointB;
		for (int i = 0; i < n; i++){

			cin >> pointA >> pointB;
			if (pointA > pointB) {
				sumA += (pointA + pointB);
			} else if (pointB > pointA) {
				sumB += (pointA + pointB);
			} else {
				sumA += pointA;
				sumB += pointA;
			}
		}
		cout << sumA << " " << sumB << endl;
	}

	return 0;
}

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