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
}

Python: import math
try:
    while True:
        a,b = input().split(" ")
        print(math.gcd(int(a),int(b)))
except EOFError:
    m = 0

Python: import fileinput

for a, b in (map(int, line.split()) for line in fileinput.input()):
    if a > b:
        a, b = b, a
    while a:
        a, b = b % a, a
    print(b)

Python: while True:
    try:
        a, b= map(int, input().split())
        while b!= 0:
            a, b= b, a%b
        print(a)
    except:
        break

Python: import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    a,b = [int(i) for i in N[l].split()]
    print(math.gcd(a, b))

Python: import math
while True:
    try:print(math.gcd(*map(int,input().split(" "))))
    except:break

Python: # AOJ 1009: Greatest Common Divisor
# Python3 2018.7.4 bal4u

def gcd(a, b):
	while b != 0:
		r = a % b
		a, b = b, r
	return a

while True:
	try: a, b = map(int, input().split())
	except: break
	print(gcd(a, b))

Python: import math
while 1:
    try:
        a,b = map(int,input().split())
        print(math.gcd(a,b))
    except:
        break

Python: import sys
for e in sys.stdin:
    p, q = map(int, e.split())
    if p < q:p, q = q, p
    while True:
        if p % q == 0:
            print(q)
            break
        else:
            p, q = q, p % q

Python: from math import gcd
while True:
    try:
        a, b= map(int, input().split())
        print(gcd(a, b))
    except:
        break

Python: while 1:
    try:a,b=map(int,input().split())
    except:break
    while b:a,b=b,a%b
    print(a)

Python: def main():

    while True:
        try:

            a, b = map(int, input().split())
            print(euclid_algorithm(a, b))

        except EOFError as e:
            break

def euclid_algorithm(a, b):

    while a and b:

        if a > b:
            a = a - b
        else:
            b = b - a

    return a if a else b

if __name__ == '__main__':
    main()

Python: def gcd(x, y):
    if y==0: return x
    z = x % y
    return gcd(y, z)
        
while True:
    try:
        a, b = (int(i) for i in input().split())
    except EOFError:
        break
    if a<b: print(gcd(b,a))
    else: print(gcd(a,b))

Python: import sys

def gcd(a,b):
    if(b):
        return gcd(b,(a%b))
    else:
        return a

List = []
for i in sys.stdin:
    List.append(i)

for data in List:
    print(gcd(int(data.split()[0]),int(data.split()[1])))

Python: from math import gcd
from sys import stdin

for line in stdin:
    a,b = [int(i) for i in line.split()]
    print(gcd(a,b))

Python: # -*- coding: utf-8 -*-
"""


"""
import sys
from sys import stdin
import fractions
input = stdin.readline


def main(args):
    for line in stdin:
        n, m = map(int, line.split())
        print(fractions.gcd(n, m))



if __name__ == '__main__':
    main(sys.argv[1:])

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

int gcd(int i,int j){
	if(j==0) return i;
	if(i < j) swap(i,j);
	return gcd(j,i%j);
}

int main(void){
	int i,j;
	while(cin >> i >> j) cout << gcd(i,j) << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define print(x) cout << (x) << endl
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second

inline int in(){int x;std::cin>>x;return x;}
struct FAST {FAST(){cin.tie(0);ios::sync_with_stdio(false);}} Fast;
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
/* }}} */ 

signed main(void)
{
  int a, b;

  while (cin >> a >> b){
    cout << abs(a - b) << endl;
  }

  return 0;
}

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

using namespace std;

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

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

#include<cstring>
#include<map>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<utility>
#include<sstream>
#include<stack>
using namespace std ;

//#ifndef ONLINE_JUDGE++++
    //freopen("input.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
//#endif



#define pb push_back
#define all(x) x.begin(),x.end()
#define distSqr(x1,y1,z1,x2,y2,z2) (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)
#define dist(x1,y1,x2,y2) sqrt(distSqr(x1,y1,x2,y2))
#define Set(x,v) memset(x,v,sizeof x)
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define pi acos(-1)
#define mp make_pair
#define error 1e-12
#define mod 1000007
#define For(i,n) for(i=0;i<n;i++)
#define inf 1e5

typedef long long ll;
typedef unsigned int ui;

typedef pair<ui,ui> puu;
typedef double db;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,db> pid;
typedef vector<int> VI;
typedef pair<char,char> pcc;

bool chk(int n,int pos) {return n&(1<<pos);}
void set(int& n,int pos) {n=n|(1<<pos);}
void reset(int& n,int pos) {n=n&~(1<<pos);}

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

C++: #include<iostream>

using namespace std;

long long gcd(long long a,long long b)
{
	if(a == 0)
	{
		return b;
	}
	while(b != 0)
	{
		if(a > b) a = a - b;
		else b = b - a;
	}
	return a;
}

int main()
{
	long long a,b;
	while(cin>>a>>b)
	{

		cout<<gcd(a,b)<<endl;
		
		
		//cout<<a + b<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
 
int gcd(int i,int j)
{
    if(j==0) 
		return i;
    if(i < j) 
		swap(i,j);
    return gcd(j,i%j);
	if(j < i)
		return gcd(i,j%i);
}

int main()
{
    int i,j;
    while(cin >> i >> j)
	{
		cout << gcd(i,j) << 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;
			
		break;
	}
	
	
	return 0;
}

C++: #include<iostream>

using namespace std;

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

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

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

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF){
        printf("%d\n",__gcd(a,b));
    }
    return 0;
}