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 <iostream>
using namespace std;

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

        printf("%d %d\n", c, a);
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int pointA=0,pointB=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        if(a<b){
            pointB += a+b;
        }
        if(a>b){
            pointA += a+b;
        }
        else{
            pointA += a;
            pointB += b;
        }
    }
    cout << a << b << endl;
}

C++: #include <stdio.h>

int main(void)
{
	int ans_a, ans_b;
	int n;
	int a, b;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		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 n, a, b, count = 0, pointX = 0, pointY = 0;
	cin >> n;
	do {
		cin >> a >> b;
		if (a > b) {
			pointX += (a + b);
		}
		else if (a < b) {
			pointY += (a + b);
		}
		else {
			pointX += a;
			pointY += b;
		}
		count++;
		if (count == n) {
			cout << pointX << " " << pointY << endl;
			pointX = pointY = count = 0;
			cin >> n;
		}
	} while (n != 0);
	return 0;
}

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

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

C++: #include <stdio.h>

void main()
{
	int n;
	int A, B;
	int playerA = 0, playerB = 0;
	int i = 0;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		while (i < n){
			scanf("%d %d", &A, &B);
			if (A == B){
				playerA += A;
				playerB += B;
			}
			else if (A > B){
				playerA += A + B;
			}
			else {
				playerB += A + B;
			}
			i++;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    Int x=0,y=0;
    for(Int i=0;i<n;i++){
      Int a,b;
      cin>>a>>b;
      if(a>b) x+=a+b;
      if(a<b) y+=a+b;
      if(a==b) x+=a,y+=b;
    }
    cout<<x<<" "<<y<<endl;
  }
  return 0;
}

C++: // cardgame.cpp
#include <iostream>
using namespace std;

int main(){
	int n;
	int i,j;
	int a[10000], b[10000];
	int a_point=0, b_point=0;
	cin >> n;
	for(i=0;i<n;++i){
			cin >> a[i];
			cin >> b[i];
	}
	for(j=0;j<n;++j){
		if(a[j]>b[j])
			a_point+=(a[j]+b[j]);
        else if(a[j]<b[j])
			b_point+=(a[j]+b[j]);
		else if(a[j]==b[j]){
			a_point+=a[j];
			b_point+=b[j];
		}
	}
	cout << a_point << " " << b_point << endl;
	return 0;	
}

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

int main(){
	int num;
	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;
		}
	}
	printf("%lld %lld\n", A, B);
	return 0;
}

C++: #include <stdio.h>


int main()
{

	int n;
	int a=0,b=0;
	int ac,bc;

	scanf("%d\n", &n);

	for(int i = 0; i < n; i++){
		
		scanf("%d %d", &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<iostream>

using namespace std;

int main(){

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

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;


class sai{
public:
  int ue,sita,mae,ushiro,migi,hidari;

  sai(int top=1,int front=3,int ue=1,int sita=6,int mae=3,int ushiro=4,int migi=5,int hidari=2):ue(ue),sita(sita),mae(mae),ushiro(ushiro),migi(migi),hidari(hidari) {
    for(int i=0;i<6;i++){
      if(ue==top && mae==front){break;}
      for(int t=0;t<4;t++){
	move(5);
	if(ue==top && mae==front){break;}
      }
      if(ue==top && mae==front){break;}
      if(i<4){move(1);}
      if(i==4){move(2);}
      if(i==5){move(2); move(2);}
    }

  }

  int move(int i){
    int ued=ue,sitad=sita,maed=mae,ushirod=ushiro,migid=migi,hidarid=hidari;
    if(i==1){
      ushiro=ued;
      ue=maed;
      mae=sitad;
      sita=ushirod;
    }
    if(i==2){
      migi=ued;
      ue=hidarid;
      hidari=sitad;
      sita=migid;
    }
    if(i==3){
      ushiro=sitad;
      ue=ushirod;
      mae=ued;
      sita=maed;
    }
    if(i==4){
      migi=sitad;
      ue=migid;
      hidari=ued;
      sita=hidarid;
    }
    if(i==5){
      migi=maed;
      mae=hidarid;
      hidari=ushirod;
      ushiro=migid;
    }
    return ue;
  }

  int where(int me){
    if(ue==me){return 0;}
    if(mae==me){return 3;}
    if(ushiro==me){return 1;}
    if(migi==me){return 2;}
    if(hidari==me){return 4;}
    return 0;
  }

  
};


vector<int> me[1000][1000];
int h[1000][1000];

int main(){ 
  for(int i=0;i<100;i++){
    for(int t=0;t<100;t++){
      h[i][t]=0;
      me[i][t].clear();
    }
  }
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int x=500,y=500;
    int top,front;
    cin>>top>>front;
    h[x][y]++;
    me[x][y].push_back(top);
    sai saikoro(top,front);
    while(1){
      int to=0;
      bool done=false;
      for(int t=4;t<=6;t++){
	to=saikoro.where(t);
	if(to==0){continue;}
	if(to==1 && h[x][y]>h[x][y+1]+1){me[x][y].erase(--me[x][y].end()); h[x][y]--; y++; h[x][y]++; me[x][y].push_back(saikoro.move(to)); done=true; break;}
	if(to==2 && h[x][y]>h[x+1][y]+1){me[x][y].erase(--me[x][y].end()); h[x][y]--; x++; h[x][y]++; me[x][y].push_back(saikoro.move(to)); done=true; break;}
	if(to==3 && h[x][y]>h[x][y-1]+1){me[x][y].erase(--me[x][y].end()); h[x][y]--; y--; h[x][y]++;  me[x][y].push_back(saikoro.move(to)); done=true; break;}
	if(to==4 && h[x][y]>h[x-1][y]+1){me[x][y].erase(--me[x][y].end()); h[x][y]--; x--; h[x][y]++;  me[x][y].push_back(saikoro.move(to)); done=true; break;}
      }
      if(!done){break;}
    }

      
  }
  int ans[7]={};
  for(int i=0;i<1000;i++){
    for(int t=0;t<100;t++){
      ans[me[i][t][me[i][t].size()-1]]++;
    }
  }
  for(int i=1;i<=6;i++){
    cout<<ans[i];
    if(i!=6){cout<<" ";}
  }
  cout<<endl;
  return 0;
}

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