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

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

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

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

Solution (Python):
import math

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

Solution (Python):
def gcd(n1,n2):
    if n2==0:
        return n1
    return gcd(n2,n1%n2)

def lcm(n1,n2):
    return n1/gcd(n1,n2)*n2

while True:
    try:
        a,b=[int(i) for i in input().split()]
        print("{} {}".format(int(gcd(a,b)),int(lcm(a,b))))
    except:
        break

Solution (Python):
import sys

while 1:
    line = sys.stdin.readline()
    if (not line):
        break
    x, y = map(int, line.split())
    if (x > y):
        gcd = x
        t = y
    else :
        gcd = y
        t = x
    while (t > 0) :
        tmp = gcd % t
        gcd = t
        t = tmp
    lcm = x * y / gcd
    print str(gcd) + " " + str(lcm)

Solution (Python):
import sys

def gcd(a,b):
  if b == 0: return a
  else: return gcd(b,a%b)
  
for i in sys.stdin:
  a, b = map(int, i.split())
  g = gcd(a,b)
  print g, a/g*b

Solution (Python):
while True:
    try:
        
        a, b = sorted(map(int, input().strip("\n").split(" ")), reverse=True)
        d = a * b

        
        while True:
            c = a % b
            
            if c == 0:
                break
            else:
                a, b = sorted([b, a % b], reverse=True)
        gcm = b
        lcm = d / gcm
        
        print("{0:d} {1:d}".format(int(gcm), int(lcm)))

        
        
        

    except EOFError:
        break

Solution (Python):
def GCD(x, y):
    if(x == 0):
        return(y)
    return(GCD(y % x, x))

def LCM(x, y):
    return(x * y / GCD(x, y))

while(True):
    try:
        a = map(int, raw_input().split())
        if(a[0] > a[1]):
            a[0], a[1] = a[1], a[0]
        print(GCD(a[0], a[1])),
        print(LCM(a[0], a[1]))
    except Exception:
        break

Solution (Python):
while True:
	try:
		[x, y] = map(int, raw_input().split())
		if x < y:
			a = y
			b = x
		else:
			a = x
			b = y
		while a % b:
			c = a % b
			a = b
			b = c
		print "%d %d" % (b, x*y/b)
	except (EOFError):
		break

Solution (Python):
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 "%d" % gcd(a,b),
	print "%d" % lcm(a,b)

Solution (Python):
import sys
for line in sys.stdin:
    a, b = map(int, line.split())
    A, B = min(a, b), max(a, b)

    while True:
        mod = B % A
        if mod == 0:
            gcd = A
            break
        else:
            A, B = mod, A
    lcm = gcd * (a / gcd) * (b / gcd)

    print '%d %d' % (gcd, lcm)

Solution (Python):



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:
  d = map(int, s.split())
  a,b = d[0],d[1]
  print gcd(a,b),lcm(a,b)

Solution (Python):
def gcd(n, m):
    while n!=0:
        tmp = n
        n = m % n
        m = tmp
    return m

while 1:
    try:
        n, m = map(int, input().split())
        x = gcd(n, m)
        print(x, int(n*m/x))
    except EOFError:
        break

Solution (Python):
def gcd(n, m):
    while n:
        n, m = m % n, n
    return m

while 1:
    try:
        n, m = map(int, input().split())
        g = gcd(n, m)
        print(g, int(n*m/g))
    except EOFError:
        break

Solution (Python):
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)

Solution (Python):
while 1:
    try:
        a, b = map(int, raw_input().split())
        if a > b: x, y = a, b
        else: x, y = b, a

        r = x % y
        while (r != 0):
            x = y
            y = r
            r = x % y
        gcd = y

        lcm = (a / gcd) * b

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

    except:
        break

Solution (Python):
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;

Solution (Python):
import sys


def gcd(n, m):
    while m:
        n, m = m, n % m
    return n


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

