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: Wrong Answer

Solution code:
def gcd(a,b):
    i = 2
    temp = 1
    while(i <= b):
        if(a % i == 0 and b % i == 0):
            if(temp != i):
                temp = temp * i
            while(a % temp == 0 and b % temp == 0 and temp > 5):
                a = a / temp
                b = b / temp
        i = i + 1
    print temp

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

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    if(b):
        return gcd(a,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: Wrong Answer

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

s = min(x,y)
l = max(x,y)
for i in list(range(s)[::-1]):
    if s % i == 0:
        if l % i == 0:
            print(i)
            break

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
def common_divisor(x,y):
    if x >= y:
        x = x % y
        for i in range(1,x):
            if y % i == 0 and x % i == 0:
                divisor = i
        return divisor
    else:
        for i in range(1,x):
            if y % i == 0 and x % i == 0:
                divisor = i
            return divisor

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env/ python

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env/ python

Submission status: Wrong Answer

Solution code:
def gcd(x_y):
    tmp = list(map(int, x_y.split()))
    x = tmp[0]
    y = tmp[1]

    xcd = set([ n for n in range(1, x+1) if  x % n == 0])  # xの約数
    ycd = set([ n for n in range(1, y+1) if  y % n == 0])  # yの約数
    cd = list(xcd & ycd)  # ｘとyの公約数
    return max(cd)  # ｘとyの最大公約数

x_y = input()
gcd(x_y)

Submission status: Wrong Answer

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 = input()
tmp = list(map(int, x_y.split()))
x = tmp[0]
y = tmp[1]
gcd(x, y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(c(t,u))

Submission status: Wrong Answer

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


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


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

Submission status: Wrong Answer

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: Wrong Answer

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

a=list[0]
b=list[1]

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

        print(c)

Submission status: Wrong Answer

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]
    c=list[1]    

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

        print(c)

Submission status: Wrong Answer

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

x=a%b

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

print(a)

Submission status: Wrong Answer

Solution code:
def GCD(x,y):

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

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

Submission status: Wrong Answer

Solution code:
#For integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)

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

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

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
xg=set()
yg=set()
ma=max(x,y)
for i in range(1,ma):
    if x%i==0 and i<=y:
        xg.add(i)
    if y%i==0 and i<=x:
        yg.add(i)
gcd=xg & yg
print(max(gcd))

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
ma=max(x,y)
for i in range(1,ma):
    if x%i==0 and i<=y:
        gcd=i
    if y%i==0 and i<=x:
        gcd=i
print(gcd)

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
ma=max(x,y)
for i in range(1,ma):
    if x%i==0 or y%i==0:
        gcd=i
print(gcd)

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
ma=max(x,y)
for i in range(1,ma):
    if x%i==0 or y%i==0:
        gc=i
print(gc)

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
ma=max(x,y)
for i in range(1,ma):
    if x%i==0 or y%i==0:
        g=i
print(g)

Submission status: Wrong Answer

Solution code:
l=input().split()
l = [int(s) for s in l]
for i in range(1,l[0]):
    if l[0] % i == 0 and l[1] % i == 0:
        c = i
print(c)

Submission status: Wrong Answer

Solution code:
l=input().split()
l = [int(s) for s in l]
if(l[0]<l[1]):
    a = l[1] % l[0]
else:
    a = l[0] % l[1] 
for i in range(1,a):
    if a % i == 0:
        c = i
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x, y = [int(n) for n in input().split()]
if (x < y):
    x, y = y, x
while x % y:
    (x, y) = (y, x % y)
print(x)

Submission status: Wrong Answer

Solution code:
l=input().split()
l = [int(s) for s in l]
if(l[0]<l[1]):
    a = l[1] % l[0]
else:
    a = l[0] % l[1] 
for i in range(1,a):
    if a % i == 0:
        c = i
print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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 = b
print(a)

Submission status: Wrong Answer

Solution code:
import sys

for line in sys.stdin:
    lineA=line.strip()
    A=lineA.split()
    B=map(int,A)
    if B[0]<B[1]:
        p=B[1]
        B[1]=B[0]
        B[0]=p
    e=1

    while e != 0:
        e=B[0]%B[1]
        C=B[1]
        B[1]=e
        B[0]=C

    print B[1]

Submission status: Wrong Answer

Solution code:
a,b = map(int,raw_input().split())
m = a
if a>b:
    m = b
max = 0
for i in range(2,m+1):
    if a % i == 0 and b % i == 0:
        max = i
print max

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b = map(int,raw_input().split())
while True:
    print a, b
    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: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
low = min([round(a/2), round(b/2)])
if a == b:
    print(a)
else:
    for i in range(low, 0, -1):
        if a%i==0 and b%i==0:
            print(i)
            break

Submission status: Time Limit Exceeded

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

def gcd(a, b):
    if a == b:
        return a
    big = max(a, b)
    small = min(a, b)
    big_i = big % small
    herf = round(min(small, big_i))
    for i in range(herf, 1, -1):
        if small%i==0 and big_i%i==0:
            return i
    return 1
    
print(gcd(a, b))

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
c = []
for i in range(a):
    x = i + 1
    if a%x == 0:
        if b%x == 0:
            c.append(x)
print(c[-1])

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
c = []
while True:
    for i in range(a):
        x = i + 2
        if a%x == 0:
            if b%x == 0:
                c.append(x)
                a = int(a/x)
                b = int(b/x)
                break
    if i == a-1:
        break
s = 1
for j in c:
    s = s * j
print(s)

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
c = []
if a > b:
    a, b = b, a
while True:
    for i in range(a):
        x = i + 2
        if a%x == 0:
            if b%x == 0:
                c.append(x)
                a = a//x
                b = b//x
                break
    if i == a-1:
        break
s = 1
for j in c:
    s = s * j
print(s)

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
c = []
if a > b:
    a, b = b, a
while True:
    for i in range(a):
        #print(a, i)
        x = i + 2
        if a%x == 0:
            if b%x == 0:
                c.append(x)
                a = a//x
                b = b//x
                #print(c)
                break
    if i > a**0.5:
        break
s = 1
for j in c:
    s = s * j
print(s)

Submission status: Time Limit Exceeded

Solution code:
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list
a,b = map(int,input().split())
a_set = set(make_divisor_list(a))
b_set = set(make_divisor_list(b))
matched_list = list(a_set & b_set)
print(max(matched_list))

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
def gcd(x,y):
    z = max(x,y)  %  min(x,y)
    if z == 0 :
        return [min(x,y),0]
    return gcd(max(x,y),z)

L = gcd(a,b)
K = []
for i in reversed( (range(1,L[0]+1 )) ) :
    if a % i == 0 and b % i == 0:
        K.append(i)

print(max(K))

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
def gcd(x,y):
    q = max(x,y)  %  min(x,y)
    if q == 0 :
        return [min(x,y),0]
    return gcd(min(x,y),q)

L = gcd(a,b)
K = [ i for i in reversed(range(1, L[0] +1 )) if a % i == 0 ]

print(max(K))

Submission status: Time Limit Exceeded

Solution code:
def div(x, y): #x>y
    A = 1
    for i in range(1, x+1):
        if x % i == 0 and y % i == 0:
            A = i
    return A

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

Submission status: Time Limit Exceeded

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

list_x = [i for i in range(1,x+1) if x % i == 0]

list_y = [j for j in range(1,y+1) if y % j == 0]

print(max([k for k in list_x if k in list_y]))

Submission status: Time Limit Exceeded

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

#xの約数を求める
list_x = [i for i in range(1,x+1) if x % i == 0]

#yの約数を求める
list_y = [j for j in range(1,y+1) if y % j == 0]

x_set = set(list_x)
y_set = set(list_y)

print(max(list(x_set & y_set)))

Submission status: Time Limit Exceeded

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

def gg(a,b):
    for d in range(b,0,-1):
        #print(d)
        if a%d==0 and b%d==0:
            return d
if x>y:
    print(gg(x,y))
else:
    print(gg(y,x))

Submission status: Time Limit Exceeded

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

z = x % y
if x==y:
    print(x)
else:
    gcd=0
    for i in range(1,z+1):
        if z % i ==0 and y % i ==0:
            gcd=i
    print(gcd)

Submission status: Time Limit Exceeded

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

if x < y:
    buff = x
    x = y
    y = buff
elif x == y:
    print(x)
    exit()

r = x % y
for i in range(1, r+1):
    if y % i == 0 and r % i == 0:
        d = i

print(d)

Submission status: Time Limit Exceeded

Solution code:
import sys

line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

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

while(x > 1) :
    for i in range(2, x + 1):
        if i != 1 and x % i == 0 and y % i == 0:
            divide = divide * i
            x = x / i
            y = y / i
            break

print divide

Submission status: Time Limit Exceeded

Solution code:
import sys

line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

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

while(x > 2) :
    for i in range(2, x + 1):
        if  x % i == 0 and y % i == 0:
            divide = divide * i
            x = x / i
            y = y / i
            break

print divide

Submission status: Time Limit Exceeded

Solution code:
import sys

line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

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

while(x > 1) :
    for i in range(2, x + 2):
        if  x % i == 0 and y % i == 0:
            divide = divide * i
            x = x / i
            y = y / i
            break

print divide

Submission status: Time Limit Exceeded

Solution code:
import sys

line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

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

while(x > 1):
    for i in range(2, x + 1):
        if x % i == 0 and y % i == 0:
            divide = divide * i
            x = x / i
            y = y / i
            break

print divide

Submission status: Time Limit Exceeded

Solution code:
import sys

line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

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

while(y % x != 0):
    for i in range(2, x + 1):
        if x % i == 0 and y % i == 0:
            divide = divide * i
            x = x / i
            y = y / i
            break

print divide

Submission status: Time Limit Exceeded

Solution code:
import sys

for i in sys.stdin:
    lst = i.split(' ')
    n = 1
    while n <= lst[0]:
        lst = map(int, lst)
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
            print lst[0]/n
            break
        n = n+1
    else:
        print 1
    sys.exit(0)

Submission status: Time Limit Exceeded

Solution code:
import sys
for i in sys.stdin:
    lst = i.split(' ')
    lst = map(int, lst)
    lst.sort()
 
    n = 1
    while n <= lst[0]/2:          
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
           print lst[0]/n
           break
        n = n+1
    else:
        print 1
    sys.exit(0)

Submission status: Time Limit Exceeded

Solution code:
def gcd(x, y):
    a_x = list()
    a_y = list()

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

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

    a_cd = list(set(a_x).intersection(set(a_y)))

    return max(a_cd)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
x,y = map(int,raw_input().split())
if y>x:
    tmp = x
    x = y
    y = tmp
i=2
ans = 1
while i<=x:
    if x % i ==0:
        if y % i==0:
            ans = i
    i+=1
print ans

Submission status: Time Limit Exceeded

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<=x/2:
        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: Time Limit Exceeded

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

for d in reversed(range(1, n + 1)):
    if (x % d == 0) and (y % d == 0):
        print(d)
        break

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

i = 2
while i <= 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: Time Limit Exceeded

Solution code:
#coding:UTF-8
def GCD(x,y):
    d=1
    if x > y:
        N=y
    else:
        N=x
    for i in range(1,N+1):
        if x%i==0 and y%i==0:
            d=i
    print(d)

if __name__=="__main__":
    a=input()
    x=int(a.split(" ")[0])
    y=int(a.split(" ")[1])
    GCD(x,y)

Submission status: Time Limit Exceeded

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

cd = a[0]

while a[0]%cd != 0 or a[1]%cd != 0:
    cd -= 1

print(cd)

Submission status: Time Limit Exceeded

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

cd = a[0]

while a[0]%cd != 0 or a[1]%a[0]%cd != 0:
    cd -= 1

print(cd)

Submission status: Time Limit Exceeded

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

cd = a[0]
b = a[1]%a[0]

while a[0]%cd != 0 or b%cd != 0:
    cd -= 1

print(cd)

Submission status: Time Limit Exceeded

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


def greatest_common_divisor(x, y):
    x_divisor = {i for i in range(1, x+1) if x % i == 0}
    y_divisor = {i for i in range(1, y+1) if y % i == 0}
    common_divisor = list(x_divisor.intersection(y_divisor))
    common_divisor.sort()
    print(common_divisor.pop(-1))


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


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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
data = input()
data = data.split()
x = int(data[0])
y = int(data[1])

def gcd(n,m):
    k = max(n,m)
    for i in range(k):
        if n%(k-i) == 0 and m%(k-i) == 0:
            return k-i

print(gcd(x,y))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
def gcd(n,m):
    k = max(n,m)
    for i in range(k):
        if n%(k-i) == 0 and m%(k-i) == 0:
            return k-i
x, y = map(int,input().split())
print(gcd(x,y))

Submission status: Time Limit Exceeded

Solution code:
x, y = map(int, input().split())
if x == y:
    print(x)
else:
    for i in range(1, abs(x-y)+1):
        if x % i == y % i == 0:
            j = i
    print(j)

Submission status: Time Limit Exceeded

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

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

for i in range(int(x%y/2)):
    if (x%y)% (i+1) == 0 and y%(i+1) == 0:
        kouyakusu = i+1

print(kouyakusu)

Submission status: Time Limit Exceeded

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

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

i = 0
while i < int(x%y):
    if (x%y)% (((x%y))-i) == 0 and y%(((x%y))-i) == 0:
        kouyakusu = int((x%y) - i)
        break
    i = i + 1

print(kouyakusu)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
gcd = 1
for i in range(2,min(a,b)+1):
    if a%i == 0 and b%i == 0:
        gcd = i
print(gcd)

Submission status: Time Limit Exceeded

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

while True:
    for i in range(2,min(a,b)+1):
        if a%i == 0 and b%i ==0:
            gcd *= i
            a = int(a/i)
            b = int(b/i)
            break
    else: break
print(gcd)

Submission status: Time Limit Exceeded

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

i = 2
while True:
    c = i
    for i in range(c,min(a,b)+1):
        if a%i == 0 and b%i ==0:
            gcd *= i
            a = int(a/i)
            b = int(b/i)
            break
    else: break
print(gcd)

Submission status: Time Limit Exceeded

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

for i in range(1, n+1):
    if x%i==0 and y%i==0:
        gcd = i

print(gcd)

Submission status: Time Limit Exceeded

Solution code:
x, y = map(int, input().split())
a = max(x, y)
b = min(x, y)
if a%b==0:
    gcd = b
else:
    for i in range(1, a%b+1):
        if b%i==0 and (a%b)%i==0:
            gcd = i

print(gcd)

Submission status: Time Limit Exceeded

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

def answer(x,y):
 for i in range(y, 0, -1):
  if x % i == 0 and y % i == 0:
   return i
 
if x == y:
 print(x)
elif x >= y:
 print(str(answer(x, x%y)))
else:
 print(str(answer(y, y%x)))

Submission status: Time Limit Exceeded

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

x=max(XY)
y=min(XY)
x_dy=x%y

ans=0
for d in range(1,y+1):
    if y%d==0 and x_dy%d==0:
        ans=d

print(ans)

Submission status: Time Limit Exceeded

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

x=max(XY)
y=min(XY)
x_dy=x%y

ans=0
if x==y:
    ans=x
else:
    for d in range(1,(y+1)//2):
        if y%d==0 and x_dy%d==0:
            ans=d

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
z=[]
for i in range(min(a,b)):
    if a%(i+1)==0 and b%(i+1)==0:
        z+=[i+1]
print(max(z))

Submission status: Time Limit Exceeded

Solution code:
def main():
    x, y = map(int, input().split())
    
    X = []
    for i in range(1, x + 1):
        if x % i == 0:
            X.append(i)

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

    matched_list = list(set(X) & set(Y))
    matched_list.sort()
    print(matched_list[-1])


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
dbg = False

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

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

for i in range(1, y+1):
    if y % i == 0:
        gcd_tmp = int(y / i)
        if dbg: print(gcd_tmp)
        if x % gcd_tmp == 0:
            gcd = gcd_tmp
            break

print(gcd)

Submission status: Time Limit Exceeded

Solution code:
dbg = False

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

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

for i in range(1, int((y+1)/2)+1):
    if y % i == 0:
        gcd_tmp = int(y / i)
        if dbg: print(gcd_tmp)
        if x % gcd_tmp == 0:
            print(gcd_tmp)
            exit()

print(1)

Submission status: Time Limit Exceeded

Solution code:
def greatest_common_divisor(x, y):
    if x > y:
        max = x
    else:
        max = y
    answer = 0
    for i in range(1, max+1):
        if x % i == 0 and y % i == 0:
            answer = i
    return answer

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

Submission status: Time Limit Exceeded

Solution code:
def gcd(a,b):
    i = 1
    temp = 1
    while(i <= b):
        if(a % i == 0 and b % i == 0):
            temp = i
        i = i + 1
    print temp

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

Submission status: Time Limit Exceeded

Solution code:
def gcd(a,b):
    i = 2
    temp = 1
    while(i <= b):
        while(a % i == 0 and b % i == 0):
            temp = temp * i
            a = a / i
            b = b / i
        i = i + 1
    print temp

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

Submission status: Time Limit Exceeded

Solution code:
def gcd(a,b):
    i = 2
    temp = 1
    while(i <= b):
        while(a % i == 0 and b % i == 0):
            temp = temp * i
            a = a / i
            b = b / i
        if(i % 2 == 0):
            i = i + 1
        else:
            i = i + 2
    print temp

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

Submission status: Time Limit Exceeded

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

s = min(x,y)
l = max(x,y)
for i in reversed(range(s+1)):
    if s % i == 0:
        if l % i == 0:
            print(i)
            break

Submission status: Time Limit Exceeded

Solution code:
def devisor_list(x):
    result = []
    for n in range(1, x + 1):
        if x % n == 0:
            result.append(n)
    return result

def common_max_element(array1, array2):
    result = []
    for n in array1:
        if n in array2:
            result.append(n)
    return max(result)

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

Submission status: Time Limit Exceeded

Solution code:
def gcd(x_y):
    tmp = list(map(int, x_y.split()))
    x = tmp[0]
    y = tmp[1]

    xcd = set([ n for n in range(1, x+1) if  x % n == 0])  # xの約数
    ycd = set([ n for n in range(1, y+1) if  y % n == 0])  # yの約数
    cd = list(xcd & ycd)  # ｘとyの公約数
    return max(cd)  # ｘとyの最大公約数

x_y = input()
print(gcd(x_y))

Submission status: Time Limit Exceeded

Solution code:
def gcd(x_y):
    tmp = list(map(int, x_y.split()))
    x = tmp[0]
    y = tmp[1]

    xcd = set([ n for n in range(1, x+1) if  x % n == 0])  # xの約数
    ycd = set([ n for n in range(1, y+1) if  y % n == 0])  # yの約数
    cd = list(xcd & ycd)  # ｘとyの公約数
    print(max(cd))  # ｘとyの最大公約数

x_y = input()
gcd(x_y)

Submission status: Time Limit Exceeded

Solution code:
#For integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)

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


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

Submission status: Time Limit Exceeded

Solution code:
x,y=map(int,input().split())
xg=set()
yg=set()
for i in range(1,x+1):
    if x%i==0:
        xg.add(i)
for j in range(1,y+1):
    if y%j==0:
        yg.add(j)
gcd=xg & yg
print(max(gcd))

Submission status: Time Limit Exceeded

Solution code:
l=input().split()
l = [int(s) for s in l]
for i in range(1,l[0]+1):
    if l[0] % i == 0 and l[1] % i == 0:
        c = i
print(c)

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
slist = []
if (a >= b):
    for i in range(1,b+1):
        if (a%i == 0 and b%i == 0):
            slist.append(i)
elif(a < b):
    for i in range(1, a):
        if (a%i == 0 and b%i == 0):
            slist.append(i)
print(slist[-1])

Submission status: Memory Limit Exceeded

Solution code:
import sys

input_list = map(int, raw_input().split())

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

if x < y:
	tmp = x
	x = y
	y = tmp
elif x == y:
	print(x)
	sys.exit(0)

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

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


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



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

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

Submission status: Memory Limit Exceeded

Solution code:
a,b = map(int,raw_input().split(' '))
if(a<b):
	t = a
	a = b
	b = t
m = a % b
if m == 0: print min(a,b)
for i in range(m,0,-1):
	if m%i == 0 and b%i == 0:
		print i
		break;

Submission status: Memory Limit Exceeded

Solution code:
import sys

line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

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

for i in range(2, y + 2):
    if x % i == 0 and y % i == 0:
        divide = divide * i
        x = x / i
        y = y / i
        i = 1

print divide

Submission status: Memory Limit Exceeded

Solution code:
import sys
import math

x = sys.stdin.readline()

a, b = x.split(" ")

a = int(a)
b = int(b)
y = 1

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

c = a % b

for i in range(2, a):
  if c % i == 0 and b % i == 0:
    y *= i
    c = c / i
    b = b / i
    i -= 1

print y

Submission status: Memory Limit Exceeded

Solution code:
import sys

line = sys.stdin.readline()
x, y = line.split(" ")

x = long(x)
y = long(y)

divide = 1

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

if x == y:
    divide = x

else:
    for i in range(x, 1, -1):
        if i != 1 and x % i == 0 and y % i == 0:
            divide = divide * i
            x = x / i
            y = y / i

print divide

Submission status: Memory Limit Exceeded

Solution code:
import sys

line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

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

if x == y:
    divide = x

else:
    for i in range(x, 1, -1):
        if i != 1 and x % i == 0 and y % i == 0:
            divide = divide * i
            x = x / i
            y = y / i

print divide

Submission status: Memory Limit Exceeded

Solution code:
x, y = map(int, raw_input().split())
min_xy = min([x, y])
gcd = 0
for i in range(1, min_xy+1):
    if (x % i == 0) & (y % i == 0):
        gcd = i
print gcd

Submission status: Memory Limit Exceeded

Solution code:
x,y = map(int,raw_input().split())
m = min(x,y)
cd = 1
for i in range(1,int(m) + 1):
    if x% i == 0:
        if y % i == 0:
            cd = i		
print(cd)

Submission status: Memory Limit Exceeded

Solution code:
x,y = map(int,raw_input().split())
cd = 1

while True:
    m = min(x,y)
    for i in range(2,int(m) + 1):
        if x% i == 0:
            if y % i == 0:
                cd *= i
                y /= i
                x /= i
                break
    if m / x == 1 or m / y == 1:
        break
print(cd)

Submission status: Memory Limit Exceeded

Solution code:
import re

def gcd(x, y):
    r = 1
    for i in range(1, min(x, y) + 1):
        if x % i == 0 and y % i == 0:
            r = i
    return r

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

Submission status: Memory Limit Exceeded

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

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

Submission status: Memory Limit Exceeded

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


    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: Memory Limit Exceeded

Solution code:
# coding:utf-8
def gcd(x,y):
    x_ans = []
    y_ans = []
    for i in range(1,x + 1):
        if x % i == 0:
            x_ans.append(i)
    for i in range(1,y + 1):
        if y % i == 0:
            y_ans.append(i)
    matched = []
    for ans in x_ans:
        matched += filter(lambda str: str == ans, y_ans)
    print max(matched)

n = map(int, raw_input().split())
gcd(n[0],n[1])