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>

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

C++: #include<iostream>
using namespace std;
 
int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;

	cin >> a;
	for (int i; i < a; i++){
		cin >> b;
		cin >> c;
		if (b>c){
			uma = uma + b + c;
		}
		if(b=c){
			uma = uma + b;
			ushi = ushi + c;
		}
		else{
			ushi = ushi + b + c;
		}
	}
	cout << uma <<" "<<ushi;

}

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

int main(){
	int n, card1, card2, p1, p2;
	while(cin >> n, n != 0){
		p1 = 0;
		p2 = 0;
		for(int i = 0; i < n; i++){
			cin >> card1 >> card2;
			if(card1 < card2){
				p2 += card1+card2;
			}
			else if(card1 > card2){
				p1 += card1+card2;
			}
			else if(card1 == card2){
				p1 += card1;
				p2 += card2;
			}
		}
		
		cout << p1 << ' ' << p2 << endl;
	}
	return 0;
}

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

int main(){
	while(1){
		int n;
		long a=0, b=0;
		
		
		scanf(" %d", &n);
		if(n==0) break;
		for(int i=0; i<n; ++i){
			int x, y;
			scanf(" %d %d", &x, &y);
			
			if(x>y) a+=x+y;
			else if(x<y) b+=x+y;
			else{
				a+=x; b+=y;
			}
		}
	
		printf("%ld %ld\n", a, b); 
	}

	return 0;
}

C++: #include <iostream>

int main(){
    while(true){
    int n, a_score = 0, b_score = 0;
    std::cin >> n;
    
    if(n == 0)
        break;

    for(int i = 0; i < n; ++i){
        int a, b;
        std::cin >> a >> b;
        if(a > b)
            a_score += a + b;
        else
            b_score += a + b;
    }

    std::cout << a_score << " " << b_score << std::endl;
    }
    return 0;
}

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

int main() {
	int num;
	int score_a[5];
	int score_b[5];
	int cnt = 0;
	bool flg = true;
	
	cin >> num;
	while (flg) {
		for (int i = 0; i < num; i++) {
			int a;
			int b;

			cin >> a >> b;
			if (a > b) {
				score_a[cnt] += a + b;
			}else if (b > a) {
				score_b[cnt] += a + b;
			}else {
				score_a[cnt] += a;
				score_b[cnt] += b;
			}
		}
		cnt++;
		cin >> num;
		if ((cnt == 5) || (num == 0)) {
			flg = false;
		}
	}
	for (int i = 0; i < cnt; i++) {
		cout << score_a[i] << " " << score_b << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

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

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int num=0,sum=0;

	cin >> n;

	int a[10];
	int b[10];
	for(int i=1; i<=n; i++){

		cin >> a[i] >> b[i];

		if(a[i] > b[i]){
			
			num+=a[i]+=b[i];
		}
		else if(a[i] < b[i]){
			
			sum+=b[i]+=a[i];
		}
	}

	cout << num << " " << sum << 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;
    suma = 0;
    sumb = 0;
  }
  return 0;
}

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

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,a,b,x=0,y=0;
  cin>>n;
  rep(i,n){
    cin>>a>>b;
    if(a==b){
      x+=a;
      y+=b;
    }
    else if(a>b)x+=a+b;
    else if(b>a)y+=a+b;
  }
  cout<<x<<" "<<y<<endl;
}

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++;
		}
		printf("%d %d\n", playerA, playerB);
		i = 0;
		playerA = 0;
		playerB = 0;
	}
}

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

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  int sa,sb;
  cin>>n;
  sa = sb = 0;
  while(n--){
    int a,b;
    cin>>a>>b;
    if(a>b){
      sa += a + b;
    }else{
      sb += a + b;
    }
  }

  cout<< sa << " " << sb << endl;
}

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

int main(){
    int n;
    scanf("%d",&n);
    int a,b;
    int at=0,bt=0;
    for(int i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        if(a>b){
            at+=(a+b);
        }else if(b>a){
            bt+=(a+b);
        }else{
            at+=a;
            bt+=b;
        }
    }printf("%d %d\n",at,bt);
    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;
if(n!=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 <cstdio>
#include <vector>
using namespace std;

int main(){
	int n, aa, bb;
	vector<pair<int, int> > v;
	while(1){
		aa = 0;
		bb = 0;
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		int a, b;
		for(int i = 0; i < n; i++){
			scanf("%d %d", &a, &b);
			if(a > b){
				aa += a + b;
			}else if(b > a){
				bb += a + b;
			}else{
				aa += a;
				bb += b;
			}
		}
		v.push_back(make_pair(aa, bb));
	}
	for(int i = 0; i < v.size(); i++){
		printf("%d", v[i].first);
		printf(" ");
		printf("%d\n", v[i].second);
	}
	return 0;
}