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++: // AOJ 1009
#include <iostream>
#include <cstdio>

using namespace std;

int GCD(int a, int b)
{
	while (1){
		a %= b;
		if (a == 0) return b;
		b %= a;
		if (b == 0) return a;
	}
}

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

C++: #include <stdio.h>
int gcd(int a, int b) {while (b) {int c=a%b;a=b,b=c;} return a;} int main() {int a,b;while (scanf("%d %d",&a,&b)!=EOF) printf("%d\n",gcd(a,b));return 0;}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b;
	while (cin >> a >> b) {
		for (int i = min(a,b); i > 0; i--)
		{
			if (a%i == 0 && b%i == 0)
			{
				cout << i << endl;
				goto Cpp;
			}
		}
		Cpp:
		for (int i = 0; i < 1; i++)
		{

		}
	}
}

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

int gcd(int a, int b) {
  if(b == 0) return a;
  return 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 main(){
    int x,y,q,r;
    while(cin >> x >> y){
        while(1){
            q = x/y;
            r = x - q*y;
            if(r == 0) break;
            x = y;
            y = r;
        }
        cout << y << endl;
    }
}

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

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

  int a,b;

  scanf("%d %d",&a,&b);
  
  while(1){
    if(a<b){
      swap(a,b);
    }
    if(a%b == 0){
      printf("%d\n",b);
      break;
    } else {
      swap(a,b);
      b = b%a;
    }
  }

  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++: #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>
#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[1];
			a[1] = a[1] % a[0];
			a[0] = d;
		}
	}
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    int t,s;
    vector<int>v;
    while(cin>>t>>s)
    {
        if(t==0)cout<<s<<endl;continue;

        for(int i=1;i<t;i++)
        {
           if(s%i==0&&t%i==0)v.push_back(i);
        }
        int n=v.size();
        sort(v.begin(),v.end());
        cout<<v[n-1];
        cout<<endl;
        v.clear();
    }
    return 0;

}

C++: #include <iostream>
using namespace std;
int gcd(int m, int n)
{
	int t;
	if (m < n) swap(m, n);
	while (n != 0)
		t = n, n = m % n, m = t;
	return m;
}
int main()
{
	int a, b;
	while (cin >> a)
	{
		if (cin.eof()) break;
		cin >> b;
		cout << gcd(a, b) << 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 <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  while(cin>>a>>b){
  c=a<b?a:b;
  while(1){if(b%c==0&&a%c==0)break;c--;}
  cout<<c<<endl;}
}

C++: #include <stdio.h>

int main(){
int x,y;

while(cin >> x >> y){

while(x % y != 0){
if(x > y)
x = x % y;
}
cout << x << endl;
}

}

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


void tmp(int* n,int* m)
{
	int t = *n;
	*n = *m;
	*m = t;
	return;
}

int gcd(int n,int m)//n>mªð
{
	if(n<m)
		tmp(&n,&m);
	if(m==0)
		return 0;
	if(n%m==0)
		return m;
	else
		gcd(m,n%m);
}

int main()
{
	int n,m;
	while(cin>>n && cin>>m)
		cout << gcd(n,m) << endl;
	return 0;
}

C++: #include <stdio.h>

int gcd(int x, int y){
	return x<y?gcd(y, x):y?gcd(y, x-y):x;
}

int main(void){
	int x, y;
	
	while (scanf("%d%d", &x, &y)!=EOF){
		printf("%d\n", gcd(x, y));
	}
	
	return 0;
}

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

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

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

int gcd(int a, int b) {
	int c;
	for (int i = 1; i < 10000000; i++) {
		if (a%i == 0 && b%i == 0) {
			c = i;
		}
	}
	return c;
}

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

C++: #include <iostream>

using namespace std;

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)
		{
			int temp = a;
			a = b;
			b = temp;
		}
		cout << gcd(a, b) << endl;
	}
}

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

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

  int a,b;

  while(scanf("%d",&a) != EOF){
    scanf("%d",&b);
    while(1){
      if(a<b){
	swap(a,b);
      }
      if(a%b == 0){
	printf("%d\n",b);
	break;
      } else {
	swap(a,b);
	b = b%a;
      }
    }
  }
  return (0);
}

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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int l, r;

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

void solve() {
  int a = max(l,r), b = min(l,r);
  cout<<gcd(a,b)<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>l>>r) {
    solve();
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

int x,y;

cin >> x >> y;

while(x != y){
if(x > y)x = x - y;
if(y > x)y = y - x;
}
cout << x;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int GCD(int a, int b){
	int large, small, surplus;
	large = max(a, b);
	small = min(a, b);
	surplus = large % small;
	if(surplus == 0){
		return small;
	}else{
		return GCD(small, surplus);
	}
}

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

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

int gcd(int m, int n)
{
	return (m%n==0)?n:gcd(n,m%n);
}

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