Go: package main

import "fmt"

func main() {
	var gcdArr, lcmArr [100]int
	var count int
	for {
		var x, y int
		fmt.Scanf("%d %d", &x, &y)
		if x == 0 {
			break
		}
		if x < y {
			rep := x
			x, y = y, rep
		}
		gcd := x % y
		lcm := x * y
		for gcd != 0 {
			x, y, gcd = y, gcd, x%y
		}
		gcdArr[count] = y
		lcmArr[count] = lcm / y
		count++
	}
	for i := 0; i < count; i++ {
		fmt.Printf("%d %d\n", gcdArr[i], lcmArr[i])
	}
}

C++: #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
typedef long double lb;
using namespace std;
ll gcd(ll P, ll Q){
  return Q ? gcd(Q,P % Q):P;
}
ll lcm(ll P, ll Q){
  return P / gcd(P,Q) * Q;
}
int main(){
  ll P,Q;
  while(cin >> P >> Q){
    cout << gcd(P,Q) << " " <<  lcm(P,Q) << endl;
  }
}

C++: #include "iostream"
using namespace std;

void keisann(int a,int b) {
	int ac = a;
	int bc = b;
	while (true) {
		a = a%b;
		if (a == 0) {
			cout << b << " ";
			cout << (ac*bc) / b << endl;
			break;
		}
		b = b%a;
		if (b == 0) {
			cout << a << " ";
			cout << (ac*bc) /a << endl;
			break;
		}
	}
}

int main()
{
	int a, b;
	while (cin >> a, a != EOF) {
		cin >> b;
		if (a > b) { keisann(a, b); }
		else if (a < b) {
			int c = a;
			a = b;
			b = c;
			keisann(a, b);
		}
		else if (a == b) {
			cout << a << " "<< a<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	long long a,b;
	while(cin >> a >> b)
	{		
		if(a<b)
		{
			a=a+b;
			b=a-b;
			a=a-b;
		}
		long long a1=a,b1=b;
		while (a%b != 0)
		{
			long long c=a%b;
			a=b;
			b=c;
		}
		cout << b << ' '<<a1*b1/b << endl;	
	}
}

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

int main(){
	int a, b;
	int m, n, r;
	while(cin >> a >> b){
		m = max(a, b);
		n = min(a, b);
		r = m % n;

		while(r != 0){
			m = n;
			n = r;
			r = m % n;
		}

		cout << n << ' ' << a*b/n << endl;
	}

	return(0);
}

C++: #include<iostream>

using namespace std;

int gcd(int x,int y) {//??????????????????????????????
	int r;
	if (x < y)swap(x, y);
	while (y > 0) {
		r = x%y;
		x = y;
		y = r;
	}
	return x;
}

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

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

typedef unsigned int uint;

uint func1(uint a,uint b){
    while(a != b){
        if(a>b)a-=b;
        else b-=a;
    }
    return a;
}

uint func2(const uint a,const uint b){
    uint a2=a,b2=b;
    while(a2 != b2){
        if(a2>b2)b2+=b;
        else a2+=a;
    }
    return a2;
}

int main(){
    uint a,b;
    cin >> a >> b;

    cout << func1(a,b) << " " << func2(a,b);

    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
    return (b == 0)? a:gcd(b, a%b);
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);

}
int main()
{
    ll a,b,c,d;
    cin >> a >> b;
    c=gcd(a,b);
    d=lcm(a,b);
    cout << c <<' ' << d << endl;
    return 0;
}

C++: #include <iostream>

int get_GCD(u_int a, u_int b)
{
    while(a != 0 && b != 0){
        if(a >= b)
            a %= b;
        else
            b %= a;
    }
    return a != 0 ? a : b ;
}

inline int get_LCM(const u_int a, const u_int b, const u_int GCD)
{
    return a * (b / GCD);
}

int main()
{
    u_int a, b, GCD;
    while(std::cin >> a >> b){
            GCD = get_GCD(a, b);
            std::cout << GCD << " " << get_LCM(a, b, GCD) << std::endl;
    }    

    return 0;
}

C++: #include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y){

    if(x<y) return gcd(y,x);
    if(y==0) return x;
    return gcd(y,x%y);

}

