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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

# MAIN
x, y = map(int, raw_input().split())
print euclideanAlgorithm(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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

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

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

Submission status: Accepted

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

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

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

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

print(x)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

  print(b)

  return 0


if __name__ == '__main__':
  main()

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(' '))
n = min(x, y)

print(gcd(x, y))

Submission status: Accepted

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

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

print gcd(a,b)

Submission status: Accepted

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

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

print(gcd(x,y))

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

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

Submission status: Accepted

Solution code:
import sys
import math

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

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

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

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

print(divisor)

Submission status: Accepted

Solution code:
# 1_1_B

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(a)

Submission status: Accepted

Solution code:
import sys

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

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

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

Submission status: Accepted

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

print(str(x))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:UTF-8
def GCD(x,y):
    d=0
    if x < y:
        d=y
        y=x
        x=d
    if y==0:
        print(x)
    else:
        GCD(y,x%y)
if __name__=="__main__":
    a=input()
    x=int(a.split(" ")[0])
    y=int(a.split(" ")[1])
    GCD(x,y)

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:
x, y = sorted([int(i) for i in input().split()])
while x > 0:
    z = x
    x = y % x
    y = z
    
print(y)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import time

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

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

gcd(a,b)

Submission status: Accepted

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

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

Submission status: Accepted

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

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, raw_input().split())
print gcd(x, y)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B&lang=jp
#??????????????????????????????
#?????§??¬?´???°???????????????????????????????????¨????????¨?¨????????????????
def gcd(x,y):
    tmp = y
    
    if y > x:
        y = x
        x = tmp

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

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

Submission status: Accepted

Solution code:
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B&lang=jp
#??????????????????????????????
#?????§??¬?´???°???????????????????????????????????¨????????¨?¨????????????????
def gcd(x,y):
    
    if y > x:
        x, y = y, x

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

Submission status: Accepted

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

Submission status: Accepted

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

print gcd(x, y)

Submission status: Accepted

Solution code:
def calc_gcd(x, y):
    """
    math.gcd()????????¨??§????????????python3.5??\??????AOJ???python?????????????????????3.4????????§?????¨??§?????????
    """
    if y == 0:
        return x
    else:
        return calc_gcd(y, x % y)


if __name__ == '__main__':
    data = [int(x) for x in input().split(' ')]
    result = calc_gcd(data[0], data[1])
    print('{0}'.format(result))

Submission status: Accepted

Solution code:
def greatest_common_divisor(a, b):
  if a == 0 or b == 0:
    return max(a, b)

  return greatest_common_divisor(max(a, b) - min(a, b), min(a, b))

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

Submission status: Accepted

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

"""
input:
147 105

output:
21
"""

import sys


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__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    print(gcd(n1, n2))

Submission status: Accepted

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

"""
input:
147 105

output:
21
"""

import sys


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


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    print(gcd(n1, n2))

Submission status: Accepted

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

def gcd(A, B):
	if B==0: return(A)
	else: return(gcd(B, A%B))

print(gcd(A,B))

Submission status: Accepted

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

def gcd(num_a, num_b):
    if num_b == 0:
        return num_a
    elif num_a == 0:
        return num_b

    if num_a < num_b:
        return gcd(num_a, num_b % num_a)
    else:
        return gcd(num_b, num_a % num_b)

num_a, num_b = [int(x) for i, x in enumerate(input().split()) if i < 2]
print(gcd(num_a, num_b))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
data = list(map(int, input().split()))
a,b = max(data), min(data)
r = a % b

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

print(b)

Submission status: Accepted

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


#input number
l = raw_input()

x, y = [int(e) for e in l.split()]
 
if x < 1 and x > 10000000000:
	exit()

if y < 1 and y > 10000000000:
	exit()

print gcd(x, y)

Submission status: Accepted

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


def gcd(x, y):
    # GCD(Greatest Common Divisor)
    if x < y:
        x, y = y, x

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

    print(x)


def to_xy(v):
    return [int(c) for c in v.split()]


if __name__ == '__main__':
    x, y = to_xy(input())
    gcd(x, y)

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

Submission status: Accepted

Solution code:

a,b = map(int,input().split())
while True:
    r=a%b
    if r==0:
        break
    else:
        a=b
        b=r
print(b)

Submission status: Accepted

Solution code:
#Greatest Common Diveser
def gcd(x, y):
    if x >= y:
        x = x % y
        if x == 0:
            return y
        return gcd(x, y)
    else:
        y = y % x
        if y == 0:
            return x
        return gcd(x, y)

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

Submission status: Accepted

