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>                                                  
using namespace std;                                                 
                                                                     
int main() {                                                         
  while (true) {                                                     
    int n;                                                           
    cin >> n;                                                        
    if (n==0) {                                                      
      break;                                                         
    }                                                                
    int A, B;                                                        
    int Ascore = 0, Bscore = 0;                                      
    for (int i=0; i<n; i++) {                                        
      cin >> A >> B;                                                 
      if (A>B) {                                                     
        Ascore += (A+B);                                             
      } else if (B>A) {                                              
        Bscore += (A+B);                                             
      } else {                                                       
        Ascore += A;                                                 
        Bscore += B;                                                 
      }                                                              
    }                                                                
    cout << Ascore << " " << Bscore << endl;                         
  }                                                                  
  return 0;                                                          
}

C++: #include<iostream>
int main(){
int a;
std::cin>>a;
std::cout<<a;
return 0;
}

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

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

int main() {
	int q[10000 - 1], w[10000 - 1];
	int n;
	int a = 0;
	int b = 0;
	int x = 1;
	while (x == 10000) {
		cin >> n;
		if (n == 0) {
			break;
		}

		for (int i = 1; i <= n; ++i) {
			int c, d;
			cin >> c >> d;
			if (c == d) {
				a = a + c;
				b = b + d;
			}
			else if (c > d) {
				a = a + c + d;
			}
			else {
				b = b + c + d;
			}
		}
		q[x] = a;
		w[x] = b;
		x++;
	}
	for (int j = 1; j <= x; ++j) {
		cout << q[j] << " " << w[j] << endl;
	}
}

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

int main() {
	int i, a, b, n, ap, bp;

	while (1) {
		cin >> n;
		if (n == 0)break;
		ap = bp = 0;
		for (i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b) {
				ap += a + b;
			} else if (a < b) {
				bp += a + b;
			} else {
				ap += a;
				bp += b;
			}
		}
		cout << ap << " " << bp << endl;
	}
	return 0;
}

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

int main()
{
    int n;
    int sum_A[5];
    int sum_B[5];
    int A, B;
    int j = 0;

    while (n != 0){
        cin >> n;
        
        for (int i = 0; i < n; i++){
            cin >> A;
            cin >> B;
            if (A > B){
                sum_A[j] += A + B;
            }
            else {
                sum_B[j] += A + B;
            }
            A = 0;
            B = 0;
        }
        for (int l = 0; l < j; l++){
            cout << sum_A << " " << sum_B << endl;
        }
        j++;
    }
    return (0);
}

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

C++: #include <iostream>

using namespace std;

int main(){
	int n, asco, bsco;
	int a[10000], b[10000];

	while (cin >> n, n != 0){

		asco = bsco = 0;

		for (int i = 0; i < n; i++){
			cin >> a[i] >> b[i];
			
			if (a[i] == b[i]){
				asco += a[i];
				bsco += b[i];
			}
			else if(a[i] > b[i]){
				asco += a[i] + b[i];
			}
			else {
				bsco += a[i] + b[i];
			}
		}

		cout << asco << " " << bsco << endl;
	}
	return 0;
}

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

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
     
using namespace std;

main {
  int n;
  for(;;) {
    cin>>n;
    if(n==0)break;
    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=d;}
     }
    cout<<a<<' '<<b<<endl;
  }
  bye;
}

C++: #include <iostream>
using namespace std;
 
int main() {
  int n, a, b, pointA, pointB;

  cin >> n;
  while(n != 0) {
    

    pointA = 0;
    pointB = 0;

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

    cout << pointA << ' ' << pointB << endl;
    cin >> n;
  }   
 
  return 0;
}

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

int main() {
  int d;
  while(true) {
    cin>>d;
    if(d==0) break;

    int a,b,sa=0,sb=0;
    for(int i=0; i<d; i++) {
      cin>>a>>b;
      if(a>b) sa+=a+b;
      else if(b>a) sb+=a+b;
      else sa+=a,sb+=b;
    }

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
int n,q,s,k,h,w,r;
int a[100000];
int d[100000][20],g[20];
void BNS(int x){
	int left=0,sea=19,ran=10;
	while(true){
		sea-=ran,ran/=2;
		if(g[sea]<=x)left=max(sea,left),sea+=ran*2;
		if(!ran)break;
	}
	h=left,w=g[h];
	return;
}
int main(){
	cin>>n;
	w=1,h=0;while(w<=n)w*=2,h++;
	for(int i=0;i<n;i++){cin>>a[i];d[i][0]=a[i];}
	w=1;
	for(int i=1;i<h;i++){
		w*=2;
		for(int j=0;j<=n-w;j++)d[j][i]=min(d[j][i-1],d[j+w/2][i-1]);
	}
	w=1;for(int i=0;i<20;i++)g[i]=w,w*=2;
	cin>>q;
	for(int u=0;u<q;u++){
		scanf("%d%d",&s,&k);
		BNS(k);
		printf("%d\n",min(d[s][h],d[s+k-w][h]));
	}
	return 0;
}

C++: #include<iostream>
int main() {
	int vec=0;
	int n;
	int a=0;
	int b=0;
	int game_a, game_b;
	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; b += game_b; }
				else if (game_a > game_b)a += game_a + game_b;
				else b += game_a + game_b;
			}
			std::cout << a << " " << b << std::endl; a = 0; b = 0;
		}
	}
	return 0;
}