Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

//Min .
func Min(a, b int) int {
	switch a < b {
	case true:
		return a
	default:
		return b
	}
}

//GCDandLCM .
func GCDandLCM(i []int) (int, int) {
	a := i[0]
	b := i[1]

	for {
		if a == b {
			break
		} else {
			a, b = Min(a, b), int(math.Abs(float64(a-b)))
		}
	}

	return a, i[0] * i[1] / a
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()
		g, _ := GCDandLCM(i)
		fmt.Println(g)
	}

}

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;
}

C++: 


/*
USER:
TASK:
ALGO:
*/
/*
#pragma warning (disable: 4786)
#pragma comment (linker, "/STACK:0x800000")
*/
/*#include <cstring>
#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 <ctime>
#include <memory.h>
#include <cassert>*/
#include<bits/stdc++.h>

#define INF_MAX     2147483647
#define INF_MIN     -2147483648
#define INF         (1 << 30)
#define EPS         1e-9
#define N           2 + 1000000
#define MOD         10000000007
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define Pi acos(-1.0)
#define MP(x, y) make_pair(x, y)
#define REV(s, e) reverse(s, e)
#define SET(p) memset(p, -1, sizeof(p))
#define CLR(p) memset(p, 0, sizeof(p))
#define MEM(p, v) memset(p, v, sizeof(p))
#define CPY(d, s) memcpy(d, s, sizeof(s))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define SZ(c) (int)c.size()
#define PB(x) push_back(x)
#define ff first
#define ss second
#define i64 long long
#define ld long double
#define pii pair< int, int >
#define psi pair< string, int >
#define ALL(c) (c).begin(),(c).end()
#define REP(i, n) for(int i=0; i<(int)n; ++i)
#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 FOR(i, c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
using namespace std;

template< class T > T _abs(T n) { return (n < 0 ? -n : n); }
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 sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template <class T> string toStr(const T &x)
{ stringstream s; s << x; return s.str(); }

template <class T> int toInt(const T &x)
{ stringstream s; s << x; int r; s >> r; return r; }

template<class T> string itoa(T a)
{
    if(!a) return "0";
    string ret;
    for(T i=a; i>0; i=i/10) ret.PB((i%10)+48);
    reverse(ALL(ret));
    return ret;
}
#define on(n,pos) (n | (1LL<<(pos)))
#define off(n,pos) n & ~(1LL<<pos)
#define isOn(n,pos) (bool)(n & (1LL<<(pos)))

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int a, b, gcd = 0;

    while(cin>>a>>b)
    {
        for(int i = 1; i <= a && i <= b; i++)
        {
            if(a % i == 0 && b % i == 0)
            {
                gcd = i;
            }
        }
        cout<<gcd<<endl;
        gcd = 0;
    }
    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(z == x || z == y)break;
}

cout << x;

}

C++: #include <iostream>
#include <vector>

using namespace std;

int get(int, int);

int main(int argc, char *argv[]) {
  int x, y;

  while (cin >> x >> y)
    cout << getLCM(x, y) << endl;
  return 0;
}

int get(int x, int y) {
  int tmp;

  if (x < y) {
    tmp = y;
    y = x;
    x = tmp;
  }
  while (x % y != 0) {
    tmp = x % y;
    x = y;
    y = tmp;
  }
  return y;
}

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);
  }
}