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:
twoNumbers=list(map(int,input().split()))
x=twoNumbers[0]
y=twoNumbers[1]
devidedBy=[]
syou=[]
if x>=y:
    for number in range(1, y+1):
        if y%number==0:
            if number>y//number:
                break
            else:
                if not number in devidedBy:
                    devidedBy.append(number)
                if not y//number in syou:
                    syou.append(y//number)
else:
    for number in range(1, x+1):
        if x%number==0:
            if number>x//number:
                break
            else:
                if not number in devidedBy:
                    devidedBy.append(number)
                if not x//number in syou:
                    syou.append(x//number)

if devidedBy[len(devidedBy)-1]==syou[len(syou)-1]:
    del devidedBy[len(devidedBy)-1]

devidedBy.extend(syou)
index=len(devidedBy)-1
while index>=0:
    if x>=y:
        if x%devidedBy[index]==0:
            print(devidedBy[index])
            break
        else:
            index-=1
    else:
        if y%devidedBy[index]==0:
            print(devidedBy[index])
            break
        else:
            index-=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

def gcd(big, small):
    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
    
print(gcd(a, b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
print(c[-1])

Submission status: Wrong Answer

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)

print(x_y_divisor)

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


print(y_divisor)

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

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

Submission status: Wrong Answer

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)
                print(a, b)
                break
    if i == a-1:
        break
s = 1
for j in c:
    s = s * j
print(s)

Submission status: Wrong Answer

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 = int(a/x)
                b = int(b/x)
                break
    if i == a-1:
        break
if b%a ==0:
    c.append(x)
s = 1
for j in c:
    s = s * j
print(s)

Submission status: Wrong Answer

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
        print(a, i)
        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: Wrong Answer

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**0.5:
        break
s = 1
for j in c:
    s = s * j
print(s)

Submission status: Wrong Answer

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

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 x > a**0.5:
            break
    if x > a**0.5:
        break
s = 1
for j in c:
    s = s * j
print(s)

Submission status: Wrong Answer

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
        #print(a, x)
        if a%x == 0:
            if b%x == 0:
                c.append(x)
                a = a//x
                b = b//x
                #print(c)
                break
            elif b%(a//x) == 0:
                c.append(a//x)
                a = x
                b = b//(a//x)
                #print(c)
                break
        #if x%1000 == 0:
            #print(x)
        if x > a**0.5:
            break
    if x > a**0.5:
        break
s = 1
for j in c:
    s = s * j
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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] )) ) :
    if a % i == 0 and b % i == 0:
        K.append(i)

print(max(K))

Submission status: Wrong Answer

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(2, (L[0] +1) // 2) )) :
    if a % i == 0 and b % i == 0:
        K.append(i)

print(max(K))

Submission status: Wrong Answer

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

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)

print(min(gcd(a,b)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    c = max([a, b])
    d = min([a, b])
    if c % d == 0:
        return d
    else:
        gcd(d, c % d)
        
nums = input().split()
print(gcd(int(nums[0]), int(nums[1])))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def swap(x,y):
    temp = x
    x = y
    y = temp
def gcd(x,y):
    if x<y:
        swap(x,y)
    while(x == y):
        x = x%y
        swap(x,y)
    print(x)

Submission status: Wrong Answer

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

def gg(a,b):
    for d in range(b,1,-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: Wrong Answer

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

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

print(gcd)

Submission status: Wrong Answer

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

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

print(gcd)

Submission status: Wrong Answer

Solution code:
data = list(map(int,input().split()))
if(data[0] < data[1]): data[0],data[1] = data[1],data[0]
z = data[0] % data[1]
gcd = 0
for i in range(1,z):
    if(z%i == 0 and data[1]%i == 0 and gcd < i): gcd = i
print(gcd)

Submission status: Wrong Answer

Solution code:
data = list(map(int,input().split()))
if(data[0] < data[1]): data[0],data[1] = data[1],data[0]
z = data[0] % data[1]
gcd = 0
for i in range(1,z):
    if(z%i == 0 and data[1]%i == 0 and gcd < i): gcd = i
if(gcd == 0): print(1)
else: print(gcd)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a > b:
 c = a%b
 print b%c
 if a < b:
  c = b%a
  print a%c
 else:
  print a

Submission status: Wrong Answer

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

a, b = [ int( val ) for val in raw_input( ).split( " " ) ]
print( gcd( a, b ) )

Submission status: Wrong Answer

Solution code:
print("Spam")

Submission status: Wrong Answer

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

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

print y

Submission status: Wrong Answer

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

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

print y

Submission status: Wrong Answer

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, x + 1):
    if x % i == 0 and y % i == 0:
        divide = divide * i
        x = x / i
        y = y / i
        i -= 1

print divide

Submission status: Wrong Answer

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, x + 1):
    if x % i == 0 and y % i == 0:
        divide = divide * i
        x = x / i
        y = y / i
        i = 1

print divide

Submission status: Wrong Answer

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

if a == 1:
  y = 1

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

print y

Submission status: Wrong Answer

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, x + 2):
    if x % i == 0 and y % i == 0:
        divide = divide * i
        x = x / i
        y = y / i
        i = 1

print divide

Submission status: Wrong Answer

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

if a == b:
  y = a

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

print y

Submission status: Wrong Answer

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, x + 2):
    if x % i == 0 and y % i == 0:
        divide = divide * i
        x = x / i
        y = y / i
        i = 1
if x == y:
    divide = x

print divide

Submission status: Wrong Answer

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(2, x + 2):
        if x % i == 0 and y % i == 0:
            divide = divide * i
            x = x / i
            y = y / i
            i = 1

print divide

Submission status: Wrong Answer

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
y = y % x

if x == y:
    divide = x

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

print divide

