Problem:
Greatest Common Divisor Write a program which finds the greatest common divisor of two natural numbers a and b  Input  a and b are given in a line sparated by a single space. Output Output the greatest common divisor of a and b . Constrants 1 ≤ a , b ≤ 10 9  Hint You can use the following observation: For integers x and y , if x ≥ y , then gcd( x , y ) = gcd( y , x % y ) Sample Input 1 54 20 Sample Output 1 2 Sample Input 2 147 105 Sample Output 2 21

Solution (Python):
a,b=map(int,input().split())
while b:a,b=b,a%b
print(a)

Solution (Python):
import math
print(math.gcd(*map(int,input().split())))

Solution (Python):
x, y = map(int, input().split())

if x > y :
    pass
else :
    x, y = y, x

while x % y != 0 :
    d = x % y
    x = y
    y = d
print(y)

Solution (Python):
data = [int(n) for n in input().split(" ")];

def gcd(m, n):
    m = m % n;
    if m == 0:
        return n;
    return gcd(n, m);

print(gcd(max(data), min(data)));

Solution (Python):
def gcm(a, b):

    if a % b == 0:
        return b
    else:
        return gcm(b, a % b)


if __name__ == '__main__':

    [a, b] = [int(x) for x in input().split()]

    print(gcm(a,b))

Solution (Python):
def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x%y
    return x

x, y = list(map(int, input().split()))
print(gcd(x, y))

Solution (Python):
from math import gcd
a, b = map(int, input().split())
print(gcd(a, b))

Solution (Python):
s = input().split()
A = int(s[0])
B = int(s[1])

if A < B:
  v = B
  B = A
  A = v

R = A % B
while R !=0:
  A = B
  B = R
  R = A % B
print(B)

Solution (Python):

def euclidean_algorithm(x,y):
    if x > y:
        p = y
        r = x%y
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p
    elif x == y:
        return x
    elif x < y:
        p = x
        r = y%x
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p

num1,num2 = raw_input().split()
maximam = euclidean_algorithm(int(num1), int(num2))
print(maximam)

Solution (Python):
def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

if __name__ == '__main__':
    a, b = [int(x) for x in input().split()]
    print (gcd(a, b))

Solution (Python):
from math import gcd
x,y = [int(i) for i in input().split()]
print(gcd(x,y))

Solution (Python):


a, b = map(int, raw_input().split())
if a < b:
    a, b = b, a
while b != 0:
    a, b = b, a % b

print a

Solution (Python):



import sys

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

x, y = map(int, sys.stdin.readline().split())
print(gcd(x, y))

Solution (Python):
inp=sorted(list(map(int,input().split())))
while inp[1]>=inp[0]:
    a=inp[1]%inp[0]
    if a==0:
        break
    inp[1]=inp[0]
    inp[0]=a

print(inp[0])

Solution (Python):
def greatest_common_divisor(x, y):
    while True:
        if x == 0 or y == 0:
            break
        elif x >= y:
            x %= y
        else:
            y %= x

    return x+y

if __name__ == '__main__':
    x, y = map(int, input().split())
    gcd = greatest_common_divisor(x, y)
    print(gcd)

Solution (Python):
def gcd(x, y):
    if x < y:
        x, y = [y, x]

    while y > 0:
        r = x % y
        x = y
        y = r
    return x

x, y = [int(n) for n in input().split()]
print(gcd(x, y))

Solution (Python):
x, y = map(int, input().split())

def gcd(x,y):
    if x < y:
        x, y = y, x
    d = int()
    while y > 0:
        r = x % y
        x, y = y, r

    return x

print(gcd(x, y))

Solution (Python):
def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        r = x % y
        x = y
        y = r

    return x

def main():
    x, y = (int(n) for n in input().split())
    print(gcd(x, y))

main()

Solution (Python):
def GSD(x, y):
    while True:
        x0 = max(x, y)
        y0 = min(x, y)
        if x0 % y0 == 0:
            return y0
        x = x0 % y0
        y = y0
x, y = map(int, input().split(' '))
print(GSD(x, y))

Solution (Python):

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

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

Solution (Python):
str_input = input()
list_input = str_input.split(" ")
x = int(list_input[0])
y = int(list_input[1])
while y != 0:
    mod = x % y
    x = y
    y = mod
print(x)