for line in sys.stdin:
    l = line.replace('\n', '')
    a, b = l.split()
    a = int(a)
    b = int(b)
    print(gcd(a, b), lcm(a, b))

Solution (Python):
while True:
    try:
        a,b=map(int,input().split())
        y=a*b
        if b>a:
            a,b=b,a
        
        while a%b:
            x=a
            a,b=b,x%b

        print(b,int(y/b))

    except:
        break

Solution (Python):
import sys


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


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

def main():
    
    for line in iter(sys.stdin.readline, ""):
        
        
        
        tmp = line.split(" ")
    
        a = int(tmp[0])
        b = int(tmp[1])
        
        
        
        
        if a > b:
            c = a
            d = b
        else:
            c = b
            d = a

        print (str(gcd(c, d)) + " " + str(int(lcm(c,d))))

        
        
        
        
        

    
     
if __name__ == "__main__":
    main()

Solution (Python):
import sys


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


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

def main():
    
    for line in iter(sys.stdin.readline, ""):
        
        
        
        tmp = line.split(" ")
    
        a = int(tmp[0])
        b = int(tmp[1])
        
        
        
        
        if a > b:
            c = a
            d = b
        else:
            c = b
            d = a

        print (str(gcd(c, d)) + " " + str(int(lcm(c,d))))

        
        
        
        
        

    
     
if __name__ == "__main__":
    main()

Solution (Python):
while(1):
    try:
        i = raw_input()
        a, b = map(int, i.split())
        x, y = a, b
        while(b != 0):
            tmp = b
            b = a % b
            a = tmp
        print a,
        print x*y/a
    except:
        break

Solution (Python):

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 s in sys.stdin:
    a,b = map(int,s.split())
    a,b = max(a,b),min(a,b)
    print gcd(a,b),lcm(a,b)

Solution (Python):

import sys
import fractions

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

for s in sys.stdin:
    a,b = map(int,s.split())
    gcd_ab = fractions.gcd(a,b)
    lcm_ab = lcm(a,b)

    print gcd_ab,lcm_ab

Solution (Python):
import sys

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

for line in sys.stdin:
    a, b = sorted(list(map(int, line.split())))
    print(gcd(a, b), lcm(a, b))

Solution (Python):

import sys
from fractions import gcd

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

Solution (Python):
def gcd(m,n):  
    while m%n>0:
        m,n=n,m%n
    else:
        return n

while True:
    try:    
        a,b = map(int,raw_input().split())
        a,b = max(a,b),min(a,b)
        g = gcd(a,b)
        l = a*b/g
        print "%d %d" % (g, l)
    except EOFError: 
        break

Solution (Python):


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

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

Solution (Python):

import fractions
while True:
    try:
        a, b=map(int, input().split())
        s=fractions.gcd(a,b)
        print("{0} {1:.0f}".format(s,a*b/s))
    except:
        break

Solution (Python):
import sys
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.readlines():
    num = map(int, line.strip().split())
    print "%i %i"%(gcd(num[0],num[1]) , lcm(num[0],num[1]))

Solution (Python):
while True:
	try:
		temp = [int(x) for x in raw_input().split()]
		m = max(temp)
		n = min(temp)

		while True:
			if n == 0:
				print m, (temp[0]*temp[1])/m
				break
			else:
				temp2 = n
				n = m % n
				m = temp2

	except:
		break

Solution (Python):
def GCD(a,b):
    if b == 0:
        return a
    else:
        r = a % b
        return GCD(b, r)
        
while True:
    try:
        data = map(int, raw_input().split())
    except:
        break
    if data[0] > data[1]:
        a = data[0]
        b = data[1]
    else:
        a = data[1]
        b = data[0]
    x = GCD(a, b)
    y = a*b / x
    
    print x, y

Solution (Python):
def gcd(a,b):
	while a>0 and b>0:
		if a<b:
			b -= a
		elif a>b:
			a -= b
		else:
			return a
	raise

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


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

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

Solution (Python):
import sys

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

