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<bits//stdc++.h>
using namespace std;

int main(){
int n;
while(cin>>n)
{
	if(n%2==1){
		cout<<"1 ";
		n-=1;
		}
		
	if(n%4==2){
		cout<<"2 ";
		n-=2;
		}	
		
	if(n%8==4){
		cout<<"4 ";
		n-=4;
		}	
		
	if(n%16==8){
		cout<<"8 ";
		n-=8;
		}	
		
	if(n%32==16){
		cout<<"16 ";
		n-=16;
		}	
		
	if(n%64==32){
		cout<<"32 ";
		n-=32;
		}	
		
	if(n%128==64){
		cout<<"64 ";
		n-=64;
		}	
		
	if(n%256==128){
		cout<<"128 ";
		n-=128;
		}	
		
	if(n%512==256){
		cout<<"256 ";
		n-=256;
		}	
		
	if(n%1024==512){
		cout<<"512 ";
		n-=512;
		}	
		cout<<"\b"<<endl;
	}
	return 0;
		}

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	
	li a;
	while(cin>>a){
		bool omori[10]={false};
		bool ff=true;
		li fo=9;
		li div=512;
		li now=9;
		while(a>0){
			//p2(a,div);
			if(a>=div){
				if(ff){ff=false; fo=now;}
				a-=div;
				omori[now]++;
			}
			div/=2;
			now--;
		}
		li w=1;
		rep(i,10){
			if(omori[i]){
				cout<<w;
				if(i!=fo)cout<<" ";
			}
			w*=2;
		}
		puts("");
	}
	
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	vector<int> a;
	while(cin>>n){
		if(n>=512){
			n-=512;
			a.push_back(512);
		}
		if(n>=256){
			n-=256;
			a.push_back(256);
		}
		if(n>=128){
			n-=128;
			a.push_back(128);
		}
		if(n>=64){
			n-=64;
			a.push_back(64);
		}
		if(n>=32){
			n-=32;
			a.push_back(32);
		}
		if(n>=16){
			n-=16;
			a.push_back(16);
		}
		if(n>=8){
			n-=8;
			a.push_back(8);
		}
		if(n>=4){
			n-=4;
			a.push_back(4);
		}
		if(n>=2){
			n-=2;
			a.push_back(2);
		}
		if(n==1){
			a.push_back(1);
		}
		sort(a.begin(),a.end());
		cout<<a[0];
		for(int i=1;i<a.size();i++){
			cout<<" "<<a[i];
		}
		cout<<endl;
	}
	return 0;
}

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

int main(int argc, const char * argv[])
{
    int cu[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
    int g, j = 0, cu2[10] = {0};
    while (cin >> g) {
        for (int i = 0; i < 11; i++) {
            if ((g - cu[i]) < 0) {
                g -= cu [i - 1];
                cu2[j] = cu[i - 1];
                i = 0; j++;
            }
            if (g == 0) break;
        }
        for (int i = 0; i < j / 2; i++) {
            int tmp;
            tmp = cu2[j - 1 - i];
            cu2[j - 1 - i] = cu2[i];
            cu2[i] = tmp;
        }
        for (int i = 0; i < j; i++) {
            printf("%d ", cu2[i]);
        }
        puts("");
    }
    return 0;
}

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

using namespace std;

bool a[10];

    int main(){

    int N;
    int i=0;
    
    while(!cin.eof())
    {
        cin>>N;
        i = 0;
        for(int j=0;j<10;j++)
        {
            a[j] = 0;
        }
        
        for(int k=9;k>-1;k--){
            
            if(i+(pow(2,k)) <= N){
                i += pow(2,k);
                a[k] = 1;
            }
        }
        
        bool last = false;
        for(int k=0;k<10;k++){
            
            if(a[k] ==1)
            {
                if(last){
                    cout<<" ";
                }
                last =true;
                cout<<pow(2,k);    
            }        
        }
 
        cout<<endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n;
	while (cin >> n) {
		ostringstream oss;
		for (int i = 0; n; i++) {
			if (n & 1)oss << pow(2, i) << ' ';
			n >>= 1;
		}
		oss.str().pop_back();
		cout << oss.str() << endl;
	}
	return 0;
}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0031&lang=jp

#include <algorithm>
#include <iostream>
#include <vector>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <math.h>
#include <iomanip>
#include <sstream>

using namespace std;

//テ」ツδ榲」ツつッテ」ツδュテ・ツョツ堙ァツセツゥ
#define ALL(v) (v).begin(),(v).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define SORT(x) sort(begin(x),end(x))
#define SELECT_SORT(x, n) sort(begin(x),begin(x)+n)
#define SWAP(type, a, b) do {type tmp = a; a = b; b = tmp;} while (0)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))

//テ・ツョツ堙ヲツ閉ー
#define INF 2000000000000
#define MAX 10

//DEBUGテァツ板ィ
#define BAR() cout << "----------------------------" << endl;
#define DUMP(v) (cerr << #v << ": " << v << endl)
#define PRINT(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

vector<int> weight;

void binary(int x)
{
	int y,i,ans;
	ans=0;
	i=0;
	bool first=true;
	while (x>0)
	{
		y=x%2;
		ans=ans+y*pow(10,i);
		if(y){
			if(first){
				cout << weight[i]; first=false;
			}else{
				cout << " " << weight[i];
			}
		}
		x=x/2;
		i=i+1;
	}
	return;
}

int main()
{
	weight.push_back(1);
	for(int i=1; i<10; ++i){
		weight.push_back(weight[i-1]*2);
	}
	
	int obj;
	
	while(cin >> obj)
	{
		
		binary(obj);
		cout << endl;
	}
	
}

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

using namespace std;

array< int, 10 > weight_array{ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
array< int, 1024 > sum_table;
array< array< int, 10 >, 1024 > bit_table;

void MakeTable()
{
	int i = 0, j = 0, tmp = 0;
	for ( i = 0 ; i < 1023 ; i++ )
	{
		tmp = i;
		for ( j = 0 ; j < 9 ; j++ )
		{
			sum_table[i] = ( tmp % 2 ) * weight_array[j] + sum_table[i];
			bit_table[i][j] = tmp % 2;
			tmp = tmp >> 1;
		}
	}
}

int main()
{
	int weight, j, i;
	MakeTable();

	while( cin >> weight )
	{
		for ( i = 0 ; i < 1024 ; i++ )
		{
			if ( sum_table[i] == weight )
			{
				for ( j = 0 ; j < 10 ; j++ )
				{
					if ( bit_table[i][j] == 1 )
					{
						cout << weight_array[j] << " ";
					}
				}
				break;
			}
		}
	}

	return 0;
}

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

int main(){

  int n;

  while(cin >> n){

    int z = 512,a[100] = {0},count = 0,count2 = 0;

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

      if(n - z >= 0){
	n -= z;
	a[i] = z;
	count++;
      }
      z /= 2;
    }

    for(int i=1;i<=10;i++){

      if(a[i] != 0){
	cout << a[i];
	count2++;

	if(count2 == count) break;
	cout << " ";

      }
    }

    cout << endl;

  }
}