Go: package main

import "fmt"

func main() {
	var a, b int
	var gcd, lcm int

	for {
		_, err := fmt.Scanf("%d %d", &a, &b)
		if err != nil {
			return
		}

		var big, small int
		// GCD
		if a > b {
			big = a
			small = b
		} else {
			big = b
			small = a
		}

		for {
			if big%small == 0 {
				gcd = small
				break
			} else {
				small, big = big%small, small
			}
		}

		// LCM
		lcm = a * b / gcd

		fmt.Println(gcd, lcm)
	}
}

C++: #include <math.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
	long long int x, y;
	while (cin >> x >> y) {
		long long int a, b, c;
		a = max(x, y);
		b = min(x, y);
		c = a % b;
		while (c) {
			a = b;
			b = c;
			c = a % b;
		}
		cout << b << ' ' << x * y / b << endl;
	}
	return 0;
}

C++: #include <cstdio>
#define L long long int

L lcm(L a,L b){
  if(a==b)
    return a;
  else if(a<b)
    return lcm(b,a);
  else
    return lcm(a-b,b);
}

L gcd(L a,L b){
  return a*b/lcm(a,b);
}

int main(){
  L a,b;

  while(~scanf("%lld %lld",&a,&b))
    printf("%lld %lld\n",lcm(a,b),gcd(a,b));
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<30
#define ALEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

ll gcd(ll a, ll b) {
    if(a < b) swap(a, b);
    while(b > 0) {
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

ll lcm(ll a, ll b) {
    if(a == 0 || b == 0) {
        cout << "Error" << endl;
        return 0;
    }

    return (a * b / gcd(a, b));
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(16);

  ll a, b;
  while(cin >> a >> b) cout << gcd(a, b) << " " << lcm(a, b) << endl;

  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int gcd (int a, int b)
{
	if (a > b){
		swap(a,b);
	} // end if
	while (b % a != 0){
		b = b % a;
		if (a > b){
			swap(a,b);
		} // end if
	} // end while

	return a;
}
long lcm (int a, int b)
{
	long res = a/gcd(a,b);
 	res *= b;
	return res;
}
int main()
{
//	cut here before submit 
//	freopen("testcase.gl", "r", stdin);
	string str = "";

	while (getline (cin, str )){
		int a, b;
		stringstream ss(str);
		ss >> a >> b;
		cout << gcd(a,b) << ' ' << lcm(a,b) << endl;
	} // end for

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long int ll;
typedef vector<long long int> vi;

int main(){
	ll a, b, da, db, c, GCD, LCM = 0, k = 0;
	bool f;
	while (cin >> a >> b){
		da = a;
		db = b;
		if (a > b){
			k = a;
			a = b;
			b = k;
		}
		while (1){
			c = b%a;
			if (c == 0){
				GCD = a;
				break;
			}
			b = a;
			a = c;
		}
		LCM = da*db / GCD;
		cout << GCD <<" "<< LCM << "\n";
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
  int c;
  while (a != 0){
    c = a;
    a = b % a;
    b = c;
  }
  return (b);
}

int lcm(int a, int b)
{
  if (a == 0 || b == 0) return (0);
  return ((a / gcd(a, b)) * b);
}

int main()
{
  int a, b;
  cin >> a >> b;
  cout << gcd(a, b) << " " << lcm(a, b) << endl;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;

int gcd(int a, int b) {
   int r;
   while((r = a % b) != 0)
   {
       a = b;
       b = r;
   }
   return b;
}

int main(void){
   int a, b, tmp;
   if (a < b){
       tmp = b;
	b = a;
	a = tmp;

   }
   (cin >> a >> b);
     int lcm = b * a / gcd(a,b);
     cout << gcd(a,b) << " " << lcm << endl;
   
   return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int gcd(int x, int y)
{
	if (x%y == 0)
		return y;
	if (x < y)
		swap(x, y);
	return gcd(y, x%y);
}
int main()
{
	while (true)
	{
		int n, m;
		cin >> n >> m;
		if (cin.fail())
			break;
		cout << gcd(n, m) <<" "<< n / gcd(n,m) * m << endl;
	}
}

C++: #include <iostream>
using namespace std;
int gcd(int x,int y){
	if(x==0)return y;
	return gcd(y%x,x);
}
int main(){
	while(true){
		int a,b;
		cin>>a>>b;
		if(cin.eof())return 0;
		int g=gcd(a,b);
		cout<<g<<' '<<a/g*b;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;

int main(){
	long long  a,b,ta,tb;
	
	while(cin>>a>>b){
	ta=a;tb=b;
	if(a<b)swap(a,b);
	while(true){
		int tmp=a;
		a=b;
		b=tmp%a;
		if(a<b){
		b=1;
		break;
		}
		if(a%b==0)break;
	}
	cout<<b<<" "<<ta*tb/b<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int a,b,r,G,R,L,tmp;
  while(cin >> a >> b){
    R = a; L = b;
    if(b > a){
      a = tmp; a = b; b = tmp;
    }
    while(1){
	  r = a % b;
	  if(r == 0)
	    break;
	  a = b;
	  b = r;
	   }
    G = b;
    R = R / G;
    L = L / G;
    cout << G <<" "<< R*L*G << endl;
  }
}

C++: include<stdio.h>


//公約数の関数
unsigned long long int kouyakusuu_f(unsigned long long int a,unsigned long long int b)
{
	//返す変数
	unsigned long long int kouyakusuu_ans = 0;

	//無限ループ
	for (unsigned long long int i = a;;i -= 2)
	{
		//両方割れるなら
		if (a %i == 0)
		{
			if (b % i == 0)
			{
				kouyakusuu_ans = i;
				break;
			}
		}
	}

	return kouyakusuu_ans;
}



//公倍数の関数
unsigned long long int koubaisuu_f(unsigned long long int a,unsigned long long int b)
{
	//保存用変数(aとbをもう入れちゃう)
	unsigned long long int hozon1 = a,hozon2 = b;
	//インクリメント変数
	int count1 = 0,count2 = 0;

	//合うまで続ける
	while (hozon1 != hozon2)
	{
		//aのほうが小さいとき(bが大きい)
		while (hozon1 < hozon2)
		{
			count1++;
			//小さいaを少しずつ増やす
			hozon1 = a * count1;
		}
		//bの方が小さいとき(aが大きい)
		while (hozon2 < hozon1)
		{
			count2++;
			//小さいbを少しずつ増やす
			hozon2 = b * count2;
		}
	}

	//どうせ同じだからどっちでも問題ない
	return hozon1;
}




int main(void)
{
	//公倍数と公約数
	unsigned long long int kouyakusuu = 0;
	unsigned long long int koubaisuu = 0;
	//入力
	unsigned long long int a = 0,b = 0;

	//回しまくる
	while (scanf("%d %d",&a,&b) != EOF)
	{
		//同じ値ならそのマンまでいいでしょう
		if (a != b)
		{
			//公約数を関数よりもとめる
			kouyakusuu = kouyakusuu_f(a,b);
			//公倍数を関数により求める
			koubaisuu = koubaisuu_f(a,b);
		}
		//同じ値ならそのまま
		else
		{
			koubaisuu = a;
			kouyakusuu = a;
		}
		//表示
		printf("%llu %llu\n",kouyakusuu,koubaisuu);
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,x,y,r;
	cin>>a>>b;
	x=a;	y=b;
	while(1){
		if(b>a)	swap(a,b);
		r=a%b;
		if(r==0)	break;
		a=b;
		b=r;
	}
	cout<<b<<" "<<x*y/b<<endl;
	return 0;
}

C++: #include <iostream>
using namespace std;

int get_gcd(int a, int b) {
  int r;
  while (r = a % b) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int a, b;
  while (cin >> a >> b) {
    int gcd = get_gcd(a, b);
    int lcm = a / gcd * b;
    cout << gcd << " " << lcm << endl;
  }
  return 0;
}