Go: 
package main

import (
	"fmt"
	"math"
)

func solve(n int) int {
	i := 0
	for {
		if val := math.Pow(2, float64(i)); val*2 > float64(n) {
			return int(val)
		}
		i++
	}
}

func main() {
	for {
		var n int
		_, err := fmt.Scan(&n)
		if err != nil {
			break
		}

		res := []int{}
		for {
			val := solve(n)
			res = append(res, val)
			n -= val

			if n <= 0 {
				break
			}
		}

		for i := range res {
			if i != 0 {
				fmt.Print(" ")
			}
			fmt.Print(res[len(res)-i-1])
		}
		fmt.Println()
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int n;
	while(~scanf("%d",&n)){
		bool f = false;
		for(int i=0; (1<<i)<=n; i++)if( n&(1<<i) ){
			if( f )putchar(' ');
			printf("%d",1<<i);
			f = true;
		}
		puts("");
	}
	return 0;
}

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

int main()
{
    int n;
	int w[10]={1,2,4,8,16,32,64,128,256,512};
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
	
		// n - w[i] で引けた配列番号を flag[i] で記憶

		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}

		// flag[i] が 0 でなければ w[i] を表示

		for(int i=0; i<9 ; i++){
			if(flag[i]!=0){
				cout << w[i] <<" ";
			}
		}
		if(flag[9]!=0){
			cout << w[9];
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{
    for (int w; cin >> w;) {
        bool first = true; // flag for output
        for (int x = 1; w; x <<= 1) {
            int result = w & x;
            if (result) {
                if (first) {
                    first = false;
                    cout << result;
                } else
                    cout << " " << result;
                w -= x;
            }
        }
        cout << endl;
    }

    return 0;
}

C++: //-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef  long long LL;
typedef  vector<int> VI;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#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())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int wheit[10] = { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };
	int a;
	while (cin >> a)
	{
		VI ANS;
		REP(i, 10)
		{
			if (a >= wheit[i])
			{
				a -= wheit[i];
				ANS.push_back(wheit[i]);
			}
		}
		REP(i, SZ(ANS))
		{
			if (i != SZ(ANS) - 1 || i == 0)
			{
				cout << ANS[SZ(ANS) - i];
			}
			else
			{
				cout << " ";
				cout << ANS[SZ(ANS) - i];
			}
		}
		cout << endl;
	}
#ifdef _DEBUG
	while (1);
#endif // _DEBUG

	return 0;
}

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

int main() {
	int we[10] = { 1,2,4,8,16,32,64,128,256,512 };
	int n;
	vector<int>v;
	vector<int>::iterator pv=v.begin();
	while (cin >> n) {
		int h = 9;
		while (n == 0) {
			if (n - we[h] > 0) {
				n -= we[h];
				v.push_back(h);
			}
			h--;
		}
		for (int i = v.size(); i >-1; i--) {
			cout << we[*pv];
			pv++;
			if (i != 0) { cout <<" "; }
			else { cout << endl; }
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  bool f, g = 0;
  int n, i;
  while (cin >> n) {
    if (g) {
      cout << endl;
      g = 0;
    }
    f = 0;
    for (i = 0; i < 10; i++) {
      if (f) {
        cout << ' ';
        f = 0;
      }
      if (n & 1 << i) {
        cout << (1 << i);
        f = 1;
      }
    }
    g = 1;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    int weight;
    while(cin >> weight)
{
        vector<int> vi;
        for(int i = 512; weight != 0; i = i / 2)
{
            if(weight >= i)
{
                weight -= i;
                vi.push_back(i);
            }
        }
        int size = vi.size();
        if(size > 0)
{
            cout << vi[size - 1];
            for(int i = size - 2; i >= 0; i--)
{
                cout << " " << vi[i];
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int w;
	while( cin >> w ) {
		vector<int> a;

		int x = 0;
		for( int i = 0; i < 10; ++i ) {
			if( w & (1 << i) ) {
				x |= 1 << i;
				a.push_back( 1 << i );
			}

			if( x == w ) {
				break;
			}
		}

		for( int i = 0; i < a.size(); ++i ) {
			cout << a[i] << (i < a.size()-1 ? ' ' : '\n');
		}
	}
}

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 < 1024 ; i++ )
	{
		tmp = i;
		for ( j = 0 ; j < 10 ; j++ )
		{
			bit_table[i][j] = tmp % 2;
			sum_table[i] = bit_table[i][j] * weight_array[j] + sum_table[i];
			tmp = tmp >> 1;
		}
	}
}

void PrintTable()
{
	for ( int i = 0 ; i < 1024 ; i++ )
	{
		cout << i << " " << sum_table[i] << " {";
		for ( int j = 0 ; j < 10 ; j++ )
		{
			cout << bit_table[i][j] << " ";
		}
		cout << "}" << endl;
	}
}

int main()
{
	int weight, j, i;
	MakeTable();
	//PrintTable();
	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] << " ";
					}
					if( j == 9 )
					{
						cout << endl;
					}
				}
				break;
			}
		}
	}

	return 0;
}