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) break;

        int a = 0, b = 0;
        while(N--) {
            int i, j;
            cin >> i >> j;
            if(i > j) a += i+j;
            else if(i < j) b += i+j;
            else {
                a += i;
                b += j;
            }
        }
        cout << a << ' ' << b << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <iostream>
using namespace std;
int main (){
while (1){
int i,ny[100]={0},ny2[100]={0},sum=0,sum2=0;
scanf ("%d",&i);
if (i==0)break;
for (int s=0;s<i;s++){
        scanf ("%d%d",&ny[s],&ny2[s]);
}
for (int s=0;s<i;s++){
        if (ny[s]==ny2[s]){
        sum=sum+ny[s];
        sum2=sum2+ny2[s];
        }
        else if (ny[s]>ny2[s]){
                sum=sum+ny[s]+ny2[s];
        }
        else {
                sum2=sum2+ny[s]+ny2[s];
        }
}
printf ("%d %d\n",sum,sum2);
}
return -1;
}

C++: #include <iostream>

int main(int argc, char **argv){
	int n = 0;
	while(std::cin >> n, n > 0){
		int a = 0;
		int b = 0;
		int a_score = 0;
		int b_score = 0;

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

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

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int c;
	int a,b;
	int tokuten1 = 0;
	int tokuten2 = 0;
	
	while (cin >> c) {
		if (c == 0) {
			break;
		}
		for (int i = 0; i < c; i++) {
			cin >> a >> b;
			if (a > b) {
				tokuten1 += (a + b);
			} else if (a < b) {
				tokuten2 += (a + b);
			} else {
				tokuten1 += a;
				tokuten2 += b;
			}
		}
		cout << tokuten1 << " " << tokuten2 << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n[10000000],s1,s2;
int main(){
int p,a,b;
cin>>p;
for(int i=0;i<p;i++){
cin>>a>>b;
if(a>b){s1+=a+b;}
else if(b>a){s2+=a+b;}
else{s1+=a;s2+=b;
}
cout<<s1<<' '<<s2<<endl;
}

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

int main() {
	int n,i,result[2] = {0,0};
	cin >> n;
	int num[2];
	for(i = 0;i < n;i++){
		cin >> num[0] >> num[1];
		if(num[0] > num[1])result[0]+= num[0] + num[1];
		else if(num[0] < num[1])result[1]+= num[0] + num[1];
		else{
			result[0] += num[0];
			result[1] += num[1];
		}
	}
	cout << result[0] << " " << result[1] <<endl;
	return 0;
}

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

int main()
{	
	
	int n;
	while(cin>>n){
		if(n==0) return 0;
		
		int a[n], b[n];
		int a_cnt=0, b_cnt=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		for(int i=0;i<n;i++){
			if(a[i]>b[i]){
				a_cnt += a[i] + b[i];
			}else if(a[i]==b[i]){
				a_cnt += a[i]; b_cnt += b[i];
			}else{
				b_cnt += b[i] + a[i];
			}
		}
		cout<<a_cnt<<' '<<b_cnt<<endl;
	}
	return 0;
}

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

int main()
{
  int n;
  int i = 0;
  cin >> n;

  int *a = new int[n];
  int *b = new int[n];

  while (i < n) {
    cin >> a[i];
    cin >> b[i];
    i++;
  }

  i = 0;
  int sum_a = 0;
  int sum_b = 0;
  while (i < n) {
    if (a[i] < b[i]) {
      sum_b += a[i] + b[i];
    } else if (a[i] > b[i]) {
      sum_a += a[i] + b[i];
    } else {
      sum_a += a[i];
      sum_b += b[i];
    }
    i++;
  }

  cout << sum_a
       << " "
       << sum_b
       << endl;    
  
  delete [] a;
  delete [] b;
  
  return (0);
}

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

using namespace std;

int main(){
	int n;
	int inputa,inputb;
	int atotal,btotal;
	vector<int> a;
	vector<int> b;
	while(cin >> n, n !=0){
		a.clear();
		b.clear();
		atotal=btotal=0;
		for(int i=0;i<n;i++){
			cin>>inputa>>inputb;
			if(inputa > inputb){
				atotal += inputa + inputb; 
			}else if(inputa < inputb){
				btotal += inputa + inputb;
			}else{
				atotal +=inputa;
				btotal +=inputb;
			}
		}
		cout<<atotal<<" "<<btotal<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cstdio>
using namespace std;
int main(){
	int n,a[10000],b[10000],i,Acount=0,Bcount=0;
	while(cin>>n){
		if(n==0)break;
		for(i=0;i<n;i++){
			cin>>a[i]>>b[i];
			if(a[i]>b[i])Acount+=a[i]+b[i];
			else if(a[i]<b[i])Bcount+=a[i]+b[i];
			else {
				Acount+=a[i];
				Bcount+=b[i];
			}
		}
		cout<<Acount<<" "<<Bcount<<endl;
		Acount=0;
		Bcount=0;
	}
	return 0;
}

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 namespace std;

int main(){
  int n;
  cin >> n;
  int a,b;a
  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 <stdio.h>
int main()
{
	int n=1,b[10000]={0},c[10000]={0},i,e=0,f=0;
	while(n!=0){
		scanf("%d",&n);
		if(n==0){continue;}
		for(i=0;i<n;i++)
		{
			scanf("%d %d",&b[i],&c[i]);
		}
		for(i=0;i<n;i++)
		{
			if(b[i]>c[i]){e+=(b[i]+c[i]);}
			else if(b[i]<c[i]){f+=(b[i]+c[i]);}
			else{e+=b[i];f+=c[i];}
		}
		printf("%d %d\n",e,f);
		e=0;f=0;
	}
	return 0;
}

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

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

int main()
{
	while (1) {
		int n;
		cin >> n;
		if (n == 0)
			break;
		int a, b, A, B;
		A = 0;
		B = 0;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b)
				A += a + b;
			if (a < b)
				B += a + b;
			if (a == b) {
				A += a;
				B += b;
			}
		}
		cout << A << " " << B << endl;
	}
	return 0;
}