Go: package main

import "fmt"

func main() {
	var gcdArr, lcmArr [50]int
	var count int
	for {
		var x, y int
		fmt.Scanf("%d %d", &x, &y)
		if count == 51 {
			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>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;

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

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

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

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

C++: #include<iostream>
#include<utility>
using namespace std;
int main()
{
  int a=0;
  int b=0;
  long int c=0;
  int n,m;
  int i,j,l;

  while(scanf("%d %d",&n,&m) != EOF)
    {
      i = n;
      j = m;

      //koyaku
      if((n >= m) != true)swap(n,m);
      while(1)
	{
	  int amari = n % m;
	  n = m;
	  m = amari;
	  if(amari == 0) break;
	}
      
      //kobai
      l = i*j/n;
      
      cout << n << " " << l << endl;
    }
}

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

int gcd(int x,int y){
  if(y==0)return x;
  return gcd(y,x%y);
}
int main(){
  int a,b;
  while(cin>>a>>b){
    int g=gcd(a,b);
    cout<<g<<' '<<a/g*b<<endl;
  }
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
 long long int a, b, c, temp, min, A, B;
 while(cin >> a >> b){
  if(a == 0){
    cout << "0" << " " << "0" << endl;
  }
  else if(b == 0){
    cout << "0" << " " << "0" << endl;
  }
  else if(a < b){
    temp = a;
    a = b;
    b = temp;
  }

    
  else if (a > b){
    A = a;
    B = b;

    while(1){
      c = A % B;
      if(c == 0) break;
      else if(c != 0){
        A = B;
        B = c;
      }
    }
    min = (a * b) / B;
    cout << B << " " << min << endl;
  }
  else if(a == b){
    cout << a << " " << a << endl;
  }

 }
 return 0; 
}

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

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

using namespace std;

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

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

C++: #include <iostream>
 
using namespace std;
 
int GCD(int a, int b)
{
    if(a % b == 0) { return b; }
 
    if(b % a == 0) { return a; }
 
    if(a > b) { return GCD(a % b, b); }
 
    if(a < b) { return GCD(a, b % a); }
}
 
int LCM(int a, int b)
{
    return a / GCD(a, b) * b;
}
 
int main()
{
    int a, b;
 
    while(cin >> a >> b)
    {
        cout << GCD(a, b) << ' ' << LCM(a, b) << endl;
    }
 
    return 0;
}

C++: #include<stdio.h>
a;main(b){while(scanf("%d%d",&a,&b))printf("%d %d\n",a,b);
}

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

int main()
{
    long int a, b, gcd, lcm, amari, wara, wari;
 
    while(cin>>a>>b){
        wara=0;
        wari=0;
        amari=0;
        gcd=0;
        lcm=0;

        if (a > b){
            wara = a;
            wari = b;
        }
        else{
            wara = b;
            wari = a;
        }
        amari = wara % wari;
        while (amari != 0)
        {
            wara = wari;
            wari = amari;
            amari= wara % wari;
        }
        gcd = wari;
        lcm = a * b / gcd;
        cout<<gcd<<" "<<lcm<<endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(void)
{
    unsigned int a, b;
    while (cin >> a >> b)
    {
        int t = 1, g = 1;
        unsigned int l = 1;
        if (a < b)
        {
            while (t < b)
            {
                if (a % t == 0 && b % t == 0)
                {
                    g = t;
                }
                t++;
            }
            a = a / g;
            b = b / g;
            l = g * a * b;
        }
        else
        {
            while (t < a)
            {
                if (a % t == 0 && b % t == 0)
                {
                    g = t;
                }
                t++;
            }
            a = a / g;
            b = b / g;
            l = g * a * b;
        }
        cout << g << ' ' << l << endl;
    }
}

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



int main(void){
	//GCD=?????§??¬?´???°
	//LCM=????°???¬?????°

	long int a, b,Max,Min,GCD,LCM,count;


	while (cin>>a>>b){
		count = 0;
		Max = max(a, b);
		Min = min(a, b);
		//GCD

		//????°????????????£????????£????????????????????????????????§??¬?´???°??§??????
		for (int i = 1;;i++){

			if (Min %i == 0 && Max%(Min/i)==0){//?????????????????????
				GCD = Min/i; 
				count++;
			}		
			if (count == 1)break;
		}

		//LCM

		for (int i = 1;; i++){
			if ((Max*i) % Min == 0){
				LCM = (Max*i);
				count++;
			}if (count == 2)break;
		}


		cout << GCD << " " << LCM << endl;
	
	}
	
	
	return 0;
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

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

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

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

C++: ruby 5416061-aoj-0005.rb

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
	unsigned long long a,b,c,d,maxx=1230,minn=0,m,n;
	while (cin>>a>>b){
		m=a;
		n=b;
		if (a>b){
			while(1){
				maxx=a%b;
				a=b;
				b=maxx;
				if (maxx==0){
					maxx=a;
					break;
				}
				
			}
		}
		else {
			while(1){
				maxx=b%a;
				b=a;
				a=maxx;
				if (maxx==0){
					maxx=b;
					break;
				}
			}
		}
		a=m;
		b=n;
		cout<<maxx<<" "<<a*b/maxx<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int a, b, c, r;
	int gcd, lcm;

	while (cin >> a >> b){
		if (b > a){
			c = a; 
			a = b; 
			b = c;
		}

		lcm = a * b;

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

		lcm /= gcd;

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

	return 0;
}