#include <iostream>                                                                                                       
                                                                                                                          
using namespace std;                                                                                                      
                                                                                                                          
int main() {                                                                                                              
  long long int a, b, m, n, t, lcm, gcd;                                                                                  
                                                                                                                          
  while (cin >> a && cin >> b) {                                                                                          
    if (b > a) {                                                                                                          
      t = a;                                                                                                              
      a = b;                                                                                                              
      b = t;                                                                                                              
    }                                                                                                                     
                                                                                                                          
    m = a;                                                                                                                
    n = b;                                                                                                                
    while (m % n != 0) {                                                                                                  
      t = n;                                                                                                              
      n = m % n;                                                                                                          
      m = t;                                                                                                              
    }                                                                                                                     
    lcm = n;                                                                                                              
    gcd = a * b / lcm;                                                                                                    
    cout << lcm << " " << gcd << endl;                                                                                    
  }                                                                                                                       
                                                                                                                          
  return 0;                                                                                                               
} 

Measured memory_bytes: 0