Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	weight := []int{512, 256, 128, 64, 32, 16, 8, 4, 2, 1}

	for sc.Scan() {
		var wgt []int
		i, _ := strconv.Atoi(sc.Text())

		if i > 1023 {
			i = 1023
		}

		bin := fmt.Sprintf("%010b", i)

		for i := 9; i >= 0; i-- {
			if bin[i] == '1' {
				wgt = append(wgt, weight[i])
			}
		}

		for i := 0; i < len(wgt); i++ {
			if i == len(wgt)-1 {
				fmt.Printf("%d\n", wgt[i])
			} else {
				fmt.Printf("%d ", wgt[i])
			}

		}
	}

}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int g[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int w;
  vector<int> sum;
  
  while(cin >> w) {
    sum.clear();
    for(int i = 9 ; i >= 0 ; i--) {
      if(g[i] <= w) {
	w -= g[i];
	sum.push_back(g[i]);
      }
    }
    sort(sum.begin(), sum.end());
    for(int i = 0 ; i < sum.size() ; i++) {
      if(i != sum.size()-1) cout << sum[i] << ' ';
      else cout << sum[i] << endl;
    }
  } 
  return 0;
}

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

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int main() {
	for (int n; cin >> n; ) {
		for (int i = 0; (n >> i); i++) if ((n >> i) & 1) cout << (1 << i) <<' ';
		cout << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>

int main()
{
	int n;
	int i;
	int weight[]={1,2,4,8,16,32,64,128,256,512};
	bool isFirsttime;

	while(scanf("%d", &n)!=EOF){
		isFirsttime=true;
		for(i=0; i<10; i++){
			if(n%2==1){
				if(isFirsttime){ printf("%d", weight[i]); isFirsttime=false; }
				else printf(" %d", weight[i]);
			}
			n = n>>1;
		}
		printf("\n");
	}

	return 0;
}

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

int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main(void)
{
    int sum;
    priority_queue < int, vector<int>, greater<int> > ans;
    
    while (scanf("%d", &sum) != EOF) {
        for (int i = 9; 0 <= i; i--){
            if (sum <= 1){
                if (sum == 1){
                    ans.push(sum);
                    break;
                }
            }
            else if (weight[i] <= sum){
                sum -= weight[i];
                ans.push(weight[i]);
            }
        }
        while (!ans.empty()){
            printf("%d", ans.top());
            ans.pop();
            if (ans.empty()) printf("\n");
            else printf(" ");
        }
    }
    
    return (0);
}

C++: #include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;

int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        vector<int>vec;
        for(int i=512;i>0;i=i>>1){
            if(n>=i){
                n-=i;
                vec.push_back(i);
            }
        }
        for(int i=0;i<vec.size()-1;i++)
            cout<<vec[vec.size()-1-i]<<" ";
        cout<<vec[0]<<endl;
    }
    return 0;
}

C++: #include<stdio.h>
int ex(int n)
{
    if(n == 0)return 1;
    return ex(n - 1) * 2;
}
int main()
{
    int n;
    while(scanf("%d",&n) != -1)
    {
        int mem[10] = {0};
        for(int i = 9; i >= 0; i--)
        {
            if(n >= ex(i))mem[i] = 1,n -= ex(i);
        }
        n = 0;
        for(int i = 0; i < 10; i++)
        {
            if(n != 0)printf(" ");
            if(mem[i] == 1)printf("%d",ex(i)),n++;
        }
        printf("\n");
    }
    return 0;
}

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

using namespace std;

const int weight[] = {1,2,4,8,16,32,64,128,256,512};

int main(){
  int req,i,n;
  stack<int> st;
  while(cin >> req) {
    n=0;
    for(i=9;i>=0;i--){
      if(req >= n + weight[i]) {
	n += weight[i];
	st.push(weight[i]);
      }
    }
    while(st.size()){
      n = st.top(); st.pop();
      cout << n;
      if(st.size()) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main(){
	int f[9]={2,4,8,16,32,64,128,256,512};
	int s[9]={0};
	int w,i,h=0;
	while(scanf("%d",&w)!=EOF){
		for(h=0,i=0;i<9;i++){s[i]=0;}
		if(w%2==1){h+=1;printf("1 ");}
		for(i=0;i<9;i++){
			if(w>h){h+=f[i];s[i]=1;}
			if(w<h){h-=f[i-1];s[i-1]=0;}
			if(w==h){break;}
		}
		for(i=0;i<9;i++){
			if(s[i]==1){
				printf("%d ",f[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main() {

	int weight;
	int temp[10];
	temp[9] = 512;
	vector<int> ans;

	for (int i = 8; i >= 0; i--)
		temp[i] = temp[i + 1] / 2;

	while (cin >> weight) {

		ans.clear();

		for (int i = 9; i >= 0; i--) {

			if (weight - temp[i] >= 0) {

				weight -= temp[i];
				ans.push_back(temp[i]);

			}
		}

		for (int i = ans.size() - 1; i > 0; i--)
			cout << ans[i] << " ";

		cout << ans[0] << "\n";

	}
	return 0;

}

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

int main(){
  int w;
  int b[10]={0};

  while(std::cin >> w){
    for(int i=0;i<10;i++){
      b[i] = 0;
    }
    for(int i=9;i>=0;i--){
      if(w>=std::pow(2,i)){
        w = w - std::pow(2,i);
        b[i] = 1;
      }
    }
    for(int i=0;i<10;i++){
      if(b[i] == 1){
        std::cout << std::pow(2,i) << ' ';
      }
    }
    std::cout << std::endl;
  }
}

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

int x;

void func(int p2, int y, int first)
{
	int flag = 0;
	
	if (y == 0) {
		return;
	}
	
	if (y >= p2) {
		func(p2 / 2, y - p2, 0);
		flag = 1;
	}
	else {
		func(p2 / 2, y, first);
	}
	
	if (flag == 1) {
		cout << p2;
		if (first) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}
}

int main()
{
	while (cin >> x) {
		func(512, x, 1);
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){

	int n;
	while(cin >> n && n != 0){
		ll *b = new ll[41126];
		fill(b,b+41126,0);

		ll *prv = new ll[41126];
		ll *nxt = new ll[41126];
		int p ,nx;
		p = nx = 0;
		for(int i = 0; i < (n*(n+1))/2; i++){
			ll tmp;
			cin >> tmp;
			if(tmp % 2 == 0){
				prv[p++] = tmp;
			}
			else{
				nxt[nx++] = tmp;
			}
		}
		sort(prv,prv+p);
		sort(nxt,nxt+nx);

		int idx = 0;
		for(int i = 0; i < p; i++){
			b[idx++] = prv[i];
		}
		for(int i = 0; i < nx; i++){
			b[idx++] = nxt[i];
		}

		double aa = (b[0]*b[1])/b[n];
		aa = sqrt(aa);
		vector<int> nums;
		int vvv = (int)(aa+0.1);
		for(int i = 0; i < p; i++){
			nums.push_back(b[i]/vvv);
		}

		cout << vvv << endl;
		sort(nums.begin(),nums.end());
		for(int i  = 0; i < nums.size(); i++){
			cout << nums[i];
			if(nums.size() - 1 == i)
				cout << endl;
			else
				cout << " ";
		}
		delete [] prv;
		delete [] nxt;
		delete [] b;
	}

	return 0;
}