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):
x, y = map(int, input().split())
while x != y:
  if x > y:
    x -= y
  else:
    y -= x
print(x)

Solution (Python):
def getGCD(a, b): 
    if a < b:
        a, b = b, a
    c = a % b
    if c == 0:
        return b
    else:
        return getGCD(b, c)

x, y = map(int, input().split())
print(getGCD(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())
while b: a,b=b,a%b
print(a)

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

if x<y:
    str=x
    x=y
    y=str
while True:
    r=x%y
    x=y
    y=r
    if r==0:
        print(x)
        break

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

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

z = 0
if x < y:
    z = gcd(y, x)
else:
    z = gcd(x, y)

print(z)

Solution (Python):
def culc(x, y):
    if x > y:
        n_large = x
        n_small = y
    else:
        n_large = y
        n_small = x

    while True:
        
        n_remainder = n_large % n_small
        if n_remainder == 0: break
        n_large = n_small
        n_small = n_remainder

    return n_small

if __name__ == "__main__":

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

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

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

while y > 0:
    X = x
    Y = y
    x = Y
    y = X % Y
print(x)

Solution (Python):
def GCD(x, y):
    if x < y:
        if y % x == 0:
            print(str(x))
        else :
            GCD(x, y%x)
    elif x > y:
        if x % y == 0:
            print(str(y))
        else :
            GCD(y, x%y)
    else :
        print(str(x))

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

Solution (Python):






import sys
import math


class mymath:
    
    pi = 3.14159265358979323846264338

    
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

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

    
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()


class output:
    
    def list(self, l):
        l = list(l)
        
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()






































def get_input():
    N = []
    while True:
        try:
            N.append(input())
            
            
        except EOFError:
            break
    return N

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d


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

print(mymath.gcd(x, y))

Solution (Python):
if __name__=='__main__':
    a, b = tuple(map(int, input().split(' ')))
    x = min([a, b])
    y = max([a, b])
    while True:
        x, y = y%x, x
        if x == 0:
            break
    print(y)

Solution (Python):
def find_gcd(a: int, b: int) -> int:
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return find_gcd(b, a % b)


if __name__ == "__main__":
    a, b = list(map(lambda x: int(x), input().split()))
    print(f"{find_gcd(a, 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):
import math

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

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

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


if __name__ == "__main__":
    a, b = map(int, input().split())
    print(gcd(a, b))

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

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

while True:
	if y==0:
		break
	x,y=y,x%y
print(x)

Solution (Python):
from sys import stdin
a, b = [int(_) for _ in stdin.readline().rstrip().split()]

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

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


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

Solution (Python):
def euclidean(x, y):
    if y > x:
        x, y = y, x
    while y > 0:
        x_tmp = x
        y_tmp = y
        
        x = y_tmp
        y = x_tmp % y_tmp
    
    return x
        

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

print(euclidean(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):
from sys import setrecursionlimit
setrecursionlimit(10**5)
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):
def gcd(a,b):
    x = max(a,b)
    y = min(a,b)
    
    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 = list(map(int,input().split()))

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

print(y)

Solution (Python):
def gcd(n, m):
    
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a
N,M = map(int, input().split())
print(gcd(N,M))

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 EuclideanAlgolism(x, y):
   if x<y:
       x, y = y, x
   while y!=1:
        if x%y == 0:
            break
        else:
            x, y = y, x%y
   print(y)

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

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


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

Solution (Python):
a=list(map(int,input().split()))
x,y=a[0],a[1]
d=1
while x>0 and y>0:
    if x<=y:
        d=x
        y=y%x
    else:
        d=y
        x=x%y
print(d)

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

Solution (Python):
L=input().split( )
x=int(L[0])
y=int(L[1])
if x<y:
    w=x
    x=y
    y=w

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

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

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

print(gcd(x, y))

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

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 gc(n,m):
    if(n%m==0):
        return m
    else:
        return gc(m,n%m)

x,y=map(int,input().split())
ans=0
if(x>y):
    ans=gc(x,y)
else:
    ans=gc(y,x)
print(ans)

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


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


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



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

print(gcd(x, y))

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

if __name__ == '__main__':
	d = [int(s) for s in input().split()]
	d.sort()
	while len(d) != 1:
		res=gcd(d[0],d[1])
		del d[:1]
		d[0] = res
	print(d[0])

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

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

    for i in range(b//2 + 1, 0, -1):
        if a % i == 0 and b % i == 0:
            return i

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

print (gcd(x,y))

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

if(y > x):
    v = x
    x = y
    y = v
        
r = x % y
while(r != 0):
    x = y
    y = r
    
    r = x % y


print(y)

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


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

Solution (Python):
a, b = map(int, input().split())
x, y = max(a, b), min(a, b)
z = x % y
ans = 0

while 1:
    if z == 0:
        z = y
        break
    elif z >= y:
        break
    else:
        y, z = z, y % z

for i in range(z, 0, -1):
    if y % i == 0 and z % i == 0:
        ans = i
        break

print(ans)

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

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

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

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

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

print(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):
	r = x % y
	return gcd(y, r) if r else y

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

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

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):
in_data = [int(i) for i in input().split()]
a = in_data[0]
b = in_data[1]
gcd = []
if a > b:
    large_number = a
    small_number = b
else:
    large_number = b
    small_number = a
    
while True:
    mod_result = large_number % small_number
    if mod_result == 0:
        answer = small_number
        break
    large_number = small_number
    small_number = mod_result
    
print(answer)

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

print(math.gcd(x,y))

Solution (Python):
import sys

import math




"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

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


"""ここからメインコード"""


def main():
    
    r, e, p = range, enumerate, print
    ip = IP()
    id = Idea()
    mod = 10 ** 9 + 7

    """この下から書いてね"""
    x, y = ip.IL()
    print(math.gcd(x, y))


main()

Solution (Python):
def sort(a, b):
    amari = a % b
    if amari == 0:
        return b
    else:
        ans = sort(b, amari)
    return ans

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

Solution (Python):
import math

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

print(math.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 = map(int,input().split())
while True:
    if a < b:
        a, b = b, a
    if a % b == 0:
        print(b)
        break
    else:
        a = a - b

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

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

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

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


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())
if x > y:
    Max = x
    Min = y
else:
    Max = y
    Min = x
R = Max%Min
while R!= 0:
    Max = Min
    Min = R
    R = Max%Min
print(Min)

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

Solution (Python):
def greatest_common_divisor(x, y):
    amari = x % y
    return y, amari

numbers = [int(i) for i in input().split()]
x = numbers[0]
y = numbers[1]
while y != 0:
    x, y = greatest_common_divisor(x, y)
print(x)

Solution (Python):
import sys

nums = [int(num) for num in input().split(" ")]

if nums[0] == nums[1]:
    print(nums[0])
    exit()
elif nums[0] > nums[1]:
    big_num = nums[0]
    small_num = nums[1]
else:
    big_num = nums[1]
    small_num = nums[0]

while (big_num % small_num) != 0:
    tmp = big_num
    big_num = small_num
    small_num = tmp % small_num

print(small_num)

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

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

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

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

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


if a<b:
    key = a
    a = b
    b = key
r = a%b
while r != 0:
    a = b
    b = r
    r = a%b
print(b)

Solution (Python):


def getGCM(a, b):
    if b > a:
        a, b = b, a
    while True:
        r = a % b
        if r == 0:
            return b
        else:
            a = b
            b = r

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

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())
ans = gcd(x,y)
print(ans)

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

a, b = max(nums), min(nums)

prev_m = a
while True:
    d, m = divmod(a, b)
    if m:
        prev_m = m
        a, b = b, m
    else:
        print(prev_m)
        break

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

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

Solution (Python):
import math

list = list(map(int, input().split()))
a = list[0]
b = list[1]

print(math.gcd(a, b))

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

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

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

print(x)

Solution (Python):
def Euclid(x,y):
    if x<y:
        hoge = x
        x = y
        y = hoge
    a = x%y
    while a!=0:
        x = y
        y = a
        a = x % y
    print(y)

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

Solution (Python):
def printArrLine( arr ):
    print(' '.join(list(map(str,arr))))
    
def inputArrLine():
    return [int(i) for i in input().split()]

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

ar = inputArrLine()
a = ar[0]
b = ar[1]

print(gcd(a,b))

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

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

print(math.gcd(a, b))

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

Solution (Python):


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

if A >= B:
    while True:
        if A % B == 0:
            print(B)
            break
        A, B = B, A % B
else:
    while True:
        if B % A == 0:
            print(A)
            break
        B, A = A, B % A

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())
d = gcd(x, y)
print(d)

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

