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 = [int(i) for i in input().split(" ")]

r = a % b
while r > 0 :
    a = b
    b = r
    r = a % b
print(b)

Solution (Python):
import math

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

Solution (Python):
from fractions import gcd

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

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

Solution (Python):
import math
print(eval("math.gcd(" + ",".join(input().split()) + ")"))

Solution (Python):
import math

x, y = list(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):
def GCD(x,y):
    a = x%y
    while a != 0:
        x = y
        y = a
        a = x%y
    return y

L = input().split()
L = [int(L[0]),int(L[1])]
L = sorted(L)
x = L[0]
y = L[1]

print(GCD(x,y))

Solution (Python):
A = list(map(int,input().split()))
a = 1
k = 0
b = 0

if A[0]>A[1]:
    k = A[1]
    A[1] = A[0]
    A[0] = k

while a != 0:
    a = A[1]%A[0]
    if a==0:
        print(A[0])
    A[1] = A[0]
    A[0] = a

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

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

Solution (Python):



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






mod = 0
while True:
    mod = max(x, y) % min(x, y)
    x  = y
    y = mod
    if mod <= 0: break
    
print(x)

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

x, y = [int(s) for s in input().split()]
print(GCD(x, y))

Solution (Python):


def euclid(x, y):
    return y if not x%y else euclid(y, x%y)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)

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

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

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

print(gcd2(x, y))

Solution (Python):
def gcd(x, y):
    a, b = x, y

    while True:
        r = a % b

        if r == 0:
            print(b)
            break

        a, b = b, r

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

    if a < b:
        a, b = b, a

    gcd(a, b)

main()

Solution (Python):

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


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


result = greatest_common_divisor(input_data[0], input_data[1])
print(result)

Solution (Python):
from math import gcd

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

Solution (Python):






def gcd(a: int, b: int) -> int:
    if b == 0:
        return a
    
    return gcd(b, a%b)


def main():
    a, b = (int(e) for e in input().split(" "))
    print(gcd(a, b))


if __name__ == "__main__":
    main()

Solution (Python):

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


max_i = 0
min_i = 1
if data[0] < data[1]:
    max_i = 1
    min_i = 0

a = data[min_i]


b = data[max_i] % a

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

print(a)

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

Solution (Python):
x, y = map(int, input().split())
if x >= y:
    while True:
        a,b = divmod(x,y)
        if b == 0:
            print(y)
            break
        else:
            x = y
            y = b
elif x < y:
    while True:
        a,b = divmod(y,x)
        if b == 0:
            print(x)
            break
        else:
            y = x
            x = b

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):
def gcd(x, y):
    if x < y:
        gcd(y, x)
        return

    while y > 0:
        m = x % y
        x = y
        y = m
    print(x)


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

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

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

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

print(y)

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

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

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

Solution (Python):
def euclidean_algorithm(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 = map(int, input().split(' '))
    print(euclidean_algorithm(x, y))


if __name__ == '__main__':
    main()

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

if a < b:
    x = b
    y = a
else:
    x = a
    y = b

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

print(x)

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

Solution (Python):
x, y = list(map(int, input().split()))
while not x == 0:
    m = min(x, y)
    x = max(x, y) % m
    y = m
print(y)

Solution (Python):
def help(a):
    x = a[0] % a[1]
    a[0] = a[1]
    a[1] = x
    return a

a = list(map(int, input().split()))
if a[0]<a[1]:
    tmp = a[0]
    a[0] = a[1]
    a[1] = tmp

while a[1]>1:
    help(a)
if a[1]==0:
    print(a[0])
else:
    print(a[1])

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

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

print(gcd(a, b))

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

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

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

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

r = euclid(x,y)
print(r)

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

Solution (Python):
from math import gcd
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
    elif x >= y:
        return gcd(y, x%y)
    else:
        return 1

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

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

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

print(x)

Solution (Python):
def gcd(a, b):
    r1 = a
    r2 = b
    while True:
        r = r1 % r2
        if r == 0:
            return r2
        else:
            r1 = r2
            r2 = r

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

Solution (Python):
a,b = [int(i) for i in input().split()]
while a%b != 0:
    a, b = b, a%b
print(b)

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):
x,y=map(int,input().split())
x,y=max(x,y),min(x,y)
while(y!=0):
	x,y=y,x%y
