Go: package main

import (
	"fmt"
)

// Game is one game.
type Game struct {
	pointA, pointB int
}

func main() {
	var n int
	game := &Game{0, 0}
	fmt.Scanf("%d", &n)
	for n != 0 {
		game.initGame()
		game.execGame(n)
		game.printResult()
		fmt.Scanf("%d", &n)
	}
}

func (game *Game) execGame(n int) {
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		switch {
		case a == b:
			game.pointA += a
			game.pointB += b
		case a > b:
			game.pointA += a + b
		case b > a:
			game.pointB += a + b
		}
	}
}

func (game *Game) initGame() {
	game.pointA = 0
	game.pointB = 0
}

func (game *Game) printResult() {
	fmt.Println(game.pointA, game.pointB)
}

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

int main()
{
	int n;
	int a, b;
	std::vector<int> ansa;
	std::vector<int> ansb;
	int sa;
	int sb;
	
	while(1) {
		std::cin >> n;
		if (n == 0) {
			break;
		}
		sa = 0;
		sb = 0;
		for (int i = 0; i < n; i++)
		{
			std::cin >> a >> b;
			if (a > b) {
				sa += a + b;
			}
			else if (a == b) {
				sa += a;
				sb += b;
			}
			else {
				sb += a + b;
			}
		}
		ansa.push_back(sa);
		ansb.push_back(sb);
	}

	for (int i = 0; i < ansa.size(); i++)
	{
		std::cout << ansa[i] << " " << ansb[i] << std::endl;
	}

	return 0;
}

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

void opera(int n);
int main(void)
{
	int n;
	
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		else {
			opera(n);
		}
	}
	
	return (0);
}

void opera(int n)
{
	int a_sum = 0;
	int b_sum = 0;
	
	
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		
		if (a == b){
			a_sum += a;
			b_sum += b;
		}
		else if (a > b){
			a_sum = a_sum + a + b;
		}
		else {
			b_sum = b_sum + a + b;
		}
	}
	
	printf("%d %d\n", a_sum, b_sum);
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

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

        cout << x << ' ' << y << endl;
    }
}

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

using namespace std;

int main(){
  int n;
  while(scanf("%d", &n), n){
    int A = 0;
    int B = 0;

    for(int i = 0; i < n; i++){
      int a, b;
      scanf("%d%d", &a, &b);
      if(a < b) B += a + b;
      if(a > b) A += a + b;
      if(a == b){ A += a; B += b; }
    }

    printf("%d %d\n", A, B);
  }

  return 0;
}

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
	if(n==0)break;
	sumA=0,sumB=0;
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
sumA+=a;
sumA+=b;
}
if(a==b){
sumA+=a;
sumB+=b;
}
if(a<b){
sumB+=a;
sumB+=b;
}}
printf("%d %d",sumA,sumB);
}}

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

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

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

C++: #include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		int sa = 0,sb = 0;
		while (n--) {
			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;
		}
	}
}

C++: #include<iostream>
#include<vector>
int main() {
	std::vector<int> a, b;
	while (true) {
		int n;
		int as = 0; int  bs = 0;
		std::cin >> n;
		if (!n) {
			break;
		}
		for (int i = 0; i < n;){
			int n, m;
			std::cin >> n >> m;
			if (n > m) {
				as += n + m;
			}
			if (m > n) {
				as += n + m;
			}
		}
		a.push_back(as);
		b.push_back(bs);
	}
	for (int i = 0; i < a.size(); ++i) {
		std::cout << a[i] << " " << b[i] << std::endl;
	}
return 0;
}

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

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

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main () {
    whole(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 a,b,n,i;
	int suma=0,sumb=0;
	while(1){
		cin>>n;
		if(n==0)break;
		suma=0;sumb=0;
		for(i=0;i<n;i++){
			cin>>a>>b;
			if(a==b){
				suma+=a;
				sumb+=b;
			}
			else if(a>b){
				suma+=a+b;
			}else{
				sumb+=a+b;
			}
		}
		cout<<suma<<" "<<sumb<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int scA=0;
  int scB=0;
  while(1){
  cin>>n;
  if(n==0)break;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(a>b)scA+=a+b;
    if(a<b)scB+=a+b;
    if(a==b){
      scA+=a;
      acB+=b;
    }
  }
    cout<<scA<<' '<<scB<<endl;
  }

  return 0;
  
}

C++: #include<iostream>
#include<vector>
#include<string>
int main() {
	int n;
	int a, b;
	std::vector<int> k,t;
	while (true)
	{
		std::cin >> n;
		if (n == 0)
			break;
		int g = 0;
		int s = 0;
		for (int i = 0; i < n; ++i) {
			if (i == 0)
				g -= g,
				s -= s;
			std::cin >> a >> b;
			if (a == b)g += a, s += b;
			if (a > b) g += a + b;
			if (a < b) s += b + a;
		}
		k.push_back(g);
		t.push_back(s);
	}
	for (int i = 0; i < k.size(); ++i) {
		std::cout << k[i] << " " << t[i] << std::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 >> bs;
        if(as > bs){
            A = A + as + bs;
        }else if(as < bs){
            B = B + as + bs;
        }else{
            A = A + as;
            B = B + bs;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}