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 <bits/stdc++.h>
using namespace std;

#define INF_MAX 	2147483647
#define INF_MIN 	-2147483648
#define INF 		(1 << 30)
#define SORT(a,n)   sort(a,a+n)
#define EPS			1e-9
#define PI 			acos(-1.0)
#define N 		    2 + 100
#define MOD			10000000007
#define sz(x) 		(int)(x).size()
#define all(x) 		(x).begin(), (x).end()
#define pb 			push_back
#define mp			make_pair
#define ms(x, a) 	memset((x), (a), sizeof(x))
#define ff           first
#define ss           second
#define rep(i,a,b)  for(int i=(a); i<(b); i++)
#define repC(i,x) 	for(size_t i=0; i<x.size(); i++)
#define repIT(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define nn          '\n'
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define i64 __int64
#define isValid(x, y) ( x >= 0 And x < row And y >= 0 And y < col )
#define dump cin.ignore()


typedef long long 		LL;
typedef pair<int,int> 	pii;
typedef vector<int> 	vi;
typedef vector<string> 	vs;
typedef vector<char>	vc;
typedef vector<bool>    vb;
typedef vector< pii >   vii;
typedef map<string,int> msi;
typedef map<int,int>	mii;
typedef map<char,int>   mci;
typedef map<int,string>	mis;

template<class T> T Abs(T x) {return x>0 ? x : -x;}
template<class T> T Max(T a, T b) {return a>b ? a : b;}
template<class T> T Min(T a, T b) {return a<b ? a : b;}
template<class T> T gcd(T a, T b) {return (b ? gcd(b,a%b) : a);}
template< class T > T sq(T x){ return x * x;}
template< class T > T lcm(T a, T b){ return (a / gcd<T>(a, b) * b); }
template< class T > T deb(T cmd) {cout << "debugger:" << endl; cout << cmd << endl;}
template< class T > T deb(T cmd1, T cmd2) {cout << "debugger:" << endl; cout << cmd1 << "\t" << cmd2 << endl;}
template< class T > T deb(T cmd1, T cmd2, T cmd3) {cout << "debugger:" << endl; cout << cmd1 << "\t" << cmd2 << "\t" << cmd3 << endl;}
template< class T > T deb(T cmd1, T cmd2, T cmd3, T cmd4) {cout << "debugger:" << endl; cout << cmd1 << "\t" << cmd2 << "\t" << cmd3 <<"\t" << cmd4 << endl;}
bool isVowel(char ch){ch=tolower(ch);return(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u');}

//int dx[4] = {-1, 0, 0, 1};
//int dy[4] = {0, -1, 1, 0};
//int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
//int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

#define MAX 10000

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("in.txt", "r", stdin);
	#endif

    int a, b;

    while(scanf("%d %d", &a, &b) == 2)
        cout << gcd(a, b) << nn;

    return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

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

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

	return 0;
}

C++: #include <stdio.h>

int main(){
int x,y;

int byakko(int x, inty){
if(x > y)
return x % y;
else
return y % x;

return x;
}

while(scanf("%d %d", &x, &y)){
cout << byakko(x, y) << endl;
}
}

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

int main(){

	int n, m, low;
	
	while(cin >> n >> m){
		low = min(n, m);
		for(int i=low; i>0; i--){
			if(n % i == 0 && m % i == 0){
				cout << i << endl;
				break;
			}
		}
	}

	return 0;

}

C++: #include<iostream>
using namespace std;
int main(){
	long long 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;

long long gcd(long long m, long long n){
	//Euclid's algorithm
	if(m<n){ 
		swap(m, n);
	}

	do {
		if(n==0){
			return m;
		}
		
		int swap = m % n;
		m = n;
		n = swap;
	} while(1);
}

//1009
int main(){

	long long m, n;
	while(cin >> m >> n){
		long long  GCD;
		
		GCD = gcd(m, n);
		cout << GCD <<  endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b){
    int r=a%b; 
    while(r!=0){ 
      a=b; 
      b=r; 
      r=a%b; 
    }
    cout<<b<<endl;
  }
  return 0;
}

C++: #include<iostream>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){for(int a,b;std::cin>>a>>b;std::cout<<gcd(a,b)<<"\n");}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n1,n2,minv,maxv,i;
  while(cin >> n1){
    cin >> n2;
    minv=min(n1,n2);
    maxv=1;
    for(i=1;i<=minv;i++){
      if(n1%i==0&&n2%i==0) maxv=max(maxv,i);
    }
    cout << maxv << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<boost/math/common_factor.hpp>

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

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

  while(cin >> x >> y){
    int temp;
    if(x==0 && y==0) break;
    while(y!=0){
      x = x % y;
      temp = x;
      x = y;
      y = temp;
    }
    cout << x << endl;
  }
  return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

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

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

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

int main(){
  int n,m;

  while(cin>>n>>m){
    if(n<m) swap(n,m);
    int ans = gcd(n,m);
    cout << ans << endl;
  }

  return EXIT_SUCCESS;
}

C++: #include<iostream>
main(){for(int a,b,t;std::cin>>a>>b;printf("%d\n",a))for(;b;a=b,b=t%b)t=a;}

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>
#include <string>
#include <vector>
using namespace std;

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

C++: #include<iostream>
main(){for(int a,b,t;std::cin>>a>>b;printf("%d\n",a))for(;t=b;a=t)b=a%b;}