print(x)

Solution (Python):
def gcd(x,y):
    if x < y:
        x1 = x
        x = y
        y = x1
    while y > 0:
        r = x%y
        x = y
        y = r
    return x
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
    
    print(x)    


nums=list(map(int,input().split()))
gcd(nums[0], nums[1])

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

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

Solution (Python):
A = [list(map(int, s.split())) for s in open(0)][0]
x, y = A[0], A[1]
if y > x:
    l, s = y, x
else:
    l, s = x, y
while l % s >  0:
    m = l % s 
    l = s 
    s = m
print(s)

Solution (Python):

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

def greatest_common_divider(x, y):
  while y > 0:
    n = x % y
    x = y
    y = n
  return x

print(greatest_common_divider(x, y))

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

Solution (Python):
def gcd(a, b):
    mod = max(a, b) % min(a, b)
    if mod == 0:
        print(b)
    else:
        gcd(min(a, b), mod)

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

Solution (Python):
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    a, b = sc.intarr()
    print(gcd(a, b))


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


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()

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

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

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

Solution (Python):
X, Y = map(int, input().split())
x = max(X, Y)
y = min(X, Y)

'''
for i in range(y):
    if(x%(y-i)==0)and(y%(y-i)==0):
        print(y-i)
        exit()
'''
while x != y:
    if x > y:
        x -= y
    else:
        y -= x
print(x)

Solution (Python):

from fractions import gcd


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

Solution (Python):
def main():
    x, y = list(map(int, input().split()))
    if x < y:
        x, y = y, x
    n = gcd(x, y)
    print(n)

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

main()

Solution (Python):
def greatest_common_divisor(a, b):
    
    
    residue = a % b
    if residue != 0:
        return greatest_common_divisor(b, residue)
    return b


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


if __name__ == "__main__":
    main()

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

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

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

x = xy[0]
y = xy[1]

while y!= 0:
    xx = y
    yy = x%y

    x = xx
    y = yy


print(x)

Solution (Python):
inputNum = input().split()

x = int(inputNum[0])
y = int(inputNum[1])

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

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

    else:
        return y

print(str(gcd(x, y)))

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

Solution (Python):
def gcd(x,y):
	a = max(x,y)
	b = min(x,y)

	while a%b!=0:
		r = a%b
		a=b
		b=r
	return b

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

if __name__ == '__main__':
	main()

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

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

print(find_gcd(x, y))

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

Solution (Python):


def GCD(a,b):
    r = a % b
    if(r == 0):
        return b
    else:
        return GCD(b,r)
        
a,b = map(int,input().split())

ans = GCD(a,b)
print(ans)

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

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

x = max(l)

y = min(l)
z = x%y

if z == 0:
  z = x

else:
  while x%y > 0:
    z = x%y
    if y > z :
      x = y
      y = z
    else:
      x = z

print(z)

Solution (Python):
def Euklides(m, n):
    while m % n != 0:
            tempVal = n
            n = m % n
            m = tempVal
            Euklides(m, n)
    return n

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

Solution (Python):
import math

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


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

main()

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())
x = max(a,b)
y = min(a,b)
def saidai(x,y):
    if x%y == 0:
        return y
    else:
        return saidai(y,x%y)
print(saidai(x,y))

Solution (Python):
from math import gcd

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

print(gcd(x, y))

Solution (Python):


def Euklides(m, n):
    while m % n != 0:
            tempVal = n
            n = m % n
            m = tempVal
            Euklides(m, n)
    return n
    
n, m = list(map(int, input().split()))
if m > n:
    print(Euklides(m, n))
else:
    print(Euklides(n, m))

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

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

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

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

Solution (Python):
x,y=list(map(int,input().split()))
def gcd(x,y):
    if x==1 or y==1:
        return 1
    elif x == 0:
        return y
    elif y == 0:
        return x
    elif x >=y:
        return gcd(x%y,y)
    else:
        return gcd(y%x,x)