Solution (Python):

x, y = map(int, input().split(' '))
q = x % y
while q != 0:
    t = y
    y = q
    x = t
    q = x % y
print(y)

Solution (Python):
n = list(map(int, input().split()))

x = n[0]
y = n[1]

if x < y:
    x, y = y, x
while y > 0:
    r = x % y
    x = y
    y = r

print(x)

Solution (Python):
def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while y > 0:
        r = x % y
        x = y
        y = r

    return print(x)

x_y = input()
tmp = list(map(int, x_y.split()))
x = tmp[0]
y = tmp[1]
gcd(x, y)

Solution (Python):
from collections import defaultdict

def gcd(x,y):
    if max(x,y) % min(x,y) == 0 : return min(x,y)
    else : return gcd(min(x,y) ,max(x,y)%min(x,y))

if __name__ == '__main__' :
        a,b = [int(i) for i in input().split(" ")]
        print(gcd(a,b))

Solution (Python):
x, y = sorted(list(map(int, input().split())), reverse=True)
while 1:
  if x % y == 0:
    print(y)
    break
  else:
    a = y
    b = x % y
    x = a
    y = b

Solution (Python):
a, b = map(int, input().split())
while b: a, b = b, a % b
print(a)

Solution (Python):
def greatest_common_division(x, y):
    if x < y:
        x, y = y, x

    if y == 0 or x == y:
        return x
    else:
        return greatest_common_division(y, x % y)

x, y = map(int, input().split())
print(greatest_common_division(x, y))

Solution (Python):
def gcd(a, b):
    """calculate the greatest common divisor of a, b

    >>> gcd(54, 20)
    2
    >>> gcd(147, 105)
    21
    >>> gcd(100000002, 39273000)
    114
    """
    if a > b:
        a, b = b, a

    if a == 0:
        return b

    return gcd(b % a, a)


def run():
    a, b = [int(i) for i in input().split()]
    print(gcd(a, b))


if __name__ == '__main__':
    run()

Solution (Python):



def gcd(x, y):
    if x < y:
        x, y = y, x

    while y > 0:
        r = x % y
        x = y
        y = r

    return x


if __name__ == '__main__':

    x, y = map(int, input().split())
    print(gcd(x, y))

Solution (Python):
a = list(map(int, input().split()))
t , u = a[0],a[1]

def c(x,y):
  if x % y:
    return(c(y,x%y))
  else:
    return(y)

print(c(t,u))

Solution (Python):
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)


alllist = list(map(int, input().split()))
alllist = sorted(alllist, reverse=True)


result = gcd(alllist[0], alllist[1])
print(result)

Solution (Python):
x, y = [int(x) for x in input().split()]
def gcd(a, b):
    m = a%b
    return gcd(b, m) if m else b
print(gcd(x, y))

Solution (Python):
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

x,y=map(int,raw_input().split())
print(gcd(x,y))

Solution (Python):
s=input()
r=s.split()
x=int(r[0])
y=int(r[1])
r=x%y

while r!=0:
    x=y
    y=r
    r=x%y

print(y)

Solution (Python):
def gcd(x,y):
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

x,y = map(int,input().split())
print(gcd(x,y))

Solution (Python):

import math
a,b=map(int,input().split())
def f(x,y):
    while(1):
        tmp=x%y
        x=y
        y=tmp
        if tmp==0:
            gcd=x
            break
    return gcd
print(f(a,b))

Solution (Python):

x,y=map(int,input().split())

a=1

while a!=0:
    if x>y:
        a=x%y
    else:
        a=y%x
    x=y
    y=a

print(x)

Solution (Python):
x,y = map(int, input().split())
i=1
while i!=0:
    if x>y:
        i=x%y
        x=y
        y=i
    else:
        i=y%x
        y=i

print(x)

Solution (Python):


x,y=map(int, input().split())

if x>y:
  while 1:
   if (x%y)==0:
    print(y)
    break
   a=x%y
   x=y
   y=a
else:
  while 1:
   if (y%x)==0:
    print(x)
    break
   a=y%x
   y=x
   x=a

Solution (Python):
line=input().split()
x=int(line[0])
y=int(line[1])
def gcd(x,y):
    r=x%y
    while(r>0):
        x=y
        y=r
        r=x%y
    return y
    
print (gcd(x,y))