Solution code:
#Greatest Common Diveser
def gcd(a, b):
    while a > 0:
        if a < b: a, b = b, a
        a = a % b
    return b

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
def gcd(n,m):
    if n < m:
        tmp = m
        m = n
        n = tmp
    while m > 0:
        r = n % m
        n = m
        m = r
    return n
    
x, y = map(int,input().split())
print(gcd(x,y))

Submission status: Accepted

Solution code:
def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while y != 0:
        x, y = y, x % y
    return x

X, Y = (int(s) for s in input().split())
print(gcd(X, Y))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

if x < y:
    a = x
    x = y
    y = a

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

max_kouyakusu = kouyakusu(x,y)

Submission status: Accepted

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

a,b = map(int,raw_input().split())
if a < b :
  temp = a
  a = b
  b = temp
print gcd(a,b)

Submission status: Accepted

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

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:
    ret = a
    a = b
    b = ret


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

print(str(gcd(a,b)))

Submission status: Accepted

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

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

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

print(x)

Submission status: Accepted

Solution code:
def gcd(x, y):
    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:
def gcd(x, y):
    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:
# -*- coding: utf-8 -*-


def converter(a, b):
    larger = max(a, b)
    smaller = min(a, b)
    if larger == 0 or smaller == 0:
        return larger
    else:
        return converter(smaller, larger % smaller)        


def main():
    a, b = [int(x) for x in raw_input().strip().split(' ')]
    print converter(a, b) 


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def converter(a, b):
    larger = max(a, b)
    smaller = min(a, b)
    if smaller == 0:
        return larger
    else:
        return converter(smaller, larger % smaller)        


def main():
    a, b = [int(x) for x in raw_input().strip().split(' ')]
    print converter(a, b) 


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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


def main():
    a, b = sorted([int(x) for x in raw_input().strip().split(' ')])
    print converter(a, b) 


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def main():
    a, b = sorted([int(x) for x in raw_input().strip().split(' ')])
    print converter(a, b) 


if __name__ == '__main__':
    main()

Submission status: Accepted

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


a, b = sorted([int(x) for x in raw_input().strip().split(' ')])
print converter(a, b)

Submission status: Accepted

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


a, b = sorted([int(x) for x in raw_input().split(' ')])
print converter(a, b)

Submission status: Accepted

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

if a > b:
    A = a
    B = b
else:
    A = b
    B = a

GCD = 1
while True:
    A, B = B, A%B
    
    if B == 0:
        break
    
print (str(A))

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !
def mcg(a,b):
    if a==b:
        return a
    else:
        
        while a%b !=0:
            x = a%b
            a = b
            b = x
        return x

num =sorted(list(map(int,input().split(" "))))
print(mcg(num[0],num[1]))

Submission status: Accepted

Solution code:
def gdc(a,b):
    #print("%d, %d"%(a,b))
    if min(a,b) == 0:
        return a
    else:
        return gdc(min(a,b), max(a,b)%min(a,b))
        
a = [int(s) for s in input().split(" ")]
print(gdc(a[0],a[1]))

Submission status: Accepted

Solution code:

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

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

    return b


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

Submission status: Accepted

Solution code:
import sys

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

# print(gcd(54, 20))
# print(gcd(147, 105))

input = sys.stdin.readline()
input = input.split(" ")
input = [int(i) for i in input]

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

Submission status: Accepted

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

def mak(A, B) :
    while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
    return A

if a > b : print(mak(a, b))
else     : print(mak(b, a))

Submission status: Accepted

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

import sys
import os
import math


a, b = list(map(int, input().split()))
# a?????§?????????????????????
if b > a:
    a, b = b, a

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

result = gcd(a, b)
print(result)

Submission status: Accepted

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

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

y = gcd(a,b)
print(y)

Submission status: Accepted

Solution code:
def gcd(a,b):
    if a>b:
        x=a
        y=b
    else:
        x=b
        y=a

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

p,q=[int(i) for i in input().split(" ")]
print(gcd(p,q))

Submission status: Accepted

Solution code:
tmp=input().split()
m=int(tmp[0])
n=int(tmp[1])

while(m!=n):
    if(m>n):
        m=m-n
    else:
        n=n-m

print(m)

Submission status: Accepted

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


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

Submission status: Accepted

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

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

print(b)

Submission status: Accepted

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

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


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

Submission status: Accepted

Solution code:
def gcd(a,b):
    x,y = (a,b) if a>b else (b,a)
    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:
