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 <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>1;i--){
            if(b%i==0&&a%i==0){
                cout<<i<<endl;
                break;
            }
        }
    }
}

C++: #include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int a, b;
	while (cin >> a >> b) {
		cout << a - b << endl;
	}
}

C++: 
#include <stdio.h>
#include <iostream>
#include <map>
#include <set>
using namespace std;

typedef long long int ll;

ll solve(ll p, ll q);

int main(void) {

	ll p, q;
	while(true) {
		if( cin.eof() ) { break; }
		cin >> p >> q;
		cout << solve( p, q ) << endl;
	}

	return 0;
}

ll solve( ll p, ll q ) {
	if( q == 0 ) return p;
	return solve( q, p%q );
}

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

int main() {
  int a, b;
  while(cin >> a >> b) {
    int t;
    if(a > b) t = b;
    else      t = a;

    for(; t >0; t--) {
      if(a % t == 0 && b % t == 0) break;
    }
    cout << t << endl;
  }
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  while(cin >> a >> b){
    cout << gcd(a,b)<<endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	long long n, m;
	while (cin >> n >> m) cout << __gcd(n, m) << endl;
	return 0;
}

C++: #include<stdio.h>

int main(){
	int a,b,t;
	
	while(0<=scanf("%d%d",&a,&b)){
		if(a<b){
			t=a;
			a=b;
			b=t;
		}
		while(a%b!=0){
			a=a%b;
			if(a<b){
				t=a;
				a=b;
				b=t;
			}
//			printf("%d %d\n",a,b);
		}
		
		printf("%d\n",b);
	}
	return 0;
}

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 if(a > b){
                c = a % b;
            }
            else {
                cout << b << endl;
                break;
            }
            if(c != 0){
                a = b;
                b = c;
            }
            else {
                if(a > b){
                    cout << b << endl;
                    break;
                }
                else {
                    cout << a << endl;
                    break;
                }
            }
        }
    }
}

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

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

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 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++: #define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, m, n) for(int i = m; i >= n; i--)

int gcd(int u, int v){
	while(u > 0){
		if(u < v) swap(u, v);
		u %= v;
	}
	return v;
}
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(void){
	int a,b;
	while(cin>>a>>b)
	cout<<__gcd(a,b)<<endl;
}

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

template <typename T>
T gcd(T a, T b){
	T r;
	while(b > 0){
		r = a % b;
		a = b;
		b = r;
	}
	return a;
}

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

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

int main() {
	vector<int>a(2);
	while (cin>>a[0]>>a[1]) {
		while (1) {
			sort(a.begin(), a.end());
			if (a[1] % a[0] == 0) { cout << a[0] << endl; break; }
			int d = a[0];
			a[0] = a[1] % a[0];
			a[1] = d;
		}
	}
}

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

int gcdf(int a,int b)
{
	return(b==0?a:gcdf(b,a%b));
}
int gcd(int a,int b){
	return(a>b?gcdf(a,b):gcdf(b,a));
}

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

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

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

C++: #include <stdio.h>
int gcd(int a,int b){
if(b==0)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);
}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int x,y,z;
  while(cin >> x >> y){
    if(x<y) swap(x,y);
    while((z=x%y)!=0){
      x=y;
      y=z;
    }
    cout << y << endl;
  }
}