Solution (Python):
def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    
    r = x % y
    while r != 0:
        x = y
        y = r
        r = x % y

    return y


x, y = map(int, input().split())
print(gcd(x, y))

Solution (Python):
def gcd(x,y):
    if x<y:
        tmp=x
        x=y
        y=tmp
    while y>0:
        r=x%y
        x=y
        y=r
    return x

x,y=map(int,input().split())
print(gcd(x,y))

Solution (Python):
import math
line=input().split()
x=int(line[0])
y=int(line[1])
print(math.gcd(x,y))

Solution (Python):
list=[int(i) for i in input().split()]



if list[0]>list[1]:
    a=list[0]
    b=list[1]
else:
    b=list[0]
    a=list[1]    


if a%b==0:
    print(b)
else:
    while b>0:
        c=a%b
        a=b
        b=c
    print(a)

Solution (Python):
def cgd(x,y):
	while(True):
		r=x%y
		if r==0:
			m=y
			break
		x=y
		y=r
	
	return m

a,b=map(int,input().split())
if a>b:
	m=cgd(a,b)
elif a<b:
	m=cgd(b,a)
else:
	m=a
print(m)

Solution (Python):


def Greatest_Common_Divisor(x,y):
    if y>x:
        x,y=y,x
    if x>=y and y>0:
        return Greatest_Common_Divisor(y,x%y)
    return x

if __name__ == "__main__":
    x=list(map(int,input().split()))
    print(Greatest_Common_Divisor(x[0],x[1]))

Solution (Python):
a,b=map(int,input().split())

x=a%b

while x>0:
	a=b
	b=x
	x=a%b

print(b)

Solution (Python):
list=[int(i) for i in input().split()]

if list[0]>list[1]:
    a=list[0]
    b=list[1]
else:
    b=list[0]
    a=list[1]    


if a%b==0:
    print(b)
else:
    while b>0:
        c=a%b
        a=b
        b=c
    print(a)

Solution (Python):
x,y=map(int,input().split())
c=x%y

while c!=0:
    x=y
    y=c
    c=x%y
print(y)

Solution (Python):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

a, b = map(int, input().split())
if a < b:
    a, b = b, a
print(gcd(a, b))

Solution (Python):
x,y=map(int,input().split())
a=1
while a!=0:
    a=x%y
    tmp=y
    y=a
    x=tmp
print(tmp)

Solution (Python):
def gc(x, y):
    while y > 0:
        x %= y
        x, y = y, x
    return x



A = [int(i) for i in input().split()]
print(gc(A[0],A[1]))

Solution (Python):
def GCD(x,y):

    if(x >= y):
        z = y
        w = x%y
    else:
        z = x
        w = y%x

    if(not(w == 0)):
        return GCD(z,w)
    else:
        return z

A = [int(i) for i in input().split()]
print(GCD(A[0],A[1]))

"""実行結果

100 55
5



66 77
11

"""

Solution (Python):
def gcd(x,y):
    r=x%y
    if r==0:
        return y
    else:
        return gcd(y,r)
x,y=map(int, input().split())
if x>y:
    r=gcd(x,y)
if x==y:
    r=x
if x<y:
    r=gcd(y,x);
print(r)

Solution (Python):
def gcd(x,y):
   if x<=y:
     tmp=x
     x=y
     y=tmp
   r=x%y
   while(r!=0):
     x=y
     y=r
     r=x%y
   return y
a=input().split()
b=[int(i) for i in a]
print(gcd(b[0],b[1]))

Solution (Python):


x = input().split()
a = int(x[0])
b = int(x[1])

while(a % b != 0):
    c = b
    b = a % b
    a = c
print(b)

Solution (Python):

if __name__ == '__main__':
	s = input().split()
	if s[0] < s[1]:
		tmp = s[0]
		s[0] = s[1]
		s[1] = tmp
	while True:
		x = int(s[0]) % int(s[1])
		if x==0:
			break
		s[0] = s[1]
		s[1] = x

	print (s[1])

Solution (Python):
def gcd(x,y):
    while 1:
        tmp = x%y
        if tmp==0:
            return y
        x = y
        y = tmp

a = list(map(int, input().split()))

if a[0]<=a[1]:
    s = gcd(a[1],a[0])
else:
    s = gcd(a[0],a[1])

