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>

int main(){
	std::ios::sync_with_stdio(false);
    while(true){
		int n, a_score = 0, b_score = 0;
		std::cin >> n;
		
		if(n == 0)
			break;

		for(int i = 0; i < n; ++i){
			int a, b;
			std::cin >> a >> b;
			if(a > b)
				a_score += a + b;
			else if(a < b)
				b_score += a + b;
			else
				a_score += a, b_score += b;
		}

		std::cout << a_score << " " << b_score << std::endl;
    }
    return 0;
}

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

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

	cin >> n;

	while (n != 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;

		cin >> n;

	}
}

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

int main()
{
	int a;
	int r, l;
	int rsum, lsum;
	rsum = 0;
	lsum = 0;
	while (cin >> a && (a != 0)){
		
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << rsum << ' ' << lsum << endl;
	} 
	cout << "end";
}

C++: #include<stdio.h>

int main(){

int N;int A,B,SA=0,SB=0;
while(1){
SA=0,SB=0;

scanf("%d",&N);
if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d",&A,&B);
if(A>B)SA+=A+B;
else if(B>A)SB+=A+B;
}

printf("%d %d\n",SA,SB);
}
return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main () {
    while(cin >> n) {
       if(n == 0) { break; }
       for (i=1; i<=n; i++) {
           cin >> pA >>pB;
           if (pA >pB) {
               tA += pA + pB;
           } else {
               if (pA <pB) {
                   tB += pA + pB;
               } else {
                   tA += pA;
                   tB +- pB;
               }
           }
       }
       cout << tA << " " << tB << endl;
       tA = 0; tB = 0;
     }
     return 0;
}

C++: #include<iostream>
int score_a,score_b;
int main(void)
{
using namespace std;
int n,data_a,data_b;
while(1)
{
cin>>n;
if(!n)break;
score_a=0;
score_b=0;
for(;n>0;n--){
cin>>data_a;
cin>>data_b;
if(data_a>data_b){
score_a+=(data_a+data_b);
}else if(data_a<data_b){
score_b+=(data_a+data_b);
}else{
score_a+=data_a;
score_b+=data_b;
}
}
cout<<score_a<<" "<<score_b<<endl;
}
return 0;
}

C++: #include<iostream>
using namespace std;
 
int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
             cin >> A >> B;
             (A > B)? resa +=(A+B):resb+=(A+B);
             if(A==B) {resa += (A+B); resb +=(A+B);};
        }
    cout << resa << " " << resb << endl;
    }
}

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

int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;
	int i;
	while (true){
		cin >> a;
		if (a == 0){ break; }
		else{
			while (true){
				if (i<a){
					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;
					}
					i++;
				}if (i == a){ break; }
			}
			cout << uma << " " << ushi << endl;
			uma = 0;
			ushi = 0;
			i = 0;
		}
	}
}

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

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

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

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
Int Ap, Bp;

int main()
{
	int n;
	int a, b;
	
	while (cin >> n, n){
		REP(i, n){
			cin >> a >> b;
			if (a > b){
				Ap += a;
				Ap += b;
			}
			else if (a < b){
				Bp += a;
				Bp += b;
			}
			else{
				Ap += a;
				Bp += b;
			}
		}

		cout << Ap << " " << Bp << endl;
	}
	return 0;

}

C++: #include<vector>
#include<algorithm>
#include<string>

int main(){

  std::vector<std::pair<int,int> > data;

  char buf[100];
  int n;

  std::cin >> buf;
  n = atoi(buf);

  char a[100];
  char b[100];

  for (int i=0; i<n ; i++){
    std::cin >> a;
    std::cin >> b;
    data.push_back(std::pair<int,int>(atoi(a),atoi(b)));
  }

  int you = 0;
  int opp = 0;

  for (std::vector<std::pair<int,int> >::iterator it = data.begin(); it != data.end(); it++){
    int yv = (*it).first;
    int ov = (*it).second;
    if (yv > ov ){
      you += yv+ov;
    }else if (yv < ov){
      opp += yv+ov;
    }else{
      you += yv;
      opp += ov;
    }
  }

  std::cout << you << " " << opp << std::endl;

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n=1;
int a,b,pa,pb;
for(;n!=0;){
cin>>n;
if(n==0){break;}
pa=0;pb=0;
for(int i=0;i<n;i++){
a=0;b=0;
cin>>a;
cin>>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<iostream>
#include<string>
#include<cmath>
using namespace std;

int main(){
  int n,a=0,b=0;
  for(;;){
  cin>>n;
  if(n==0)break;
  
  int A[n],B[n];
  for(int i=0;i<n;i++){
    cin>>A[i]>>B[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
    while(0==0){
    int n;
    cin >> n;
    if(n==0) break;
    int pointA=0,pointB=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        if(a<b){
            pointB += a+b;
        }
        if(a>b){
            pointA += a+b;
        }
        else{
            pointA += a;
            pointB += a;
        }
    }
    cout << pointA <<  " " << pointB << endl;
    }
}

C++: #include <iostream>

using namespace std;
int main()
{
    while(true) {
        int loop;
        cin >> loop;
        int p1=0,p2=0;
        if(loop==0)break;
        while(loop--)
        {
            int a,b;
            cin >> a >> b ;
            if(a > b) {
                p1 = p1 + a + b;
            }else if(a==b) {
                p1 += a;
                p2 += b;
            }
            else {
                p2 = p2 + a + b;
            }
        }
        cout << p1 << " " << p2 << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int c1,c2,p1 = 0,p2 = 0;
  scanf("%d",&n);
  
  while(n--){
    scanf("%d %d",&c1,&c2);
    if(c1 > c2)p1 += c1+c2;
    else if(c1 < c2)p2 += c1+c2;
    else{
      p1 += c1;
      p2 += c2;
    }
  }
  printf("%d %d\n",p1,p2);
}