print(gcd(x,y))

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

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

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

a = -1
while a != 0:
    a = x % y
    x = y
    y = a
    
print(x)

Solution (Python):
def greatestc(a, b):
    if a < b:
        a, b = b, a

    c = a % b    
    while c != 0:
        a = b
        b = c
        c = a % b
    return b

if __name__ == '__main__':
    a, b = input().split(' ')

    print(greatestc(int(a), int(b)))

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

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

while True:
    if x[1] % x[0] == 0:
        print(x[0])
        break
    else:
        tmp = x[1] % x[0]
        x[1] = x[0]
        x[0] = tmp

Solution (Python):
def gcd( x, y):
    if x>y:
        return gcd( x-y, y)
    elif x<y:
        return gcd( x, y-x)
    else:
        return x

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

if __name__=="__main__":
    main()

Solution (Python):
import sys

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

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

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

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

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

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

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

def gcd(a, b):
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    while dividend % divider != 0:
        r = dividend % divider
        dividend = divider
        divider = r
	
    return divider












print(gcd(a, b))

Solution (Python):
import sys
input = sys.stdin.readline

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

def gcd(x,y):
    if x<y:
        tmp=x
        x=y
        y=tmp
    if x%y==0:
        return y
    return gcd(y,x%y)
print(gcd(X,Y))

Solution (Python):

a,b=input().split()

if a>b:
    a=int(a)
    b=int(b)

else:
    x=int(a)
    a=int(b)
    b=x

while True:
    ext=a%b
    if ext==0:
        gcd=b
        break
    else:
        a=b
        b=ext

print(gcd)

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

while b>0:
    b=x%y
    if b==0:
        print(y)
        break
    x=y
    y=b

Solution (Python):

def yuc(a,b):
    if a>b:
        if a%b==0:
            return b
        else:
            c=a%b
            i=yuc(b,c)
            return i
    else:
        if b%a==0:
            return a
        else:
            c=b%a
            i=yuc(a,c)
            return i
x,y=(int(i) for i in input().split())
f=yuc(x,y)
print(f)

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

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

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

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

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

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

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

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

Solution (Python):
import math

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


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

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

Solution (Python):
"""
17D8101031C 杉山　祥吾 ID:keisei334 python
"""

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

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

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

"""実行結果
147 105
21
"""

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

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

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

Solution (Python):
import math

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

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

print(gcd(x,y))

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

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

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

Solution (Python):
import math

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



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

print(x)

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())
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):
a, b = map(int, input().split())

if a < b: a, b = b, a
while b > 0:
    r = a % b
    a = b
    b = r

print(a)

Solution (Python):
from math import gcd
x, y = (int(i) for i in 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, input().split())
print(gcd(x,y))

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

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

print(a)

Solution (Python):
from functools import reduce
import operator
def factor(a):
    b = 1
    d = []
    while b:
        if a == 2:
            d.append(a)
            break
        for i in range(2, a):
            if a % i == 0:
                b = a // i
                d.append(i)
                a = b
                break
            elif a == i+1:
                d.append(a)
                b = 0
    return d

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

x_f = factor(x)
y_f = factor(y)

common = list(set(x_f) & set(y_f))
common_n = [min(x_f.count(common[i]),y_f.count(common[i])) for i in range(len(common))]


if common == []:
    print(1)
else:
    print(reduce(lambda x,y:x*y, list(map(lambda x,y:x ** y, common, common_n))))

Solution (Python):
def gcd(x,y):
    if x<y:
        z=x
        x=y
        y=z
    while True:
        if x%y==0:
            break
        else:
            z=x%y
            x=y
            y=z
    return y

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

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())
assert 1 <= x and x <= 10000000000, "xは範囲外です"
assert 1 <= y and y <= 10000000000, "yは範囲外です"
if x == y:
    print(x)
elif x == 0 or y == 0:
    print(0)
else:
    if x < y:
        (x, y) = (y, x)
    d = calc_gcd(x, y)
    print(d)

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

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

