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<vector>
#include<cassert>
using namespace std;
int main(){
  int n,index,bg;
  vector<int> dp[1024];
  for(int i=1;i<=1023;i++){
    if(!dp[i].empty())continue;
    if(i == 1 || i == 2 || i == 4 || i == 8 || i == 16 || i == 32 || i == 64 || i == 128 || i == 256 || i == 512){
      dp[i].push_back(i);
      continue;
    }  
    bg = i-1;
    for(int j=1;j<bg;j++){
      index = bg+j;
      for(int k=0;k<dp[j].size();k++){
	dp[index].push_back(dp[j][k]);
      }
      for(int k=0;k<dp[bg].size();k++){
	dp[index].push_back(dp[bg][k]);
      }
    }
  }

  while(cin >> n){
    assert(n<=1023);
    for(int i=0;i<dp[n].size();i++){
      cout << dp[n][i];
      i==dp[n].size()-1?cout << endl:cout << " ";
    }
  }
  return 0;
}

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

using namespace std;

int main(){
	int w, g[10];
	vector<int> ans;
	
	for(int i=0; i<10; i++) g[i] = pow(2,i);
	
	while(cin >> w){
		ans.clear();
		for(int i=9; i>=0; i--){
			if(w<=1){
				if(w==1)ans.push_back(w);
				break;
			}
			else if(g[i]<=w){
				w -= g[i];
				ans.push_back(g[i]);
			}
						
		}
		for(int i=ans.size()-1; i>=0; i--){
			cout << ans[i];
			(i==0)? cout << endl : cout << " ";
		}
	}


	return 0;
}

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


int main(){
	int weight[10];
	weight[1] = 1;
	for(int i = 2;i<=9;i++)weight[i]=2*weight[i-1];
	while(true)
	{
	int object;
	cin >> object;
	for(int i =1;i <=9;i++){
		if((object % 2)==1)
			{
			cout << weight[i] ;
			if( i != 9 ) cout << " ";
			}
		object = object /2;
		}
	cout << endl;
	if (cin.eof())break;
	}
	
	return 0;
}

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

using namespace std;

string IntToString(int number) {
	stringstream ss;
	ss << number;
	return ss.str();
}

int main(void) {
	int in;
	int omori[] = {512,256,128,64,32,16,8,4,2,1};
	int i;
	string ret;

	while(!cin.eof()) {
		cin >> in;
		ret = "";
		for(i = 0; i < 10; i++) {
			if(omori[i] <= in) {
				in -= omori[i];
				ret = IntToString(omori[i]) + ((ret=="")?(""):(" ")) + ret;
			}
			if(in == 0) { break; }
		}
		cout << ret << endl;
	}

	return 0;
}

C++: using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
int bun[]={1,2,4,8,16,32,64,128,256,512};
int main()
{
	int x;
	while(cin>>x){
		for(int i=0;i<10;i++){
			if((x>>i)&1)printf(bun[i]>x/2?"%d\n":"%d ",bun[i]);
		}
	}
    return 0;
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[10]={1,2,4,8,16,32,64,128,256,512}; 
  
 int main()
 {
   int N;
   while(cin>>N)
   {
     int count=0;
     int num[10]={0};
     while(N)
     {
       num[count++]=N%2;
       N/=2;        
     }      
     for(int i=0;i<count-1;i++) cout<<num[i]<<" ";
     cout<<num[count-1]<<endl;           
   }
   //while(1);     
   return 0;  
 }

C++: #include<iostream>
#include<cmath>
using namespace std;
 
int main(){
    int n,a[10],c;
     
    while(cin>>n){
        c=0;
        for(int i=0;i<10;i++) a[i]=0;
        for(int i=9;i>=0;i--){
            if(n>=pow(2,i)){
                n-=pow(2,i);
                a[i]++;
            }
        }
        for(int i=0;i<10;i++){
            if(a[i]!=0){
                if(c!=0) cout << " ";
                cout << pow(2,i);
                c++;
            }
        }
        cout << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

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

bool tukauka[10];//大きい順

int n,owari;
int main(){
	while(cin >> n){
		for(int i = 0;i < 10; i++) {
			if(n >= omosa[i]){
				tukauka[i] = true;
				n -= omosa[i];
			}
		}
		for(int i=9;i!=0;i--){
			if(tukauka[i])owari=i;
		}
		for(int i = 0; i < 10; i++) {
			if( i==9-owari) {
				cout << omosa[9 - i] ;
			}else if(tukauka[9 - i]){
				cout<< omosa [9 - i]<<" ";
			}
		}
		cout << endl;
		for(int i=0;i<10;i++)tukauka[i]=false;
                owari=0;
	}
	return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  for (int w; cin >> w, cin;) {

    vi ans;
    for (int i = 0; i < 10; ++i) {
      int g = 1 << i;
      if (w & g) ans.push_back(g);
    }
    cout << ans << endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int weight[10]={1,2,4,8,16,32,64,128,256,512,};
bool weightFlag[10];
int main(){
    int n,dummy=0;
    while(cin>>n){
        if(n>=weight[9]){
            n-=weight[9];
            weightFlag[9]=true;
        }
        if(n>=weight[8]){
            n-=weight[8];
            weightFlag[8]=true;
        }
        if(n>=weight[7]){
            n-=weight[7];
            weightFlag[7]=true;
        }
        if(n>=weight[6]){
            n-=weight[6];
            weightFlag[6]=true;
        }
        if(n>=weight[6]){
            n-=weight[6];
            weightFlag[6]=true;
        }
        if(n>=weight[5]){
            n-=weight[5];
            weightFlag[5]=true;
        }
        if(n>=weight[4]){
            n-=weight[4];
            weightFlag[4]=true;
        }
        if(n>=weight[3]){
            n-=weight[3];
            weightFlag[3]=true;
        }
        if(n>=weight[2]){
            n-=weight[2];
            weightFlag[2]=true;
        }
        if(n>=weight[1]){
            n-=weight[1];
            weightFlag[1]=true;
        }
        if(n>=weight[0]){
            n-=weight[0];
            weightFlag[0]=true;
        }
        for(int i=0;i<10;i++){
            if(weightFlag[i]){
                cout<<weight[i];
                    cout<<' ';
            }
        }
        cout<<'\b'<<endl;
        for(int i=0;i<10;i++) weightFlag[i]=false;
    }
    return 0;
}