print(s)

Solution (Python):
x,y=map(int,input().split())
while x%y!=0:
	tmp=y
	y=x%y
	x=tmp
print(y)

Solution (Python):
x,y=map(int,input().split())
r=x%y

while r!=0:
        x=y
        y=r
        r=x%y
print(y)

Solution (Python):
n=input().split()
x=int(n[0])
y=int(n[1])
if 1<=x<1000000000 and 1<=y<=1000000000:
	if x>y:
		while y!=0:
			t=y
			y=x%t
			x=t
		print(x)
	else:
		while x!=0:
			t=x
			x=y%t
			y=t
		print(y)

Solution (Python):



def greatest_common_divisor(x, y):
    r = None

    if x >= y:
        r = x%y
        if r == 0: return y
    else:
        r = y%x
        if r == 0: return x

    return greatest_common_divisor(y, r)

x, y = [int(n) for n in input().split(' ')]
print(greatest_common_divisor(x, y))

Solution (Python):
def gcd(a,b):
    if b==0:
        return a
    c=a%b
    return gcd(b,c)
x,y=map(int,input().split())
if x<y:
    x,y=y,x
m=gcd(x,y)
print(m)

Solution (Python):
def gcm(x, y):
    if x == 0:
        return y
    if y == 0:
        return x
    if x==y:
        return x
    if x>y:
        return gcm(x%y,y)
    else:
        return gcm(y%x,x)


x, y = list(map(int, input().split()))

print(gcm(x, y))

Solution (Python):
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
print(gcd(*map(int, input().split())))

Solution (Python):
if __name__ == '__main__':
    s = input().split()
    if s[0] < s[1]:
        tmp = s[0]
        s[0] = s[1]
        s[1] = tmp
    while True:
        x = int(s[0]) % int(s[1])
        if x==0:
            break
        s[0] = s[1]
        s[1] = x
 
    print (s[1])

Solution (Python):
a, b = map(int, input().split())

while b > 0:
    if a < b:
        a, b = b, a
    a, b = b, a % b
print(a)

Solution (Python):

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def main():
    l, r = tuple(map(int, input().split(' ')))
    print(gcd(l, r))

main()

Solution (Python):



x, y = map(int, input().split())

while y != 0:
    x, y = y, (x % y)

print(x)

Solution (Python):
x, y = map(int, input().split(' '))

def gcd(x1,x2):
    if(x2 == 0):
        return x1
    else:
        return gcd(x2, x1 % x2)
    
if(x>=y):
    print(gcd(x,y))
else:
    print(gcd(y,x))

Solution (Python):
x, y = [ int(i) for i in input().split()]

if x > y:
    x, y = y, x

while True:
    if x % y:
        x, y = y, x % y
        continue
    break

print(y)

Solution (Python):
"""
最大公約数を求める
"""
def gcd(a, b):
    while (a != 0 and b != 0):
        if (a >= b):
            a = a % b
        else:
            b = b % a
    return a+b

if __name__ == '__main__':
    x, y = map(int, input().split())
    print(gcd(x,y))

Solution (Python):
def gcd(x,y):
    if y==0:
        return x
    else:
        x=x%y
        return gcd(y,x)

A=list(map(int,input().split(' ')))
print(gcd(A[0],A[1]))

Solution (Python):
import math
x, y = map(int, input().split())
print(math.gcd(x, y))

Solution (Python):


def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def get_gcd(x, y):
    if x < y: return get_gcd(y, x)
    
    
    if y == 0: return x
    return get_gcd(y, x % y)

def main():
    a = intinput()
    x = a[0]; y = a[1]
    
    print(get_gcd(x, y))

if __name__ == "__main__":
    main()

Solution (Python):
import math

x, y = map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
def gcd(x, y):
    if x <= y:
        tmp = x
        x = y
        y = tmp
    if y == 0:
        return x
    return gcd(y, x % y)


inputs = input().split()
x = int(inputs[0])
y = int(inputs[1])

print(gcd(x, y))

Solution (Python):
import math

def gcd(a,b):
    if a<b: a,b=b,a
    c=a%b
    if c==0:
        return b
    else:
        return gcd(b,c)
    
S=[ int(x) for x in input().split()]    
print(gcd(S[0],S[1]))

Solution (Python):

import math

