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>
#include <vector>

#define FOR(i,begin,end) for(int i = (begin); i < (end); ++i)

using namespace std;

struct Data {
    int A, B;
    Data(int a, int b) : A(a), B(b) {}
};

int N;
vector<Data> inputs;

void solve() {
    int A_sum = 0, B_sum = 0;
    FOR(i, 0, N) {
        int A = inputs[i].A;
        int B = inputs[i].B;
        if (A > B) {
            A_sum += A + B;
        } else if (A < B) {
            B_sum += A + B;
        } else {
            A_sum += A;
            B_sum += B;
        }

        cout << A_sum << " " << B_sum << endl;
    }
}

int main() {
    cin >> N;
    while (N > 0) {
        inputs.clear();

        FOR(i, 0, N) {
            int A, B;
            cin >> A >> B;
            inputs.push_back(Data(A, B));
        }

        solve();
        cin >> N;
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n!=0){
    vector<pair<int,int> > pii;
    int pa=0,pb=0;
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      pii.push_back(make_pair(a,b));
      if(pii[i].first>pii[i].second)
	pa+=(pii[i].first+pii[i].second);
      else if(pii[i].first<pii[i].second)
	pb+=(pii[i].first+pii[i].second);
      else{
	pa+=pii[i].first;pb+=pii[i].second;
      }
    }
    cout<<pa<<" "<<pb<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
//#include <unordered_set>
//#include <unordered_map>
//#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,vector<T>& vec){
    typename vector<T>::iterator it,endit=vec.end();
    os << "[";
    for(it=vec.begin();it!=endit;it++){
        os << " " << *it << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}



int main(){
	int n,a,b;
	int Pa,Pb;
	for(;;){
		n=input<int>();
		if(n==0)
			break;
		Pa=0,Pb=0;
		repeat(i,n){
		a=input<int>();b=input<int>();
		if(a>b)
			Pa+=a+b;
		else if(a==b){
			Pa+=a;Pb+=b;
		}else if(a<b)
			Pb+=a+b;
		}
		cout << Pa << " " << Pb << endl;
	}
	return 0;
}

C++: 
#include <iostream>

int A[10000], B[10000];

int main()
{
	int n, a, b;
	std::cin >> n;
	while (n != 0)
	{
		a = 0; 
		b = 0;
		for (int i = 0; i < n; i++)
		{
			std::cin >> A[i] >> B[i];
			if (A[i] > B[i])
			{
				a += A[i] + B[i];
			}
			if (A[i] == B[i])
			{
				a += A[i];
				b += B[i];
			}
			if (A[i] < B[i])
			{
				b += B[i];
			}
		}
		std::cout << a << " " << b << std::endl;
		std::cin >> n;
	}
    return 0;
}

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

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

		int p0=0, p1=0;

		for (int i = 0; i < n; ++i){
			int a, b;
			cin >> a >> b;
			if (a>b) p0 += a + b;
			else if (a == b);
			else p1 += a + b;
		}
		cout << p0 << ' ' << p1 << endl;
	}
}

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

C++: #include <bits/stdc++.h>
#include <stdint.h>

typedef uint32_t u32;
typedef uint64_t u64;

int main() {

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

C++: #include <iostream>

using namespace std;

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

C++: # coding: utf-8
# Here your code !


def latte():
    return int(input())

while True:
    x=y=0
    n=latte()
    if n==0 :break
    for i in range(n):
        a,b=map(int,input().strip().split())
        if a>b:
            x+=a+b
        elif b>a:
            y+=a+b
        else :
            x+=a
            y+=b
    
    print(x,y)

C++: #include<stdio.h>

int main(){
	int n;
	int A=0;
	int B=0;
	int i=0;
	scanf("%d", &n);
	int x[10000];
	int y[10000];
	while(i<n){
	scanf("%d", &x[i]);
	if(0>x[i] || 9<x[i]){
	return 0;
	}
	scanf("%d", &y[i]);
	if(0>y[i] || 9<y[i]){
	return 0;
	}
	++i;
}
	i=0;
	while(i<n){
	if(x[i]>y[i]){
	A=A+x[i]+y[i];
}else {
	if(x[i]<y[i]){
	B=B+x[i]+y[i];
}else{
	A=A+x[i];
	B=B+y[i];
			}
		}
	++i;
	}
	printf("%d %d\n", A, B);
		return 0;
}

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

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

using namespace std;

int main() {

	int n, a, b, c, d;

	while(1) {
		cin >> n;
		if(n==0)
			break;
		a=0;
		b=0;
		while(n!=0) {
			cin >> c >> d;
			if(c>d)
				a+=c+d;
			else if(c<d)
				b+=c+d;
			else {
				a+=c;
				b+=d;
			}
	
			n--;
		}
		cout << a << " " << b << endl;
	}


	return 0;

}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	cin>>n;
	while(true){
        if(n==0){break;}
	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;
    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 += a;
        }
    }
    cout << pointA <<  " " << pointB << endl;
}