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: Accepted

Solution code:
import sys

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

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

for x in sys.stdin.readlines():
    n = [float(y) for y in x.split()]

    print "%d %d" % (gcd(n[0], n[1]),(lcm(n[0], n[1])))

Submission status: Accepted

Solution code:
#coding: utf-8
def GCM(m, n):
    while 1:
        if n == 0: return m
        m -= (m/n)*n
        m,n = n,m
    
while 1:
    try:
        a,b = map(int, raw_input().split())
        x = GCM(a,b)
        y = a*b / x
        print "%d %d" % (x, y)
    except EOFError:
        break

Submission status: Accepted

Solution code:

while True:
    try:
        x = map(int, raw_input().split(' '))
        
        if x[0] < x[1]:
            m = x[1]
            n = x[0]
        else:
            m = x[0]
            n = x[1]
           
           
        # m is greatrer than n
        while n !=0:
            m,n = n,m % n
        
        print m,x[0]*x[1]/m
    except EOFError:
        break

Submission status: Accepted

Solution code:
def swap(a, b):
    a = a ^ b
    b = a ^ b
    a = a ^ b
def gcd(x, y):
    if(x < y):
        swap(x, y)
    mod = x % y
    if mod == 0:
        return y
    else:
        return gcd(y, mod)
def lcm(x, y):
    return x * y / gcd(x, y)
while True:
    try:
        (a, b) = map(int ,raw_input().split())
    except EOFError:
        break
    print gcd(a, b), lcm(a, b)

Submission status: Accepted

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

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

while True:
    try:
        a, b = map(int, raw_input().split())
        print gcd(a, b), lcm(a, b)
    except (EOFError):
        break

Submission status: Accepted

Solution code:
def gcd(a, b):
    r = a % b
    if r == 0: return b
    else: return gcd(b, r)
 
def lcm(a, b):
    return a*b/gcd(a,b)
 
while True:
    try:
        x = map(int, raw_input().split(" "))
        print "%d %d" % (gcd(x[0], x[1]), lcm(x[0], x[1]))
         
    except EOFError:
        break

Submission status: Accepted

Solution code:
#!/usr/bin/python
import sys

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

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

for l in sys.stdin:
    a = [int(s) for s in l.split()]
    print str(gcd(a[0],a[1]))+" "+str(lcm(a[0],a[1]))

Submission status: Accepted

Solution code:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys
from fractions import gcd
from itertools import count

for line in sys.stdin:
    small, large = sorted(int(n) for n in line .split())
    for i in count(large, large):
        if not i % small:
            lcm = i
            break
    print(gcd(large, small), lcm)

Submission status: Accepted

Solution code:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys
from fractions import gcd