x, y = [int(i) for i in input().split()]


print(math.gcd(x,y))

Solution (Python):

def gcd(x,y):
    if x<y:
        x, y = y, x
    r = x%y
    while(r>0):
        x=y
        y=r
        r = x%y
    return y

x, y = [int(i) for i in input().split()]


print(gcd(x,y))

Solution (Python):
def gcd(x, y):
    if x % y == 0: return y
    return gcd(y, x%y)

x, y = map(int, input().split())
print(gcd(x, y))

Solution (Python):
from sys import stdin
def stdinput():
    return stdin.readline().strip()

def main():
    a, b = map(int, stdinput().split())

    a, b = min(a, b), max(a, b)
    while b % a != 0:
        a, b = b % a, a
    
    print(a)

if __name__ == '__main__':
    main()

Solution (Python):
import math
x, y = list(map(int, input().split()))
print(math.gcd(x, y))

Solution (Python):
def gcd(a, b):
    return gcd(b, a % b) if b != 0 else a

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

Solution (Python):
arr = list(map(int, input().split()))
n1 = min(arr[0], arr[1])
n2 = max(arr[0], arr[1])
while n1 != 0:
	temp = n2 % n1
	n2 = n1
	n1 = temp
print(n2)

Solution (Python):
x, y = map(int, input().split())
while True:
    if y > x:
        a = x
        x = y
        y = a
    x = x % y
    
    if x == 0:
        print(y)
        break

Solution (Python):
import math
x,y = map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
n1, n2 = map(int, input().split())

a = min(n1, n2)
b = max(n1, n2)

while a != 0:
	temp = b % a
	b = a
	a = temp

print(b)

Solution (Python):
x,y = map(int, input().split())
if y < x:
    x,y = y,x
while x%y:
    x,y = y,x%y
print(y)

Solution (Python):
a,b = map(int, input().split())

if(a < b):
    swap = a
    a = b
    b = swap

x = 1
while(x != 0):
    x = a % b
    a = b
    b = x

print(a)

Solution (Python):
x, y = [int(n) for n in input().split()]


def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)


print(gcd(x, y))

Solution (Python):
x, y = [int(n) for n in input().split()]
if (x < y):
    x, y = y, x
while y:
    (x, y) = (y, x % y)
print(x)

Solution (Python):
x, y = [int(n) for n in input().split()]
if (x < y):
    x, y = y, x
while y:
    (x, y) = (y, x % y)
print(x)

Solution (Python):
l=input().split()
l = [int(s) for s in l]
a = l[0]
b = l[1]
while (b != 0 and a != 0):
    if(a < b):
        b = b % a
    else:
        a = a % b
if(a == 0):
    print(b)
else:
    print(a)

Solution (Python):
def gcd(x,y):
    _x = min(x,y)
    _y = max(x,y)
    _z = _y % _x
    if _z == 0:
        return _x
    else:
        return gcd(_x,_z)

def run():
    x, y = [int(i) for i in input().split()]
    print(gcd(x,y))

if __name__ == '__main__':
    run()

Solution (Python):
def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    return gcd(y, x % y)

x, y = [int(i) for i in input().split()]
print(gcd(x, y))

Solution (Python):
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

x, y = [int(i) for i in input().split()]
if x < y:
    x, y = y, x
print(gcd(x, y))

Solution (Python):
x,y=[int(i) for i in input().split()]
if x<y:
    x,y=y,x
while True:
    if y==0:
        print(x)
        break
    a=x%y
    x=y
    y=a

Solution (Python):


numbers = [int(i) for i in input().rstrip().split()]
a = numbers[0]
b = numbers[1]

gcd = 1
while a != 0 and b != 0:
    if a >= b:
        a %= b
    else:
        b %= a
if a == 0:
    gcd = b
else:
    gcd = a

print(gcd)

Solution (Python):


numbers = [int(i) for i in input().rstrip().split()]
a = numbers[0]
b = numbers[1]

def gcd(a, b):
    gcd = 1
    while a != 0 and b != 0:
        if a >= b:
            a %= b
        else:
            b %= a
    if a == 0:
        gcd = b
    else:
        gcd = a
    return gcd

print(gcd(a, b))

Solution (Python):
def gcd(a, b):                  
    if b%a==0: return a
    return gcd(b%a, a)



