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 <string>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

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

int main() {
    int n;
    while(cin >> n) {
        vector<int> needed;
        REP(i,10) {
            if (n / weights[i]) {
                needed.push_back(weights[i]);
                n %= weights[i];
            }
        }
        reverse(needed.begin(), needed.end());
        REP(i,needed.size()-1) {
            cout << needed[i] << " ";
        }
        cout << needed[needed.size()-1] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int weight[10];
	weight[0] = 1;
	for(int i = 1; i < 10; i++){
		weight[i] = weight[i-1]*2;
	}
	int n;
	while(cin >> n){
		vector<int> ans;
		for(int i = 10; i >= 0; i--){
			if(weight[i] <= n){
				n -= weight[i];
				ans.pb(weight[i]);
			}
			if(n == 0)break;
		}
		for(int i = ans.size()-1; i > 0; i--){
			if(i == 1)cout << ans[i] << endl;
			else  cout << ans[i] << " ";
		}
	}


	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include <iostream>

using namespace std;

int main() {
    int n = 0;

    while (scanf("%d", &n) != EOF) {
        int t = 1;

        for (int i = 0; i < 10; ++i) {
            if ((n & t) == t) {
                if (i != 0) {
                    cout << " ";
                }
                cout << t;
            }

            t *= 2;
        }
        cout << endl;
    }

    return 0;
}

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

int baigaesi(int a){
  int n=1;
  if(a == 0)
    return 1;
  else
    for(int i=0;i<a;i++)
      n *= 2;
  return n;
}

int main(){

  int n;

  while(cin >> n){
    int i;
    std::vector<int> an;

    for(i=0;;i++){
      if(n==1){
	an.push_back(1);
	break;
      }
      an.push_back(n%2);
      n /= 2;
    }

    for(int j=0;j<=i;j++){
      if(an[j] == 1)
	cout << baigaesi(j);
      if(j==i) break;
      cout << ' ';
    }
    cout << endl;
  }

  return 0;
}

C++: #include <stdio.h>

int main(void)
{
int n;
while (scanf("%d", &n) != EOF){
int i;
if ((n & 1) != 0) {
printf("1");
}
for (i = 1; i < 20; i++)
{
if (((n >> i) & 1) != 0){
printf(" %d", 2 << i);
}
}
puts("");
}

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

int main() {
	short int n;
	while (cin >> n) {
		for(int i=1; n>0; i*=2,n/=2){
			if (n % 2 == 1) {
				cout << i;
				if (n > 1)
					cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

C++: /*
	0031:Weight
*/
#include	<iostream>
#include	<cmath>

using namespace std;

int main(void) {
	while(1) {
		int w;
		int bundo[2][10] = { 0 };
		
		cin >> w;
		if( cin.eof() ) { break; }
		
		for(int i = 0; i < 10; i++) {
			bundo[0][i] = pow(2, i);
		}
		
		for(int i = 0; i < 10; i++) {
			if(w >= bundo[0][9 - i]) {
				w -= bundo[0][9 - i];
				bundo[1][9 - i] = 1;
			}
		}
		
		for(int i = 0; i < 9; i++) {
			if(bundo[1][i] == 1) {
				cout << bundo[0][i];
				for(int j = i + 1; j < 10; j++) {
					if(bundo[1][j] == 1) {
						cout << ' ';
						break;
					}
				}
			}
		}
		if(bundo[1][9] == 1) {
			cout << bundo[0][9];
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	int n;
	int tmp;
	while(cin >> n){
		vector<int> ans;
		for(int i = 9; i >= 0; i--){
			if(n - pow(2, i) >= 0){
				ans.push_back(pow(2, i));
				n -= pow(2, i);
			}
		}
		sort(ans.begin(), ans.end());
		for(int i = 0; i < ans.size() - 1; i++){
			cout << ans[i] << " ";
			tmp = i;
		}
		cout << ans[tmp + 1] << endl;
	}
}

C++: // 2012/10/28 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int obj;
		cin >> obj;

		if(cin.eof())
			break;

		bool spc = false;

		for(int i=0; i<8; i++){
			if(obj%2==1){
				if(spc){
					cout << ' ';
				}

				int wgt = 1;
				for(int j=0; j<i; j++){
					wgt *= 2;
				}
				cout << wgt;

				spc = true;
			}

			obj /= 2;
		}

		cout << endl;
	}

	return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const LL INF = 1e18;

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

int main(){
	int m;
	sort(g,g+10,greater<int>());
	while(cin>>m){
		vector<int>res;
		REP(i,10){
			if(m>=g[i]){
				m%=g[i];
				res.PB(g[i]);
			}
		}
		SORT(res);
		REP(i,SZ(res)){
			cout<<res[i];
			if(i!=SZ(res)-1)cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}
/*

*/

C++: #include<iostream>
#include<bitset>
#include<cmath>
using namespace std;
int main(){
	int weight;
	cin>>weight;
	bitset<10> num(weight);
	int i;
	for(i=0;num[i]==0;++i);
	cout<<pow(2.0,i);
	for(++i;i<10;++i){
		if(num[i]==1)cout<<' '<<pow(2.0,i);
	}
	cout<<endl;
}