Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for {
		if sc.Scan() == false {
			break
		}
		str := sc.Text()
		cols := strings.Split(str, " ")
		n, _ := strconv.Atoi(cols[0])
		m, _ := strconv.Atoi(cols[1])
		var gcd int
		if n > m {
			gcd = getGcd(n, m)
		} else {
			gcd = getGcd(m, n)
		}
		fmt.Println(gcd)
	}
}

func getGcd(n int, m int) int {
	var mod int
	nn := n
	mm := m
	for {
		mod = nn % mm
		if mod == 0 {
			break
		}
		nn = mm
		mm = mod
	}
	return mm
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main( void )
{
	int x, y;
	while ( cin >> x >> y )
	{
		if ( x > y )
			swap( x, y );

		while ( x != 0 && y != 0 )
		{
			y = y % x;
			if ( x > y )
				swap( x, y );
		}

		cout << y << endl;

	}
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m;
	while(cin>>n){
		cin>>m;
		int res=1;
		while(res){
			res=n%m;
			n=m;
			m=res;
		}
		cout<<n<<endl;
	}
	return 0;
}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int a,b;
	while(cin>>a>>b){
		cout <<__gcd(a, b)<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

typedef pair<int,int> P;

const int INF=INT_MAX/3;
//const int V_MAX=10000,E_MAX=10000;
//int V,E;
const int N=10000;

int gcd(int a,int b){
  if(b==0) return a;
  return gcd(b,a%b);
}



int main(){
  int a,b;
  while(cin>>a>>b)
    cout<<gcd(a,b)<<endl;

  return 0;
}

C++: #include <iostream>

int eucgcd(int m, int n)
{
	int p = m%n;
	
	while( p > 0 )
	{
		m = n;
		n = p;
		p = m%n;
	}
	
	return n;
}


int main()
{
	int m,n;
	
	while( std::cin >> m >> n, (m||n) )
	{
		if( m >= n )
			std::cout << eucgcd(m, n) << std::endl;
		else
			std::cout << eucgcd(n, m) << std::endl;
	}
	
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int x,y,i,j,k,c,s,d,gcd=0;
	for(i=0;i<49;i++){
		cin>>x>>y;
		if(x>y){
			for(j=1;j<=x;j++){
				k=x%j;
				c=y%j;
				if(k==0&&c==0){
					gcd=j;
				}
				if(j==x){
					cout<<gcd<<endl;
				}
			}
		}else{
			for(j=1;j<=y;j++){
				s=x%j;
				d=y%j;
				if(s==0&&d==0){
					gcd=j;
				}
				if(j==y){
					cout<<gcd<<endl;
				}
			}
		}

	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<ll> divisor(ll n) {
    vector<ll> res;
    for(ll i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

int main() {
    int a,b;
    while(cin >> a >> b) {
        map<int,int> m;
        vector<ll> v = divisor(a);
        rep(i,v.size()) {
            m[v[i]]++;
        }

        v = divisor(b);
        rep(i,v.size()) {
            m[v[i]]++;
        }

        int ans = 1;
        map<int,int>::iterator ite;
        for(ite = m.begin(); ite != m.end(); ite++) {
            if(ite->second == 2) {
                ans = max(ans, ite->first);
            }
        }

        cout << ans << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int *a, *b, s, t, c;
	int p, q;
	a = &p;
	b = &q;
	while(cin >> p >> q){
		s = *a;
		t = *b;
		c = 1;
		for(int tmp = (*a > *b)? *b : *a, i = 2; i <= tmp; i++){
			while(s%i == 0 && t%i == 0){
				s /= i;
				t /= i;
				tmp /= i;
				c *= i;
			}
		}
		cout << c << " " << endl;
}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int x,y,i,j,k,c,s,d,gcd=0;
	for(i=0;i<49;i++){
		cin>>x>>y;
		if(x==0&&y==0)
			cout<<"0"<<endl;
		if(x>y){
			for(j=1;j<=x;j++){
				k=x%j;
				c=y%j;
				if(k==0&&c==0){
					gcd=j;
				}
				if(j==x){
					cout<<gcd<<endl;
				}
			}
		}else{
			for(j=1;j<=y;j++){
				s=x%j;
				d=y%j;
				if(s==0&&d==0){
					gcd=j;
				}
				if(j==y){
					cout<<gcd<<endl;
				}
			}
		}

	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int *a, *b, s, t, c;
	int p, q;
	a = &p;
	b = &q;
	while(cin >> p >> q){
		s = *a;
		t = *b;
		c = 1;
		for(int tmp = (*a > *b)? *b : *a, i = 2; i <= tmp; i++){
			while(s%i == 0 && t%i == 0){
				s /= i;
				t /= i;
				tmp /= i;
				c *= i;
			}
		}
		cout << c << endl;
}
	return 0;
}

C++: #include <stdio.h>

int gcd(int x, int y){
	return x<y?gcd(y, x):y?gcd(y, x-y):x;
}

int main(void){
	int x, y;
	
	while (scanf("%d", &x), x!=EOF){
		scanf("%d", &y);
		printf("%d\n", gcd(x, y));
	}
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
int main(){
    int a,b;
    while(cin>>a>>b){
        if(a<b)swap(a,b);
        for(int i=a;i>0;i--){
            if(b%i==0&&a%i==0){
                cout<<i<<endl;
                break;
            }
        }
    }
}

C++: #include <iostream>

using namespace std;

int gcd (int a, int b )
{
	if (a > b ){
		swap (a, b );
	} // end if
	while (b % a != 0 ){
		b = b % a;
		if (a > b ){
			swap (a, b );
		} // end if
	} // end while

	return a;
}

int main()
{
	int n, m;

	while (cin >> n >> m ){
		int res = gcd (n, m );
		cout << res << endl;
	} // end loop
		
	return 0;
}

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

int main(){
	int a,b,r;
	while(cin >> a >> b){
		if(a<b){ r=a; a=b; b=r; }
		r=a%b;
		if(r==0){ cout << b << endl; }
		while(1){
			a=b;
			b=r;
			r=a%b;
			if(r==0){ cout<<b<<endl; break; }
		}
	}
}

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

int GCD( int a, int b )
{
    if( a % b == 0 )
        return b;
    return GCD( b, a % b );
}

int main()
{
    int a, b;

    while( cin >> a >> b )
        cout << GCD( a, b ) << endl;

    return 0;
}

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

int main(){

  int n,m;
  while(cin >> n >> m) {

    if(n > m) swap(n,m);

    while(n != 0) {
      int t = n;
      n = m % n;
      m = t;
    }
    cout << m <<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef pair<int,string> P;
typedef long long int lld;
#define INF (1<<20)

int gcd(int x,int y) {
  int t;
  while(y!=0) {
    t = x % y;
    x = y;
    y = t;
  }
  return x;
}

int main(){
  int a,b;
  while(cin >> a >> b){
    cout << gcd(a,b) << endl;
  }
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int gcd(int m,int n)
 {
    return n==0 ? m: gcd(n,m%n);    
 }
 
 int main()
 {
   int m,n;
   while(cin>>m>>n)
   {
     int result=gcd(m,n);
     cout<<result<<endl;                  
   }
   //while(1);
   return 0;
 }