for ab in sys.stdin:
    a,b=map(int,ab.split(" "))
    if a<=b:
        tmp = a
        a = b
        b = tmp
    g = gcd(a,b)
    l = a*b/g
    print g,l

Solution (Python):
while True:
    try:
        spam=map(int, input().split(' '))
        spam = [i for i in spam]
        spam.sort()
        cola = spam[0] * spam[1]
        while True:
            if spam[0] == 0:
                print('{} {}'.format(spam[1],int(cola/spam[1])))
                break
            pre = spam[0]
            spam[0] = spam[1] % spam[0]
            spam[1] = pre
    except:
        break

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

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

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

Solution (Python):


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 n in sys.stdin:
    a, b = map(int, n.split())
    a, b = max(a, b), min(a,b)
    print gcd(a, b), lcm(a, b)

Solution (Python):


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

Solution (Python):
import sys
for n in sys.stdin:
	l=map(int,n.split())
	b=l[0]*l[1]
	u=[max(l),min(l)]
	while u[1]!=0:
		u=[u[1],u[0]%u[1]]
	print "%d %d"%(u[0],b/u[0])

Solution (Python):
import sys
for n in sys.stdin:
	u=map(int,n.split())
	b=u[0]*u[1]
	while u[1]!=0:u=[u[1],u[0]%u[1]]
	print "%d %d"%(u[0],b/u[0])

Solution (Python):
import sys
for n in sys.stdin:
	u=map(int,n.split())
	b=u[0]*u[1]
	while u[1]!=0:u=[u[1],u[0]%u[1]]
	print"%d %d"%(u[0],b/u[0])

Solution (Python):
import sys
for n in sys.stdin:
	u=map(int,n.split())
	b=u[0]*u[1]
	while u[1]!=0:u=[u[1],u[0]%u[1]]
	print"%d %d"%(u[0],b/u[0])

Solution (Python):


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

	
	r=a%b
	x,y=a,b
	while(r>0):
		x=y
		y=r
		r=x%y
	gcd=y
	lcm=int(a*b/gcd)
	print("{0} {1}".format(gcd, lcm))

Solution (Python):
import sys

def dividend(num, Q):
    a = Q
    b = (num / Q) * Q
    Q = num - (num / Q) * Q
    if num  == b:
        aaa(a)
        return
    dividend(a, Q)
    
def aaa(greatest_common_divisor):
    least_common_multiple = num1 * num2 / greatest_common_divisor
    print('%s %s' % (greatest_common_divisor, least_common_multiple))
    return

for input_line in sys.stdin:
    num1 = int(input_line.split(' ')[0])
    num2 = int(input_line.split(' ')[1])
    
    if num1 <= num2:
        dividend(num2, num1)
    elif num1 > num2:
        dividend(num1, num2)

Solution (Python):
def GCD_cal(a,b):
	if(b==0):
		return(a)
	a,b=b,a%b
	return(GCD_cal(a,b))

while(True):
	try:
		a,b=map(int,input().split(" "))
	except:
		break
	if(a<b):
		a,b=b,a
	GCD=GCD_cal(a,b)
	LCM=int(a*b/GCD)
	print("{0} {1}".format(GCD,LCM))

Solution (Python):
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

Solution (Python):





while True:
    try:
        a,b = map(int,raw_input().split(' '))
        s,t = a,b
        while True:
            r = s % t
            if not r:
                LCM = t
                break
            else:
                s,t = t,r
        
        print LCM, a*b/LCM
    except:
        break

Solution (Python):

def gcd(a, b):
    """Return greatest common divisor using Euclid's Algorithm."""
    while b:      
        a, b = b, a % b
    return a

def lcm(a, b):
    """Return lowest common multiple."""
    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

Solution (Python):
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)

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

Solution (Python):
import sys

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

Solution (Python):


def gcd(a,b):
    big,small=max(a,b),min(a,b)
    while big%small!=0:
        big,small=small,big%small
    return small

