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 ≤ 109

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



Sample input:
54 20


Sample output:
2

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
if a <= b:
    a, b = b, a

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

print(b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#ALDS1_1_B

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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(r)

print(y)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(x)

Submission status: Accepted

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

Submission status: Accepted

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

print(math.gcd(x,y))

Submission status: Accepted

Solution code:
import sys
# import bisect
import math
# import itertools
# import numpy as np
# import collections

"""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進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        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])
                    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():
    # 1文字に省略
    r, e, p = range, enumerate, print
    ip = IP()
    id = Idea()
    mod = 10 ** 9 + 7

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


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcd(x,y):
    if x < y:
        x,y = y,x # x>yという状態を作っておく
    while y > 0:  #yが0になるまで（下記においてyはxをyで割ったときの余り）
        r = x % y #余りをrとして一時保管
        x = y     #yをxに代入して
        y = r     #余りをyとする
    return x      #余り（y）が0になった時のxの値を返す

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
#Euclidean Algorithm
#Aetene
if a<b:
    key = a
    a = b
    b = key
r = a%b
while r != 0:
    a = b
    b = r
    r = a%b
print(b)

Submission status: Accepted

Solution code:
# coding: utf-8

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcd(a, b):
    if a == b:
        return a
    else:
        if a < b:
            a, b = b, a #so, a > b
        if b == 0:
            return a
        return gcd(b, a % b)

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

Submission status: Accepted

Solution code:
import math

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

print(math.gcd(a, b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

print(math.gcd(a, b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#最大公約数を求めるアルゴリズム

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#Greatest Common Divisor
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B&lang=jp

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

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

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

print(math.gcd(x, y))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcd(m, n):
  r = m % n
  return gcd(n, r) if r else n

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

print(math.gcd(a,b))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(b)

Submission status: Accepted

Solution code:
import fractions

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

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

Submission status: Accepted

Solution code:
def gcd(x, y):
    if x < y:
        x, y = y, x
        # x,y = y,x はswap(値の交換)を表す

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


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


# ユークリッドの互除法により最大公約数: GreatestCommonDivisorを求める

# 以下のようなアルゴリズムはn回の割り算を行う必要があるため、大きな数に対しては時間内に出力を得ることはできない
# gcd(x, y)
#     n = min(x, y)
#     for d = n downto 1
#         if x と y がともに d で割り切れる
#             return d

# ユークリッドの互除法による最大公約数の判定
# gcd(x, y)
#     if x < y
#         swap(x, y)
#     while y > 0
#         r = x % y
#         x = y
#         y = r

#     return x

# ユークリッドの互除法
# a = bq + r
# 74 = 54*1+20
# 54 = 20*2+14
# 20 = 14*1+6
# 14 = 6*2+2
# 6 = 2*3+0


# 一行に複数入力
# >> > a, b = map(int, input().split())  # 標準入力を行う
# 33 66
# >> > print(a)
# 33
# >> > print(b)
# 66

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcn(a,b):
    if a == 0:
        return b
    else:
        return gcn(b%a,a)
dat = input()
dat = dat.split(" ")
print(gcn(int(dat[0]),int(dat[1])))

Submission status: Accepted

Solution code:
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())
ans = gcd(a, b)
print(ans)

Submission status: Accepted

Solution code:
# GCD
def gcd(m,n):
	while not n == 0:
		tmp = n
		n = m % n
		m = tmp
	return m
x,y = map(int, tuple(input().split(' ')))
print(gcd(x,y))

Submission status: Accepted

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

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

Submission status: Runtime Error

Solution code:
x = input()
y = input()

if x < y:
	tmp = x
	x = y
	y = tmp

x_y_divisor = list()
y_divisor = list()
x_mod_y = x % y


for i in range(1,(x_mod_y)+1):
	if x_mod_y % i == 0:
		x_y_divisor.append(i)


for i in range(1,y+1):
	if y % i == 0:
		y_divisor.append(i)


x_y_divisor_set = set(x_y_divisor)
y_divisor_set = set(y_divisor)

ans_divisor = y_divisor_set.intersection(x_y_divisor_set)
print(max(ans_divisor))

Submission status: Runtime Error

Solution code:
input_list = map(int, raw_input().split())

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

if x < y:
	tmp = x
	x = y
	y = tmp

x_y_divisor = list()
y_divisor = list()
x_mod_y = x % y


for i in range(1,(x_mod_y)+1):
	if x_mod_y % i == 0:
		x_y_divisor.append(i)


for i in range(1,y+1):
	if y % i == 0:
		y_divisor.append(i)


x_y_divisor_set = set(x_y_divisor)
y_divisor_set = set(y_divisor)

ans_divisor = y_divisor_set.intersection(x_y_divisor_set)
print(max(ans_divisor))