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 A, B, card[10000][2];

int main(){

	while(1){

		int n, i;

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

		for(i=0; i<n; i++){
			cin >> card[i][0] >> card[i][1];
		}

		for(i=0; i<n; i++){
			if(card[i][0]==card[i][1]){
				A += card[i][0];
				B += card[i][0];
			}
			else if(card[i][0] > card[i][1]){
				A += card[i][0] + card[i][1];
			}
			else{
				B += card[i][0] + card[i][1];
			}
		}

		cout << A << ' '<< B << endl;

	}

	return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
  int n;
  while(cin>>n && n!=0) {
    int pointA = 0, pointB = 0;
    int tmpA, tmpB;
    for(int i=0; i<n; i++) {
      cin>>tmpA>>tmpB;
      if(tmpA > tmpB) {
        pointA += tmpA+tmpB;
      }
      else if(tmpA < tmpB) {
        pointB += tmpA+tmpB;
      }
      else {
        pointA += tmpA;
        pointB += tmpB;
      }
    }
    cout<<pointA<<" "<<pointB<<endl;
  }
}

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

C++: #include<iostream>
#include<vector>
int main() {
	int i = 0;
	std::cin >> i;
	std::vector <int> ha, hb;
	while (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;
	}
	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))

//repetition//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

C++: #include <iostream>

using namespace std;

int main(void)
{
	int n;
	int a, b;
	
	while (1){
		cin >> n;
		if (n == 0)break;
		
		a = b = 0;
		for (int i = 0; i < n; i++){
			int ca, cb;
			cin >> ca >> cb;
			if (ca > cb){
				a += ca + cb;
			}
			else if (ca == cb){
				a += ca;
				b += cb;
			}
			else {
				b += ca + cb;
			}
		}
		
		cout << a << ' ' << b << endl;
	}
	
	return (0);
}

C++: #include <stdio.h>
#define loop(num)	for(int a = 0; a < num; a++)

int main(){
	int num;
	do{
		long long A = 0, B = 0;
		int a_card, b_card;
		scanf("%d", &num);
		loop(num){
			scanf("%d%d", &a_card, &b_card);
			if (a_card < b_card) B += (a_card + b_card);
			if (b_card < a_card) A += (a_card + b_card);
			if (a_card == b_card){
				A += a_card;
				B += b_card;
			}
		}
		if (num != 0)
		printf("%lld %lld\n", A, B);
	} while (num != 0);
	return 0;
}

C++: #include <cstdio>
int main(){
 int asum,bsum,a,b,n,i;
 asum=bsum=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d %d",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) { asum += a; bsum += b; }
 };
 printf("%d %d\n",asum,bsum);
 return 0;
};

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

int main(void)
{
  int n;

  while (true) {
    int n;
    std::cin >> n;
    if (n == 0) break;
    std::vector<int> cards_A, cards_B;
    for (int i = 0; i < n; i++) {
      int card_A, card_B;
      std::cin >> card_A >> card_B;
      cards_A.push_back(card_A);
      cards_B.push_back(card_B);
    }
    int score_A = 0;
    int score_B = 0;
    for (int i = 0; i < n; i++) {
      if (cards_A.at(i) == cards_B.at(i)) {
        score_A += cards_A.at(i);
        score_B += cards_B.at(i);
      }
      else {
        int score_sum = cards_A.at(i) + cards_B.at(i);
        if (cards_A.at(i) > cards_B.at(i)) score_A += score_sum;
        if (cards_A.at(i) < cards_B.at(i)) score_B += score_sum;
      }
    }
    std::cout << score_A << " " << score_B << std::endl;
  }

  return 0;
}

C++: #include<cstdio>

using namespace std;

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

C++: #include<iostream>

using namespace std;

int main()
{
	int n;
	int i;
	int card_A,card_B;
	int ans_A,ans_B;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
			
		ans_A=ans_B=0;
		
		for(i=0;i<n;i++)
		{
			cin >> card_A >> card_B ;
			if(card_A>card_B)
				ans_A+=card_A+card_B;
			else if(card_A == card_B)
			{
				ans_A+=card_A;
				ans_B+=card_B;
			}
			else
				ans_B+=card_A+card_B;
		}
		
		cout << ans_A << " " << ans_B << endl;
	}
}

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

int main ()
{
while  (true)
  {
  int loop,vna,vnb;
  scanf("%d",&loop);
  if (loop == 0)
    {
	break;
	  };
  vna=0;
  vnb=0;
  for (int i=0;i<loop;i++)
    {
      int vn2,vn3;
      scanf("%d",&vn2);
      scanf("%d",&vn3);
      if (vn2 > vn3)
	{
	  vna = vna + vn2 + vn3;
	    };
      if (vn2 < vn3)
	{
	  vnb = vnb + vn2 + vn3;
	    };
      if(vn2 == vn3)
	{
	  vna = vna + vn2;
	  vnb = vnb + vn3;
	};
    };
  printf ("%d %d\n",vna,vnb);


 };

}

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

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

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