def lcm(a,b):
    return int(a*b/gcd(a,b))
 
def main():
    while True:
        try:
            IN=input()
            val=IN.split()
            g=gcd(int(val[0]),int(val[1]))
            l=lcm(int(val[0]),int(val[1]))

            print(g,l)
        except:
            break
if __name__ == '__main__':
    main()

Solution (Python):
import sys

while True:
    try:
	a,b = map(int,raw_input().split())
	tempa = a
	tempb = b
	while tempa % tempb != 0 :
	    tempa , tempb = (tempb,tempa%tempb)
	gcd = tempb
	lcm = a * b / gcd
	print "%d %d" % ( gcd, lcm)
	

    except EOFError:
	break

Solution (Python):
import sys
for line in sys.stdin:
    a, b = map(int, line.split())
    c = a * b
    while b:
        a, b = b, a % b
    print(str(a) + ' ' + str(c / a))

Solution (Python):
import sys
def kouyakusuu(a,b):
  A = max(a,b)
  B = min(a,b)
  d = A % B
  if d == 0:
    return B
  else:
    return kouyakusuu(B,d)
for line in sys.stdin.readlines():
  a,b = map(int,line.split())
  m = kouyakusuu(a,b)
  n = a*b//m
  print(m,n)

Solution (Python):
def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a%b)
while True:
	try:
		a, b = map(int, raw_input().strip().split(' '))
		print "%d %d" % (gcd(a, b), a*b/gcd(a, b))
	except EOFError:
		break

Solution (Python):
import sys
def gcd(a,b):
    if a==b:
        return a
    while(b>0):
        a,b = b,a%b
        if b==0:
            return a
def lcm(a,b):
    n=1
    m=1
    while(n*a!=m*b):
        if n*a>m*b:
            m+=1
        elif n*a<m*b:
            n+=1
    return n*a
lines = sys.stdin.readlines()
for line in lines:
    line = line.split(" ")
    inp = []
    for i in line:
        inp.append(int(i))
    inp.sort()
    a = inp[0]
    b = inp[1]
    print("%d %d" % (gcd(a,b),lcm(a,b)))

Solution (Python):

import sys

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

for l in sys.stdin:
  x, y = map(int, l.split())
  g = gcd(x, y)
  l = x * y / g
  print g, l

Solution (Python):
import sys
list = sys.stdin.readlines()

e=0
GCD = 0
def Euclide(a, b):
    if b == 0:
        return a
    if a < b:
        tmp = a
        a = b
        b = tmp
    e = a%b
    return Euclide(b, e)

for i in list:
    i = i.split(' ')
    GCD = Euclide(int(i[0]), int(i[1]))
    print(str(GCD)+" "+str(int(int(i[0])/GCD*int(i[1]))))

Solution (Python):
import sys
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b,gcdnum=0):
    if gcdnum==0:
        return a * b // gcd (a, b)
    else:
        return a * b // gcdnum

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

Solution (Python):
import sys

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

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

Solution (Python):
import sys
def gcd(a,b):
    if b== 0:return a
    return gcd(b,a%b)
def return_lcm(a,b):
    prime = gcd(a,b)
    return prime*(a/prime)*(b/prime)
def solve():
    a = []
    for line in sys.stdin:
        digit_list = line.split(' ')
        new_list = []
        for j in digit_list:
            new_list.append(int(j))
        a.append(new_list)
    for data in a:
        print str(gcd(data[0],data[1])) + ' ' + str(return_lcm(data[0],data[1]))

if __name__ == "__main__":
    solve()

Solution (Python):
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, raw_input().split())
  except EOFError:
    break
  print "%d %d" % (gcd(a, b), lcm(a, b))

Solution (Python):



import sys

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:
    a, b = map(int, line.split())
    print( str(gcd(a,b))+" "+str(lcm(a,b)) )

Solution (Python):
import sys