for line in sys.stdin:
    small, large = sorted(int(n) for n in line .split())
    G = gcd(large, small)
    print(G, large // G * small)

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

Solution code:
while True:
	try:
		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
	except: break

Submission status: Accepted

Solution code:
import sys
def gcd(a,b):
    if (b == 0):
        return a
    return gcd(b,a%b)
for line in sys.stdin:
    a,b = [int(x) for x in line.split()]
    d = gcd(a,b)
    print d,a*b/d

Submission status: Accepted

Solution code:
import sys
def g(a,b):
    if b==0: return a
    return g(b,a%b)
for l in sys.stdin:
    a,b=map(int,l.split())
    c=g(a,b)
    print c,a/c*b

Submission status: Accepted

Solution code:
while True:
    try:
        a = map(int,raw_input().split())

	n = [a[0],a[1]]

        while True:
            if a[0] < a[1]:
	        tmp = a[0]
                a[0] = a[1]
	        a[1] = tmp

            a[0] = a[0] - a[1]
	    if a[0] == 0:
		break

	b = n[0]*n[1]/a[1]

	print "%d %d" % (a[1],b)

    except EOFError:
	break

Submission status: Accepted

Solution code:

import sys
import fractions
import re


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


#input_file = open(sys.argv[1], "r")

#for line in input_file:
for line in sys.stdin:
    ab = map(int, re.split(" +", line))
    a, b = tuple(ab)
    gcd_ab = fractions.gcd(a, b)
    lcm_ab = lcm(a, b)
    print gcd_ab, lcm_ab

Submission status: Accepted

Solution code:
while True:
	try:
		n = map(int, raw_input().split())
		a = max(n) 
		b = min(n)
		ab = a * b
		while b != 0 :
			c = a % b
			a = b
			b = c
		print str(a) + " " + str(ab / a)
	except EOFError:
		break

Submission status: Accepted

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

try :
  while True :
    (a,b) = map(int, raw_input().split())

    print gcd(a,b), lcm(a,b)
except EOFError :
  pass

Submission status: Accepted

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

while True:
    try:
        a,b = map(int, raw_input().split())
        c = gcd(a, b)
        print "{0} {1}".format(c, a*b/c)
    except:
        break

Submission status: Accepted

Solution code:
import sys

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

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

for line in sys.stdin:
    data = map(int, line.split())
    a, b = data
    print "%d %d" % (gcd(a, b), lcm(a, b))

Submission status: Accepted

Solution code:
def gcm(a, b):
    if a<b: a,b = b,a

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

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

while True:
    try:
        a, b = map(int, raw_input().split())
    except:
        break
    print "%d %d" %(gcm(a,b), lcm(a,b))

Submission status: Accepted

Solution code:
import fractions

while True:
    try:
        (a, b) = map(int, raw_input().split())
        c = fractions.gcd(a, b)
        print c, ((a*b)/c)
    except EOFError:
        break

Submission status: Accepted

Solution code:
# GCD and LCM

import sys


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

datas = []

for line in sys.stdin:
	datas.append(map(int, line.split()))

for data in datas:
	g = gcd(data[0], data[1])
	print "{0} {1}".format(g, data[0] * data[1] / g)

Submission status: Accepted

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: Accepted

Solution code:
while 1:
        try:
                a, b = map(int,raw_input().split())
        except EOFError:
                break
        ac, bc = a, b
        while 1:
                if a < b:
                        b = b - a
                elif b < a:
                        a = a - b
                elif a == b:
                        x = [a,ac*bc/a]
                        print "{:.10g} {:.10g}".format(*x)
                        break

Submission status: Accepted

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,s.split())
	print gcd(*i), lcm(*i)

Submission status: Accepted

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 sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print "%d %d" %(c,a/c*b)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for s in sys.stdin:
    a,b=map(int,s.split())
    if a<b:a,b=b,a
    c=gcm(a,b)
    print c,a/c*b

Submission status: Accepted

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

for s in sys.stdin:
    a,b=map(int,s.split())
    if a<b:a,b=b,a
    c=gcm(a,b)
    print c,a/c*b

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
for i in sys.stdin:
	m, n = map(int, i.split())
	t1, t2 = m, n
	while True:
		if m % n == 0:
			break
		m, n = n, m % n
	a = n
	b = (t1/ a) * t2
	print("{} {}".format(a, b))

Submission status: Accepted

Solution code:
import sys
def gcm(a,b):
    return gcm(b,a%b) if b else a
for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print c,a/c*b

Submission status: Accepted

Solution code:
import sys
def gcm(a,b):
    x=gcm(b,a%b) if b else a
    return x
for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print c,a/c*b

Submission status: Accepted

Solution code:
import sys
def g(a,b):
  x=g(b,a%b) if b else a
  return x
for s in sys.stdin:
  a,b=map(int,s.split())
  c=g(a,b)
  print c,a/c*b

Submission status: Accepted

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

import sys

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


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

    [a, b] = List

    # LCM
    LCM = 1
    i = 1
    while( i <= min(a, b) ):
        i += 1
        if not isprime(i): continue
        while(a % i == 0 and b % i == 0):
            LCM *= i
            a /= i
            b /= i

    # GCD
    GCD = List[0] * b

    print LCM, GCD

Submission status: Accepted

Solution code:
gcd, lcm = [], []
while True:
	try:
		a, b = map(int, raw_input().split())
		if a > b:
			m, n = a, b
		else:
			m, n = b, a		

		while n != 0:
			m, n = n, m % n 
		gcd.append(m)
		lcm.append(a * b / m)
	except EOFError:
		break

for gcd, lcm in zip(gcd, lcm):
	print '%d %d' % (gcd, lcm)

Submission status: Accepted

Solution code:
while True:
    try:
        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/g
        print g, l
    except:
        break