Solution (Python):
def greatestdivisor(x, y):
    if y>x:
        tmp = x
        x = y
        y = tmp
        
    while y>0 :
        r = x%y
        x = y
        y = r
    print(x)
    
A=input().split(" ")
greatestdivisor(int(A[0]), int(A[1]))

Solution (Python):

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

r = m % n

while r != 0:
    m = n
    n = r
    r = m % n 

print(n)

Solution (Python):
import math

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

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


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

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

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

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

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

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

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

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

print(y)

Solution (Python):
import math

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

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

z = x % y

while True:
    if z==0:
        print(y)
        break
    temp = z
    z = y % z
    y = temp

Solution (Python):

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

    return gcd(a%b,b)

inputs=input().split()

print(gcd(int(inputs[0]), int(inputs[1])))

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

print(gcd(A, B))

Solution (Python):


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

x = max(a, b)
y = a + b - x

while x % y > 0:
    z = x % y
    x = y
    y = z
print(str(y))

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

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

print(gcd(x, y))

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

def main():
	x,y = map(int,input().split())
	print(gcd(x,y))
	return

main()

Solution (Python):


def greatest_common_devisor(x, y):
    if x > y:
        x, y = y, x
    
    amari = y % x

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

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

Solution (Python):
"""import math
x,y=map(int,input().split())
print(math.gcd(x,y))"""
x,y=sorted(list(map(int,input().split())))
r=x
while 1:
    if x%y==0:break
    r=x%y
    x=y
    y=r
print(r)

Solution (Python):


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

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

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

print(y)

Solution (Python):
def GCD(p,q):
    if p<q:p,q=q,p
    if p%q==0:
        return q
    else:
        return GCD(q,p%q)

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

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

    return gcd(b % a, a)


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

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

n=list(map(int,input().split()))
if n[0]==n[1]:
  print(gc(n[0],n[1]))
elif n[0]>n[1]:
  a=n[0]%n[1]
  print(gc(n[1],a))
else:
  a=n[1]%n[0]
  print(gc(n[0],a))

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

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

    return x
    
print(gcd(a,b))

Solution (Python):

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


def main():
    A, B = tuple(map(int, input().split()))
    ans = gcd(A, B)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def euc(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return euc(b%a, a)
if __name__ == '__main__':
    a, b = map(int,input().split())
    print(euc(a, b))

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

Solution (Python):
x, y = map(int, input().split())
b = max(x, y)
s = min(x, y)
c = b % s
while c != 0:
  b = s % c
  b, s, c = s, c, b
print(s)

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

print(x)

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

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


gcd(x,y)

Solution (Python):
def test():

	inputs = list(map(int,input().split()))
	
	if inputs[0] > inputs[1]:
		a = inputs[0]
		b = inputs[1]
	else:
		a = inputs[1]
		b = inputs[0]

	while b > 0:

		r = a % b
		a = b
		b = r

	print(a)


if __name__ == "__main__":
	test()

Solution (Python):
def f(a,b):
    return a if b==0 else f(b,a%b)
n,m=map(int,input().split())
print(f(n,m))

Solution (Python):
Z= input().split()
X=int(Z[0])
Y=int(Z[1])
while(X!=Y):
    if(X>Y):
        R=X-Y
        X=Y
        Y=R
    elif(X<Y):
        R=Y-X
        Y=R
print(Y)

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

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

Solution (Python):
x,y=map(int,raw_input().split())
a=0
if x<y:
	x,y=y,x

while True:
	a=x%y
	if a==0:
		a=y
		break
	elif x%a==0 and y%a==0:
		break
	x=y
	y=a
	
print a

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


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

Solution (Python):


import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

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

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

print(GCD(x,y))

Solution (Python):
def Input():
    data = list(map(int,input().split()))
    return data

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

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

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):
from math import gcd
  
n, m = map(int, input().split())
print(gcd(n, m))

Solution (Python):
from math import gcd
 
a, b = map(int, input().split())
print(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())
def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y
print(gcd(x,y))

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):
from math import gcd
 
n, m = map(int, input().split())
print(gcd(n, m))

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

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

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

A, B = map(int, input().split())
print(gdc(A, B))