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>

int n,an,bn,i,j;
int a[10000],b[10000];
int main (){
	n=1;
	while(n){
		scanf("%d",&n);
		if(n==0) break;
		an=0;
		bn=0;
		for (i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
		}
		for(j=0;j<n;j++){
			if(a[j]>b[j]) an=an+(a[j]+b[j]);
			else if(a[j]<b[j]) bn=bn+(a[j]+b[j]);
			else if (a[j]==b[j]) { 
				an=an+a[j];
				bn=bn+b[j];
			}
		}
		printf("%d %d\n",an,bn);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int num;

    while(true)
    {
        cin >> num;
        if(num == 0) break;

        int score1 = 0;
        int score2 = 0;
        int card1;
        int card2;
        for(int i = 0; i < num; ++i)
        {
            cin >> card1 >> card2;
            if(card1 > card2)
            {
                score1 += card1 + card2;
            }
            else if(card1 < card2)
            {
                score2 += card1 + card2;
            }
            else
            {
                score1 += card1;
                score2 += card2;
            }
        }
        cout << score1 << ' ' << score2 << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main() {
    int c,m,n;
    cin>>c;
    int a[c];
    int b[c];
    for(int i=0;i<c;i++){
        cin>>a[i]>>b[i];
        if(a[i]>b[i]){
            m+=a[i]+b[i];}
        if(a[i]<b[i]){
            n+=a[i]+b[i];}
        if(a[i]==b[i]){
            m+=a[i];
            n+=b[i];
        }
    }
    cout<<m<<" "<<n<<endl;
}

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,aa=0,ab=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a>b){
      aa+=a+b;
    }
    if(a<b){
      ab+=a+b;
    }
    if(a==b){
      aa+=a;
      ab+=b;
    }
  }
  cout<<aa<<' '<<ab<<endl;
  return(0);
}

C++: #include<iostream>
#include<string>
using namespace std;
int N, S, i, cnt, R, num;
string str, s;
string ring[101];
int main(){
    cin >> str >> N;
    S = str.size();
    for (i=0; i<N; i++){
        cin >> s;
        ring[i] = s + s;
    }
    cnt = 0;
    for (i=0; i<N; i++){
        R = ring[i].size();
        for (num = 0; num < R-S+1; num++){
            if( ring[i].substr(num,S) == str ){
                cnt++; break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

C++: #include<iostream>

using namespace std;

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

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int n, p[2], c[2];
  while(scanf("%d", &n) && n){
    p[0] = p[1] = 0;
    while(n--){
      scanf("%d%d", c, c+1);
      if(c[0] > c[1]) p[0] += c[0]+c[1];
      else if(c[0] < c[1]) p[1] += c[0]+c[1];
      else p[1] += c[1], p[0] += c[1];
    }
    printf("%d %d\n", p[0], p[1]);
  }
  return 0;
}

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

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

C++: #include<iostream>

using namespace std;

int main(){
	int n, stage, stage2, i;

	while (true) {
		int left = 0, right = 0;
		cin >> n;
		if(n == 0) break;
		for(i = 0; i < n; i ++){
			cin >> stage >> stage2;
			if(stage > stage2) left += stage + stage2;
			else if(stage < stage2) right += stage + stage2;
			else{
				left += stage;
				right += stage2;
			}
		}
		cout << left << " " << right << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main () {
    int a, b, n, scorea, scoreb;
    while (1) {
        scanf("%d", &n);
        if (n == 0) break;
        while (n--) {
            scanf("%d %d", &a, &b);
            if (a == b) {
                scorea += a;
                scoreb += b;
            }
            else if (a > b) {
                scorea += a + b;
            } else {
                scoreb += a + b;
            }
            printf("%d %d\n", scorea, scoreb);
        }
    }

    return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,asum,bsum,a,b,i;
	while(1){
		cin>>n;
		if(n==0)break;
		asum=0; bsum=0;
		for(i=0;i<n;i++){
			cin>>a>>b;
			if(a==b)asum+=a,bsum+=b;
			if(a>b)asum+=a+b;
			if(b>a)bsum+=a+b;
		}
		cout<<asum<<' '<<bsum<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
int main() {
	int n;
	int g = 0;
	int s = 0;
	int a, b;
	std::cin >> n;
	for (int i = 0; i<n; ++i) {
		std::cin >> a >> b;
		if (a == b)g += a, s += b;
		if (a>b) g += a + b;
		if (a<b) s += b + a;
	}
	std::cout << g << " " << s << std::endl;
	return 0;
}

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

int main() {
    int N=0;
    while(cin >> N && N!=0) {
        vector<int> A(N), B(N);
        for(int i=0; i<N; ++i) cin >> A[i] >> B[i];

        int ret_a=0, ret_b=0;
        for(int i=0; i<N; ++i) {
            if(A[i] < B[i]) {
                ret_b += A[i]+B[i];
            } else if(A[i] > B[i]) {
                ret_a += A[i]+B[i];
            } else {
                ret_a += A[i]; ret_b += B[i];
            }
        }
        cout << ret_a << " " << ret_b << endl;
    }
}

C++: #include<iostream>

using namespace std;

int main(){

  int n,A,B;

  A=0;
  B=0;

  for( ; ; ){

  cin>> n;

  if(n==0)break;

   for(int i=0;i<n;i++){
 
     int a,b;

     cin>>a>>b;

     if(a>b){
       A=A+a+b;
     }
     if(a<b){
       B=B+a+b;
     }
     if(a==b){
       A=A+a;
       B=B+b;
     }
   }
   cout<<A<<" "<<B<<endl;
  }

  return 0;
}

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

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

C++: #include<iostream>
#include<vector>
int main() {
	int vec=0;
	int n;
	int a=0;
	int b=0;
	int game_a, game_b;
	std::vector<int>veca, vecb;
	while (1) {
		std::cin >> n;
		if (n == 0)break;
		else {
			for (int i = 0; i < n; ++i) {
				std::cin >> game_a>>game_b;
				if (game_a > game_b)a += game_a + game_b;
				else b += game_a + game_b;
			}
			veca.push_back(a); vecb.push_back(b);
		}
	}
	for (int i = 0; i < veca.size(); ++i) {
		std::cout << veca[i] <<" "<<vecb[i]<< std::endl;
	}
	return 0;
}