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 euclid(int a, int b){
	int l = max(a, b);
	int r = min(a, b);
	int buf;
	if(a==0 || b==0) return 0;

	while(r!=0){
		buf = r;
		r = l%r;
		l = buf;
	}
	return l;
}
int main(){
	int a,b,ret;
	while(cin>>a>>b, !cin.eof()){
		ret = 0;
		cout<<euclid(a,b)<<endl;
	}
}

C++: #include<algorithm>
int a,b;main(){while(~scanf("%d%d",&a,&b);printf("%d\n",std::__gcd(a,b)));}}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){

    long long int a,b;
    while(cin>>a>>b)cout<<__gcd(a,b)<<endl;


    return 0;
}

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

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

C++: int gcd(a,b){return b?gcd(b,a%b):a;}
main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",gcd(a,b));}

C++: #include<iostream>
#include<stdio.h>
#include<cmath>
#define INF 9999999
using namespace std;
int a,b,c;
int main(){
	while(cin>>a>>b){
		while(b!=0){
			c=a%b;
			a=b;
			b=c;
		}
		cout<<a<<endl;
	}
	return 0

C++: #include <iostream>

using namespace std;

int main(){

int x,y,z;

cin >> x >> y;

while(true){
if(x > y){
z = x % y;
x = x - z;
}
if(y > x){
z = y % x;
y = y - z;
}
if(x == 0 || y == 0)break;
}

cout << z;

}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#include<numeric>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b;
    while(cin>>a>>b){
        for(int i=1000000;i>=0;i--)
            if(a>=i&&b>=i&&a%i==0&&b%i==0)
            {cout<<i<<endl; break;}
    }
}

C++: #include <iostream>
using namespace std;
int main(){
  int a,b;
  while( cin >> a >> b ){
    if(a < b)swap(a,b);
    int c;
    while(1){
      c=a%b;
      a = b;
      b = c;
      if(c == 0)break;
    }
    cout << a << endl;
  }
}

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

int main(){

  long long int n,m,a,b,c;

  while(cin >> n >> m){
    a = max(n,m);
    b = min(n,m);
    c = a % b;
    a = b;
    b = c;
    while(a % b != 0){
      c = a % b;
      a = b;
      b = c;
    }

    cout << b << endl;
  }
}

C++: #include <iostream>
using namespace std;
int main(){
    int a,b;
    while(cin>>a>>b){
        int r=1;
        while(r!=0){
            r=a%b;
            a=b;
            b=r;
        
            
        }
       cout<<a<<endl;
}
}

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

int main() {
	int a, b, r;
	while(cin >> a >> b){
		if(a<b){
			int tmp = a;
			a = b;
			b = tmp;
		}
		r = a%b;
		while(r != 0){
			a = b;
			b = r;
			r = a%b;
		}
		cout << b << endl;
	}
	
	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 {
                cout << b << endl;
                break;
            }
        }
    }
}

C++: 
#include <iostream>

int gcd(int m, int n);


int main(int argc, const char * argv[])
{
    //std::cout << "Hello World\n";
    while(true){
        int n, m;
        std::cin >> n >> m;
        //std::cout << n << "," << m << "\n";
        std::cout << gcd(n, m) << "\n";
    }
    return 0;
}

int gcd(int m, int n){
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

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

int gcd(int x, int y) {
	if (y == 0) return x;
	else return gcd(y, x % y);
}

int main(){
    int a, b;
    while( scanf("%d %d", &a, &b) != EOF ){
        cout<<gcd(a,b)<<endl;
    }
    return 0;
}

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

int gcd(int x, int y) {
	if (y == 0)return x;
	else return gcd(y, x%y);
}

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

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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};


//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b;
	while(!cin.eof() && cin >> a >> b){
		if(b > a){
			int temp = b;
			b = a;
			a = temp;
		}
		while(b > 0){
			int z  = a % b;
			a = b;
			b = z;
		}
		cout << a << endl;
	}
	
	return 0;
}

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

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

C++: #include<stdio.h>
int main(){
  int x,y;
  for(;scanf("%d%d",&x,&y)>0;){
    for(;y!=0;){
      int r=x%y;x=y;y=r;
    }
    printf("%d\n",x);
  }
}