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;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)

int main(void){
	int n;
	int a = 0, b = 0;
	cin >> n;
	rep(i, n){
		int x, y;
		cin >> x >> y;
		if(x > y){
			a += x + y;
		}
		if(y > x){
			b += x + y;
		}
		if(y == x){
			a += x;
			b += y;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

C++: #include <iostream>

void Game(int round, std::istream& in, std::ostream& out)
{
    int scoreA = 0;
    int scoreB = 0;
    for(int i = 0; i < round; ++i){
        int a, b;
        in >> a >> b;
        if(a > b){
            scoreA += a + b;
        }else
        if(a < b){
            scoreB += a + b;
        }else{
            scoreA += a;
            scoreB += b;
        }
    }
    out << scoreA << " " << scoreB << std::endl;
}

int main()
{
    int n;
    std::cin >> n;
    while(n){
        Game(n, std::cin, std::cout);
        std::cin >> n;
    }
    return 0;
}

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

int main(){
    
    while(1)
    {
        int num;
        cin>>num;
        
        if(num == 0)
        {
            break;
        }
        
        vector< int > cardA(num);
        vector< int > cardB(num);
        
        for(int i=0;i<num;++i)
        {
            int pA, pB;
            cin>>pA>>pB;
            cardA[i] = pA;
            cardB[i] = pB;
        }
        
        int pointA = 0;
        int pointB = 0;
        
        for(int i=0;i<um;++i)
        {
            if(cardA[i] ==cardB[i])
            {
                pointA += cardA[i];
                pointB += cardA[i];
            }
            else if(cardA[i] > cardB[i])
            {
                pointA += cardA[i] + cardB[i];
            }
            else
            {
                pointB += cardA[i] + cardB[i];
            }
        }
        
        cout<<pointA<<" "<<pointB<<endl;
    }
    
    return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int ans_a, ans_b;
	int n;
	int a, b;
	
	scanf("%d", &n);
	ans_a = ans_b = 0;
	while (n){
		scanf("%d %d", &a, &b);
		
		if (a > b){
			ans_a += (a + b);
		}
		else if (a < b){
			ans_b += (a + b);
		}
		else {
			ans_a += a;
			ans_b += b;
		}
		
		n--;
	}
	
	printf("%d %d\n", ans_a, ans_b);
	
	return (0);
}

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

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

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

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

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

int main(){
  int n,i,a,b;

  while(1){
    int x=0, y=0;
    cin >> n;
    if( n == 0 ) break;
    if( n <= 10000){
      for( i = 1 ; i <= n ; i++){
	cin >> a >> b ;
	if ( a > b ){
	  x =x+ (a+b); 
	}
	else if ( a == b){
	  x = x+a;
	  y = y+b;
	}
	else y =y+(a+b);
      }
    }
    cout << x << " " << y <<endl;
  }
  
  return 0 ;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n&&n){
    int ansa=0,ansb=0;
    int a[n];
    int b[n];
    for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
      if(a[i]>b[i]) ansa+=(a[i]+b[i]);
      else if(b[i]>a[i]) ansb+=(a[i]+b[i]);
      else {
	ansa+=a[i];
	ansb+=b[i];
      }
    }
    cout<<ansa<<" "<<ansb<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

  int n;

  for( ; ; ){

  cin>> n;

  int A,B;

  A=0;
  B=0;

  if(n==0)break;

   for(int i=0;i<n;i++){
 
     int a,b;

     cin>>a>>b;

     if(a>b){
       A=A+a+b;
     }
     if(a<b){
       B=B+a+b;
     }
     if(a==b){
       A=A+a;
       B=B+b;
     }
   }
   cout<<A<<" "<<B<<endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int maisuu, a[15000], b[15000];
	long long int a_p = 0, b_p = 0;
	cin >> maisuu;
	if (maisuu == 0){
		return 1;
	}
	for (int i = 0; i < maisuu; i++){
		cin >> a[i];
		cin >> b[i];
	}
	for (int i = 0; i < maisuu; i++){
		if (a[i] < b[i]){
			b_p += a[i] + b[i];
		}
		else if (a[i]>b[i]){
			a_p += a[i] + b[i];
		}
		else if (a[i] == b[i]){
			a_p += a[i];
			b_p += b[i];
		}
	}
	cout << a_p << " " << b_p << endl;
	return 0;
}

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

int main() {
	int n, a, b;
	
	while(cin>>n,n) {
		a = 0;b = 0;
		for(int i=0;i<n;i++) {
			int sa, sb;
			cin>>sa>>sb;
			if(sa>sb)a+=sa+sb;
			else if(sb>sa)b+=sa+sb;
			else {
				a+=sa;
				b+=sb;
			}
		}
		cout<<a<<" "<<b<<endl;
	}
	
	return 0;
}

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

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

return 0;
}

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

int main(){
	int n;
	int point_a, point_b, a, b;

	point_a = point_b = 0;
	cin >> n;

	while(n > 0){
		cin >> a >> b;
		if(a > b)
			point_a += a+b;
		else if(a < b)
			point_b += a+b;
		else{
			point_a += a;
			point_b += b;
		}
		n--;
	}

	cout << point_a << " " << point_b << endl;

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n = 0;
	int p[10][2];
	int a = 0;
	int b = 0;
	cin >> n;
	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 <iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int x,y;
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b){
				x+=a;
				x+=b;
			}else if(a<b){
				y+=a;
				y+=b;
			}else if(a==b){
				x+=a;
				y+=b;
			}
		}
		cout<<x<<" "<<y<<endl;
	}
}

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

int main(){
 int n, a, b, a_sum, b_sum;
 while(cin>>n, n){
  a_sum=b_sum=0;
  while(n--){
   cin>>a>>b;
   if(a>b)a_sum+=a+b;
   else if(a<b)b_sum+=a+b;
   else a_sum+=a, b_sum+=b;
  }
  printf("%d %d\n", a_sum,b_sum);
 }
 return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a=0, b=0,n,s,t;
	cin >> n; while (n != 0) {
		a = 0; b = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d%d", &s, &t);
			if (s > t)a += s + t;
			else if (t > s)b += s + t;
			else { a += s; b += t; }
		}
		cout << a << " " << b << endl; cin >> n;
	}
	return 0;
}