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 res = 1;
    while(res){
        cin >> res;

        if(res == 0)
            break;

        int n[2][res];

        for(int i=0; i<res; i++){
            cin >> n[0][i];
            cin >> n[1][i];
        }
        int x = 0;
        int y = 0;

        for(int j=0; j<res; j++){
            if(n[0][j]>n[1][j])
                x += n[0][j]+n[1][j];
            else if(n[0][j]==n[1][j]){
                x += n[0][j];
                y += n[1][j];
            }
            else
                y += n[0][j]+n[1][j];
            }

            cout << x << ' ' << y << '\n';

    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{	
	int c, a, b, a1, b1;
	while (cin >> c&&c != 0) {
		a = 0; b = 0;
		for (int i = 0; i < c; i++) {
			cin >> a1 >> b1;
			if (a1 > b1) {
				a += (a1 + b1);
			}
			else if (a1 < b1) {
				b += (a1 + b1);
			}
			else {
				a += a1;
				b += b1;
			}
		}
		cout << endl;
		cout << a << ' ' << b << endl;
		cout << endl;
	}
	return 0;
}

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

int A = 0, B = 0, j;

int main(){
    cin >> j;
    for(int i = 0; i < j; i++){
        int as, bs;
        cin >> as;
        cin >> bs;
        if(as > bs){
            A += as + bs;
        }else if(as < bs){
            B += as + bs;
        }else{
            A += as;
            B += bs;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

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

C++: #include<stdio.h>

int main(){
	int i=0,x,a[10000],b[10000],aP=0,bP=0;
	scanf("%d",&x);
	while(i<x){
scanf("%d%d",&a[i],&b[i]);
	++i;
	}
	i=0;
	while(i<x){
		if(a[i]==b[i]){
			aP=aP+a[i];
			bP=bP+b[i];
		}else if(a[i]>b[i]){
		aP=aP+a[i]+b[i];
		}else{
		bP=bP+a[i]+b[i];
		}
		++i;
	}
	printf("%d %d\n",aP,bP);
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main(){
	int a[10002],b[10002],i,j=0,ans1[10000],ans2[10000];
	int A=0,B=0,n;
	cin>>n;
	while(n!=0){
		for(i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		for(i=0;i<n;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;
		cin>>n;
	}
    return 0;
	
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,s1=0,s2=0,a,b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>b)s1+=a+b;
		else if(a<b)s2+=a+b;
		else{
			s1+=a;
			s2+=b;
		}
	}
	cout<<s1<<" "<<s2<<'\n';
	return 0;
}

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

using namespace std;

int main() {
	int a, b, n;
	vector<int*> scores;

	while (cin >> n) {
		if (n == 0)
			break;
		int *score = new int(2);
		score[0] = 0;
		score[1] = 0;
		for (int i = 0; i < n; i++) {
			cin >> a >> b; 
			if (a > b)
				score[0] += a + b;
			if (a < b)
				score[1] += a + b;
			if (a == b) {
				score[0] += a;
				score[1] += b;
			}
		}
		scores.push_back(score);
	}

	for (int i = 0; i < scores.size(); i++) {
		cout << scores[i][0] << " " << scores[i][1] << endl;
	}

	return 0;
}

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

int main(){
	int n,hand[2],sum[2];
	while(1){
		sum[0]=0;
		sum[1]=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>hand[0]>>hand[1];
			if(hand[0]>hand[1]){
				sum[0]+=hand[0]+hand[1];
			}else if(hand[0]<hand[1]){
				sum[1]+=hand[0]+hand[1];
			}else{
				sum[0]+=hand[0];
				sum[1]+=hand[1];
			}
		}
		cout<<sum[0]<<' '<<sum[1]<<endl;
	}
	return 0;
}

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

}

C++: #include <iostream>

int score_a, score_b;

int main(void)
{
    int n, data_a, data_b;

    while(1)
    {
        std::cin >> n;
        if (n == 0) break;
        score_a = 0;
        score_b = 0;
        for(; n > 0 ; n--) {
            std::cin >> data_a;
            std::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;
            }
        }
        std::cout << score_a << " " << score_b << std::endl;
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

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

C++: #include<stdio.h>
int main(void){
    int loop,a,b,c=0,d=0;
    scanf("%d",&loop);
    for(int i=0;loop<i;i++){
        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++: main(n,a,b,A,B){for(;A=B=0,scanf("%d", &n),n;printf("%d %d\n",A,B))for(;n--;)scanf("%d%d",&a,&b),(a>b)?A+=a+b:(a<b)?B+=a+b:(A+=a,B+=b);}

C++: #include <cstdio>

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

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

C++: #include<stdio.h>

int main(void){
	int a_point,b_point,i,a_card,b_card,n;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		a_point=0,b_point=0;
		for(i=0;i<n;n++){
			scanf("%d %d",&a_card,&b_card);
			if(a_card>b_card) a_point+=a_card+b_card;
			else if(a_card<b_card) b_point+=a_card+b_card;
			else {
				a_point+=a_card;
				b_point+=b_card;
			}
			printf("%d %d\n",a_point,b_point);
		}
	return 0;
}

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

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

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