int main(){

    cin.sync_with_stdio(false);

    while(1){

        long long x,y;

        cin >> x >> y;

        long long m = gcd(x,y);

        cout << m << " " << x/m * y << endl;

    }

    return 0;

}

C++: #include<cstdio>
int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        int gcd1=gcd(a,b);
        printf("%d ",gcd1);
        printf("%d\n",a*b/gcd1);
    }
    return 0;
}

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

void gcd(int a,int b)
{
  int ans,p,q[10000];

  p=max(a,b); q[0]=min(a,b);
  for(int i=0;;i++){
    if(!q[i]){
      cout<<p<<" "; break;
    }
    q[i+1]=p%q[i]; p=q[i];
  }
}

int lcm(int a,int b)
{
  int ans=0,p=min(a,b),q=max(a,b);

  for(int i=1;;i++){
    for(int j=1;;j++){
      if(p*i==q*j){
	ans=p*i; break;
      }
      if(p*i<q*j) break;
    }
    if(ans) break;
  }
  cout<<ans<<endl;
}

int main()
{
  int a,b;

  while(cin>>a>>b){
    gcd(a,b); lcm(a,b);
  }
}

C++: #include <iostream>
using namespace std;
long a1,a2;
long gcd,lcm;

long GCD(long a,long b){
    long i = 2;
    long minimum = min(a,b);
    if (minimum == 0){
        i = 0;
    }
    else if (minimum == 1){
        i = 1;
    }
    else {
        for (i = 1; i <= minimum; i++) {
            if (a % (minimum - i + 1) == 0 & b % (minimum - i + 1) == 0) {
                i = minimum - i + 1;
                break;
            }
        }
    }
    return i;
}

int main(){
    while(cin >> a1 >> a2) {
        gcd = GCD(a1,a2);
        if (gcd == 0){
            lcm = 0;
        }
        else{
            lcm = a1*a2/gcd;
        }
        cout << gcd << " " << lcm << endl;
    }
}

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

int gcd(int a,int b){
	if(b==0) return a;
	
	return gcd(b,a%b);
}

int main(){
	
	while(true){
		int a,b;
		cin >> a >> b;
		
		if(cin.eof()) break;
		
		int g = gcd(a,b);
		cout << g << ' ' << a/g*b << endl;
		
	}
	
	return 0;
	
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<cstring>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){
    int a,b;
    while(scanf("%d%d",a,b)!=EOF){
        
        if(b>a)swap(b,a);
        ll aa=a,bb=b;
        ll o,p,q;
        while(bb!=0){
            o=bb;
            p=aa%bb;
            aa=bb;bb=p;
        }
        ll i=1;
        while(true){
            i++;
            ll ao=a*i;
            if(ao%b==0){
                q=ao;
                break;
            }
        }
        cout<<o<<" "<<q<<endl;
    }
    
    
    
    
    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	
	int a, b, c = 0;
	while (cin >> a, cin >> b)
	{
		for (int i = 1; i <= a, i <= b; i++)
		{
			if (a % i == 0 && b % i == 0)
			{
				c = i;
			}
		}
		cout << c << " " << a*b / c << endl;
	}
	getchar();
	getchar();
	return 0;
}

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

int gcd(int x,int y)
{
  if(y==0)
    return x;
  return gcd(y,x%y);
}

int lcm(int x,int y)
{
    return x/gcd(x,y)*y;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
      printf("%d %d\n",gcd(a,b),lcm(a,b));
    }
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	long long x , y , i , j , tmp , tmp2;
	while( cin >> x >> y ){
		long long n = x>y ? x:y;
		for( i=1 ; i<=n ; i++ ){
			if( x%i+y%i==0 )
				tmp = i ;
		}
		i=n;
		while(1){
			i++;
			if( i%x+i%y==0 ){
				tmp2=i;
				break;
			}
		}
		cout << tmp <<" "<< tmp2 << endl;
	}
}