ary=[]
ans=[]
def gcd(a,b):
    x=sorted([a,b])
    while x[1]%x[0]!=0:
        dif=x[1]%x[0]
        x[1]=x[0]
        x[0]=dif
    return x[0]
for i in sys.stdin:
    ary.append(list(map(int,i.split())))
    ans.append([gcd(*ary[-1]),int(ary[-1][0]*ary[-1][1]/gcd(*ary[-1]))])
for i in range(len(ans)):
    print('{0:d} {1:d}'.format(*ans[i]))

Solution (Python):
while True:
    try:
        [x, y] = map(int, raw_input().split())
        if x < y:
            a = y
            b = x
        else:
            a = x
            b = y
        while a % b:
            c = a % b
            a = b
            b = c
        print "%d %d" % (b, x*y/b)
    except (EOFError):
        break

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

try:
    while 1:
        a,b = list(map(int,input().split()))
        c = gcd(a, b)
        print('{} {}'.format(c,int(c * (a/c) * (b/c))))

except Exception:
    pass

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

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


while True:
	try:
		x,y=map(int,input().split())
		print(gcd(x,y),lcm(x,y))

	except EOFError:
		break

Solution (Python):
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))

Solution (Python):
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

Solution (Python):


while True:
    try:
        a, b = map(int, raw_input(). split())
        x = a * b
        while True:
            c = a % b
            a = b
            b = c
            if b == 0:
                break
        x = x / a
        print("%d %d" % (a, x))
    except:
        break

Solution (Python):


import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    t1, t2 = a, b
    while True:
        if a%b:
            a, b = b, a%b
        else:
            break
    gcd = b
    lcm = t1/gcd*t2
    print "%d %d" %(gcd, lcm)

Solution (Python):
import sys

def gcd(inta, intb):
    large = max(inta, intb)
    small = min(inta,intb)
    mod = large % small
    if mod ==0:
        return small
    else:
        return gcd(small, mod) 
    
def lcm(inta, intb, intgcd):
    return (inta * intb // intgcd)

sets = sys.stdin.readlines()
for line in sets:
    a, b = map(int, line.split())
    c = gcd(a, b)
    print(c, lcm(a, b, c))

Solution (Python):
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
def lcm(a,b,g):
    return a*b/g

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

Solution (Python):
import sys
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a,b):
	return a*b//gcd(a,b)
	
sets = sys.stdin.readlines()
for line in sets:
    a, b = map(int, line.split())
    print(gcd(a,b), lcm(a, b))

Solution (Python):
def get_input():
    while True:
        try:
            yield "".join(input())
        
        except EOFError:
            break
            
def calcGCD(a,b):
    if a>b:
        large = a
        small = b
    elif a<b:
        large = b
        small = a
    else:
        return a
        
    
    while True:
        
        if large == small:
            return large
        
        temp_small = large - small
        
        if temp_small < small:
            large = small
            small = temp_small 
        else:
            large = temp_small
            small = small

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


if __name__  == "__main__":
    array = list(get_input())
    for i in range(len(array)):
    
        temp_a,temp_b = array[i].split()
    
        a,b = int(temp_a),int(temp_b)
    
        gcd = calcGCD(a,b)
        lcm = calcLCM(a,b,gcd)
        lcm = int(lcm)
        
        print("{} {}".format(gcd,lcm))

Solution (Python):


def main():
	while True:		
		try:
			a, b = [int(x) for x in input().split(" ")]
		except:
			return
		else:
			print(gcd(a, b),lcm(a, b))
def lcm(a, b):
	return (a * b) // gcd(a,b)
def gcd(a, b):
	while b != 0:
		a, b = b, a % b
	return a	
			
if __name__ == '__main__':
  main()

Solution (Python):
import sys
dataset = sys.stdin.readlines()


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

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

for item in dataset:
    a, b = list(map(int, item.split()))
    print(gcd(a, b), lcd(a,b))

Solution (Python):
import sys