Submission status: Accepted

Solution code:
import sys

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

for line in sys.stdin:
    (a,b)=line.split(" ")
    a=eval(a)
    b=eval(b)
    g=gcd(a,b)
    print("%d %d" % (g,a*b/g))

Submission status: Accepted

Solution code:

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

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

while True:
    try:
        a, b = map(int, raw_input().split())
    except EOFError:
        break

    g = gcd(a, b) 
    print "{} {}".format(g, lcm(a,b,g))

Submission status: Accepted

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

def get_lcm(a,b,g):
	return a * b / g

while True:
	try:
		a,b = map(int, sorted(raw_input().split()))
		GCD = get_gcd(a,b)
		LCM = get_lcm(a,b,GCD)
		print "{} {}".format(GCD, LCM)
	except EOFError:
		break

Submission status: Accepted

Solution code:
import sys

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

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

for ab in sys.stdin:
    a,b=map(int, ab.split())
    a,b=max(a,b),min(a,b)
    print gcd(a,b),lcm(a,b)

Submission status: Accepted

Solution code:
from fractions import gcd
while 1:
    try:
        a, b = map(int, raw_input().split())
        print gcd(a, b), a * b / gcd(a, b)
    except:
        break

Submission status: Accepted

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


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

try:
    while True:
        a, b = map(int, raw_input().split())
        print gcd(a, b), lcm(a, b)
except:
    pass

Submission status: Accepted

Solution code:
# coding:utf-8
import sys

# 最大公約数
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 s in sys.stdin:
  a, b = map(int,s.split())
  gcd_num = gcd(a, b)
  lcm_num = lcm(a, b)
  print "%d %d"%(gcd_num, lcm_num)

Submission status: Accepted

Solution code:
import fractions
while True:
	try:
		x,y = map(int,raw_input().split())
		print '%d %d' % (fractions.gcd(x,y),x/fractions.gcd(x,y)*y)
	except EOFError:
		break

Submission status: Accepted

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

