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 = 0;
	int p[10][2];
	int a = 0;
	int b = 0;
	cin >> n;
	while(0){
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 2; j++){
				cin >> p[i][j];
			}
			if (p[i][0] == p[i][1]){
				a = a + p[i][0];
				b = b + p[i][1];
			}
			else if (p[i][0] < p[i][1]){
				b = b + p[i][0] + p[i][1];
			}
			else if (p[i][0] > p[i][1]){
				a = a + p[i][0] + p[i][1];
			}
		}
		cout << a << " " << b << endl;
		return 0;
	}
	}

C++: #include <stdio.h>


int main(void)
{

	int n;
	int a=0,b=0;
	int ac,bc;

	scanf("%d", &n);

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


	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,x=0,y=0;
  while(n!=0){
    cin>>n;
    if(n==0)continue;
    rep(i,n){
      cin>>a>>b;
      if(a==b){
	x+=a;
	y+=b;
      }else if(a>b)x+=(a+b);
      else if(a<b)y+=(a+b);
    }
    cout<<x<<" "<<y<<endl;
    x=0;
    y=0;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
int main() {
	int i = 0;
	std::cin >> i;
	std::vector <int> ha,hb;
	if (i != 0) {
		int A = 0, B = 0;
		std::vector<int> a(10000), b(10000);
		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];
			}
		}
		ha.push_back(A);
		hb.push_back(B);
	}
	for (int j = 0; j < i; ++j) {
		std::cout << ha[j] << " " << hb[j] << std::endl;
	}
}

C++: #include<bits\stdc++.h>
using namespace std;
int main(void){
	int n,asum,bsum,a,b,i;
	while(1){
		cin>>n;
		if(n==0)break;
		asum=0; bsum=0;
		for(i=0;i<n;i++){
			cin>>a>>b;
			if(a==b)asum+=a,bsum+=b;
			if(a>b)asum+=a+b;
			if(b>a)bsum+=a+b;
		}
		cout<<asum<<' '<<bsum;
	}
	return 0;
}

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


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

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

}

C++: #include <iostream>

int main(){
    int n, a[10], b[10], apt, bpt;
    while(1){
        std::cin >> n;
        if(!n)
            return 0;
        apt = bpt = 0;
        for(int i=0; i<n; i++){
            std::cin >> a[i] >> b[i];
            if(a[i] > b[i])
                apt += a[i] + b[i];
            else if(b[i] > a[i])
                bpt += a[i] + b[i];
            else{
                apt += a[i];
                bpt += b[i];
            }
        }
        std::cout << apt << ' ' << bpt << std::endl;
    }
    return 0;
}

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

int main()
{

	int n;
	int a=0,=0;
	int ac,bc;

	cin >> n;

	while(n > 0){
		n--;
		cin >> ac >> bc;
		if(ac > bc)
			a += ac + bc;
		else if(ac < bc)
			b += ac + bc;
		else
			a += ac, b = bc;
	}
	printf("%d %d\n", a,b);


	return 0;
}

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

int main(){
	int i,n,a,b;
	long apoint=0,bpoint=0;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a;
		cin >> b;
		if(a>b){apoint+=a;apoint+=b;}
		else if(b>a){bpoint+=a;bpoint+=b;}
		else {apoint+=a;bpoint+=b;}
	}
	cout << apoint <<' ' << bpoint << endl;
	return 0;
}

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

			
		}
		cout<<A<<" "<<B<<endl;
	}
}

C++: #include <iostream>

int main(int argc, char const* argv[])
{
  int i, n, a, b, a_score, b_score;

  while (true) {
    a_score = 0;
    b_score = 0;

    std::cin >> n;
    if (n == 0) { break; }

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

      if (a > b) {
        a_score += (a + b);
      } else if (b > a) {
        b_score += (a + b);
      } else {
        a_score += a;
        b_score += b;
      }
    }
    std::cout << a_score << " " << b_score << std::endl;
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    int n;

    while(cin >> n && n) {
        int a = 0,b = 0;
        rep(i,n) {
            int x,y;
            cin >> x >> y;

            if(x == y) {
                a += x;
                b += y;
            } else if(x > y) {
                a += (x+y);
            } else {
                b += (x+y);
            }
        }

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

    return 0;
}

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

using namespace std;

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

	return 0;
}

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

int main() {
	int aten = 0,bten = 0,a,b;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		if(a > b){
			aten = aten + a + b;
		}
		else if(a == b){
			aten = aten + a;
			bten = bten + a;
		}
		else{
			bten = bten + a + b;
		}


	}
	cout << aten << " " << bten << endl;
	return 0;
}

C++: #include <iostream>
#include <cstdlib>
#define MAX_SIZE 1001


int main()
{
    bool isRun = true;
    int len;
    int resA, resB;
    int playerA, playerB;
    while(isRun) {
        std::scanf("%d", &len);
        if (len == 0) {
            isRun = false;
        } else {
            resA = resB = 0;
            for (int i = 0; i < len; i++) {
                std::scanf("%d %d", &playerA, &playerB);
                if (playerA > playerB) resA += playerA + playerB;
                else if (playerA < playerB) resB += playerA + playerB;
                else if (playerA == playerB) {
                    resA += playerA; resB += playerB;
                }
            }
            std::printf("%d %d\n", resA, resB);
        }
    }
    return 0;
}

C++: #include <iostream>

int main(){
    int n,a,b,ina,inb;
    
    while(std::cin >> n,n){
        a=0;b=0;
        for(int i=0;i<n;i++){
            std::cin >> ina >> inb;
            if(ina>inb){
                a += ina + inb;
            }else if(ina==inb){
                a += ina;
                b += inb;
            }else{
                b += ina + inb;
            }
        }
        std::cout << a << ' ' << b << ' ' << std::endl;
    }
    
    return 0;
}