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):

c,d = list(map(int,input().split()))

if d>c:
    a = d
    b = c
else:
     a = c
     b = d

def gcd(x,y):
    if y == 0:
        return x
    else:
        r = x%y
        return gcd(y,r)
    
print(gcd(a,b))

Solution (Python):
twoNumbers=list(map(int,input().split()))
x=twoNumbers[0]
y=twoNumbers[1]
devidedBy=[]
syou=[]
if x>=y:
    for number in range(1, y+1):
        if y%number==0:
            if number>y//number:
                break
            else:
                if not number in devidedBy:
                    devidedBy.append(number)
                if not y//number in syou:
                    syou.append(y//number)
else:
    for number in range(1, x+1):
        if x%number==0:
            if number>x//number:
                break
            else:
                if not number in devidedBy:
                    devidedBy.append(number)
                if not x//number in syou:
                    syou.append(x//number)

if devidedBy[len(devidedBy)-1]==syou[len(syou)-1]:
    del devidedBy[len(devidedBy)-1]

devidedBy.extend(syou)
devidedBy.sort()
index=len(devidedBy)-1
while index>=0:
    if x>=y:
        if x%devidedBy[index]==0:
            print(devidedBy[index])
            break
        else:
            index-=1
    else:
        if y%devidedBy[index]==0:
            print(devidedBy[index])
            break
        else:
            index-=1

Solution (Python):
X, Y = map(int, input().split())

def gcd(_x, _y) :
    x = min(_x, _y)
    y = max(_x, _y)
    
    if x == 0 or y == 0 :
        return 0
    if x == y :
        return X
    elif y % x == 0 :
        return min(x, y)
    elif y % x != 0 :
        return gcd(y % x, x)
        
print(gcd(X, Y))

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

def gcd(a, b):
    if a == b:
        return a
    big = max(a, b)
    small = min(a, b)
    while not big % small == 0:
        big, small = small, big%small
    return small
    
print(gcd(a, b))

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

def gcd(a, b):
    big = max(a, b)
    small = min(a, b)
    while not big % small == 0:
        big, small = small, big%small
    return small
    
print(gcd(a, b))

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

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

Solution (Python):
def main():
    a, b = tuple(map(int,input().split()))
    if a < b:
        (a, b) = (b, a)
        
    print(gcd(a, b))

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

if __name__ == '__main__':
    main()

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

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

if __name__ == '__main__':
    main()

Solution (Python):
nums = sorted(list(map(int, input().split())), reverse=True)


def gcd(mx, mi):
    if mi == 0:
        return mx
    amari = mx % mi
    return gcd(mi, amari)

print(gcd(nums[0], nums[1]))

Solution (Python):
import sys

input_list = map(int, raw_input().split())

x = input_list[0]
y = input_list[1]

if x < y:
	tmp = x
	x = y
	y = tmp
elif x == y:
	print(x)
	sys.exit(0)


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

print(x)

Solution (Python):
a, b = map(int, input().split())
c = []
if a > b:
    a, b = b, a
if b%a == 0:
    print(a)
else:
    while True:
        for i in range(a):
            x = i + 2
            
            if a%x == 0:
                if b%x == 0:
                    c.append(x)
                    a = a//x
                    b = b//x
                    
                    break
                elif b%(a//x) == 0:
                    c.append(a//x)
                    a = x
                    b = b//(a//x)
                    
                    break
            
                
            if x > a**0.5:
                break
        if x > a**0.5:
            break
    s = 1
    for j in c:
        s = s * j
    print(s)

Solution (Python):
a, b = map(int, input().split())
c = []
if a > b:
    a, b = b, a
if b%a == 0:
    print(a)
else:
    while True:
        for i in range(a):
            x = i + 2
            if a%x == 0:
                if b%x == 0:
                    c.append(x)
                    a = a//x
                    b = b//x
                    break
                elif b%(a//x) == 0:
                    c.append(a//x)
                    a = x
                    b = b//(a//x)
                    break
            if x > a**0.5:
                break
        if x > a**0.5:
            break
    s = 1
    for j in c:
        s = s * j
    print(s)

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

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

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

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

Solution (Python):
def gcd(aa,bb):
    while bb!=0:
        r=bb
        bb=aa%bb
        aa=r
    return aa
a,b=map(int,raw_input().strip().split())

print gcd(a,b)

Solution (Python):
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a
print(gcd(*map(int, input().split())))

Solution (Python):
a,b = map(int,input().split())
def gcd(x,y):
    q = max(x,y)  %  min(x,y)
    if q == 0 :
        return [min(x,y),0]
    return gcd(min(x,y),q)

print(max(gcd(a,b)))

Solution (Python):
def sort_two_nums_tuple(x,y):
    return max(x,y),min(x,y)

def calculate_gcd(x,y):
    remain = float('inf')
    while remain != 0:
        remain = x % y
        x = y
        y = remain
    return x

input_x,input_y = map(int,input().split())
x,y = sort_two_nums_tuple(input_x,input_y)
ans = calculate_gcd(x,y)
print(ans)

Solution (Python):
def gcd(x,y):
    a=max(x,y)
    b=min(x,y)
    if a%b==0:
        return b
    else:
        return gcd(a%b,b)
A,B=map(int,input().split())
print(gcd(A,B))

Solution (Python):
import math
def div(x, y): 
    A = 1
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0 and y % i == 0:
            A = max(A, i)
        j = int(x/i)
        if x % j == 0 and y % j == 0:
            A = max(A, j)
    return A
x, y = map(int, input().split(" "))
print(div(x,y))

Solution (Python):
def gcd(a, b):
    c = max([a, b])
    d = min([a, b])
    if c % d == 0:
        return d
    else:
        return gcd(d, c % d)
        
nums = input().split()
print(gcd(int(nums[0]), int(nums[1])))

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

if x < y:
    x, y = y, x
while y > 0:
    x, y = y, x % y
print(x)

Solution (Python):
from sys import stdin
 
x, y = [int(x) for x in stdin.readline().rstrip().split()]
 
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a
 
print(gcd(x, y))

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


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

Solution (Python):
def divide(a, b):
	if a < b:
		return divide(b, a)
	if b == 0:
		return a
	return divide(b, a%b)
	
nums=list(map(int,input().split()))

ans = divide(nums[0], nums[1])

print(ans)

Solution (Python):

def gcd(a,b):
  if a<b: a,b=b,a
  c=a%b
  if c==0:
    print(b)
  else:
    return gcd(b,c)

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

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

print(math.gcd(a,b))

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

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

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

def gdp(x,y):
    if x > y:
        big = x
        small = y
    else:
        big = y
        small = x
    if big%small == 0:
        print(small)
        return
    else:
        gdp(small,big%small)

gdp(x,y)

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

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

print(x)

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

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

if gcd[0]<gcd[1]:
	gcd[0],gcd[1]=gcd[1],gcd[0]
while gcd[1]>0:
	r=gcd[0]%gcd[1]
	gcd[0]=gcd[1]
	gcd[1]=r
print(gcd[0])

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):
def main():
    x, y = map(int, input().split())
    if y > x:
        x, y = y, x
    while y > 0:
        r = x % y
        x = y
        y = r

    print(x)


if __name__ == '__main__':
    main()

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

def swap(x,y):
    temp = x
    x = y
    y = temp
    return(x,y)

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

    while(x != y and y != 0):
        x = x%y
        x,y = swap(x,y)
    print(x)

gcd(x,y)

Solution (Python):



def gcd ( ax, ay):
    x = ax
    y = ay
    while (True):
        if x < y :
            tmp = x
            x = y
            y = tmp
        x=x %y
        if x == 0:
            return y
        elif x == 1:
            return 1



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

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

def gg(a,b):
    if a%b==0 and b%b==0:
        return b
    return gg(b,a%b)

if x>y:
    print(gg(x,y))
else:
    print(gg(y,x))

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

x,y=map(int,input().split())
print("%d"%(calc_gcd(x,y)))

Solution (Python):
data = list(map(int,input().split()))
if(data[0] < data[1]): data[0],data[1] = data[1],data[0]

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

print(gcd(data[0],data[1]))

Solution (Python):
def GCD_calc(A,B):
    if(A>=B):
        big = A
        small = B
    else:
        big = B
        small = A
    r=big%small
    if r == 0:
        return small
    else:
        return GCD_calc(small,r)

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

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

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

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

while True:
    if b % a == 0:
        print(a)
        break
    else:
        b = b % a
        if a > b: a, b = b, a

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

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

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

Solution (Python):
def main():
    nums = map(int, raw_input().split())
    print gcd(nums[0], nums[1])

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

main()

Solution (Python):
a,b = map(int,raw_input().split(' '))
while(True):
	if(a == b):
		print a
		break
	if(a < b):
		t = a
		a = b
		b = t
	a,b = b,a%b
	if(b == 0):
		print a
		break

Solution (Python):
a,b = map(int,input().split())
if a<b:
	a,b = b,a
while 1:
	if a%b==0:
		break
	a,b = b,a%b
print(b)

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

def gcd(a,b):
	c = a%b
	if c==0:
		return b
	elif c == 1:
		return c
	else:
		return gcd(b, c)

if a > b:
	print gcd(a, b)
elif a < b:
	print gcd(b, a)
else:
	print a

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

a, b = map(int, raw_input().split(' '))

print gcd(a, b)

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

mini, big = (a, b) if a < b else (b, a)

while True:
    rem = big % mini
    if rem == 0:
        break
    mini, big = rem, mini

print(mini)

Solution (Python):
l=[int(x) for x in raw_input().split(" ")]

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

print gcd(l[0], l[1])

Solution (Python):
import sys


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
    
if __name__ == '__main__':
    ab = sys.stdin.readline()
    a, b = ab.split()
    a, b = int(a), int(b)
    
    sys.stdout.write(str(gcd(a, b)) + '\n')

Solution (Python):
def euclid(m,n):
    while m%n>0:
        m,n=n , m%n
    else:
        return n

x,y = map(int,raw_input().split())
if x < y:
    x,y = y,x
print euclid(x,y)

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

if x<y:
	temp = x
	x = y
	y = temp

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

print(x)

Solution (Python):
import fractions

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

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


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

if x >= y:
    n = gcd(x, y)
    print(n)
else:
    n = gcd(y, x)
    print(n)

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

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

print x

Solution (Python):

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

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

print(y)

Solution (Python):

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

print(y)

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

a, b = [ int( val ) for val in raw_input( ).split( " " ) ]
if a < b:
	a, b = b, a
print( gcd( a, b ) )

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

a, b = [ int( val ) for val in input( ).split( " " ) ]
if a < b:
	a, b = b, a
print( gcd( a, b ) )

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

Solution (Python):

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

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

Solution (Python):


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

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

if __name__ == '__main__':
    main()

Solution (Python):


def GCD(x,y):
    while y!=0:
        tmp=y
        y=x%y
        x=tmp
    return x

if __name__ == "__main__":
    x,y=list(map(int,input().split()))
    if x<y:
        tmp=x
        x=y
        y=tmp
    print(GCD(x,y))

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

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

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

print(gcd(*map(int, input().split())))

Solution (Python):

def gcd(x, y):
    if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

    return d


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

if x < y:
    buff = x
    x = y
    y = buff
elif x == y:
    print(x)
    exit()

d = gcd(x, y)

print(d)

Solution (Python):

def gcd(x, y):
    if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

    return d


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

if x < y:
    buff = x
    x = y
    y = buff
elif x == y:
    print(x)
    exit()

d = gcd(x, y)

print(d)

Solution (Python):

def gcd(x, y):
    if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

    return d


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

if x < y:
    buff = x
    x = y
    y = buff
elif x == y:
    print(x)
    exit()

d = gcd(x, y)

print(d)

Solution (Python):
x, y = map(int, raw_input().split())
flag = True
while flag:
    if y > x:
        x, y = y, x
    mod = x % y
    x, y = y, mod
    if mod == 0:
        print x
        quit()

Solution (Python):


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

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

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

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

while b!=0:
	(a,b)=(b,a%b)

print(a)

Solution (Python):
def Euclidean(input_list):
  
  x = input_list[1]
  y = input_list[0]
  r = x % y
  if r != 0:
    list = [r, y]
    list.sort()
    return Euclidean(list)
  else:
    return y

list = map(int, raw_input().split(" "))
list.sort()
print Euclidean(list)

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

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

    return x

x = num_list[0]
y = num_list[1]

print gcd(x, y)

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

while(x != y or x>1 or y > 1):
    if(x < y):
        tmp = x
        x = y
        y = tmp
    if( y == 0):
        break

    x %= y
print(x)

Solution (Python):
ex = raw_input()
n_s, m_s = ex.split()
n = int(n_s)
m = int(m_s)

while n > 0:
    temp = n
    n = m % n
    m = temp

print m

Solution (Python):
import sys

def div(x, y):
    if x % y == 0:
        print y
    else:
        div(y, x%y)


line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

if x < y:
    x, y = y, x

if x == y:
    print x

else:
    div(x, y)

Solution (Python):
def grecom(x,y):
    if(x==0 or y==0):
        return x+y
    if(x==1 or y==1):
        return 1
    if(x==y):
        return x
    if(y>x):
        return grecom(y%x,x)
    else:
        return grecom(x%y,y)

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

Solution (Python):
import sys

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

line = sys.stdin.readline()
(a, b) = line.split()
a = int(a)
b = int(b)
if a > b:
  b, a = a, b

print gcd(a, b)

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

def gcd(a, b):
  if a > b:
    a, b = b, a

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

print(gcd(a, b))

Solution (Python):
inp = map(int, raw_input().split())
x = max(inp)
y = min(inp)
while True:
    r = x % y
    x = y
    y = r
    if y == 0:
        break
print x

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

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

if __name__=='__main__':
	main()

Solution (Python):




def mygcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    else:
        (x1, y1) = (max(x, y), min(x, y))
        return mygcd(y, x % y)


def main():
    print(mygcd(*map(int, input().split())))

if __name__ == "__main__":
    main()

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

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

Solution (Python):


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

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

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

a,b = map(int, raw_input().split(' '))
if a > b:
    print gcd(a,b)
else:
    print gcd(b,a)

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

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

Solution (Python):
import sys                                               
for i in sys.stdin:
    lst = i.split(' ')
    lst = map(int, lst)
    lst.sort()

    n = 1
    maxn = 1
    while n*n <= lst[0]:
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
            print lst[0]/n
            break
        elif lst[0]%n == 0 and lst[1]%n == 0:
            maxn = n
        n = n+1
    else:
        print maxn
    sys.exit(0)

Solution (Python):
def gcd(a, b):
    
    while b > 0:
        a, b = b, a % b
    return a
a, b = map(int, input().split())
print(gcd(a, b))

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

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

while x:
    x, y = y % x, x

print(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

if __name__ == "__main__":
    x, y = map(int, input().split())
    print(gcd(x, 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 = [int(n) for n in input().split()]
while True:
    tmp = x % y
    if tmp == 0:
        break
    x, y = y, tmp
print(y)

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

if __name__ == "__main__":
    A = map(int, raw_input().split())
    print euclideanAlg(A[0], A[1])

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

s = map(int, raw_input().split())
if s[0] < s[1]:
    print "%d" % gcd(s[1], s[0])
else:
    print "%d" % gcd(s[1], s[0])

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

Solution (Python):
a=map(int,raw_input().split())
a.sort()
while a[1]%a[0]!=0:
 a[0],a[1]=a[1]%a[0],a[0]
print(a[0])

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

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

n1,n2 = map(int,raw_input().split())
print gcd(n1,n2)

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

	return b

if __name__ == '__main__':
	l = list(map(int, input().split()))
	x = l[0]
	y = l[1]

	ans = gcd(x, y)
	print(ans)

Solution (Python):
A,B= map(int, raw_input().split())
while B > 0:
    A, B = B, A%B
print A

Solution (Python):


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

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

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

x, y = map(int, input().split())
b = max(x, y)
s = min(x, y)
a = gcd(b, s)
print(a)

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

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

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

Solution (Python):
import sys
def gcd(a, b):
    while b != a :
        if a > b:
             a -= b 
        elif b > a:
            b -= a
    return a

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

Solution (Python):
x,y = map(int,raw_input().split())
if x==y:
    print x
else:
    if y>x:
        tmp = x
        x = y
        y = tmp
    i=2
    ans = 1
    al = []
    while i*i<=x:
        if x % i ==0:
            if y % i==0:
                al.append(i)
                x = x/i
                y = y/i
                continue
        i+=1
    if len(al)==0:
        pass
    else:
        for j in al:
            ans *= j
    print ans

Solution (Python):
x,y = map(int,raw_input().split())
if x==y:
    print x
else:
    if y>x:
        tmp = x
        x = y
        y = tmp
    i=2
    ans = 1
    al = []
    while i*i<=x:
        if x % i ==0:
            if y % i==0:
                al.append(i)
                x = x/i
                y = y/i
                continue
        i+=1
    if len(al)!=0:
        for j in al:
            ans *= j
    print ans

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

def divisor(x, y):
    while x % y != 0:
        amari = x % y
        if amari == 0:
            return y
        x = y
        y = amari
    return y
print(divisor(x, y))

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


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

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

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

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

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

Solution (Python):
import sys
import math

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

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

Solution (Python):


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

if y > x:
	w = y
	y = x
	x = w

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

print(x)

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

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

Solution (Python):
a,b =map(int,raw_input().split())
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
print gcd(a,b)

Solution (Python):
def main():
  a, b = list(map(int, input().split()))
  if a < b:
    a, b = b, a
  while b > 1:
    r = a % b
    if r == 0:
      break
    a, b = b, r

  print(b)

  return 0


if __name__ == '__main__':
  main()

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 = map(int, input().split(' '))
n = min(x, y)

print(gcd(x, y))

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

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

print gcd(a,b)

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

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

print(gcd(x,y))

Solution (Python):


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

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

print(int(gcd(n, m)))

Solution (Python):
import sys
import math

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

if a==b:
    print(a)
    sys.exit(0)

min = a if a < b else b
divisor = 1

i = 2
while i < math.sqrt(min):
    if a % i == 0 and b % i == 0:
        a = a / i
        b = b / i
        divisor = divisor * i
    else:
        i = i + 1

print(divisor)

Solution (Python):


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

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

Solution (Python):
targ = [int(n) for n in input().split(' ')]
big,small = max(targ),min(targ)
while big % small != 0:
    disp = small
    small = big % small
    big = disp
print(small)

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

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

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

if a < b:
    t = a
    a = b
    b = t
while b != 0 and b <= a:
    t = a % b
    a = b
    b = t

print(a)

Solution (Python):
import sys

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

    if x % y == 0:
        return y                
    else:
        return get_gcd(y, x % y)
    
if __name__ == '__main__':
    data = sys.stdin.readline().strip().split(' ')
    x = int(data[0])
    y = int(data[1])

    ans = get_gcd(x, y)
    print(ans)

Solution (Python):
n = input().split()
x = int(n[0])
y = int(n[1])
if x < y:
    bf = x
    x = y
    y = bf
while y > 0:
    r = x % y
    x = y
    y = r

print(str(x))

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

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

Solution (Python):

def GCD(x,y):
    d=0
    if x < y:
        d=y
        y=x
        x=d
    if y==0:
        print(x)
    else:
        GCD(y,x%y)
if __name__=="__main__":
    a=input()
    x=int(a.split(" ")[0])
    y=int(a.split(" ")[1])
    GCD(x,y)

Solution (Python):

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

Solution (Python):
x, y = sorted([int(i) for i in input().split()])
while x > 0:
    z = x
    x = y % x
    y = z
    
print(y)

Solution (Python):
b, a = map(int, raw_input().split(" "))
if a >= b:
    temp = b
    b = a
    a = temp

while 1:
    r = b % a
    if r == 0:
        print(a)
        break
    b = a
    a = r

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

Solution (Python):
import time

x,y = map(int,raw_input().split())
b = int(min(x,y))
a = int(max(x,y))

def gcd(a,b):
    if a % b != 0:
        r = a % b
        return gcd(b,r)
    else:
        print(b)

gcd(a,b)

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

while a[0] > 0:
    b = a[1]%a[0]
    a[1] = a[0]
    a[0] = b
    
print(a[1])

Solution (Python):
def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
x, y = (map(int, input().split()))
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

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

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

Solution (Python):
def gcd(b, s):
    mod = b % s
    if mod != 0:
        return gcd(s, mod)
         
    else:
        return s
 
x, y = map(int, input().split())
b = max(x, y)
s = min(x, y)
a = gcd(b, s)
print(a)

Solution (Python):
natural = list(map(int, input().split()))
natural.sort
x = natural[1]
y = natural[0]
while (y != 0):
	x, y = y, x % y
print(x)

Solution (Python):



def gcd(x,y):
    tmp = y
    
    if y > x:
        y = x
        x = tmp

    while not y == 0:
        y = x % y
        x = tmp
        tmp = y

    return x
def main():
    target = [int(a) for a in input().split()]
    print(gcd(target[0], target[1]))
    
if __name__ == "__main__":
    main()

Solution (Python):



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

    while not y == 0:
        x, y = y, x % y
    
    return x
def main():
    target = [int(a) for a in input().split()]
    print(gcd(target[0], target[1]))
    
if __name__ == "__main__":
    main()

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

Solution (Python):
def gcd(x, y):
    if x == y:
        return x
    while(1):
        if x < y:
            temp = x
            x = y
            y = temp
        x = x%y
        if x == 0:
            return y
            
x, y = map(int, raw_input().split())

print gcd(x, y)