x, y = map(int, input().split())
print(gcd(x, y))

Solution (Python):
def gcd_loop(a,b):
    if a < 0: a = -a
    if b < 0: b = -b
    if b < a: b, a = a, b
    if a == 0:
        return b
    while True:
        if b%a == 0:
            return a
        a, b = b%a, a


x, y = map(int, input().split())
print(gcd_loop(x, y))

Solution (Python):
a, b = map(int, input().split())
slist = []
if (a > b):
    c = a%b
    d = b
    while (c != 0 and d != 0):
        if (c < d):
            d = d%c
        elif (c > d):
            c = c%d
    if(c == 0):
        print(d)
    elif(d == 0):
        print(c)
        
    
elif(a < b):
    c = a
    d = b%a
    while (c != 0 and d != 0):
        if (c < d):
             d = d%c
        elif (c > d):
            c = c%d
    if(c == 0):
        print(d)
    elif(d == 0):
        print(c)
        
else:
    print(a)

Solution (Python):
x,y =[int(i) for i in input().split()]
if x < y :
    t = x
    x = y
    y = t
while y > 0 :
    r = x % y
    x = y
    y = r
print(x)

Solution (Python):
a, b = map(int, input().split())
if b > a:
    t = b
    b = a
    a = t

while not b == 0:
    t = b
    b = a % b
    a = t
print(a)

Solution (Python):
a, b = map(int, input().split())
if b > a:
    t = b
    b = a
    a = t

while not b == 0:
    t = b
    b = a % b
    a = t
print(a)

Solution (Python):
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

x, y = [int(w) for w in input().split()]

print(gcd(x, y))

Solution (Python):
a,b = map(int, input().split())
if b > a:
    t = b
    b = a
    a = t
while b != 0:
    t = b
    b = a % b
    a = t
print(a)

Solution (Python):
a, b = map(int, raw_input().split())
c = 0
while True:
    if a == b:
        c = a
        break

    if a < b:
        tmp = b
        b = a
        a = tmp

    a = a % b
    if a == 0:
        c = b
        break

print(c)

Solution (Python):
def gcd(a,b):
    if b > a:
        a, b = b, a
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

a, b = map(int, raw_input().split())
print gcd(a,b)

Solution (Python):
data = map(int, raw_input().split())
x = data[0]
y = data[1]

m = 1
while m != 0:
	m = x % y
	x = y
	y = m
	
print x

Solution (Python):

from __future__ import division, print_function
from sys import stdin
a, b = (int(s) for s in stdin.readline().split())
while b:
    a, b = b, a % b
print(a)

Solution (Python):


from __future__ import print_function
import time
import sys
import io
import re
import math


h,i=map(int, raw_input().split())


while i != 0:
    siki= h % i
    h = i
    i = siki

print (h)

Solution (Python):
A=map(int,raw_input().split())
A.sort()

while A[1]%A[0]!=0:
    temp=A[0]
    A[0]=A[1]%A[0]
    A[1]=temp

print A[0]

Solution (Python):
x, y = map(int, raw_input().split())
if x < y:
	x, y = y, x
while True:
	a = x % y
	if a == 0:
		print y
		break
	else:
		x, y = y, a

Solution (Python):
l = map(int,raw_input().split())
l.sort()
a,b = l
max = 0
while True:
    tmp = a%b
    if tmp == 0:
        max = b
        break
    a = b
    b = tmp
print max

Solution (Python):
a, b = map(int,raw_input().split())
while True:
    if min(a, b) == 1:
        print 1
        break
    elif 1 < b < a:
        a = a % b
    elif 1 < a < b:
        b = b % a
    else:
        print max(a, b)
        break

Solution (Python):
def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m%n)

a, b = map(int, raw_input().split())
print gcd(a, b)

Solution (Python):
def gcd(a,b):
    c = a % b
    if c == 0:
        return b
    else:
        return gcd(b, c)
    
if __name__ == "__main__":
    import sys
    a, b = [ int(e) for e in sys.stdin.readline().strip().split() ]
    print gcd(max(a,b), min(a,b))

Solution (Python):
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

x, y = map(int, input().strip().split())
print(gcd(x, y))

Solution (Python):
number = list(map(int, input().split(" ")))

if number[0] < number[1]:
    number[0], number[1] = number[1], number[0]