import sys

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

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def lcd(a,b): ##return least common multiple of a and b
    if a > b:
        return lcd(a-b,b)
    elif a < b:
        return lcd(b-a,a)
    elif a == b:
        return a

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
def gcd(x, y):
    '''??????????????????????????????
    x>=y?????¨??????gcd(x, y)??¨gcd(y, x%y)?????????????????¨????????¨??????'''

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

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

    return x
    
def test():
    '''??? input =
    147 105
    ->
    21'''

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

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

if __name__ == '__main__':
    test()

Submission status: Accepted

Solution code:
def gcd(x, y):
    '''??????????????????????????????
    x>=y?????¨??????gcd(x, y)??¨gcd(y, x%y)?????????????????¨????????¨??????'''

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

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

    return x
    
def test():
    '''??? input =
    147 105
    ->
    21'''

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

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

if __name__ == '__main__':
    test()

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
    
if __name__ == '__main__':
    x, y = map(int, input().split())

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

Submission status: Accepted

Solution code:
#ALDS1_1-B Greatest Common Divisor
def gcd(x,y):
    if x%y == 0:
        print(y)
    else:
        gcd(y,x%y)

x,y = [int(x) for x in input().split()]
if x>y:
    gcd(x,y)
else:
    gcd(y,x)

Submission status: Accepted

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


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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import re

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

    l = list(range(1, int(min(x, y) / 2) + 1))
    l.reverse()
    r = 1
    #for i in range(1, int(min(x, y) / 2) + 1):
    for i in l:
        if x % i == 0 and y % i == 0:
            return i
    return 1
 
x, y = map(int, re.split(' ', raw_input()))
print(gcd(x, y))

Submission status: Accepted

Solution code:
import re

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

    l = list(range(1, int(min(x, y) / 2) + 1))
    l.reverse()
    r = 1
    for i in l:
        if x % i == 0 and y % i == 0:
            return i
    return 1
 
x, y = map(int, re.split(' ', raw_input()))
print(gcd(x, y))

Submission status: Accepted

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

if x > y:
    larger = x
    smaller = y
else:
    larger = y
    smaller = x

while True:
    quot, rem = divmod(larger, smaller)  # a > b ?????????
    larger = smaller
    smaller = rem
    if rem == 0:
        gcd = larger
        break

print(gcd)

pass

Submission status: Accepted

Solution code:

def gcd(x, y):

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

    if y == 0:
        return x

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


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

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):
 if x < y:
  x,y = y,x
 while y > 0:
  r = x % y
  x = y
  y = r
 return x

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

Submission status: Accepted

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

Submission status: Accepted

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

    if r != 0:
        x = y
        y = r
    else:
        print(y)

Submission status: Accepted

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

print(gcd(x,y))

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

    if x % y == 0:
        return y

    return gcd(y, x%y)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding=utf-8

a, b = map(int, input().split())
if a > b:
    big_num = a
    sml_num = b
else:
    big_num = b
    sml_num = a

while True:
    diviser = big_num % sml_num
    if diviser == 0:
        break
    else:
        big_num = sml_num
        sml_num = diviser

print(sml_num)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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


line = sys.stdin.readline().strip().split(" ")
A = int(line[0])
B = int(line[1])

print(gcd(A,B))

Submission status: Accepted

Solution code:
import sys

def get_gcd(x, y):
    if (x % y == 0) or (y % x == 0):
        return min(x, y)
    return get_gcd((max(x, y) % min(x, y)), min(x, y))

if __name__ == "__main__":
    array = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))
    print get_gcd(array[0], array[1])

Submission status: Accepted

Solution code:
def gcd(x, y):
    while y != 0:
        temp = x % y
        x = y
        y = temp
    print x

l = map(int, raw_input().split())
gcd(*l)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
?????§??¬?´???°
??????????????¶??° x, y ?????\?????¨???????????????????????§??¬?´???°????±???????????????°????????????????????????????????????

?????????
??´??° x, y ???????????????x ??\ y ????????° x ??¨ y ????????§??¬?´???°??? y ??¨ x % y ????????§??¬?´???°???????????????
????????§ x % y ??? x ??? y ??§?????£???????????§????????????
"""

# ?????????
x,y = list(map(int,input().strip().split()))
if x < y:
    z = x
    x = y
    y = z

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    print(gcd(X, Y))

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

main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(euclidean_alg(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:
x, y = map(int, raw_input().split())
if x < y:
    tmp = y
    y = x
    x = tmp

while 1:
    tmp = x % y
    x = y
    y = tmp
    if tmp == 0:
        tmp = x
        break
print tmp

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Aizu Problem ALDS_1_1_B: Greatest Common Divisor
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


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

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

Submission status: Accepted

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

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

kotae = division(x,y)
print(kotae)