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 a,b,n;
    a=b=0;

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

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	do{
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> a >> b;
			if(a>b) suma+=a+b;
			else if(a<b) sumb+=a+b;
			else{suma+=a;sumb+=b;}
		}
		printf("%ld %ld\n",suma,sumb);
	}while(n!=0);
	return 0;
}

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

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

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

int main(){
  int n;
  int Acard,Bcard;
  int Atotal,Btotal;
while(true){
  cin>>n;
  if(n==0){
    break;
  }
  for(int i=0;i<n;i++){
    cin>>Acard>>Bcard;
    if(Acard>Bcard){
      Atotal+=Acard+Bcard;
    }else if(Bcard>Acard){
      Btotal+=Acard+Bcard;
    }else{
      Atotal+=Acard;
      Btotal+=Bcard;
    }
  }

  cout<<Atotal<<' '<<Btotal<<'\n';
}
  return 0;
}

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

C++: #include<cstdio>
#include<queue>

using namespace std;

int main()
{
	int ap, bp, turnnum, acard, bcard;
	ap = bp = 0;
	queue<int>adeck, bdeck;
	while (1)
	{
		scanf("%d", &turnnum);
		if (turnnum == 0)break;

		for (int i = 0; i < turnnum; i++)
		{
			scanf("%d %d", &acard, &bcard);
			adeck.push(acard);
			bdeck.push(bcard);
		}
		while (adeck.empty() == false)
		{
			if (adeck.front()>bdeck.front())
			{
				ap += adeck.front() + bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
			else if(adeck.front() < bdeck.front())
			{
				bp += adeck.front() + bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
			else
			{
				ap += adeck.front();
				bp += bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
		}
		printf("%d %d\n", ap, bp);
                ap=0;bp=0;
	}

}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0500

#include <iostream>
using namespace std;

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

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

C++: #include <iostream>

int main(){
    int n, a[10], b[10], apt, bpt;
    while(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<stdio.h>
int main()
{
	int n, a, b, i, point1, point2;
	point1 = 0;
	point2 = 0;
	scanf("%d", &n);
	for ( i = 0; i < n; i++)
	{
		scanf("%d %d", &a, &b);
		if ( a > b )point1 = point1 + a + b;
		else if ( a < b )point2 = point2 + a + b;
		else if ( a == b )
	 	{
			point1 = point1 + a;
			point2 = point2 + b;
		}
	}
	printf("%d %d", point1, point2);
}

C++: #include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
void cscan(void);
void clear(void);

int n,sa=0,sb=0;

int main(){

  int end=1;

  while(end){

  scanf("%d",&n);

  if(n==0){
    break;
  }

  cscan();

  printf("%d %d\n",sa,sb);

  clear();

}

  return 0;
}

void cscan(){

  int i,j;
  int a,b;

  for(i=0;i<n;i++){

    scanf("%d %d",&a,&b);

    if(a==b){
      sa+=a;
      sb+=b;
    }
    else if(a>b){
      sa+=a+b;
    }
    else if(a<b){
      sb+=a+b;
    }

  }
}

void clear(){

  sa=sb=0;

}

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

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

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

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

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

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

C++: #include<iostream>
using namespace std;
int n[10000000],s1,s2;
int main(){
int p,a,b;
while(true){
s1=0;s2=0;
cin>>p;
if(p==0){
break;
}
for(int i=0;i<p;i++){
cin>>a>>b;
if(a>b){s1+=a+b;}
else if(b>a){s2+=a+b;}
else{s1+=a;s2+=b;}
}
cout<<s1<<' '<<s2<<endl;
}
}

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

int main(){
	int n, a, b;
	int sa, sb;
	
	while(1){
		cin >> n;
		if(n==0) break;
		sa=0; sb=0;
		
		for(int i=0;i<n;i++){
			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 <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	long long int a,b,n,x,y;
while(1){	a=0;
	b=0;
	scanf("%lld",&n);
	if(n==0) break;
	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;
}