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(a, b):
    for i in range(1, a+1):
        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: Accepted

Solution code:
import sys
a=[map(int,i.split())for i in sys.stdin]
for i,j in a:
	c,d=i,j
	while d:
		if c > d:c,d = d,c
		d%=c
	print(c,i//c*j)

Submission status: Accepted

Solution code:
import sys
a=[map(int,i.split())for i in sys.stdin]
for i,j in a:
	c,d=i,j
	while d:
		if c>d:c,d=d,c
		d%=c
	print(c,i//c*j)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

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

def main():
    for line in sys.stdin:
        a, b = map(int, line.split())
        d = gcd(a, b)
        m = a * b // d
        print("{} {}".format(d, m))

if __name__ == "__main__": main()

Submission status: Accepted

Solution code:
import sys
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: Accepted

Solution code:
def main():
	import sys

	for line in sys.stdin:
		a, b = map(int, line.split())
		c = a*b

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

		print(b, c//b)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Aizu - 0005
def De(a):
    res = []
    tmp = 2
    while a != 1:
        while not (a % tmp):
            a = round(a / tmp)
            res.append(tmp)
        tmp += 1
    return res

while True:
    try:
        tmp = input()
        a = [int(i) for i in tmp.split(' ')]
    except:
        break
    b = De(a[1])
    a = De(a[0])
    pa, pb = 0, 0
    GCD, LCM = 1, 1
    while True:
        if pa == len(a):
            for i in range(pb, len(b)):
                LCM *= b[i]
            break;
        if pb == len(b):
            for i in range(pa, len(a)):
                LCM *= a[i]
            break;
        if a[pa] == b[pb]:
            GCD *= a[pa]
            LCM *= a[pa]
            pa += 1
            pb += 1
            continue
        if a[pa] < b[pb]:
            LCM *= a[pa]
            pa += 1
            continue
        if a[pa] > b[pb]:
            LCM *= b[pb]
            pb += 1
            continue
    print('%d %d'%(GCD, LCM))

Submission status: Accepted

Solution code:
import sys

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

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

Solution code:
import sys;

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

for line in sys.stdin:
	[a, b] = [int(num) for num in line.split()];
	print(str(gcd(a, b)) + ' ' + str(lcm(a, b)));

Submission status: Accepted

Solution code:
import fileinput

for line in fileinput.input():
    tokens = list(map(int, line.strip().split()))
    a, b = tokens[0], tokens[1]
    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: Accepted

Solution code:
while 1:
    try:
        x,y=[int(i) for i in input().split()]
        a=x
        b=y

        while 1:
            c=x%y
            if x%y==0:
                print(y,a*b//y)
                break
            else:
                x=y
                y=c
    except EOFError:
        break

Submission status: Accepted

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

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

Submission status: Accepted

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(min(line), max(line))
        print(str(g) + " " + str(line[0]*line[1]//g))  # + str(lcm(line[0], line[1]))
    except:
        exit()

Submission status: Accepted

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


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


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

Submission status: Accepted

Solution code:
import sys

def main():
    """ ????????? """
    MAX = 2000000000
    istr = sys.stdin.read()
    wi = istr.splitlines()
    for i in wi:
        a, b = list(map(int,i.split()))
        if a < b:
            a, b = b, a

        """ ????????????????????????????????§?????§??¬?´???°????????? """
        x = a
        y = b
        while y > 0:
            z = x % y
            x = y
            y = z

        """ a ??¨ b ????????? a ??¨ b ???????°???¬?´???°??§?????? """
        l = a * b // x

        print("{} {}".format(x,l))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
  
def gcd(m,n):
    return m if n==0 else gcd(n, m%n)

for m,n in [map(int,x.split()) for x in list(sys.stdin)]:
    g = gcd(m,n)
    print(g,(m//g)*n)

Submission status: Accepted

Solution code:
import sys
  
def gcd(m,n):
    return m if n==0 else gcd(n, m%n)

for m,n in [map(int,x.split()) for x in list(sys.stdin)]:
    g = gcd(m,n)
    print(g,m//g*n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def calc(i1, i2):

    a = i1
    b = i2
    if (i1 < i2):
        a = i2
        b = i1
    
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    gcd = b
    lcm = (i1 * i2) / gcd

    return gcd, lcm


for line in sys.stdin:
    datas =line.split()
    if (len(datas)):

        li = list(map(int, datas)) 
        a = li[0]
        b = li[1]

        x, y = calc(a, b)

        print("%d %d" % (x, y))

    else:
        break

Submission status: Accepted

Solution code:
import fractions

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 = [fractions.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: Accepted

Solution code:
import sys
def main():
    for line in sys.stdin:
        a,b = map(int, line.split())
        if a > b:
            a,b = b,a
        p = a * b #product

        while True:
            hoge = a
            a = b % a
            b = hoge
            if a == 0:
                gcd = b
                break

        lcm = p // gcd
        print(gcd, lcm)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# Aizu Problem 0006: GCD and LCM
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


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


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


for line in sys.stdin:
    a, b = [int(_) for _ in line.split()]
    print(gcd(a, b), lcm(a, b))

Submission status: Accepted

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

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


while True:
    try:
        nums = list(map(int, input().split()))
        print(gcd(nums[0], nums[1]), lcd(nums[0], nums[1]))

    except EOFError:
        break

Submission status: Accepted

Solution code:
import fileinput as fi
def gcd_euler(a,b):
    if b == 0: return a
    u = a
    v = b
    r = u % v
    while True:
        if r == 0:return v
        u = v
        v = r
        r = u % v



if __name__ == "__main__":
    for line in fi.input():
        a,b = list(map(int,line.strip().split()))
        if a > b:gcd=gcd_euler(a,b)
        else:gcd=gcd_euler(b,a)
        print(gcd,int((a*b)/gcd))

Submission status: Accepted

Solution code:
try:
    while True:
        x=list(sorted(map(int, input().split())))
        a=x[0]
        b=x[1]
        while b%a != 0:
            c=a
            a=b%a
            b=c
        print(a, x[0]*x[1]//a)
except EOFError:
    pass

Submission status: Accepted

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


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


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

    print "%d %d" % (gcd(x, y), lcm(x, y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x%y)

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

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

Submission status: Accepted

Solution code:
import math
import sys

while True:
	try:
		a,b = map(int, input().split())
		p = a
		q = b
		while True:
			r = p%q
			if r == 0:
				x = q
				break
			else:
				p = q
				q = r
		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: Accepted

Solution code:
import sys
for line in sys.stdin:
    a,b = map(int, line.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: Accepted

Solution code:
#!/usr/bin/python
# coding: utf-8

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

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

Submission status: Accepted

Solution code:
import sys

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

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

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

Submission status: Accepted

Solution code:
t = 0
while t == 0:	
	try:
		x,y=[int(i) for i in input().split()]
	except:
		break
	else:
		a = x * y
		if x < y:
			x,y =y,x
		while y > 0:
			r = x % y
			x = y
			y = r
	print(str(x) + " " + str(int(a / x)))

Submission status: Accepted

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


d = []
m = []
while True:
    try:
        a, b = map(int, input().split())
        if a > b:
            num = gcd(a, b)
        elif a < b:
            num = gcd(b, a)
        else:
            num = a
        d.append(num)
        m.append(int(a*b/num))
    except EOFError:
        break

for i in range(len(d)):
    print(d[i], m[i])

Submission status: Accepted

Solution code:
import sys
import fractions

def main():

    dataset = sys.stdin.readlines()
    for data in dataset:
        a, b = map(int, data.split())
        gcd_num = fractions.gcd(a, b)
        print('%d %d' % (gcd_num, a * b / gcd_num))
        
    
main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
#from me.io import dup_file_stdin

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

#@dup_file_stdin
def solve():
    for line in sys.stdin:
        x,y = map(int,line.split(" "))
        f = gcd(x,y)
        print("{} {}".format(f, x//f*y))
 
solve()

Submission status: Accepted

Solution code:
# coding=utf-8


def solve_gcd(number1: int, number2: int) -> int:
    two_list = [number1, number2]
    two_list.sort()
    if two_list[1] % two_list[0] == 0:
        return two_list[0]
    r = two_list[1] % two_list[0]
    return solve_gcd(two_list[0], r)


def solve_lcm(number1: int, number2: int, number3: int) -> int:
    return number1*number2//number3


if __name__ == '__main__':
    while True:
        try:
            a, b = map(int, input().split())
        except EOFError:
            break
        gcd = solve_gcd(a, b)
        lcm = solve_lcm(a, b, gcd)
        print(gcd, lcm)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

while True:
	try:
		data = map(int, raw_input().split())
		if data[0] > data[1]:
			a = data[0]
			b = data[1]
		else:
			a = data[1]
			b = data[0]
		
		r = 1
		while r > 0:
			q = a / b
			r = a - b * q
			a = b
			b = r
		gcd = a
		lcm = data[0] * data[1] / gcd

		print("{:} {:}".format(gcd, lcm))

	except EOFError:
		break

Submission status: Accepted

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

Solution code:
def GCD(m, n):
    while n:
        m, n = n, m % n
    return m

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

Submission status: Accepted

Solution code:
import sys

for i in sys.stdin:
    a,b=list(map(int, i.split()))
    d=a*b
    if a>b:
        temp=a
        a=b
        b=temp
    c=a%b
    while c!=0:
        a=b
        b=c
        c=a%b
    g=b
    l=int(d/g)
    print("{} {}".format(g,l))

Submission status: Accepted

Solution code:
def GCD(a,b):
    while (a % b) != 0:
        a,b = b, 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 GCD(a,b),LCM(a,b)
    except:
        break

Submission status: Accepted

Solution code:
import sys
for i in sys.stdin:
    a,b=map(int,i.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: Accepted

Solution code:
def main():
    while True:
        try:
            a,b = map(int,input().split())
            c = a*b
            if a < b:
                a,b = b,a
            while a%b != 0:
                a,b = b,a%b
            print(b,c//b)
        except EOFError:
            exit()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def gcd(a,b):
    if a > b:
        x = a
        y = b
    else:
        x = b
        y = a
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def lcm(a,b,c):
    return int(a*b/c)

while 1:
    try:
        a,b = [int(x) for x in input().split()]
        res_gcd = gcd(a,b)
        res_lcm = lcm(a,b,res_gcd)
        print('{} {}'.format(res_gcd,res_lcm))
    except:
        break

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

Solution code:
import sys


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


for line in sys.stdin:
  try:
    a, b = [int(i) for i in line.split()]
    g = gcd(a, b)
    l = a * b / g
    print("%d %d" % (g, l))
  except:
    break

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

Submission status: Accepted

Solution code:
import sys

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

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

a = ""
for input in sys.stdin:
    a += input
l = a.split()
for i in range(0,len(l),2):
    if(int(l[i]) > int(l[i+1])):
        print gcd(int(l[i]),int(l[i+1])),lcm(int(l[i]),int(l[i+1]))
    else:
        print gcd(int(l[i+1]),int(l[i])),lcm(int(l[i+1]),int(l[i]))

Submission status: Accepted

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

    def gcd(self):
        if self.a < self.b:
            self.a, self.b = self.b, self.a
        while self.b:
            self.a, self.b= self.b, self.a % self.b

        return self.a

    def print(self):
        lcm = self.a * self.b // self.gcd()
        print(self.gcd(), lcm)

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

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:
    try:
        s = input()
        a,b = [int(i) for i in s.split(' ')]
    except:
        break
    print(gcd(a, b), lcm(a, b))

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    a,b = [int(i) for i in N[l].split()]
    A = a
    B = b
    if(a<b):
        c = a
        a = b
        b = c

    while b > 0:
        nexta = b
        nextb = a % b
        a = nexta
        b = nextb

    g = a
    print(g, int(A*B/g))

Submission status: Accepted

Solution code:
import math,sys
for e in sys.stdin:
 a,b=list(map(int,e.split()));g=math.gcd(a,b)
 print(g,a*b//g)

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 g,d=a,b=list(map(int,e.split()))
 while d:g,d=d,g%d
 print(g,a*b//g)

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 a,b=list(map(int,e.split()));p=a*b
 while b:a,b=b,a%b
 print(a,p//a)

Submission status: Accepted

Solution code:
import sys 
for e in sys.stdin:
    a, b = map(int, e.split())
    p = a * b
    while b:
        a, b = b, a%b
        pass
    print (a,p//a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    try:
        a, b = map(int, input().split(" "))
        if a < b:
            key = a
            a = b
            b = key
        A = a
        B = b
        while a % b != 0:
            key = a % b
            a = b
            b = key
        key = int(A * B / b)
        print(b, key)
    except:
        break

Submission status: Accepted

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)


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# 最大公約数(greatest common divisor)を求める関数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# 最小公倍数(least common multiple)を求める関数
# //は切り捨て除算
def lcm(a, b):
    return a * b // gcd(a, b)

lines = sys.stdin.readlines()
for line in lines:
    a = list(map(int, line.split(" ")))
    print(gcd(a[0], a[1]), lcm(a[0], a[1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    try:
        r = sorted(list(map(int, input().split())))
        
        
        def euclidfunc(a, b):
            while b != 0:
                a, b = b, a % b
            return a
        
        
        def lcmfunc(a, b):
            return a * b // euclidfunc(a, b)
        
        
        print("{a} {b}".format(a=euclidfunc(r[1], r[0]), b=lcmfunc(r[1], r[0])))
    except EOFError:
        break

Submission status: Accepted

Solution code:
while 1:
    try:
        a = list(map(int, input().split()))
        b=list(a)
        a.sort()
        while a[1]%a[0] != 0:
            a[1] %= a[0]
            a.sort()
        print(a[0], int(b[0]*b[1]/a[0]))
    except:
        break

Submission status: Accepted

Solution code:
import math
while 1:
    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 sys
for i in sys.stdin:
    a, b = map(int, i.split())
    p, q = max(a, b), min(a, b)
    while True:
        if p % q == 0:
            break
        else:
            p, q = q, p % q
    print("{} {}".format(q, int(a * b / q)))

Submission status: Accepted

Solution code:
import sys
for i in sys.stdin:
    a, b = map(int, i.split())
    p, q = max(a, b), min(a, b)
    while p % q != 0:
        p, q = q, p % q
    print("{} {}".format(q, int(a * b / q)))

Submission status: Accepted

Solution code:
def F(x, y):
    if x % y == 0:
        return y
    return F(y, x % y)
while True:
    try:
        x, y = map(int,input().split())
        print('{0} {1}'.format(F(x, y), int(x * y / F(x, y))))
    except EOFError:
        break

Submission status: Accepted

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

def lcm(a,b):
	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:
import math
while True:
    try:
        a, b = map(int, input().split())
        gcd = math.gcd(a, b)
        lcm = (a * b) // gcd
        print(gcd, lcm)
    except Exception:
        break

Submission status: Accepted

Solution code:
import math

while True:
    try:
        a, b = [int(i) for i in input().split()]

        gcd = math.gcd(a, b)
        lcm = a * b // gcd

        print(f'{gcd} {lcm}')
    except EOFError:
        break

Submission status: Accepted

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[1])
    p=i[0]*i[1]/o
    print(o,int(p))

Submission status: Accepted

Solution code:
# Vol0005.
import sys


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' % (gcd, lcm))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
def f(x, y):
    if x % y == 0:
        return y
    return f(y, x % y)
a = []
while True:
    try:
        a.append(list(map(int, input().split())))
    except EOFError:
        break
for i in a:
    g = f(i[0], i[1])
    l = (i[0] * i[1]) / g
    print(g, int(l))

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:
from sys import stdin
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 int(a*b/gcd)

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

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

Submission status: Accepted

Solution code:
import sys


def euc(n,m):
    if max(n,m)%min(n,m) == 0:
        return min(n,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: Accepted

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

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

if __name__ == "__main__":
    while True:
        try:
            a, b = map(int, input().split())
            g = gcd(a, b)
            l = lcm(a, b)
            print("{} {}".format(g, l))
        except:
            break

Submission status: Accepted

Solution code:
import sys

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

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

def run():
    data = []
    for n in sys.stdin:
        a, b = list(map(int, n.split()))
        data.append((a,b))

    for _data in data:
        a, b = _data
        g = gcd(a,b)
        l = lcm(a,b,g)
        print(g, l)

if __name__ == '__main__':
    run()

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:
import sys;print"\n".join("%d %d"%(lambda x:(x[2],x[0]/x[2]*x[1]))((lambda f,x:(x[0],x[1],f(f,x[0],x[1])))(lambda f,a,b:a%b==0 and b or f(f,b,a%b),map(int,s.split(' '))))for s in sys.stdin)

Submission status: Accepted

Solution code:
import sys
def gcd(a,b):
	if b != 0:
		return gcd(b,a%b)
	else:
		return a
def lcm(a,b,g):
	return b / g * a
for s in sys.stdin:
	ls = map(int,s.split(' '))
	print "%d %d" % (gcd(ls[0],ls[1]),lcm(ls[0],ls[1],gcd(ls[0],ls[1])))

Submission status: Accepted

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

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

def lcm(a,b):
  d = (a*b) / gcd(a,b)
  print d
while True:
  try:
   x = map(int,raw_input().split(" "))
   a,b = x[0],x[1]
   print gcd(a,b),(a*b)/gcd(a,b)

  except EOFError:
    break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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: Accepted

Solution code:
import sys

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

def calc(a, b):
    gcd_val = gcd(a, b)
    lcm_val = a * b / gcd_val
    return (gcd_val, lcm_val)


for line in sys.stdin.readlines():
    line = line.strip()
    a, b = map(int, line.split())
    print "{0[0]:d} {0[1]:d}".format(calc(a, b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:UTF-8

def gcd(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)

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

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

    except Exception:
        break;

Submission status: Accepted

Solution code:
import sys
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
def lcm(a,b):
    return a*b/gcd(a,b)
for i in sys.stdin.readlines():
    a,b=map(int,i.split())
    print "{} {}".format(gcd(a,b),lcm(a,b))