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>

using namespace std;
int euclid(int n, int m);

int main(){
  int n,m;
  while(cin>>n>>m){
    cout <<euclid(n,m)<<endl;
  }
}

int euclid(int n,int m){
  if(n<m){
  int temp;
  temp=m;
  m=n;
  n=temp;
  }
  if(n%m==0){
    return m;
  }else{
    return euclid(m,n%m);
  }
}

C++: #include <iostream>

using namespace std;

int gcd(int a,int b) {

  if(b==0) return a;

  else 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)
{
	if( n == 0 )
		return m;
	else 
		return eucgcd( n, m%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 <stdio.h>
#include <string.h>

long int gcd(long int a, long int b)
{
return (b==0 ? a : gcd (b, a%b));
}
int main()
{
    long long a, b;
    while(scanf ("%lld %lld", &a, &b) != EOF)
    {
              long long x = gcd(a,b);
              printf("%d\n", x);
    }
return 0;
}

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

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

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

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;



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

    
    return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;

int tx[] = {1,0};
int ty[] = {0,1};

ll GCD(ll a ,ll b){
	return b > 0 ? GCD(b,a%b) : a;
}

int main(){
	int a,b;
	while(~scanf("%d %d",&a,&b)){
		printf("%lld\n",GCD(a,b));
	}
}

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

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

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b){
    while(b){
      a%=b;
      swap(a,b);
    }
    cout<<a<<endl;
  }
  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){
	int c;
	if(a<b){
		a+=b;b=a-b;a-=b;
	}
	while(b!=0){
		c=a%b;
		a=b;
		b=c;
	}
	return a;
}

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

C++: #include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

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

void solve(){
  int a,b;
  while(cin>>a>>b){
    if(a<b){
      swap(a,b);
    }
    cout<<gcd(a,b)<<endl;
  }
}

int main(void){
  solve();
  return 0;
}

C++: #include <iostream>

using namespace std;

int gcd(int m, int n){
	if(m < n){ return gcd(n, m); }
	if(n == 0){ return m; }
	if(m % n == 0){ return n; }
	return gcd(n, m % n);
}

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

C++: // AOJ 1009
#include<cstdio>

int gcd( int a, int b )
{
	if( !b )
		return a;

	return gcd( b, a%b );
}

int main()
{
	int a, b;
	while( scanf( "%d%d", &a, &b ) != EOF )
		printf( "%d\n", gcd( a, b ) );

	return 0;
}

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

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

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

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

int GCD(int n, int m){
  if (n == 0) return m;
  return GCD(m % n, n);
}

int main()
{
  int n, m;

  while (cin >> n >> m){
    if (n > m){
      int c = n;
      n = m;
      m = c;
    }
    cout << GCD(n, m) << endl;
  }

  return 0;
}

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