Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		w := 512
		weights := make([]int, 10)
		for i := 9; i >= 0; i-- {
			if n >= w {
				weights[i] = w
				n -= w
			}
			w /= 2
		}

		output := []int{}
		for i := 0; i < 10; i++ {
			if weights[i] > 0 {
				output = append(output, weights[i])
			}
		}
		outputStr := fmt.Sprint(output)
		fmt.Println(outputStr[1:(len(outputStr) - 1)])
	}
}

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;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;

const int M = 512;

int main(void){
    for(int w; cin >> w; cout << endl)
        for(int a = 1, c = 0; a <= M; a *= 2)
            if(a & w) cout << (c ? " ":"") << a, c = 1;

    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,tmp[10]={512,256,128,64,32,16,8,4,2,1};
  while(cin >> n && n!=EOF){
    int cnt[10]={0};
    for(int i=0;i<10;i++){
      if(n-tmp[i]>=0){
    n-=tmp[i];
    cnt[i]++;
      }
      if(n==0) break;
    }
    int flg=0;
    for(int i=9;i>=0;i--){
      if(cnt[i]==1){
      if(flg==1)cout << " ";
    cout << tmp[i];
    flg=1;
      }
    }
    cout << endl;
  }
}

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

int main(void)
{
	int n;
	while(cin >> n)
	{
		int e = 1;
		bool first_output = true;
		for(int i=0; i<=10; i++)
		{
			if( (n & e) == e )
			{
				if(first_output)
				{
					cout << e;
					first_output = false;
				}
				else
					cout << " " << e;
			}
			e *= 2;
		}
		cout << endl;
	}
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int n;

int main()
{
  while(cin >> n){
    for(int i=0; n; n>>=1, i++) if(n & 1) cout << (1 << i) << (n >> 1 ? " " : "\n");
  }

  return 0;
}

C++: #include<iostream>

using namespace std;

void conv(int n, int a[10])
{
	for(int i=0;i<10;i++)
	{
		a[i]=n%2;
		n=n/2;
	}
}

int pow(int x, int n)
{
	int ans=1;
	for(int i=0;i<n;i++)
	{
		ans*=x;
	}
	return ans;
}

int main(void)
{
	int w;
	while(cin>>w)
	{
		int a[10];
		conv(w,a);
		for(int i=0;i<10;i++)
		{
			if(a[i]==1)
			{
				cout<<pow(2,i)<<" ";
			}
		}
		cout<<endl;
	}
}

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

using namespace std;
const int V[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
int n;

void solve(){
    vector<int> w;
    for(int i=0; i<10; i++){
        int f = n/V[i];
        if(f!=0){
            n -= V[i];
            w.push_back(V[i]);
        }
    }
    for(int i=w.size()-1; i>=0; i--){
        cout<< w[i]<<" ";
    }
    cout<<endl;
}
int main(){
    while(cin>>n){
        solve();
    }
    return 0;
}

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

int main(){
	int a;
	while(cin>>a){
		int w[10]={},j=0;
		while(a){
			rep(i,0,10){
				if(pow(2,i)<=a && a<pow(2,i+1)){
					a-=pow(2,i);
					w[i]++;
				}
			}
		}
		rep(i,0,10){
			if(w[i]){
				if(j==0){
					cout<<pow(2,i);
					j++;
				}else cout<<" "<<pow(2,i);
			}
		}
		cout<<endl;
	}
}

C++: #include <iostream>

using namespace std;

void k(int a, int* b)
{
	bool flag[10] = {};
	bool isFirst = true;

	for (int i = 9; i >= 0; i--)
	{
		if (a - b[i] >= 0)
		{
			a = a - b[i];
			flag[i] = true;
		}
	}

	for (int i = 0; i < 10; i++)
	{
		if (flag[i])
		{
			if (isFirst)
			{
				isFirst = false;
			}
			else
			{
				cout << " ";
			}
			cout << b[i];
		}
	}
	cout << endl;
}
int main()
{
	int a;
	int weights[10];

	weights[0] = 1;
	for (int i = 1; i < 10; i++)
	{
		weights[i] = weights[i - 1] * 2;
	}

	while (cin >> a)
	{
		k(a, begin(weights));
	}

	return 0;
}