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 <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;


int main(){
    int a,b,sa=0,sb=0,n;
    
    
    while(1){
    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(a<b)
            sb+=a+b;
        else{
            sa+=a;
            sb+=b;
        }
    }
    
    printf("%d %d\n",sa,sb);
    }
    return 0;
    
}

C++: #include<iostream>

void main(){

	int n;

	int a=0, b=0;

	int x, y;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

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

	goto f;

flag:

	std::cout << a << b << std::endl;

}

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

int main(){
  int pnt_a = 0;
  int pnt_b = 0;
  int car_a;
  int car_b;
  int num;

  while(cin >> num){
    if(!num) break;
    for(; num; num--){
      cin >> car_a;
      cin >> car_b;
      if(car_a < car_b) pnt_b += (car_a + car_b);
      else if (car_a > car_b) pnt_a += (car_a + car_b);
      else {pnt_a += car_a; pnt_b += car_b;}
    }

    cout << pnt_a << " " << pnt_b << "\n";
    pnt_a = pnt_b = 0;
  }

return 0;
}

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

int main() {
    while(true) {
        int n; scanf("%d", &n);
        if(n==0) break;
        int a=0,b=0;
        while(n--) {
            int x,y; scanf("%d%d", &x, &y);
            (x>=y?a:b)+=x;
            (x<=y?b:a)+=y;
        }
        printf("%d %d\n", a, b);
    }
    return 0;
}

C++: #include <stdio.h>

const int SET = 5;

void card_game()
{
	int n      = 0;
	int card_a = 0;
	int card_b = 0;
	
	static int point_a[SET] = {0};
	static int point_b[SET] = {0};
	
	static int set = 0;
	
	scanf("%d", &n);
	if(n == 0)
	{
		for(int i=0; i<set; i++)
		{
			printf("%d %d\n", point_a[i], point_b[i]);
		}
		
		return;
	}
	
	for(int i=0; i<n; i++)
	{
		scanf("%d %d", &card_a, &card_b);
		
		if(card_a > card_b)
		{
			point_a[set] += (card_a + card_b);
		}
		else if(card_b > card_a)
		{
			point_b[set] += (card_a + card_b);
		}
		else
		{
			point_a[set] += card_a;
			point_b[set] += card_b;
		}
	}
	
	set++;
	card_game();
}

int main(void)
{
	card_game();
}

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

C++: #include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
        while(true){
                int pa = 0, pb = 0;      
                int a, b
                scanf("%d", &n);
                if(!n) break;
                for(i = 0; i < n; i++){
                        scanf("%d%d", &a, &b);
                        if(a > b)
                                pa += a + b;
                        else if(b > a)
                                pb += a + b;
                        else if(a == b){
                                pa += a;
                                pb += b;
                        }
                }
                printf("%d %d\n", pa, pb);
        }
        return 0;
}

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

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

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

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

int main()
{
	int n,a,b,A,B;
	while(cin >> n, n)
	{
		A=B=0;
		while(n--)
		{
			cin >> a >> b;
			if(a< b) {B+=a+b;}
			if(a> b) {A+=a+b;}
			if(a==b) {A+=a;B+=b;}
		}
		cout << A << " " << B << endl;
	}
}

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

int main()
{

	int n;
	int a=0,b=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<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>

using namespace std;

int main(){

  int n,anum,bnum;
  int as, bs;

  as = bs = 0;

  scanf("%d",&n);
  
  for(int i = 0 ; i < n ; i++){
    scanf("%d%d",&anum,&bnum);
    
    if(anum == bnum){
      as += anum;
      bs += bnum;
  }
    
    else if(anum > bnum){
      as += anum;
      as += bnum; 
    }
    
    else if(anum < bnum){
      bs += anum;
      bs += bnum; 
    }  
  }
  
  printf("%d %d\n",as,bs);

  return 0;
}

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

int main()
{
	int n;
	while(cin>>n,n){
	int A=0,B=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		if(x>y)A+=x+y;
		else if(x<y)B+=x+y;
		else A+=x,B+=y;
		}
		cout<<A<<" "<<B<<"\n";
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

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

C++: #include<iostream>

using namespace std;

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

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

int main(){

  int n;

  while(cin>>n,n!=0){
    int sa=0,sb=0,a,b;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a==b){
	sa+=a;
	sb+=b;
      } else if(a>b){
	sa+=a+b;
      } else {
	sb+=a+b;
      }
    }

    cout<<sa<<" "<<sb<<endl;
  }

}

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

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

struct player{
    int point;
    int card[10000];
    inline player(){point = 0;}
};

int main()
{
    int loop;
    player a, b;
    cin >> loop;
    for(int c = 0; c < loop; c++)
    {
        cin >> a.card[c];
        cin >> b.card[c];
    }

    for(int c = 0; c < loop; c++)
    {
        if(a.card[c] < b.card[c]) b.point += a.card[c] + b.card[c];
        if(a.card[c] == b.card[c]) a.point += a.card[c], b.point +=b.card[c];
        if(a.card[c] > b.card[c]) a.point += a.card[c] + b.card[c];
    }
    cout << a.point << " " << b.point << endl;
    return EXIT_SUCCESS;
}

C++: a,b,c;main(d){for(scanf("%d");scanf("%d%d",&c,&d);a+=d>c?0:c)b+=c>d?0:d;a=!printf("%d %d\n",a,b);}