Go: package main

import (
	"fmt"
	"bufio"
	"os"
	"strings"
	"strconv"
)

func getInputAsInt(in string) (int, int) {
	inArr := strings.Split(in, " ")
	// Atoi(s string) (i int, err error) のerrは捨てる
	val1, _ := strconv.Atoi(inArr[0])
	val2, _ := strconv.Atoi(inArr[1])
	return val1, val2
}

func euclidean(val1, val2 int) (int) {
	surp := 1
	for  {
		surp = val1 % val2
		if surp != 0 {
			val1 = val2
			val2 = surp
		} else {
			break
		}
	}
	return val2
}

func calcLCM(val1, val2, gcd int) (int) {
	return val1/gcd*val2
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	
	for scanner.Scan() {
		val1, val2 := getInputAsInt(scanner.Text())
		gcd := euclidean(val1, val2)
		lcm := calcLCM(val1, val2, gcd)
		fmt.Println(gcd, lcm)
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> vii;
typedef long long ll;
typedef pair<int,int> pii;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
long long a,b;
long long GCD,LCM;
int main()
{
    while(~scanf("%lld %lld",&a,&b))
    {
        GCD=gcd(a,b);
        LCM=a/GCD*b;
        printf("%lld %lld\n",GCD,LCM);
    }
}

C++: #include <iostream>
#include <vector>

using namespace std;

int getLCM(int, int);
int getGCD(int, int, int);

int main(int argc, char *argv[]) {
  int x, y;
  vector<int> result;

  while (cin >> x >> y) {
    int lcm = getLCM(x, y);
    int gcd = getGCD(x, y, lcm);
    result.push_back(lcm);
    result.push_back(gcd);
  }
  for (int i = 0; i < result.size()/2; i++)
    cout << result[i*2] << ' ' << result[i*2+1] << endl;
  return 0;
}

int getLCM(int x, int y) {
  int tmp;

  if (x < y) {
    tmp = y;
    y = x; 
    x = tmp;
  }
  while (x % y != 0) {
    tmp = x % y;
    x = y;
    y = tmp;
  }
  return y;
}

C++: #include <stdio.h>

int main( ){
    float a[20],b[20];
    int nCount;
    for( int i = 0;scanf( "%f %f",&a[i],&b[i] ) != EOF;i++ ) nCount = i;

    for( int k = 0;k < i;k++ ){
         float buf_a = a[k],buf_b = b[k];

        while( buf_a != buf_b ){
            if( buf_a < buf_b ) buf_a += a[k];
            else                      buf_b += b[k];
        }
        printf( "%d ",( int )buf_a );
        int m,n;
        if( a[k] < b[k] ) m = b[k],n = a[k];
        else if( a[k] > b[k] ) n = b[k],m = a[k];
        else {
            printf( "%d\n",a[k] );
            continue;
        }
        while( true ){
            int buf = n;
            n = m % n;
            m = buf;
            if( n == 0 ) {
                printf( "%d\n",m );
                break;
            }
        }
    }
    return 0;
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
typedef pair<int,int> P;
typedef unsigned long long ll;
ll gcd(ll x,ll y){
    ll ma=max(x,y),mi=min(x,y),ama=ma%mi;
    if(ama==0) return mi;
    else return gcd(mi,ama);
}
ll lcm(ll x,ll y){
    ll g=gcd(x,y);
    if(g==1) return x*y;
    return g*lcm(x/g,y/g);
}
int main(){
    ll a,b;
    while(scanf("%lld %lld", &a, &b)!=EOF){
        cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
    }
    return 0;
};

C++: #include <iostream>
#include <string>
#include <vector>


class GcdAndLcm
{
public:
    GcdAndLcm() : m_gcd(0), m_lcm(0) {}
    void Run();

private:
    void readData();
    void GetData(std::string s, int& v1, int& v2);
    int calcGcd(int m, int n);
    int calcLcm(int m, int n);
    void Show();

private:
    std::vector<std::string> m_data;
    unsigned int m_gcd;
    unsigned int m_lcm;
};

void GcdAndLcm::Run()
{
    int val1 = 0, val2 = 0;

    readData();
    
    for (unsigned int i = 0; i < m_data.size(); ++i) {
        GetData(m_data[i], val1, val2);
        m_gcd = calcGcd(val1, val2);
        m_lcm = calcLcm(val1, val2);
        Show();
    }
}
void GcdAndLcm::readData()
{
    std::string line;

    while (std::getline(std::cin, line)) {
        m_data.push_back(line);
    }
}

void GcdAndLcm::GetData(std::string s, int& v1, int& v2)
{
    size_t pos = s.find(" ");
    char tmp[100] = { 0 };
    std::strncpy(tmp, s.c_str(), pos);
    v1 = std::atoi(tmp);
    std::memset(tmp, 0x00, sizeof(tmp));
    pos++;
    std::strncpy(tmp, s.c_str() + pos, s.size() - pos);
    v2 = std::atoi(tmp);
}
int GcdAndLcm::calcGcd(int m, int n)
{
    if ((0 == m) || (0 == n))
        return 0;

    while (m != n)
    {
        if (m > n) m = m - n;
        else         n = n - m;
    }
    return m;
}//gcd

int GcdAndLcm::calcLcm(int m, int n)
{
    if ((0 == m) || (0 == n))
        return 0;

    return ((m / calcGcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

void GcdAndLcm::Show()
{
    std::cout << m_gcd << " " << m_lcm << std::endl;
}

int main()
{
    GcdAndLcm gcdAndLcm;

    gcdAndLcm.Run();
}

C++: #include <algorithm>
#include <cstdio>

using namespace std;

int gcd(int a, int b) {
  return !b ? a : gcd(b, a % b);
}

int main() {
  int a, b;
  while (scanf("%d%d", &a, &b) == 2) {
    if (a > b) swap(a, b);
    int g = gcd(a, b);
    printf("%d %d\n", g, b / g * a);
  }
  return 0;
}

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

typedef long long ll;
typedef pair<ll, int> ll_i;
struct edge { int u, v; ll w; };

ll gcd(ll a, ll b) {
	if (b == 0) return abs(a);
	else return gcd(b, a % b);
}

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

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define int long long
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
signed main() {
	vector<int>a(2);
	while (cin >> a[0] >> a[1]) {
		sort(a.begin(), a.end());
		int b = gcd(a[1], a[0]);
		cout << b << " " << a[1] * a[0] / b << endl;
	}
}

C++: #include<iostream>
using namespace std;
int a,b;
int gcd(int x,int y){
    a=x;
    b=y;
    while(a>0&&b>0){
        if(a>b)
            a%=b;
        else
            b%=a;
    }
    if(a==0)
        return b;
    else if(b==0)
        return a;
}
int main(){
    int x,y;
    while(cin>>x>>y){
        int c=gcd(x,y);
        int lcm=(x*y)/c;
        cout<<c<<" "<<lcm<<endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	long a, b;
	while(scanf("%ld %ld", &a, &b) != EOF)
	{
		long x,y;
		if (a > b)
		{
			x = a;
			y = b;
		}
		else
		{
			x = b;
			y = a;
		}
		while(x != y)
		{
			long tmp = x - y;
			x = tmp > y ? tmp : y;
			y = tmp > y ? y : tmp;
		}
		long l = a/x * b;
		printf("%ld %ld\n", x, l);
	}
	return 0;
}