Solution (Python):
def gcd(x, y):
    if x < y:
        buf = x
        x = y
        y = buf
    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
    else:
        return gcd(b,a%b)

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

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

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

Solution (Python):
X, Y = list(map(int, input().split()))
x = y = 0
if X >= Y:
    x = X
    y = Y
else:
    x = Y
    y = X

def calcGCD(a, b):
    d = a % b
    if d != 0:
        a = b
        b = d
        return calcGCD(a, b)
    else:
        return b


print(calcGCD(x, y))

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


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

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

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

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

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

Solution (Python):
def mygcd(x,y):
    if y != 0:
        mygcd(y,x%y)
    else:
        print(x)

if __name__ == "__main__":
    a,b = map(int,input().split())
    if a<b:
        tmp = a
        a = b
        b = tmp
    mygcd(a,b)

Solution (Python):
import math

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

print(gcd(a,b))

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()]
ans = gcd(x, y)
print(ans)

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

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

Solution (Python):
def main():
    x, y = (int(i) for i in input().split())
    getGreatestCommonDiviser(x,y)


def getGreatestCommonDiviser(x, y):
    c = max(x,y) % min(x,y)
    if c == 0:
        print(min(x,y))
    else:
        getGreatestCommonDiviser(min(x,y),c)

main()

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:
    a = x
    b = y
