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>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define ROUNDED(N) fixed << setprecision(N)
#define SPACE " "

typedef long long ll;
using namespace std;

int nextInt() { int n; cin >> n; return n; }
double nextDouble() { double d; cin >> d; return d; }
string nextString() { string str; cin >> str; return str; }

int main() {
	cin.tie(0); //対話型には使えない
	ios::sync_with_stdio(false); //printfと共には使えない
	while (true) {
		int n = nextInt();
		if (!n) break;
		int a_sum = 0, b_sum = 0;
		for (int i = 0; i < n; i++) {
			int a = nextInt(), b = nextInt();
			if (a > b) a_sum += a + b;
			else if (a == b) a_sum += a, b_sum += b;
			else b_sum += a + b;
		}
		cout << a_sum << SPACE << b_sum << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	string str;
	getline(cin,str);
	int scoreA = 0, scoreB = 0;
	while(getline(cin,str)){
		stringstream ss(str);
		string tmp;
		getline(ss,tmp,' ');
		int a = atoi(tmp.c_str());
		getline(ss,tmp);
		int b = atoi(tmp.c_str());
		if(a>b)scoreA+=(a+b);
		else scoreB+=(a+b);
	}
	cout<<scoreA<<" "<<scoreB<<endl;
	return 0;
}

C++: #include <cstdio>
using namespace std;
int main()
{
	int a=0,b=0,n,x,y;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		if(x>y) a+=x+y;
		else if(x<y) b+=x+y;
		else{
			a+=x;
			b+=y;
		}
	}
	printf("%d %d\n",a,b);
}

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

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

int main(void){
  int a,b;
  int n;
  while(cin>>n,n){

    a = b = 0;
  while(n--){
    int c,d;
    cin>>c>>d;
    if(c>d)
      a += c + d;
    else
      b += c + d; 
  }
  cout<< a << " " << b << endl;
  }
}

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

int main(void){
    int n,ascore,bscore;
    while(true){
        cin >> n;
        if(n==0) break;
        ascore = 0;
        bscore = 0;
        int a[n],b[n];
        for(int i=0;i<n;i++){
            cin >> a[i] >> b[i];
            if(a[i]>b[i]) ascore += (a[i]+b[i]);
            else if(a[i]<b[i]) bscore += (a[i]+b[i]);
            else {
                ascore += a[i];
                bscore += b[i];
            }
        }
        cout << ascore << " " << bscore << endl;
    }
    return 0;
}

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

C++: #include <iostream>
using namespace std;
 
int main() {
  int n, a, b, pointA, pointB;

  cin >> n;
  while(n != 0) {
    

    pointA = 0;
    pointB = 0;

    for(int i = 0; i < n; i++) {
      cin >> a >> b;
 
      if(a > b) {
        pointA += (a + b);
      } else if(a < b) {
        pointB += (a + b);
      } else {
        pointA += a;
        pointB += b;
      }
    }

    cout << a << ' ' << b << endl;
    cin >> n;
  }   
 
  return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void){
int n,a,b,a1,b1;
while(1){
scanf("%d",&n);
a1=0;
b1=0;
if(n==0){break;}
for(int i=0;i<n;i++){
scanf("%d%d",&a,&b);
if(a>b){
a1=a+b;
}else if(b>a){
b1=a+b;
}else{
a1+=a;
b1+=b;
}
}
printf("%d %d\n",a1,b1);
}
return 0;
}

C++: #include<stdio.h>
void judge(int n, int a[], int b[], int *result1, int *result2) {
	while (--n >= 0) {
		if (a[n] > b[n]) {
			*result1 += a[n] + b[n];
		}
		else if (a[n] < b[n]) {
			*result2 += a[n] + b[n];
		}
		else if (a[n] == b[n]) {
			*result1 += a[n];
			* result2 += b[n];
		}
	}
}
int main() {
	int a[10];
	int b[10];
	int n, t = 0;
int i;
	int result1 = 0, result2 = 0;
	int result[10][2];
	do {
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%d %d", &a[i], &b[i]);
		}
		judge(n, a, b, &result1, &result2);
		result[t][0] = result1;
		result[t][1] = result2;
		result1 = 0;
		result2 = 0;
		t++;
	} while (n != 0);

	for (i = 0; i < t-1;i++) {
		printf("%d %d\n", result[i][0], result[i][1]);
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

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

	cin >> n;
	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 <stdio.h>

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

C++: #include <iostream>
using namespace std;
int main(void)
{
	int a,b,c,d;
	int e=0;
	int f=0;
	cin>>a;
	for (b=0;b<a;b++)
	{
		cin>>c>>d;
		if (c>d)
		{
			e=e+c+d;
		}
		else if (c<d)
		{
			f=f+d+c;
		}
		else if (c==d)
		{
			e=e+c+d;
			f=f+d+c;
		}
	}
	cout<<e<<" "<<f<<endl;
	return 0;
}

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

int main(){
  int n;
  int Acard,Bcard;
  int Atotal,Btotal;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>Acard>>Bcard;
    if(Acard>Bcard){
      Atotal+=Acard+Bcard;
    }else if(Bcard>Acard){
      Btotal+=Acard+Bcard;
    }else{
      Atotal+=Acard;
      Btotal+=Bcard;
    }
  }

  cout<<Atotal<<' '<<Btotal<<'\n';
  return 0;
}