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>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

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

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

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

C++: 
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
int main()
{
	long long a, b;
	while (cin >> a >> b)
	{
		int A, B; 
		int n = a, m = b;
		int q = a, w = a;
		
//			int n = , m = M;
			while (true)
			{
				if (q == 0) { cout << m << " "; break; }
				if (w == 0) { cout << n << " ";  break; }
				if (w > q) { w-= q; }
				else { q -= w; }
			}
		
		int s = 1;
		while (true)
		{
			if ((s*n) % m == 0)
			{
				break;
			}
			else { s++; }
		}
		//cout << s*n << " ";

		B = a*n;
		cout<< B<<endl;
	}
	return 0;

}

C++: #include<stdio.h>

int max(int a, int b){
  return (a > b) ? a : b;
}

int min(int a, int b){
  return (a < b) ? a : b;
}

int calcGCD(int a, int b){
  int _min, _max, r;
  _max = max(a, b);
  _min = min(a, b);
  r = _max % _min;
  while(r != 0){
    _max = _min;
    _min = r;
    r = _max%_min;
  }
  return _min;
}

int calcLCM(int a, int b){
  int GCD, LCM;
  GCD = calcGCD(a, b);
  LCM = a * b / GCD;
  return LCM;
}
int main(){
  int a, b;
  int list[50][2];
  int j = 0;
  while(scanf("%d%d", &a, &b)!=EOF){
    list[j][0] = calcGCD(a, b);
    list[j][1] = calcLCM(a, b);
    j+=1;
  }
  int i;
  for(i=0; i<j; i++){
    printf("%d %d\n", list[i][0], list[i][1]);
  }
  return 0;
}

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

long long gcd(long long a, long long b) {
    assert(a > 0 && b > 0);
    return (a == b) ? a : gcd(b % a, a);
}

long long lcm(long long a, long long b) {
    assert(a > 0 && b > 0);
    return (a / gcd(a, b)) * b;
}

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

C++: #include <stdio.h>

int main(){
 
    int buf1[50],buf2[50];
 
    int k = 0;
    while( scanf( "%d %d",&buf1[k],&buf2[k] ) != EOF ) k++;
 
    for( int i = 0;i < k;i++ ){
        int b1 = buf1[i],b2 = buf2[i];
        int m,n;
        if( b 1< b2 ){
            m = b2,n = b1;
        } else if( b1 > b2 ){
            m =  b1,n = b2;
        } else printf( "%d ",b2 );
 
        while( true ){
            int buf = n;
            n = m % n;
            m = buf;
            if( n == 0 ){
                printf( "%d\n",m );
                break;
            }
        }
        while( b1 != b2 ){
            if( b1 < b2 ) b1 += buf1[i];
            else             b2 += buf2[i];
        }
        printf( "%d\n",b1 );
    }
    reutrn 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int gcd(int m ,int n){
	while(n!=0){
		int r=m%n;
		m=n;
		n=r;
	}
	return m;
}

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

C++: #include<iostream>

using namespace std;

long long int a,b;

int main(void)
{
	while(cin>>a>>b){
		long long int x,y;
		x=1;
		for(int i=2;i<=a&&i<=b;){
			if(a%i==0&&b%i==0){
				x=x*i;
				a=a/i;
				b=b/i;
				i=2;
			}
			i++;
		}
		y=x*a*b;
		cout<<x<<" "<<y<<endl;
	}
}

C++: #include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll gcd(ll a, ll b){
  ll v0 = a, v1 = b, v2 = v0%v1;
  while(v2>0){
    v0 = v1;
    v1 = v2;
    v2 = v0%v1;
  }
  return v1;
}

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

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

int main(){
  long long int x,y,r,q,a,b;
  while(scanf("%lld %lld",&x,&y) != EOF){
    a = x;
    b = y;
    while(1){
      q = x/y;
      r = x -q*y;
      if(r == 0) break;
      x = y;
      y = r;
    }
    x = a*b / y;
    cout << y << " " <<  x << endl;
  }
}

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

int main(){
int  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-b;
		if(a<b)swap(a,b);
		if(b==1||a==1){
		b=1;
		break;
		}
		if(a-b==0)break;
	}
	cout<<b<<" "<<ta*tb/b<<endl;
	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

int gcd( int, int );

int main()
{
	int a, b;
	char buf[1024];
	
	while (	fgets( buf, sizeof( buf ), stdin ) && buf[0] != '\n' )
	{
		sscanf( buf, "%d %d", &a, &b );

		printf("%d ", gcd( a, b ) );

		for ( int i = 1; i * a < 2000000000; i++ )
		{
			if ( !( i * a % b ) )
			{
				printf("%d\n", i * a );
				break;
			}
		}
	}

	return 0;
}

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

C++: //"push hoge"と言われたらhogeを最後に入れ、"pop"と言われたら最後尾を取りだす。"quit"で終わり。
#include<iostream>
using namespace std;

int main(){
	int a,b,hoge = 0,j=0;
	int gcd,gcds,lcm,lcms;
	while(cin >> a >> b){


		//最大公約数
		if(a > b){
			lcm = b;
			lcms = a;
		}else{
			lcm = a;
			lcms = b;
		}
		for(int i=1;i<lcm;i++)
			if(!(lcms % (lcm / i)) && !(lcm % i)) {
				lcm = lcm / i;
				break;
			}
	
		j = 0;
		//最小公倍数
		if(a > b){
			gcd = a;
			gcds = b;
		}else{
			gcd = b;
			gcds = a;
		}
		while(1){
			j++;
			hoge = gcd * j;
			if(!(hoge % gcds)){
				gcd = hoge;
				break;
			}
		}

		cout << lcm << " " << gcd << endl;
	}
	return 0;
}