else:
    a = y
    b = x

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

print(b)

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

    return x

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

print(gcd(x,y))

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 math

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

main()

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

if num[0]>num[1]:
    x=num[0]
    y=num[1]
elif num[0]<num[1]:
    x=num[1]
    y=num[0]
else:
    x=num[1]
    y=num[0]
    b=num[1]

a=x%y

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

print(b)

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

def ju(i,j):
    if i%j==0:
        d=j
    else:
        a=i
        b=j
        c=a%b
        while c>0:
            a=b
            b=c
            c=a%b
            if c==0:
                d=b
                break
    return d

if x>=y:
    print(ju(x,y))
else:
    print(ju(y,x))

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

if b > a:
    temp = a
    a = b
    b = temp

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

print(a)

Solution (Python):



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

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

Solution (Python):
def gcd(x,y):
    if y==0:
        print(x)
        return
    else:
        gcd(y,x%y)
        
nums=list(map(int, input().split()))
gcd(max(nums[0],nums[1]), min(nums[0],nums[1]))

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

print(math.gcd(x, y))

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

while(1):
    if x % y == 0:
        print(y)
        exit()
    else:
        tmp = x % y
        x = y
        y = tmp

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

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

if a <  b:
    c = a
    a = b
    b = c
    
print(int(gcd(a, b)))

Solution (Python):
x,y=map(int,input().split())
while x%y !=0:
    A=max(x,y)
    B=min(x,y)
    C=A%B
    if C>=B:
        x=C
        y=B
    else:
        x=B
        y=C
print(y)

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)

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

Solution (Python):
x,y = list(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 answer(x,y):
    if(x==0):
        return y
    elif y==0:
        return x
    if(x>=y):
        return answer(y,x%y)
    else:
        return answer(x,y%x)
xy= list(map(int,input().split(" ")))
x,y=xy[0],xy[1]
print(answer(x,y))

Solution (Python):
n=list(map(int,input().split()))
m=[]
while n[0]!=0:
	if n[0]<=n[1]:
		m=n[0]
		n[0]=n[1]
		n[1]=m
	n[0]=n[0]%n[1]
print(n[1])

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

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

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

Solution (Python):
class Gcd:
    def __init__(self,x,y):
        if(x<=y):
            self.__a=x
            self.__b=y
        else:
            self.__a=y
            self.__b=x
    
    def gcd(self):
        self.__c=(self.__b)%(self.__a)
        if(self.__c==0):
            print(self.__a)
            return 0
        self.__b=self.__a
        self.__a=self.__c
        self.gcd()


        

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

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

Solution (Python):
def euc_core(a,b):
    mod = a % b

    return b, mod

def euc(a,b):
    a_i = a
    b_i = b
    while True:
        if b_i == 0:
            break
        a_i, b_i = euc_core(a_i, b_i)
    
    return a_i


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

if a < b :
    ai = a
    a = b
    b = ai

print(euc(a,b))

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

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

while True:
    d, r = a//b, a%b
    if r==0:
        break
    a, b = b, r

print(b)

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

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

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

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 x % y == 0:
        return y
    else:
        return gcd(y, x % y)

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

main()

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

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


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

Solution (Python):
a = [int(i) for i in input().split()]
a.sort()
while True:
    if a[1] % a[0] == 0:
        print(a[0])
        break
    else:
        a[1] = a[1]% a[0]
    a.sort()

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

print(math.gcd(a,b))

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

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

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

Solution (Python):
a, b = [int(i) for i in sorted(input().split(), reverse=True)]

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

print(b)

Solution (Python):
import fractions

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

if a >= b:
    print(fractions.gcd(b, a%b))
else:
    print(fractions.gcd(a, b%a))

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):
    r = x % y
    if r:
        return gcd(y, r)
    else:
        return y
a, b = map(int, input().split())
print(gcd(a,b))

Solution (Python):
x, y = 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(x, y))