Submission status: Wrong Answer

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
y = y % x

if x == y:
    divide = x

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

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, c):
  if c % i == 0 and b % i == 0:
    y *= i
    c = c / i
    b = b / i
    i -= 1

print y

Submission status: Wrong Answer

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, c+2):
  if c % i == 0 and b % i == 0:
    y *= i
    c = c / i
    b = b / i
    i -= 1

print y

Submission status: Wrong Answer

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, b):
  if c % i == 0 and b % i == 0:
    y *= i
    c = c / i
    b = b / i
    i -= 1

print y

Submission status: Wrong Answer

Solution code:
import sys

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

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

divide = 1

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

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

print divide

Submission status: Wrong Answer

Solution code:
import sys

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

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

divide = 1

if x > y:
    temp = x
    x = y
    y = temp

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

print divide

Submission status: Wrong Answer

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

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

print divide

Submission status: Wrong Answer

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

elif x == 1:
    divide = 1

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

print divide

Submission status: Wrong Answer

Solution code:
import sys

x = sys.stdin.readline()

a, b = x.split(" ")

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

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

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

print y

Submission status: Wrong Answer

Solution code:
import sys

x = sys.stdin.readline()

a, b = x.split(" ")

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

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

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

print y

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

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

if x == y:
    divide = x

else:
    div

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

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

if x == y:
    divide = x

else:
    div

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

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

if x == y:
    divide = x

else:
    div(x, y)

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

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

if x == y:
    divide = x

else:
    div(x, y)

Submission status: Wrong Answer

Solution code:
import sys


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


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

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

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

if x == y:
    divide = x

else:
    div(x, y)

Submission status: Wrong Answer

Solution code:
import sys

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


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

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

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

if x == y:
    divide = x

else:
    div(x, y)

Submission status: Wrong Answer

Solution code:
import sys

x = sys.stdin.readline()

a, b = x.split(" ")

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

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

if a == b:
  print a

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

Submission status: Wrong Answer

Solution code:
import sys

x = sys.stdin.readline()

a, b = x.split(" ")

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

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

if a == b:
  print a

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

  print y

Submission status: Wrong Answer

Solution code:
import sys

x = sys.stdin.readline()

a, b = x.split(" ")

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

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

if a == b:
  print a

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

Submission status: Wrong Answer

Solution code:
import sys

x = sys.stdin.readline()

a, b = x.split(" ")

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

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

if a == b:
  print a

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

Submission status: Wrong Answer

Solution code:
import sys

x = sys.stdin.readline()

a, b = x.split(" ")

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

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

if a == b:
  print a

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

Submission status: Wrong Answer

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, 2, -1):
        if i != 1 and x % i == 0 and y % i == 0:
            divide = divide * i
            x = x / i
            y = y / i
            i = 1
            print x, y, divide

print divide

Submission status: Wrong Answer

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
            i = 1
            print x, y, divide

print divide

Submission status: Wrong Answer

Solution code:
import sys

x = sys.stdin.readline()

a, b = x.split(" ")

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

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

if a == b:
  print a

else:
  for i in range(1, a+1):
    if i != 1 and a % i == 0 and b % i == 0:
      y *= i
      a = a / i
      b = b / i
      i = 1
  print y

Submission status: Wrong Answer

Solution code:
import sys

x = sys.stdin.readline()

a, b = x.split(" ")

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

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

if a == b:
  print a

else:
  for i in range(1, a+1):
    if i != 1 and a % i == 0 and b % i == 0:
      y *= i
      a = a / i
      b = b / i
      i += -1
  print y

Submission status: Wrong Answer

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(1):
    flag = 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
            print x, y, i, divide
            flag = 1
            break
    if flag == 0:
        print divide
        exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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/2:
    if x % i ==0:
        if y % i==0:
            ans = i
    i+=1
print ans

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)% ((x%y/2)-i) == 0 and y%((x%y/2)-i) == 0:
        kouyakusu = i+1

print(kouyakusu)

Submission status: Wrong Answer

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

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

print(gcd)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
import re

def gcd(x, y):
    r = 1
    for i in range(1, min(x, y)):
        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: Wrong Answer

Solution code:
import re

def gcd(x, y):
    if x == y:
        return x
    if x < y and y % x:
        return x
    if x > y and x % y:
        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: Wrong Answer

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

    maximum = min(x, y)
    m = maximum
    for i in [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]:
        if maximum % i == 0:
            m = maximum / i
            break
    r = 1
    for i in range(1, m + 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: Wrong Answer

Solution code:
def gcd(x, y):

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

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(str(answer(x, x%y)))
else:
 print(str(answer(y, y%x)))

Submission status: Wrong Answer

Solution code:
import sys

def gcd(a,b):
	temp = a
	if a<b:
		a=b
		b=a
	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: Wrong Answer

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,x_dy):
    if y%d==0 and x_dy%d==0:
        ans=d

print(ans)

Submission status: Wrong Answer

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,x_dy+1):
    if y%d==0 and x_dy%d==0:
        ans=d

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(x)
    break
  elif y % x == 0:
    print(y)
    break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))
max = 1
for m in range(1,int(A[0]/2) if A[0] < A[1] else A[1]):
    if A[0] % m == 0 and A[1] % m == 0:
        max = m
print(max)

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))
max = 1
for m in range(1,A[0] if A[0] < A[1] else A[1]):
    if A[0] % m == 0 and A[1] % m == 0:
        max = m
print(max)

Submission status: Wrong Answer

Solution code:
def greatest_common_divisor(x, y):
    if x > y:
        max = x
    else:
        max = y
    answer = 0
    for i in range(1, max):
        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: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

print(res)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    i = 2
    temp = 1
    while(i <= b):
        while(a % i == 0 and b % i == 0):
            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]))