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:
arr = list(map(int, input().split()))
n1 = min(arr[0], arr[1])
n2 = max(arr[0], arr[1])
while n1 != 0:
	temp = n2 % n1
	n2 = n1
	n1 = temp
print(n2)

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
while True:
    if y > x:
        a = x
        x = y
        y = a
    x = x % y
    #print(f"{x} {y}")
    if x == 0:
        print(y)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n1, n2 = map(int, input().split())

a = min(n1, n2)
b = max(n1, n2)

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

print(b)

Submission status: Accepted

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

Submission status: Accepted

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

if(a < b):
    swap = a
    a = b
    b = swap

x = 1
while(x != 0):
    x = a % b
    a = b
    b = x

print(a)

Submission status: Accepted

Solution code:
x, y = [int(n) for n in 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:
x, y = [int(n) for n in input().split()]
if (x < y):
    x, y = y, x
while y:
    (x, y) = (y, x % y)
print(x)

Submission status: Accepted

Solution code:
l=input().split()
l = [int(s) for s in l]
a = l[0]
b = l[1]
while (b != 0 and a != 0):
    if(a < b):
        b = b % a
    else:
        a = a % b
if(a == 0):
    print(b)
else:
    print(a)

Submission status: Accepted

Solution code:
def gcd(x,y):
    _x = min(x,y)
    _y = max(x,y)
    _z = _y % _x
    if _z == 0:
        return _x
    else:
        return gcd(_x,_z)

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

if __name__ == '__main__':
    run()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x,y=[int(i) for i in input().split()]
if x<y:
    x,y=y,x
while True:
    if y==0:
        print(x)
        break
    a=x%y
    x=y
    y=a

Submission status: Accepted

Solution code:
# Greatest Common Divisor

numbers = [int(i) for i in input().rstrip().split()]
a = numbers[0]
b = numbers[1]

gcd = 1
while a != 0 and b != 0:
    if a >= b:
        a %= b
    else:
        b %= a
if a == 0:
    gcd = b
else:
    gcd = a

print(gcd)

Submission status: Accepted

Solution code:
# Greatest Common Divisor

numbers = [int(i) for i in input().rstrip().split()]
a = numbers[0]
b = numbers[1]

def gcd(a, b):
    gcd = 1
    while a != 0 and b != 0:
        if a >= b:
            a %= b
        else:
            b %= a
    if a == 0:
        gcd = b
    else:
        gcd = a
    return gcd

print(gcd(a, b))

Submission status: Accepted

Solution code:
def gcd(a, b):                  # 0とか負の数が入るとヤバい
    if b%a==0: return a
    return gcd(b%a, a)



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

Submission status: Accepted

Solution code:
def gcd_loop(a,b):
    if a < 0: a = -a
    if b < 0: b = -b
    if b < a: b, a = a, b
    if a == 0:
        return b
    while True:
        if b%a == 0:
            return a
        a, b = b%a, a


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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
slist = []
if (a > b):
    c = a%b
    d = b
    while (c != 0 and d != 0):
        if (c < d):
            d = d%c
        elif (c > d):
            c = c%d
    if(c == 0):
        print(d)
    elif(d == 0):
        print(c)
        
    
elif(a < b):
    c = a
    d = b%a
    while (c != 0 and d != 0):
        if (c < d):
             d = d%c
        elif (c > d):
            c = c%d
    if(c == 0):
        print(d)
    elif(d == 0):
        print(c)
        
else:
    print(a)

Submission status: Accepted

Solution code:
x,y =[int(i) for i in input().split()]
if x < y :
    t = x
    x = y
    y = t
while y > 0 :
    r = x % y
    x = y
    y = r
print(x)

Submission status: Accepted

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

while not b == 0:
    t = b
    b = a % b
    a = t
print(a)

Submission status: Accepted

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

while not b == 0:
    t = b
    b = a % b
    a = t
print(a)

Submission status: Accepted

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

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

print(gcd(x, y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, raw_input().split())
c = 0
while True:
    if a == b:
        c = a
        break

    if a < b:
        tmp = b
        b = a
        a = tmp

    a = a % b
    if a == 0:
        c = b
        break

print(c)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
data = map(int, raw_input().split())
x = data[0]
y = data[1]

m = 1
while m != 0:
	m = x % y
	x = y
	y = m
	
print x

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
a, b = (int(s) for s in stdin.readline().split())
while b:
    a, b = b, a % b
print(a)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from __future__ import print_function
import time
import sys
import io
import re
import math
#start = time.clock()
#h,i = 497,284
h,i=map(int, raw_input().split())


while i != 0:
    siki= h % i
    h = i
    i = siki

print (h)

Submission status: Accepted

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

while A[1]%A[0]!=0:
    temp=A[0]
    A[0]=A[1]%A[0]
    A[1]=temp

print A[0]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = map(int,raw_input().split())
l.sort()
a,b = l
max = 0
while True:
    tmp = a%b
    if tmp == 0:
        max = b
        break
    a = b
    b = tmp
print max

Submission status: Accepted

Solution code:
a, b = map(int,raw_input().split())
while True:
    if min(a, b) == 1:
        print 1
        break
    elif 1 < b < a:
        a = a % b
    elif 1 < a < b:
        b = b % a
    else:
        print max(a, b)
        break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def gcd(a,b):
    c = a % b
    if c == 0:
        return b
    else:
        return gcd(b, c)
    
if __name__ == "__main__":
    import sys
    a, b = [ int(e) for e in sys.stdin.readline().strip().split() ]
    print gcd(max(a,b), min(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, input().strip().split())
print(gcd(x, y))

Submission status: Accepted

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

if number[0] < number[1]:
    number[0], number[1] = number[1], number[0]

remainder = 1
while remainder != 0:
    remainder = number[0]%number[1]
    number[0] = number[1]
    number[1] = remainder
    
print(number[0])

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
k = max(a,b)
l = min(a,b)
while k % l != 0:
	x = k
	k = l
	l = x % l
print(l)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions
m,n=map(int,input().split())
ans=fractions.gcd(m,n)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(gcd(x,y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import gcd

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

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

Submission status: Accepted

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

if x >= y:
    large, small = x, y
else:
    large, small = y, x

while small > 0:
    r = large % small
    large = small
    small = r

print(large)

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())
x,y=max(X,Y),min(X,Y)
print(gcd(x,y))

Submission status: Accepted

Solution code:
from math import gcd

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


    
print(gcd(x,y))

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())
x = min(X, Y)
y = max(X, Y)
while x > 0:
    r = y % x
    y = x
    x = r
    
print(y)

Submission status: Accepted

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


print(math.gcd(a, b))

Submission status: Accepted

Solution code:
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


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


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

Submission status: Accepted

Solution code:
X, Y = map(int, input().split())
while Y != 0:
	T = X
	X = Y
	Y = T % Y
print(X)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

q = x // y
r = x % y
a = y
b = r
if (r == 0):
    print(x)
    exit()

else:
    while (r != 0):
        q = a // b
        r = a % b

        if (r == 0):
            print(b)
            break
        a = b
        b = r

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

    return x

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

print(gcd(X,Y))

Submission status: Accepted

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

while True:
    if y == 0:
        break
    else:
        x, y = y, x%y

print(x)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def show(A, n):
    for i in range(n):
        if i != n-1:
            print(A[i], end=' ')
        else:
            print(A[i])


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


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

    print(gcd(a, b))


if __name__ == "__main__":
    main()

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

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

Submission status: Accepted

Solution code:
import math

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

print(math.gcd(x, y))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

Solution code:
#77 最大公約数

import math

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
x,y=map(int,input().split())

x,y=sorted([x,y])
while x%y!=0:
    x,y=y,x%y

print(y)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

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

if __name__=="__main__":
    main()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
while True :
    if N < M :
        N, M = M, N
    a = N % M
    if a == 0 :
        break
    else :
        N, M = M, a
print(M)

Submission status: Accepted

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

Submission status: Accepted

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

if n < m:
    n,m = m,n
while n % m !=0:
    n,m = m,n%m
print(m)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

v = [int(d) for d in input().split(" ")]

print(math.gcd(v[0], v[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:
# coding: utf-8
# Your code here!

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


A, B = map(int, input().split())
print(f'{calc(A, B)}')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

while x%y!=0:
    m=x%y
    x,y=max(y,m),min(y,m)

print(y)

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
x = max(m, n)
y = min(m, n)
while y > 0:
    temp = y
    y = x % y
    x = temp
print(x)

Submission status: Accepted

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

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

print(str(gcd(a[0],a[1])))

Submission status: Accepted

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

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

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

print(x)

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

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

Submission status: Accepted

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

if b > a:
    a, b = b, a

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

print(b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


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


def main():
    X, Y = [int(i) for i in input().strip().split()]
    print(gcd(X, Y))


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:
# coding: utf-8
#77

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

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

while b:
    a,b = b,a%b

print(a)

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

Submission status: Accepted

Solution code:
import fractions


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

Submission status: Accepted

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd,numbers)
    
x,y=map(int,input().split())
k=0
if x<y:
    k=x
    x=y
    y=k

z=x%y

n=(gcd(y,z))
print(n)

Submission status: Accepted

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

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

print(y)

Submission status: Accepted

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

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

print(gcd(x, y))

Submission status: Accepted

Solution code:
def greatest_common_divisor(a, b):
    a, b = max(a, b), min(a, b)
    while b != 0:
        a, b = b, a % b
    return a


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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

print(math.gcd(a,b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if y > x:
    tmp = y
    y = x
    x = tmp

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


print(i)

Submission status: Accepted

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


data = map(int, input().strip().split())
ret = GCD(*data)
print(ret)

Submission status: Accepted

Solution code:
import math
import collections
import fractions
import itertools

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
def gcd(a0, b0):
    res = 1
    a, b = min(a0, b0), max(a0, b0)

    if b % a == 0:
        res *= a
        b //= a
        a = 1

    i = 2
    while i**2 <= b0:
        if a % i == 0 and b % i == 0:
            res *= i
            a //= i
            b //= i
        else:
            i += 1

    return res


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

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

Submission status: Accepted

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

    z = x % y
    x = z
    (x, y) = (y, x)

Submission status: Accepted

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


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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
def gcd(x,y):
    if y==0:
        return x
    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:
from math import gcd
x, y = map(int, input().split())


print(gcd(x,y))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Accepted

Solution code:
import sys
from fractions import gcd

input = sys.stdin.readline


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

    ans = gcd(x, y)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#ALDS1_1_A:  Greatest Common Driver
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:
    x,y = y,x

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

def greatest_common_divisor3(x, y):
  xx = max(x, y)
  yy = min(x, y)
  v1 = xx % yy
  #print("{} {}".format(yy, v1))  # TODO delete
  if yy <= 0 or v1 <= 0:
    return max(yy, v1)
  else:
    return greatest_common_divisor3(yy, v1)

x_y = list(map(int, stdin.readline().split()))
print(greatest_common_divisor3(x_y[0], x_y[1]))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!


N,M = map(int,input().split())
#print(N,arr)
def euclid(N,M):
    #print(N,M)
    if M > N:
        N,M = M,N
    while M > 0:
        r = N % M
        N = M
        M = r
        
    return N
    
ans = euclid(N,M)
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

"""
n = min(x,y)
for d in range(n, 0, -1):
    if x % d == 0 and y % d == 0:
        print(d)
        break
"""

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

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

Submission status: Accepted

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

def gcp(x, y):
    while min(x, y) != 0:
        if x < y:
            x, y = y, x
        x = x % y
    return max(x, y)

print(gcp(a,b))

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

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

print(math.gcd(x,y))

Submission status: Accepted

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


def gcd(x, y):
    lg = max(x, y)
    sm = min(x, y)
    div = True
    while div:
        lg_temp = sm
        sm = lg % sm
        lg = lg_temp
        if sm == 0:
            div = False
            return lg_temp




print(gcd(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)
    
a,b=map(int,input().split())
g=0
g=gcd(a,b)
print(g)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x % y)
    
if __name__ == "__main__":
    x,y = map(int,input().split())
    print(gcd(x,y))

Submission status: Accepted

Solution code:
def gcd(x, y):
    z = max(x, y)
    d = min(x, y)

    i = 1
    while z % d*i != 0:
        # print('z, d = ', z, ",", d)
        # print('i = ', i )
        if z >= d*(i+1):
            i += 1
            continue
        else:
            z, d = d, z - d*i
            i = 1
        
    
    return d

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

Submission status: Accepted

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


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


resolve()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

print(gcd(x, y))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
while True :
    if N < M :
        N, M = M, N
    amari = N % M
    if amari == 0 :
        break
    else :
        N, M = M, amari
print(M)

Submission status: Accepted

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

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

ans = y
print(y)

Submission status: Accepted

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

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

print(y)