while True:
    try:
        line = input()
    except:
        break
    a, b = map(int, line.strip().split())
    g = gcd(a, b)
    print(g, a * b // g)

Submission status: Accepted

Solution code:
import sys

def readint():
    for line in sys.stdin:
        yield map(int,line.split())

def gcd(x,y):
    [x,y] = [max(x,y),min(x,y)]
    while 1:
        z = x % y
        if z == 0:
            break
        [x,y] = [y,z]
    return y

for [x,y] in readint():
    GCD = gcd(x,y)
    mx = x/GCD
    print GCD,mx*y

Submission status: Accepted

Solution code:
def gcd(u, v):
    if (v == 0): return u
    return gcd(v, u % v)

def lcm(u, v):
    return (u * v) // gcd(u, v)

while 1:
    try:
        inp = input()
    except EOFError:
        break
    else:
        u, v = inp.split(' ')
        u = int(u)
        v = int(v)
        print(gcd(u, v), lcm(u, v))

Submission status: Accepted

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: Accepted

Solution code:
def gcd(y, x):
    if x == 0:
        return y
    return gcd(x, y%x)
try:
    while True:
        a, b = sorted(map(int, input().split()), reverse=True)
        print(gcd(a,b), a*b//gcd(a,b))
except:
    pass

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
errerN=1

while errerN:
    try:
        a=list(map(int, input().split()))
        gcdN=math.gcd(a[0],a[1])
        print(gcdN, int(a[0]*a[1]/gcdN))
    except :
        errerN=0

Submission status: Accepted

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

while True :
    try :
        a, b = map(int, input().split())
    except EOFError :
        break
    
    a, b = max(a, b), min(a, b)
    x = gcd(a, b)
    print(x, a * b // x)

Submission status: Accepted

Solution code:
#2-8
while True:
    try:

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

        a = list(map(int,input().split()))
        a.sort()
        a.reverse()
        ans1 = gcd(a[0],a[1])
        ans2 = int(a[0]*a[1]/ans1)

        print(ans1,ans2)
    except:
        break

Submission status: Accepted

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

while True:
    try:
        a,b=map(int,input().split())
        print(gcd(a,b),lcm(a,b))
    except:
        break

Submission status: Accepted

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

    try:
        a, b = map(int, input().split())
    except EOFError:
        break
    print(str(gcd(b, a%b)) + " " + str(int(lcm(a, b))))

Submission status: Accepted

Solution code:
while True:
    try:
        lst = list(map(int, input().split()))
        a, b = lst[0], lst[1]
        while b != 0:
            a, b = b, a % b
            
        c = lst[0]* lst[1]/ a
        print('{:.0f}'.format(a), end = " ")
        print('{:.0f}'.format(c))

    except:
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
john=[]
while True:
    try:
        john.append(input())
    except EOFError:
        break
for i in john:
    k=list(map(int,i.split()))
    print(int(math.gcd(k[0],k[1])),int(k[0]*k[1]/math.gcd(k[0],k[1])))

Submission status: Accepted

Solution code:
import math
import sys
def gcd(a,b):
    if b==0:
        return a
    return gcd(b, a%b)
def lcm(a,b):
    return a/gcd(a,b)*b
for l in sys.stdin:
    a=list(map(int,l.split()))
    print("%d %d"%(gcd(a[0],a[1]),lcm(a[0],a[1])))

Submission status: Accepted

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

def main():
    while 1:
        try:
            a = list(map(int, input().split()))
            b = gcd(a[0],a[1])
            c = a[0]/b*a[1]
            print('%s %d' % (b,c))
        except:
            break
            
if __name__ == "__main__":
    main()

Submission status: Accepted

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

def main():
    while 1:
        try:
            a = list(map(int, input().split()))
            b = gcd(a[0],a[1])
            c = a[0]/b*a[1]
            #d = [b,c]
            print('%d %d' % (b,c))
        except:
            break
            
main()

Submission status: Accepted

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

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


while True:
    try:
        x = list(map(int,input().split()))
        ans_1 = GCD(x[0],x[1])
        ans_2 = LCM(x[0],x[1])
        print("%d %d"%(ans_1,ans_2))
    
    except:
        break

Submission status: Accepted

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

while True:
    try:
        a,b = map(int, input().split())
        g = gcd(a,b)
        print("%s %d"%(g,a/g*b))
    except:
        break

Submission status: Accepted

Solution code:
#mathモジュールをインポートする
import math
try:
    while True:
        a,b = map(int,input().split())
        #最小公約数
        num1 = math.gcd(a,b)
        #最大公倍数
        num2 = int(a * b / num1)
        print(str(num1) + " " + str(num2))
#EOFErrorをひろいコードを終了する
except EOFError:
    pass

Submission status: Accepted

Solution code:
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m
def lcm(m, n):
    return m // gcd(m, n) * n

for line in open(0).readlines():
    a, b = map(int, line.split())
    print(gcd(a, b), lcm(a, b))

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
def gcd(x,y):
    if(x%y==0):
        return y
    else:
        return(gcd(y,x%y))
try:
    while True:
        a,b= map(int, input().split())
        max1=gcd(a,b)
        min1=(a*b)//gcd(a,b)
        print(str(max1)+' '+str(min1))
except EOFError:
    pass

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
def gcd(aa, bb):
    if aa % bb == 0:
        return bb
    return gcd(bb, aa % bb)

import sys
for line in sys.stdin.readlines():
    ab = list(map(int, line.split()))
    a = max(ab)
    b = min(ab)
    g = gcd(a, b)

    print(g, a * b // g)

Submission status: Accepted

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

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

while(1):
    try:
        x,y = (int(x) for x in input().split())
        print(gcd(x,y),lcm(x,y))
    except:
        break

Submission status: Accepted

Solution code:
import math

while True:
    try:
        a, b = list(map(int, input().split()))
        print('{0} {1}'.format(math.gcd(a, b), int(a * b / math.gcd(a, b))))
    except EOFError:
        break

Submission status: Accepted

Solution code:
import math

try:
    while True:
        a, b = list(map(int, input().split()))
        print("{} {}".format(math.gcd(a, b), (a * b) // math.gcd(a, b)))
except Exception as _:
    pass

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

Solution code:
# 最大公約数：ユークリッドの互除法
import sys

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

def get_input():
    data = []
    for line in sys.stdin:
        a, b = [int(i) for i in line.split()]
        data.append((a,b))
    return data


data = get_input()

for x,y in data:
    GCD = gcd(x,y)
    LCM = x*y // GCD
    print(GCD, LCM)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
import fileinput

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

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


for line in sys.stdin:
    x, y = map(int, line.split())
    print(gcd(x,y),lcm(x,y))

Submission status: Accepted

Solution code:
import fileinput


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

for line in fileinput.input():
    x, y = [int(s) for s in line.split()]
    #print("{} {}".format(GCD(x, y), int(x * y/GCD(x, y))))#別にformatでなくてもいい
    print(GCD(x, y),int(x * y/GCD(x, y)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import gcd

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

Submission status: Accepted

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

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

import sys
s = sys.stdin.readlines()
n = len(s)
for i in range(n):
    x, y = map(int, s[i].split())
    print(GCD(x, y), LCM(x, y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys;import math;print("\n".join(["{} {}".format(math.gcd(a,b), a // math.gcd(a,b) * b) for x in sys.stdin for a, b in [[int(y) for y in x.split()]] ]))

Submission status: Accepted

Solution code:
import math

while True:
    try:
        a, b = [int(x) for x in input().split()]
        print(math.gcd(a,b), a*b // math.gcd(a,b))
    except EOFError:
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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:
        break

Submission status: Accepted

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:
        break

Submission status: Accepted

Solution code:
def lcm(a,b):
  return a//gcd(a,b)*b
def gcd(a,b):
  while b != 0:
    r=a%b
    a=b
    b=r
  return a
while True:
  try:
    a=list(map(int,input().split()))
    print(gcd(a[0],a[1]),lcm(a[0],a[1]))
  except EOFError:
    break

Submission status: Accepted

Solution code:
def lcm(a, b):
    return a // gcd(a, b) * b
 
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
 
while True:
    try:
        a = list(map(int, input().split()))
        print(gcd(a[0], a[1]), lcm(a[0], a[1]))
    except EOFError:
        break

Submission status: Accepted

Solution code:
# AOJ 0005 GCD and LCM
# Python3 2018.6.9 bal4u
 
def lcm(a, b):
    return a // gcd(a, b) * b
 
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
 
while True:
    try:
        a = list(map(int, input().split()))
        print(gcd(a[0], a[1]), lcm(a[0], a[1]))
    except EOFError:
        break

Submission status: Accepted

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: Accepted

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: Accepted

Solution code:
import fractions
while 1:
    try:
        a,b=map(int,input().split())
        c=fractions.gcd(a,b)
        print(c,(a*b)//c)
    except:break

Submission status: Accepted

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

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

while True:
    try:
        a = list(map(int, input().split()))
        print(gcd(a[0], a[1]), lcm(a[0], a[1]))
    except EOFError:
        break

Submission status: Accepted

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
while True:
    try:
        a,b = map(int,input().split())
        print (gcd(a,b),a *b // gcd(a,b))
    except:
        break

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

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

while True:
    try:
        a = list(map(int, input().split()))
        print(gcd(a[0], a[1]), lcm(a[0], a[1]))
    except EOFError:
        break

Submission status: Accepted

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

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

while True:
    try:
        a,b=map(int,input().split())
    except:
        break
    print(gcd(a,b),lcm(a,b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
  try:
    a,b=map(int,input().split())
    if a<b:
      a,b=b,a
    s=b
    r=a%s
    while True:
      if r==0:
        G=s
        break
      else:
        s,r=r,s%r
    L=int((a*b)/G)
    print(G,L)
  except EOFError:
    break

Submission status: Accepted

Solution code:
import math
import sys
for line in sys.stdin.readlines():
    a, b = list(map(int, line.split()))
    print(f'{math.gcd(a,b)} {a*b//math.gcd(a,b)}')

Submission status: Accepted

Solution code:
import math
import sys
if __name__ == '__main__':

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(a, b):
  if a % b == 0:
    return b
  else:
    return solve(b, a % b)
  
while True:
  try:
    a, b = map(int, input().split())
    lcm = solve(a,b)
    print(lcm, a * b // lcm)

  except:
    break

Submission status: Accepted

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

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

while True:
    try:
        a, b = map(int, input().split())
        print(gcd(a, b), lcm(a, b))
    except EOFError:
        break