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:
z=list(map(int,input().split()))
z.sort()
a=0

while True:
    if z[1]==z[0]:
        break
    a=z[1]-z[0]
    if z[0]%a==0:
        z[1] = z[0]
        z[0] = a
        z.sort()
        break
    z[1]=z[0]
    z[0]=a
    z.sort()

print(z[0])

Submission status: Accepted

Solution code:
def gcm(x,y):
    while y:
        x, y = y, x % y
    return x

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
x, y = max(a, b), min(a, b)

while 1:
    if x%y == 0:
        break
    x, y = y, x%y

print(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:
from fractions import gcd

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

Submission status: Accepted

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


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

print gcd(x, y)

Submission status: Accepted

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

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

def main():
    X, Y = map(int, input().split())

    print(gcd(X,Y))

if __name__ == "__main__": main()

Submission status: Accepted

Solution code:
a, b = [int(x) for x in input().split()]
while b:
    a, b = b, a % b
print(a)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
a1,b1 = list(map(int,input().split()))

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

        return(gcd(a,b))

print(gcd(a1,b1))

Submission status: Accepted

Solution code:
a = input().split()
x = int(a[0])
y = int(a[1])
while y:
    x, y = y, x%y
print(x)

Submission status: Accepted

Solution code:
num = input().split()
if int(num[0])<int(num[1]):
    x = int(num[1])
    y = int(num[0])
else:
    x = int(num[0])
    y = int(num[1])

end = 0
    
z = x % y
if z == 0:
    print(y)
else:
    while True:
        z1 = y % z
        y1 = z
        if z1 == 0:
            print(z)
            break 
        z = z1
        y = y1

Submission status: Accepted

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

def GCD(a,b):
    x = max(a,b)
    y = min(a,b)   
     
    while y :
        x, y = y, x % y
    return x

print(GCD(a,b))

Submission status: Accepted

Solution code:
def Euclid(max, min):
    if max % min == 0:
        return min
    else:
        return Euclid(min, max % min)


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

Submission status: Accepted

Solution code:
def gcd(a, b): 
    while b: 
        a, b = b, a % b 
    return a 
def lcm(a, b): 
    return a * b // gcd (a, b) 

c,d=[int(i) for i in input().split()]

print(gcd(c,d))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def swap(x, y):
    tmp = x
    x = y
    y = tmp

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

z = 0

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

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

print(gcd(a,b))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a,b=sorted(list(map(int, input().split())))

m=b%a
while m>=1:
    b=a
    a=m
    m=b%a
print(a)

Submission status: Accepted

Solution code:
def main():

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

main()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main() :
    x, y = [int(d) for d in input().split()]
    while y != 0 :
        x, y = y, x%y

    print(x)

if __name__ == '__main__' :
    main()

Submission status: Accepted

Solution code:
def main() :
    x, y = [int(i) for i in input().split()]
    while y != 0 :
        x, y = y, x%y

    print(x)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
dbg = False

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

if a > b:
    x, y = a, b
else:
    x, y = b, a

divs = [1]
for i in range(1, int((y+1)/2)+1):
    gcd_tmp = int(y / i)
    if dbg: print('%d, %d' % (i, gcd_tmp))
    if i > gcd_tmp:
        break
    if y % i == 0:
        if x % gcd_tmp == 0:
            print(gcd_tmp)
            exit()
        elif x % i == 0:
            divs.append(i)

print(max(divs))

Submission status: Accepted

Solution code:
def gcd(a,b): 
    if b == 1:
        return 1
    else:
        return (gcd(b,a%b) if b != 0 else a)
A = list(map(int,input().split()))
print(gcd(A[0],A[1]))

Submission status: Accepted

Solution code:
def gcd(X,Y):
    x = X
    y = Y
    if y > x:
        x,y = y,x
    while x % y:
        x,y = y,x%y
    return y

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def greatest_common_divisor(x, y):
    if x < y:
        x, y = y, x

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

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

Submission status: Accepted

Solution code:
N=raw_input()
N = [int(i) for i in N.split()]
m,n = (N[1],N[0]) if N[1] > N[0] else (N[0],N[1])
def gcd(m, n):
    if ((m % n) == 0):
        return n
    else:
        return gcd(n, m % n)
print gcd(m,n)

Submission status: Accepted

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

x = max(a,b)
y = min(a,b)
res = y

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

print(res)

Submission status: Accepted

Solution code:
def g(n):
 x,y=n
 r=x%y
 if r>0:g((y,r))
 else:print(y)
g(sorted(list(map(int,input().split()))))

Submission status: Accepted

Solution code:
# coding:utf-8
def gcd(a,b):
    while b:
        a, b = b, a % b
    return a
n = map(int, raw_input().split())
n.sort(reverse=True)
print gcd(n[0],n[1])

Submission status: Accepted

Solution code:
ab = [int(x) for x in input().split()]

# Naive Algorithm
# m = min(ab)
# gcd = 1
# for i in range(2, int(m/2)):
#     if ab[0] % i == 0 and ab[1] % i == 0:
#         gcd = i
# print(gcd)

# Euclidean Algorithm
while True:
    min_i = ab.index(min(ab))
    max_i = ab.index(max(ab))
    r = ab[max_i] % ab[min_i]
    if r == 0:
        print(ab[min_i])
        break
    else:
        ab[max_i] = r

Submission status: Accepted

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

'''
# 09.98 sec    13492 KB    4 lines     99 bytes
# Time Limit Exceeded
n=int(input())
r=[int(input())for _ in range(n)]
print(max([max(r[i+1:])-r[i]for i in range(n-1)]))
'''

Submission status: Accepted

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

Submission status: Accepted

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

'''
# 00.02 sec    5588 KB    4 lines     55 bytes
a,b=map(int,input().split())
while b:a,b=b,a%b
print(a)
'''

Submission status: Accepted

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

# 00.02 sec    5588 KB    4 lines     55 bytes
# a,b=map(int,input().split())
# while b:a,b=b,a%b
# print(a)

Submission status: Accepted

Solution code:
# 00.02 sec    5588 KB    4 lines     55 bytes
# a,b=map(int,input().split())
# while b:a,b=b,a%b
# print(a)

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

Submission status: Accepted

Solution code:
'''
00.02 sec    5588 KB    4 lines     55 bytes
a,b=map(int,input().split())
while b:a,b=b,a%b
print(a)
'''
import math
a,b=map(int,input().split())
print(math.gcd(a,b))

Submission status: Accepted

Solution code:
'''
# 00.02 sec    5588 KB    4 lines     55 bytes
a,b=map(int,input().split())
while b:a,b=b,a%b
print(a)
'''

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

Submission status: Accepted

Solution code:
z = input().split()
x = int(z[0])
y = int(z[1])

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

Submission status: Accepted

Solution code:
#coding: UTF-8

import sys

class Algo:
  @staticmethod
  def greatest_common_divisor(x, y):
    while True:
      r = x%y
      if r==0:
        print(y)
        break
      x, y = y, r
l = list(map(int, input().split()))
X = l[0]
Y = l[1]
Algo.greatest_common_divisor(X, Y)

Submission status: Accepted

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

###??????x >= y
if y>x:x,y = y,x

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

Submission status: Accepted

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

print(gcd(*[int(i) for i in input().split()]))

Submission status: Accepted

Solution code:
A = list(map(int,input().split()))
a=A[0]
b=A[1]
if a<b:
    a,b=b,a
while b:
    a,b=b,a%b
print(a)

Submission status: Accepted

Solution code:
A = list(map(int,input().split()))
a=A[0]
b=A[1]
while b:
    a,b=b,a%b
print(a)

Submission status: Accepted

Solution code:
A = list(map(int,input().split()))
a=A[0]
b=A[1]
while b:
    a, b = b, a%b
print(a)

Submission status: Accepted

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

l = raw_input().split()
if(int(l[0]) > int(l[1])):
    print gcd(int(l[0]),int(l[1]))
else:
    print gcd(int(l[1]),int(l[0]))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	a, b = input().split()
	a, b = int(a), int(b)
	if a < b:
		x = b
		y = a
	else:
		x = a
		y = b
	while True:
		x, y= y, x % y
		if y == 0:
			print(x)
			break
		else:
			continue

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
l = max(x, y)
s = min(x, y)

for i in range(x):
    olds = s
    oldl = l
    s = oldl % olds
    l = olds

    if s == 0:
        print(l)
        break

Submission status: Accepted

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

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

print(gcd(x, y))

Submission status: Accepted

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

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


while True:
    if b == 0:
        break
    tmp = a % b
    a = b
    b = tmp

print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def gcm(a, b):

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


if __name__ == '__main__':

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

    print(gcm(a,b))

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 = list(map(int, input().split()))
print(gcd(x, y))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# coding: UTF-8
def euclidean_algorithm(x,y):
    if x > y:
        p = y
        r = x%y
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p
    elif x == y:
        return x
    elif x < y:
        p = x
        r = y%x
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding; utf-8

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

print a

Submission status: Accepted

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

import sys

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

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

Submission status: Accepted

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

print(inp[0])

Submission status: Accepted

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

    return x+y

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

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

Submission status: Accepted

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

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

    return x

print(gcd(x, y))

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

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 最大公約数(greatest common divisor)を求める関数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(x)

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

    if a == 0:
        return b

    return gcd(b % a, a)


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


if __name__ == '__main__':
    run()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

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

    return x


if __name__ == '__main__':

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

Submission status: Accepted

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

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

print(c(t,u))

Submission status: Accepted

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


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


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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(y)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#16D8102008K 1-D Greatest Common Divisor 柳生　葉月　Yagyu Hauzki
import math
a,b=map(int,input().split())
def f(x,y):
    while(1):
        tmp=x%y
        x=y
        y=tmp
        if tmp==0:
            gcd=x
            break
    return gcd
print(f(a,b))

Submission status: Accepted

Solution code:

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

a=1

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

print(x)

Submission status: Accepted

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

print(x)

Submission status: Accepted

Solution code:
#16D8101023J 久保田凌弥 kubotarouxxx python3

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    return y


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

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

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

Submission status: Accepted

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

Submission status: Accepted

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



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


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#16D8101012J 伊藤惇 dj Python3 

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

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

Submission status: Accepted

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

x=a%b

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

print(b)

Submission status: Accepted

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

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


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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:
x,y=map(int,input().split())
a=1
while a!=0:
    a=x%y
    tmp=y
    y=a
    x=tmp
print(tmp)

Submission status: Accepted

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



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

Submission status: Accepted

Solution code:
def GCD(x,y):

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

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

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

"""実行結果

100 55
5



66 77
11

"""

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ALDS 1-B: Greatest Common Divisor

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

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

Submission status: Accepted

Solution code:

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

	print (s[1])

Submission status: Accepted

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

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

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! python3
# greatest_common_divisor.py

def greatest_common_divisor(x, y):
    r = None

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

    return greatest_common_divisor(y, r)

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

Submission status: Accepted

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

Submission status: Accepted

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


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

print(gcm(x, y))

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:
if __name__ == '__main__':
    s = input().split()
    if s[0] < s[1]:
        tmp = s[0]
        s[0] = s[1]
        s[1] = tmp
    while True:
        x = int(s[0]) % int(s[1])
        if x==0:
            break
        s[0] = s[1]
        s[1] = x
 
    print (s[1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

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

main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

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

print(x)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(y)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ALDS_1_B.

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

def get_gcd(x, y):
    if x < y: return get_gcd(y, x)
    # x >= yのときはx % yを計算してyとx % yの話にする。
    # ここでx % yのところが0ならばyが求める答えとなる。
    if y == 0: return x
    return get_gcd(y, x % y)

def main():
    a = intinput()
    x = a[0]; y = a[1]
    # Pythonではa, bのswapはa, b = b, aとか書く。
    print(get_gcd(x, y))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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


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

print(gcd(x, y))

Submission status: Accepted

Solution code:

import math

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


print(math.gcd(x,y))

Submission status: Accepted

Solution code:

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

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


print(gcd(x,y))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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