remainder = 1
while remainder != 0:
    remainder = number[0]%number[1]
    number[0] = number[1]
    number[1] = remainder
    
print(number[0])

Solution (Python):
a,b = map(int,input().split())
k = max(a,b)
l = min(a,b)
while k % l != 0:
	x = k
	k = l
	l = x % l
print(l)

Solution (Python):
x,y=map(int,input().split())
while True:
    if x<y:
        x,y=y,x
    amari=x%y
    if amari==0:
        break
    else:
        x,y=y,amari
print(y)

Solution (Python):
import math
x,y=map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
import fractions
m,n=map(int,input().split())
ans=fractions.gcd(m,n)
print(ans)

Solution (Python):
import fractions
x,y=map(int,input().split())
A=fractions.gcd(x,y)
print(A)

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

x,y = map(int,input().split())    
x,y = max(x,y),min(x,y)

print(gcd(x,y))

Solution (Python):
from math import gcd
n,m = map(int,input().split())
print(gcd(n,m))

Solution (Python):
import math
x,y=map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
from math import gcd

n, m = map(int, input().split())
print(gcd(n, m))

Solution (Python):
x, y = map(int, input().split())
while y>0:
   x, y = y, x%y
print(x)

Solution (Python):
import math
x,y = map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
import math;

x,y = map(int,input().split());

print(math.gcd(x, y));

Solution (Python):
import math
x,y=map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
x,y=map(int,input().split())
if x<y:
    x,y=y,x
while y>0:
    r=x%y
    x=y
    y=r
print(x)

Solution (Python):
import math
x,y=map(int,(input().split()))
print(math.gcd(x,y))

Solution (Python):
import math

x, y = map(int, input().split())
print(math.gcd(x, y))

Solution (Python):
x,y=map(int,input().split())
if y>x:
    x,y=y,x
while y!=0:
    x=x%y
    x,y=y,x
print(x)

Solution (Python):



def gcd(x, y):
   if x % y == 0:
      return y
   else:
      return gcd(y, x % y)

x, y = map(int, input().split())
if x < y:
   x, y = y, x

print(gcd(x, y))

Solution (Python):
from math import gcd

n, m = map(int, input().split())
print(gcd(n, m))

Solution (Python):
x,y=map(int,input().split())
if x<y:
    x,y=y,x
while x%y!=0:
    x,y=y,x%y

print(y)

Solution (Python):
import fractions
x,y = map(int,input().split())
print(fractions.gcd(x,y))

Solution (Python):
x, y = map(int, (input().split()))

if x >= y:
    large, small = x, y
else:
    large, small = y, x

while small > 0:
    r = large % small
    large = small
    small = r

print(large)

Solution (Python):
def gcd(x,y):
  while y > 0:
    r = x%y
    x = y
    y = r
  return x
X,Y = map(int,input().split())
x,y=max(X,Y),min(X,Y)
print(gcd(x,y))

Solution (Python):
from math import gcd

x,y=map(int,input().split())


    
print(gcd(x,y))

Solution (Python):
import math
a,b=map(int,input().split())

print(math.gcd(a,b))

Solution (Python):
X, Y = map(int, input().split())
x = min(X, Y)
y = max(X, Y)
while x > 0:
    r = y % x
    y = x
    x = r
    
print(y)

Solution (Python):
import math
a,b=map(int,input().split())


print(math.gcd(a, b))

Solution (Python):
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


def calc_gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    return calc_gcd(b,a%b)


A,B = map(int,input().split())
print("%d"%(calc_gcd(A,B)))

Solution (Python):
X, Y = map(int, input().split())
while Y != 0:
	T = X
	X = Y
	Y = T % Y
print(X)

Solution (Python):
from fractions import gcd
a,b = map(int,input().split())
print(gcd(a,b))

Solution (Python):
x,y = map(int,input().split())
if x < y:
    prev_x = x
    prev_y = y
    x = prev_y
    y = prev_x
while y >0:
    r = x%y
    x = y
    y = r
print(x)

Solution (Python):
x,y = (int(x) for x in input().split())

q = x // y
r = x % y
a = y
b = r
if (r == 0):
    print(x)
    exit()

else:
    while (r != 0):
        q = a // b
        r = a % b

        if (r == 0):
            print(b)
            break
        a = b
        b = r

