Problem:


GCD and LCM

Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b. 

Input

Input consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.

Constraints

 0 < a, b ≤ 2,000,000,000

 LCM(a, b) ≤ 2,000,000,000

 The number of data sets ≤ 50

Output

For each data set, print GCD and LCM separated by a single space in a line.

Sample Input

8 6
50000000 30000000

Output for the Sample Input

2 24
10000000 150000000



Sample input:
8 6
50000000 30000000


Sample output:
2 24
10000000 150000000

Submission status: Runtime Error

Solution code:

    n=input().split()
    num=[int(n[i]) for i in range(len(n))]
    max=1
    num=sorted(num)
    for i in range(1,num[0]+1):
        if num[0]%i==0:
            if num[1]%i==0:
                max=i
    print(max,int(num[0]*num[1]/max))

Submission status: Runtime Error

Solution code:
import sys

def gcd(x, y):
    return gcd(y, y - x) if x != y else x

for i in sys.stdin:
    a, b = sorted(list(map(int, i.split())))
    g = gcd(a, b)
    print(g, (a*b)//g)

Submission status: Runtime Error

Solution code:
import sys

def gcd(x, y):
    return gcd(y, y - x) if x != y else x

for i in sys.stdin:
    a, b = sorted(list(map(int, i.split())))
    g = gcd(a, b)
    print(g, int((a*b)/g))

Submission status: Runtime Error

Solution code:
def get_gcd(_a, _b):
    if _a % _b == 0:
        return _b
    return get_gcd(_b, _a % _b)


if __name__ == '__main__':
    while True:
        a, b = list(map(int, input().split()))
        gcd = get_gcd(a, b)
        lcm = a * b / gcd
        print(str(gcd) + " " + str(int(lcm)))

Submission status: Runtime Error

Solution code:
import math
def main():
    def get_inputs():
        input_list = []
        try:
            while True:
                input_list.append(input())
        except EOFError:
            return input_list

    input_list = get_inputs()
    lcm = lambda a,b: a*b / math.gcd(a,b)
    for str_num in input_list:
        tmp = str_num.split(" ")
        a,b = int(tmp[0]),int(tmp[1])
        x = math.gcd(a,b)
        y = int(lcm(a,b))
        print("{} {}".format(x,y))
    return None


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
def main():
    def get_inputs():
        input_list = []
        count = 0
        try:
            while count < 50:
                input_list.append(input())
                count += 1
        except EOFError:
            return input_list

    input_list = get_inputs()
    lcm = lambda a,b: a*b / math.gcd(a,b)
    for str_num in input_list:
        tmp = str_num.split(" ")
        a,b = int(tmp[0]),int(tmp[1])
        x = math.gcd(a,b)
        y = int(lcm(a,b))
        print("{} {}".format(x,y))
    return None


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def lcm(a,b):
	return a*b/gcd(a,b)
a,b = map(int, input().split())
print("{0:} {1:}".format(gcd(a,b), lcm(a,b))

Submission status: Runtime Error

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

def lcm(a,b):
	return a*b/gcd(a,b)
a,b = map(int, input().split())
print("{0} {1}".format(gcd(a,b), lcm(a,b))

Submission status: Runtime Error

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

def lcm(a,b):
	return a*b/gcd(a,b)

for i in input():
	a,b = map(int, i.split())
	print("{0} {1}".format(gcd(a,b),lcm(a,b)))

Submission status: Runtime Error

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

def lcm(a,b):
	return a*b/gcd(a,b)

for i in input():
	a,b = map(int, i.split())
	gcd_num = gcd(a,b)
	lcm_num = lcm(a,b)
	print("{0} {1}".format(gcd_num,lcm_num))

Submission status: Runtime Error

Solution code:
import sys
import math
for line in sys.stdin:
    a, b = map(int, line.split())
    gcdab = math.gcd(a, b)
    print(gcdab, int(a / gcdab * b))

Submission status: Runtime Error

Solution code:
import sys
import math
for line in sys.stdin:
    a, b = map(int, line.split())
    gcdab = math.gcd(a, b)
    print(gcdab, a // gcdab * b)

Submission status: Runtime Error

Solution code:
import sys
def gcd(a, b):
    for i in range(1, a):
        if a % i == 0:
            t = a // i
            if b % t == 0:
                return t
for line in sys.stdin:
    a, b = sorted(map(int, line.split()))
    gcdab = gcd(a, b)
    print(gcdab, a // gcdab * b)

Submission status: Runtime Error

Solution code:
def GcdLCM():
    
    while 1:
        x,y=map(int,input().split())
        gcd = Gcd(x,y)
        lcm = int(x*y/gcd)

        print("{} {}".format(gcd,lcm))
       
def Gcd(x,y):
    while x!=0:
        x,y=y%x,x
    return y
        
    
GcdLCM()

Submission status: Runtime Error

Solution code:
def GcdLCM():
    
    while 1:
        x,y=map(int,input().split())
        if x==None:
            break
        
        gcd = Gcd(x,y)
        lcm = int(x*y/gcd)

        print("{} {}".format(gcd,lcm))
       
def Gcd(x,y):
    while x!=0:
        x,y=y%x,x
    return y
        
    
GcdLCM()

Submission status: Runtime Error

Solution code:
def GcdLCM():
    
    for line in sys.stdin:
        x,y=map(int,line.split())
        if x==None:
            break
        
        gcd = Gcd(x,y)
        lcm = int(x*y/gcd)

        print("{} {}".format(gcd,lcm))
       
def Gcd(x,y):
    while x!=0:
        x,y=y%x,x
    return y
        
    
GcdLCM()

Submission status: Runtime Error

Solution code:
import math
while True:
    try:
        a, b = map(int, input().split())
    except:
        break
    gcd = math.gcd(a, b)
    lcm = (a*b) // gcd
    print(gcd, lcm)

Submission status: Runtime Error

Solution code:
import math
while True:
    try:
        a, b = sorted(map(int, input().split()))
    except:
        break
    gcd = math.gcd(a, b)
    lcm = (a*b) // gcd
    print(gcd, lcm)

Submission status: Runtime Error

Solution code:
import math
while True:
    a,b = map(int, input().split())
    print(str(math.gcd(a, b))+" "+str(a * b // math.gcd(a, b)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

while True:
 a,b=map(int,input().split())
 print(math.gcd(a,b),a*b//math.gcd(a,b))

Submission status: Runtime Error

Solution code:
import math

while True
 a,b=map(int,input().split())
 print(math.gcd(a,b),a*b//math.gcd(a,b))
 print()

Submission status: Runtime Error

Solution code:
import math
while True:
    try:
        a,b = map(int, input().split())
        print(math.gcd(a, b),a * b // math.gcd(a, b))
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
import math
    try:
        while True:
            
            a,b = map(int, input().split())
            print(math.gcd(a, b), a*b // math.gcd(a, b))
        except:
            pass

Submission status: Runtime Error

Solution code:
import math

try:
while True:
  a,b=map(int,input().split())
  print(math.gcd(a,b),a*b// math.gcd(a, b))
 except:
   pass

Submission status: Runtime Error

Solution code:
import math

try:
 while 1:
  a,b=map(int,input().split())
  print(math.gcd(a,b),a*b// math.gcd(a, b))
except EOFError:
   pass

Submission status: Runtime Error

Solution code:
import math

try:
 while True:
  a,b=map(int,input().split())
  print(math.gcd(a,b),a*b// math.gcd(a, b))
except EOFError:
  pass

Submission status: Runtime Error

Solution code:
from math import gcd
import sys

for line in sys.stdin:
    a, b = list(map(int, line.split()))
    print("{0} {1}".format(gcd(a, b), (a * b) / gcd(a, b)))

Submission status: Runtime Error

Solution code:
from math import gcd
import sys

for line in sys.stdin:
    a, b = list(map(int, line.split()))
    print("{0} {1}".format(gcd(a, b), int((a * b) / gcd(a, b))))

Submission status: Runtime Error

Solution code:
try:
    GCD = 0
    LCM = 0
    while True:
        lists = list(map(int, input().split()))
        l = sorted(lists)
        num = l[0] * l[1]
        while l[0] < l[1]:
            GCD = l[1] - l[0]
            l[1] = GCD
            l = sorted(l)
            LCM = int(num / GCD
        print(str(GCD) + " " + str(LCM))
except EOFError:
    pass

Submission status: Runtime Error

Solution code:
while 1 == 1:
    a, b = map(int, input().split())
    d = a * b
    if a < b:
        tmp = a
        a = b
        b = tmp

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

    g = b
    l = d / g

    print(str(g)+" "+str(int(l)))

Submission status: Runtime Error

Solution code:
import sys

for line in sys.stdin:
    a, b = map(int, input().split())
    d = a * b
    if a < b:
        tmp = a
        a = b
        b = tmp

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

    g = b
    l = d / g

    print(str(g)+" "+str(int(l)))

Submission status: Runtime Error

Solution code:
import fileinput
import math
for line in fileinput.input():
    a, b = map(int, line.split())
    gcd = math.gcd(a, b)
    lcm = a * b // gcd
    print(gcd, lcm)

Submission status: Runtime Error

Solution code:
import fileinput
import math
for line in fileinput.input():
    if line == "\n":
        break
    else:
        a, b = map(int, line.split())
        g = math.gcd(a, b)
        lcm = a * b // g
        print(g, lcm)

Submission status: Runtime Error

Solution code:
# This program computes GCD and LCM
# -*- coding: utf-8
import sys


def gcd(a, b):
    while True:
        tmpb = b
        b = a % b
        a = tmpb
        if(b == 1):
            break
    return a


def lcm(a, b):
    for i in range(max([a, b]), a*b + 1):
        if(i % a == 0 and i % b == 0):
            return i
    return a*b


for i in sys.stdin:
    try:
        line = [int(k) for k in i.split(" ")]
        g = gcd(line[0], line[1])
        print(str(g) + " " + str(int(line[0]*line[1]//g)))  # + str(lcm(line[0], line[1]))
    except:
        raise
        exit()

Submission status: Runtime Error

Solution code:
# This program computes GCD and LCM
# -*- coding: utf-8
import sys


def gcd(a, b):
    while True:
        tmpb = b
        b = a % b
        a = tmpb
        if(b == 1):
            break
    return a


def lcm(a, b):
    for i in range(max([a, b]), a*b + 1):
        if(i % a == 0 and i % b == 0):
            return i
    return a*b


for i in sys.stdin:
    try:
        line = [int(k) for k in i.split(" ")]
        g = gcd(line[0], line[1])
        print(str(g) + " " + str(line[0]*line[1]//g))  # + str(lcm(line[0], line[1]))
    except:
        raise
        exit()

Submission status: Runtime Error

Solution code:
# This program computes GCD and LCM
# -*- coding: utf-8
import sys


def gcd(a, b):
    while True:
        tmpb = b
        b = a % b
        a = tmpb
        if(b == 1):
            break
    return a


def lcm(a, b):
    for i in range(max([a, b]), a*b + 1):
        if(i % a == 0 and i % b == 0):
            return i
    return a*b


for i in sys.stdin:
    try:
        line = [int(k) for k in i.split(" ")]
        g = gcd(max(line), min(line))
        print(str(g) + " " + str(line[0]*line[1]/g))  # + str(lcm(line[0], line[1]))
    except:
        raise
        exit()

Submission status: Runtime Error

Solution code:
# This program computes GCD and LCM
# -*- coding: utf-8
import sys


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


def lcm(a, b):
    for i in range(max([a, b]), a*b + 1):
        if(i % a == 0 and i % b == 0):
            return i
    return a*b


for i in sys.stdin:
    try:
        line = [int(k) for k in i.split(" ")]
        g = gcd(max(line), min(line))
        print(str(g) + " " + str(line[0]*line[1]/g))  # + str(lcm(line[0], line[1]))
    except:
        raise
        exit()

Submission status: Runtime Error

Solution code:
import sys
  
for s in sys.stdin:
    g,r=m,n = map(int,s.split())
    while r!=0:
      g,r = r,g%r
    print(g,m//g*n)

Submission status: Runtime Error

Solution code:
import math
import sys

for line in sys.stdin.readlines():
#for line in data.split('\n'):
	x,y = [int(s) for s in line.split(' ')]
	G = math.gcd(x,y)
	L = int(x*y/G)
	print(G,L)

Submission status: Runtime Error

Solution code:
import sys
import math
def main():
    for line in sys.stdin:
        a,b = map(int, line.split())
        output1 = math.gcd(a, b)
        output2 = int(a * b / output1)
        print(output1, output2)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
import math
def main():
    for line in sys.stdin:
        a,b = map(int, line.split())
        o1 = math.gcd(a, b)
        o2 = int(a * b / o1)
        print(o1, o2)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math

lst = []
for i in range(200):
    try:
        lst.append(input())
    except EOFError:
        break

nums = [list(map(int, elem.split(' '))) for elem in lst]

# gcd 
res_gcd = [math.gcd(num[0], num[1]) for num in nums]

# lcm
res_lcm = [nums[i][0] * nums[i][1] // res_gcd[i] for i in range(len(nums))]

for (a, b) in zip(res_gcd, res_lcm):
    print('{} {}'.format(a, b))

Submission status: Runtime Error

Solution code:
ans=[]
while True:
    try:
        mins=0
        maxs=0
        nums=input().split()
        nums[0]=int(nums[0])
        nums[1]=int(nums[1])
        nums_copy=nums.copy()
        while True:
            if nums[0]%nums[1]==0:
                 maxs=nums[1]
                 break
            num=nums[1]
            nums[1]=nums[0]%nums[1]
            nums[0]=num
        mins=nums_copy[0]*nums_copy[1]/maxs
        ans.append(maxs)
        ans.append(mins)
    except:
        break

for i in range(len(ans)/2):
    print(ans[i*2],ans[i*2+1])

Submission status: Runtime Error

Solution code:

while True:
????????try:
????????????????(a, b) = map(int, input().split(" "))
????????????????(x, y) = (a, b)
????????????????while (x != 0):
????????????????????????(x, y) = (y%x, x)
????????????????print("%s %s" %(y, a*b//y))
????????except:
????????????????break

Submission status: Runtime Error

Solution code:
import math
import sys

while True:
	try:
		a,b = map(int, input().split())
		x = math.gcd(a,b)
		i = 1
		while True:
			if a*i%b == 0:
				y = a*i
				break
			else:
				i = i+1
		print(x,y)
	except EOFError:
		break

Submission status: Runtime Error

Solution code:
while True:
    a,b = map(int, input().split())
    if a < b:
        a,b = b,a

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

    def lcm(x,y):
         return x * y / gcd(x, y)

    print(gcd(a,b), int(lcm(a,b)))

Submission status: Runtime Error

Solution code:
import math, sys
def lcm(a,b):
    return int(a*b/math.gcd(a,b))

if __name__ == '__main__':
    for line in sys.stdin:
        (a,b) = map(int,line.split())
        print(math.gcd(a,b),lcm(a,b))

Submission status: Runtime Error

Solution code:
import math, sys
def lcm(a,b):
    return int(a*b/math.gcd(a,b))

if __name__ == '__main__':
    for line in sys.stdin:
        a,b = map(int,line.split())
        print(math.gcd(a,b),lcm(a,b))

Submission status: Runtime Error

Solution code:
import math, sys
def lcm(a,b):
    return int(a*b/math.gcd(a,b))

if __name__ == '__main__':
    for line in sys.stdin:
        a,b = map(int,line.split())
        print(int(math.gcd(a,b)),lcm(a,b))

Submission status: Runtime Error

Solution code:
import sys
import math

for line in sys.stdin:
    a, b = map(int, line.split(' '))
    gcd = math.gcd(a, b)
    print(gcd, a * b // gcd)

Submission status: Runtime Error

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


def LCM(a, b, a_b_GCD):
    return int((a * b) / a_b_GCD)

while True:
    a, b = map(int, input().split(' '))
    a, b = max(a, b), min(a, b)

    print(GCD(a, b), LCM(a, b, GCD(a, b)))

Submission status: Runtime Error

Solution code:
from math import gcd
from sys import stdin

for line in stdin:
    a,b = [int(i) for i in line.split()]
    g = gcd(a,b)
    print(g,int(a*b/g)

Submission status: Runtime Error

Solution code:
import fractions as f
while 1:    
    a,b=map(int,input().split())
    print(str(f.gcd(a,b))+' '+str(a*b//f.gcd(a,b)))

Submission status: Runtime Error

Solution code:
class GCD():
    def __init__(self,a,b):
        self.a = a
        self.b = b

    def swap(self):
        temp = self.a
        self.a = self.b
        self.b = temp

    def gcd(self):
        if self.b < self.a:
            self.swap()

        temp = self.b % self.a
        ans = self.b % temp

        return ans

    def lcm(self):
        gcd = self.gcd()
        temp = self.a * self.b
        ans = temp // gcd
        return gcd,ans

    def print(self):
        num = self.lcm()
        print("{0} {1}".format(num[0],num[1]))

def main():
    data = []

    while 1:
        try:
            n = input().split()

            a = int(n[0])
            b = int(n[1])

            data.append(GCD(a, b))

        except EOFError:
            break

    for array in data:
        array.print()

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
class GCD():
    def __init__(self,a,b):
        self.a = a
        self.b = b

    def swap(self):
        temp = self.a
        self.a = self.b
        self.b = temp

    def gcd(self):
        if self.b < self.a:
            self.swap()

        temp = self.b % self.a

        if temp == 0:
            ans = self.a
            return ans

        ans = self.b % temp

        return ans

    def lcm(self):
        gcd = self.gcd()
        temp = self.a * self.b
        ans = temp // gcd
        return gcd,ans

    def print(self):
        num = self.lcm()
        print("{0} {1}".format(num[0],num[1]))

def main():
    data = []

    while 1:
        try:
            n = input().split()

            a = int(n[0])
            b = int(n[1])

            data.append(GCD(a, b))

        except EOFError:
            break

    for array in data:
        array.print()

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def pd(n):
    i = 2
    ans = []
    while i ** 2 <= n:
        while n % i == 0:
            n /= i
            ans.append(i)
        i += 1
    if n > 1:
        ans.append(n)
    return ans

def gcd(a, b):
    gcd = 1
    pd_a = pd(a)
    pd_b = pd(b)
    for i in pd_a:
        if i in pd_b:
            pd_b.remove(i)
            gcd *= i
    return int(gcd)

def lcm(a, b):
    lcm = a
    pd_a = pd(a)
    pd_b = pd(b)
    for i in pd_a:
        if i in pd_b:
            pd_b.remove(i)
    for j in pd_b:
        lcm *= j
    return int(lcm)

while True:
    s = input()
    if not s:
        break
    a,b = [int(i) for i in s.split(' ')]
    print(gcd(a, b), lcm(a, b))

Submission status: Runtime Error

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

while 1:
    a, b = map(int,input().split())
    g = gcd(a, b)
    l = a / g * b
    print(g, l)

Submission status: Runtime Error

Solution code:
import sys

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

for line in sys.stdin:
    a, b = map(int,input().split())
    g = gcd(a, b)
    l = a // g * b
    print(g, l)

Submission status: Runtime Error

Solution code:
import sys;

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

for line in sys.stdin:
    a, b = map(int,input().split())
    g = gcd(a, b)
    l = a // g * b
    print(g, l)

Submission status: Runtime Error

Solution code:
import sys;

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

for line in sys.stdin:
    a, b = map(int,input().split())
    g = gcd(a, b)
    l = a * b // g
    print(g, l)

Submission status: Runtime Error

Solution code:
import sys;

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

for line in sys.stdin:
    a, b = list(map(int,input().split()))
    g = gcd(a, b)
    l = a * b // g
    print(g, l)

Submission status: Runtime Error

Solution code:
import sys

def get_divisor(num):
    divisor_list = []
    for i in range(1, int(num/2)):
        divisor = num / i

        if divisor.is_integer():
            divisor_list.append(i)
            divisor_list.append(int(divisor))
    return list(set(divisor_list))

for line in sys.stdin.readlines():
    ab = [int(str_) for str_ in line.split()]

    a_list = get_divisor(ab[0])
    b_list = get_divisor(ab[1])

    matched_list = [b for b in b_list if b in a_list]
    g = max(matched_list)
    l = int(ab[0]*ab[1] / g)
    print("{} {}".format(g, l))

Submission status: Runtime Error

Solution code:
import sys

def get_divisor(num):
    divisor_list = []
    for i in range(1, int(num/2)):
        divisor = num / i

        if divisor.is_integer():
            divisor_list.append(i)
            divisor_list.append(int(divisor))
    return list(set(divisor_list))

for line in sys.stdin.readlines():
    ab = [int(str_) for str_ in line.split()]

    a_list = get_divisor(ab[0])
    b_list = get_divisor(ab[1])

    matched_list = [b for b in b_list if b in a_list]
    g = max(matched_list)
    l = int(ab[0]*ab[1] / g)
    print("{} {}".format(g, l))

Submission status: Runtime Error

Solution code:
import sys

def get_divisor(num):
    divisor_list = []
    for i in range(1, int(num/2)):
        divisor = num / i

        if divisor.is_integer():
            divisor_list.append(i)
            divisor_list.append(int(divisor))
    return list(set(divisor_list))

for line in sys.stdin:
    ab = [int(str_) for str_ in line.split()]

    a_list = get_divisor(ab[0])
    b_list = get_divisor(ab[1])

    matched_list = [b for b in b_list if b in a_list]
    g = max(matched_list)
    l = int(ab[0]*ab[1] / g)
    print("{} {}".format(g, l))

Submission status: Runtime Error

Solution code:
def get_divisor(num):
    divisor_list = []
    for i in range(1, int(num/2)):
        divisor = num / i

        if divisor.is_integer():
            divisor_list.append(i)
            divisor_list.append(int(divisor))
    return list(set(divisor_list))

while True:
    ab = [int(str_) for str_ in input().split()]

    a_list = get_divisor(ab[0])
    b_list = get_divisor(ab[1])

    matched_list = [b for b in b_list if b in a_list]
    g = max(matched_list)
    l = int(ab[0]*ab[1] / g)
    print("{} {}".format(g, l))

Submission status: Runtime Error

Solution code:
import sys


def get_divisor(num):
    divisor_list = []
    for i in range(1, int(num/2)):
        divisor = num / i

        if divisor.is_integer():
            divisor_list.append(i)
            divisor_list.append(int(divisor))
    return list(set(divisor_list))


for line in sys.stdin.readlines():
    ab = [int(str_) for str_ in line.split()]

    a_list = get_divisor(ab[0])
    b_list = get_divisor(ab[1])

    matched_list = [b for b in b_list if b in a_list]
    g = max(matched_list)
    l = int(ab[0]*ab[1] / g)
    print("{} {}".format(g, l))

Submission status: Runtime Error

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

r=[map(int,line.split()) for line in sys.stdin]
for i in r:
    o=gcd(i[0],i[i])
    p=i[0]*i[1]/o
    print(o,p)

Submission status: Runtime Error

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

r=[list(map(int,line.split())) for line in sys.stdin]
for i in r:
    o=gcd(i[0],i[i])
    p=i[0]*i[1]/o
    print(o,p)

Submission status: Runtime Error

Solution code:
# Vol0005.


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

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

def main():
    data = []
    lines = sys.stdin.readlines()
    for line in lines:
        data.append(line.split())

    N = len(data)
    for i in range(N):
        a = int(data[i][0]); b = int(data[i][1])
        gcd = get_gcd(a, b)
        lcm = (a // gcd) * b
        print('%d %d' % (a, b))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    while 1:
        a,b=(int(x) for x in input().split())
        a1=a
        b1=b
        while b!=0:
            c=a%b
            a=b
            b=c
        print(a, a1*b1//a)

main()

Submission status: Runtime Error

Solution code:
from sys import stdin
from sys import math

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

def LCM(a,b):
    gcd = GCD(a,b)
    return a*b/gcd

for line in stdin:
    a,b = line.split(" ")
    a = int(a)
    b = int(b)
    gcd = GCD(a,b)
    lcm = math.floor(LCM(a,b))

    print(str(gcd)+" "+str(lcm))
    print()

Submission status: Runtime Error

Solution code:
import sys

def euc(n,m):
    if n == m:
        return m
    elif m == 1 | n == 1:
        return 1
    else:
        return euc(min(n,m), max(n,m)-min(n,m))

for line in sys.stdin:
    a,b = [int(i) for i in line.split()]
    print(euc(a,b),int(a*b/euc(a,b)))

Submission status: Runtime Error

Solution code:
import sys


def euc(n,m):
    if n == m:
        return m
    elif m == 1 | n == 1:
        return 1
    else:
        return euc(min(n,m), max(n,m)-min(n,m))


for line in sys.stdin:
    a,b = [int(i) for i in line.split()]
    print(euc(a,b),int(a*b/euc(a,b)))

Submission status: Runtime Error

Solution code:
import sys


def euc(n,m):
    if n == m:
        return m
    elif m == 1 or n == 1:
        return 1
    else:
        return euc(min(n,m), max(n,m)-min(n,m))


for line in sys.stdin:
    a,b = [int(i) for i in line.split()]
    print(euc(a,b),int(a*b/euc(a,b)))

Submission status: Runtime Error

Solution code:
import sys


def euc(n,m):
    if n == m:
        return m
    elif m == 1 or n == 1:
        return 1
    else:
        return euc(min(n,m), max(n,m)-min(n,m)*int(max(n,m)/min(n,m)))


for line in sys.stdin:
    a,b = [int(i) for i in line.split()]
    print(euc(a,b),int(a*b/euc(a,b)))

Submission status: Runtime Error

Solution code:
import sys


def euc(n,m):
    if n%m == 0:
        return m
    else:
        return euc(min(n,m), max(n,m)%min(n,m))


for line in sys.stdin:
    a,b = [int(i) for i in line.split()]
    print(euc(a,b),int(a*b/euc(a,b)))

Submission status: Runtime Error

Solution code:
import sys;print"\n".join("%d %d"%(lambda l:(l[0],l[2]/l[0]*l[1]))(lambda f,l:(f(f,l),l[0],l[1]))(lambda f,l:l[1]==0 and l[0] or f(f,[l[1],l[0]%l[1]]),map(int,s.split()))for s in sys.stdin)

Submission status: Runtime Error

Solution code:
    while True:
        try:
            list = [int(x) for x in raw_input().split(" ")]
            list.sort(lambda x, y: y - x)
            gcd = lcm = 0
            m = list[0]
            n = list[1]
            while True:
                r = m%n
                if r == 0:
                    gcd = n
                    break
                m = n
                n = r
            lcm = list[0] * list[1] / gcd
            print(str(gcd) + " " + str(lcm))
        except EOFError:
            break

Submission status: Runtime Error

Solution code:
while True:
	ints = raw_input()
	if ints != '':
		x = map(int,ints.split(' '))
		x.sort()
		a = x[1]
		b = x[0]
		while True:
			m=a%b
			if m!=0:
				a=b
				b=m
				continue
			else:
				break
		n = x[1]*x[0]/b
	print b,n

Submission status: Runtime Error

Solution code:
while True:
	ints = raw_input()
	if ints != '':
		x = map(int,ints.split(' '))
		x.sort()
		a = x[1]
		b = x[0]
		while True:
			m=a%b
			if m!=0:
				a=b
				b=m
				continue
			else:
				break
		n = x[1]*x[0]/b
		print b,n
		continue
	else:
		break

Submission status: Runtime Error

Solution code:
import sys
def euc(li):
    if (li[0] == 0 or li[1] == 0):
        return li[1];
    return euc((li[0]-li[1],li[1]) if li[0]>li[1] else (li[1]-li[0],li[0]))
for line in sys.stdin:
    [a,b] = [int(x) for x in line.split()]
    gcd = euc([a,b])
    print gcd,a*b/gcd

Submission status: Runtime Error

Solution code:
import sys
def euc(li):
    if (li[0] == 0 or li[1] == 0):
        return li[1]
    return euc((li[0]-li[1],li[1]) if li[0]>li[1] else (li[1]-li[0],li[0]))
for line in sys.stdin:
    [a,b] = [int(x) for x in line.split()]
    gcd = euc([a,b])
    print gcd,a*b/gcd

Submission status: Runtime Error

Solution code:
A , B = map(int,input().split())
a , b = A , B
while a != b:
        if a < b:
                b = b-a
        elif b < a:
                a = a-b
b = int(A*B/a)
print(a,b)

Submission status: Runtime Error

Solution code:
import sys

for line in sys.stdin:
    a, b = sorted(map(int, line.split(' ')))
    gcd = 1
    div = 2
    while a >= div:
        amod, bmod = a % div, b % div
        if amod == 0 and bmod == 0;
            gcd *= div
            a, b = a/div, b/div
            continue
        else:
            div += 2
    lcm = gcd * a * b
    print gcd, lcm

Submission status: Runtime Error

Solution code:
import sys

for line in sys.stdin:
    a, b = sorted(map(int, line.split(' ')))
    gcd = 1
    div = 2
    while a >= div:
        amod, bmod = a % div, b % div
        if amod == 0 and bmod == 0;
            gcd *= div
            a, b = a/div, b/div
            div = 2
            continue
        else:
            div += 1
    lcm = gcd * a * b
    print gcd, lcm

Submission status: Runtime Error

Solution code:
import sys

for line in sys.stdin:
    a, b = sorted(map(int, line.split(' ')))
    gcd = 1
    d = 2
    while a >= d:
        amod, bmod = a % d, b % d
        if amod == 0 and bmod == 0;
            gcd *= d
            a, b = a/d, b/d
            d = 2
            continue
        else:
            d += 1
    lcm = gcd * a * b
    print gcd, lcm

Submission status: Runtime Error

Solution code:
import sys

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

def lcm(a,b):
	return a*b/gcd(a,b)

for s in sys.stdin:
	i = map(int,raw_input().split())
	print gcd(*i), lcm(*i)

Submission status: Runtime Error

Solution code:
import sys
def gcm(a, b):
    if a<b: a,b=b,a
    if (a%b==0):
        return b
    else:
        return gcm(b,a%b)

for s in stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print "%d %d" %(c,a/c*b)

Submission status: Runtime Error

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

import sys

outList = []
for line in sys.stdin.readlines():
    List = map(int, line.strip().split())

    [a, b] = List

    # LCM
    LCM = 1
    for i in xrange(2, max(a, b)):
        if isprime(a) or isprime(b): break
        while(a % i == 0 and b % i == 0):
            LCM *= i
            a /= i
            b /= i

    # GCD
    GCD = List[0] * b

    print LCM, GCD

def isprime(n):
    for i in xrange(2, int(n ** 0.5) ):
        if n % i == 0: return False
    return True

Submission status: Runtime Error

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

import sys

outList = []
for line in sys.stdin.readlines():
    List = map(int, line.strip().split())

    [a, b] = List

    # LCM
    LCM = 1
    for i in xrange(2, max(a, b)):
        if isprime(i): continue
        if isprime(a) or isprime(b): break
        while(a % i == 0 and b % i == 0):
            LCM *= i
            a /= i
            b /= i

    # GCD
    GCD = List[0] * b

    print LCM, GCD

def isprime(n):
    for i in xrange(2, int(n ** 0.5)+1 ):
        if n % i == 0: return False
    return True

Submission status: Runtime Error

Solution code:
while True:
    a, b = map(int, raw_input().split())
    def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
    g = gcd(a,b)
    l = a * b/gcd(a,b)
    print g, l