def gcd(a, b):
    while b:
        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())
    print "%d %d"%(gcd(a, b), lcm(a, b))

Solution (Python):
import sys
def gcd(a,b):
    if a<b:
        t = a
        a = b
        b = t
    while b != 0:
        temp = b
        b = a%b
        a = temp
    return a

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

Solution (Python):
ans=[]
while True:
	try:
		k,l=list(map(int,input().split(" ")))
		init_k=k
		init_l=l

		while True:
			if k%l==0:
				gcd=l
				tmp_1=init_k/gcd
				tmp_2=init_l/gcd
				lcm=gcd*tmp_1*tmp_2
				break
			else:
				tmp=k%l
				k=l
				l=tmp
		gcd=int(gcd)
		lcm=int(lcm)
		ans.append(str(gcd)+" "+str(lcm))
	except:
		break

for i in ans:
	print(i)

Solution (Python):
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

Solution (Python):
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(int(gcd(a, b)), int(lcm(a, b)))
	except EOFError:
		break

Solution (Python):
def gcd(a, b):
    return gcd(b, a%b) if b else a
    
while True:
    try:
        a, b = map(int, raw_input().split())
        ans = gcd(a, b)
        print ans, a*b//ans
    except EOFError:
        break

Solution (Python):
def gcd(a,b):
    while b != 0:
        a , b = b , a % b
    return a
def lcm(a,b):
    return int(abs(a*b) / gcd(a,b))

while True:
    try:
        a, b = [int(x) for x in input().split()]
    except:
        exit()
    print(gcd(a,b),lcm(a,b))

Solution (Python):
def GcdLcm(a, b):
	p = a * b
	if a < b:
		a, b = b, a
	r = a % b
	while r != 0:
		a = b
		b = r
		r = a % b
	return [b, int(p / b)]

while True:
	try:
		a, b = [eval(item) for item in input().split()]
		g, l = GcdLcm(a, b)
		print(str(g), str(l))
	except EOFError:
		break

Solution (Python):
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())
        d = gcd(max(a, b), min(a, b))
        print(d, a * b // d)
    except:
        break

Solution (Python):
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)


def main():
    for i in sys.stdin.readlines():
        a, b = [int(x) for x in i.split()]
        print(gcd(a, b), lcm(a, b))


if __name__ == '__main__':
    main()

Solution (Python):
import sys

for s in sys.stdin:
    a = list(map(int, s.split()))
    b = a[0]
    c = a[1]

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

    d = a[0] * a[1] / b
    print(int(b), int(d))

Solution (Python):
import sys

def get_gcd(a, b):
    if a < b:
        a, b = b, a

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

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

def main():
    while True:
        data = sys.stdin.readline().strip()
        if data is None or data == '':
            break

        nums = data.split(' ')
        a = int(nums[0])
        b = int(nums[1])
        gcd = get_gcd(a, b)
        lcm = get_lcm(a, b, gcd)
        print(gcd, lcm)
        
        
if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math

a = []
for line in sys.stdin:
    a.append(line)

for n in a:
    inl=n.split()
    num1=int(inl[0])
    check=1
    list=[]
    while check<=math.sqrt(num1):
        if num1%check==0:
            list.append(check)
            list.append(num1/check)
        check+=1
    list.sort()
    list.reverse()
    num2=int(inl[1])
    for i in list:
        if num2%i==0:
            gud=i
            break
    lcm=num1*num2/gud
    print gud,lcm

Solution (Python):
import sys

temp = []
largest = 1

for line in sys.stdin:
    a,b = [int(x) for x in line.split()]
    if a > b:
        x,y = a,b
    else:
        x,y = b,a
    while y:
        x,y = y,x%y
    smallest = x * (a/x) * (b/x)
    print('%d %d' % (x, smallest))

Solution (Python):
def gcd(x, y):
  if x < y:
    tmp = x
    x = y
    y = tmp
  while True:
    if y == 0:
      break
    x = x % y
    tmp = x
    x = y
    y = tmp

  return x

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

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