Solution (Python):
x, y = map(int, input().split())
if x < y : 
	x, y = y, x
while y > 0 : 
	r = x % y
	x = y
	y = r
print(x)

Solution (Python):
x, y = map(int, input().split())
if x > y:
  x, y = y, x
while x % y != 0:
  x, y = y, x % y
print(y)

Solution (Python):
def gcd(x,y):
    if x < y:
        x,y = y,x
    while y > 0:
        r = x % y
        x = y
        y = r
        gcd(x,y)

    return x

X,Y = map(int,input().split())

print(gcd(X,Y))

Solution (Python):
import math
x,y = map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
x, y = map(int, input().split())

while True:
    if y == 0:
        break
    else:
        x, y = y, x%y

print(x)

Solution (Python):
import math
x,y = (int(x) for x in input().split())
print(math.gcd(x,y))

Solution (Python):
from math import gcd

n, m = map(int, input().split())
print(gcd(n, m))

Solution (Python):
a , b = map(int, input().split())
import math
print(math.gcd(a, b))

Solution (Python):

import math
x,y = (int(x) for x in input().split())
print(math.gcd(x, y))

Solution (Python):

def show(A, n):
    for i in range(n):
        if i != n-1:
            print(A[i], end=' ')
        else:
            print(A[i])


def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        c = a % b
        a = b
        b = c
    return b


def main():
    a, b = list(map(int, input().split()))

    print(gcd(a, b))


if __name__ == "__main__":
    main()

Solution (Python):
x, y = map(int, input().split())
while y:
  x, y = y, x%y
print(x)

Solution (Python):
import math
x,y=map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
x, y = map(int, input().split())
while y:
  x, y = y, x%y
print(x)

Solution (Python):
import math

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

Solution (Python):
import math

x,y = map(int,input().split())

print(math.gcd(x, y))

Solution (Python):



import math
a, b = map(int,input().split())
print(math.gcd(a,b))

Solution (Python):


import math

x, y = map(int,input().split())

print(math.gcd(x, y))

Solution (Python):
from fractions import gcd
print(gcd(*list(map(int, input().split(" ")))))

Solution (Python):
x, y = map(int, input().split())
if x < y:
    x, y = y, x
while y > 0:
    r = x % y
    x = y
    y = r

print(x)

Solution (Python):
a,b=map(int,input().split())
from fractions import gcd
print(gcd(a,b))

Solution (Python):


x,y=map(int,input().split())

x,y=sorted([x,y])
while x%y!=0:
    x,y=y,x%y

print(y)

Solution (Python):

import sys
input=sys.stdin.readline

def gcd(x,y):
    r = x % y
    if r == 0:
        return y
    else:
        while r != 0:
            tmp = y % r
            y = r
            r = tmp
        return y

def main():
    a,b=map(int,input().split())
    print(gcd(a,b))

if __name__=="__main__":
    main()

Solution (Python):
def gcd(x,y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    return gcd(y, x % y)
    
x,y = map(int,input().split())
ans = 0
ans = gcd(x,y)
print(ans)

Solution (Python):
import fractions
m,n=map(int,input().split())
ans=fractions.gcd(m,n)
print(ans)

Solution (Python):
def gcd(x,y):
    if y>x:
        x,y = y,x
    if y==0:
        return x
    elif x==y:
        return x
    else:
        return gcd(y,x%y)

x,y = map(int,input().split())
print(gcd(x,y))

Solution (Python):
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a,a)

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

Solution (Python):
N, M = map(int, input().split())
while True :
    if N < M :
        N, M = M, N
    a = N % M
    if a == 0 :
        break
    else :
        N, M = M, a
print(M)

Solution (Python):
x,y=map(int,input().split())
if y>x:
    x,y=y,x
while True:
    z=x%y
    if z==0:
        break
    else:
        x=y
        y=z
print(y)

Solution (Python):
n,m = map(int,input().split())

if n < m:
    n,m = m,n
while n % m !=0:
    n,m = m,n%m
print(m)

Solution (Python):
import math
x,y=map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
import math

x,y=map(int,input().split())
print(math.gcd(x,y))

Solution (Python):
import fractions
a, b = map(int, input().split())
print(fractions.gcd(a, b))

Solution (Python):
from math import gcd

n, m = map(int, input().split())
print(gcd(n, m))