Solution (Python):
while True:
    try:
        a,b = map(int, raw_input().split())
        x,y = (a,b) if a > b else (b,a)
        
        while x%y:
            m = x % y
            x,y = y,m

        print "%d %d" % (y, a*b/y)
    except (EOFError):
        break

Solution (Python):
import sys
for l in sys.stdin:
  a,b = map(int, l.split())
  x,y = (a,b) if a > b else (b,a)
  while x%y:
    m = x % y
    x,y = y,m
  print "%d %d" % (y, a*b/y)

Solution (Python):
import sys
for l in sys.stdin:
 x,y=map(int, l.split())
 m=x*y
 while x%y:x,y=y,x%y
 print "%d %d"%(y,m/y)

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

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

Solution (Python):
import sys

def gcd(a, b):
    "?????§??¬?´???°????±???????"
    if a < b:
        c = a
        a = b
        b = c
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

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

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

Solution (Python):
import sys
dataset = sys.stdin.readlines()
 
 
def gcd(a, b):
    if b > a: return gcd(b, a)
    if a % b == 0: return b
    return gcd(b, a % b)
 
def lcd(a, b):
    return a * b // gcd(a, b)
 
for item in dataset:
    a, b = list(map(int, item.split()))
    print(gcd(a, b), lcd(a,b))

Solution (Python):
def GCD(a, b):
	if b > a:
		return GCD(b, a)
	elif a % b == 0:
		return b
	return GCD(b, a % b)
		
def LCM(a, b):
	return a * b // GCD(a, b)

import sys
L = sys.stdin.readlines()
for line in L:
	x, y = list(map(int, line.split()))
	print(GCD(x, y), LCM(x, y))

Solution (Python):


import sys

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

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

def main():
    for line in sys.stdin:
        a, b = map(int, line.split())
        ng = gcd(a, b)
        nl = lcm(a, b, ng)
        print('{0:d} {1:d}'.format(int(ng), int(nl)))

if __name__ == '__main__':
    main()

Solution (Python):
import sys

for line in sys.stdin:
    n = [int(i) for i in line.replace("\n", "").split(" ")]
    n.sort()
    low = n[0]
    hi = n[1]
    while hi % low:
        hi, low = low, hi % low
    print("%d %d" % (low, n[0] / low * n[1]))

Solution (Python):
def gcd(li):
    a=max(li)
    b=min(li)
    while b>0:
        a,b=b,a%b
    return a

def lcm(li):
    return li[0]*li[1]/gcd(li)

while True:
    try:
        li=[int(i) for i in input().split(" ")]
        print("%i %i"%(gcd(li),lcm(li)))
    except:break

Solution (Python):
def gcd(a, b):
    if a == 0 or b == 0:
        return 0
    while b != 0:
        a, b = b, a%b
    return a

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

Solution (Python):
import sys
for line in sys.stdin:
    a,b = list(map(int,line.split()))
    ab = a*b
    while b: a,b = b,a%b
    print(a,ab//a)

Solution (Python):
import sys
from fractions import gcd
for line in sys.stdin:
    a, b = map(int, line.split())
    print gcd(a, b), a*b/gcd(a,b)

Solution (Python):
import sys
from fractions import gcd
[print("{} {}".format(gcd(*x), x[0] * x[1] // gcd(*x))) for x in [list(map(int, x.split())) for x in sys.stdin]]

Solution (Python):
import sys, fractions
[[print("{} {}".format(int(fractions.gcd(t[0], t[1])), int(t[0] * t[1] / fractions.gcd(t[0], t[1])))) for t in [[int(y) for y in x.split()]]] for x in sys.stdin]

Solution (Python):

import sys
from fractions import gcd
[print("{} {}".format(gcd(k[0], k[1]), (k[0] * k[1]) // gcd(k[0], k[1]))) for i in sys.stdin for k in [[int(j) for j in i.split()]]]