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<iostream>
using namespace std;

int main(){
	int N, total;
	while (cin >> N) {
		for (int i = 0; i < 10; i++) {
			if (N & 1) {
				total = 1 << i;
				cout << total;
				if (N >> 1) {
					cout << ' ';
				}
			}
			N >>= 1;
		}
		cout << endl;
	}
}

C++: #include<iostream>
#include<vector>
int n=1024;
std::vector<int> g;

int main(){
	int a;
	while(std::cin>>a){
		int n_=0;
		bool f=true;
		while(1){
			if(n<a&&f)g.push_back(n),a-=n,n_=n,f=false;
			else if(n<a)g.push_back(n),a-=n;
			else n/=2;
			if(a==1){
				g.push_back(1);
				break;
			}
		}
		
		for(std::vector<int>::reverse_iterator it = g.rbegin();it!=g.rend();++it){
			std::cout<<*it;
			if(*it!=n_)std::cout<<" ";
		}
		std::cout<<std::endl;
		n=1024;
	}
	return 0;
}

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

int main() {
  int data[] = {1,2,4,8,16,32,64,128,256,512};
  int n;
  while ( cin >> n ) {
    vector<int> num;
    num.clear();
    for ( int i = 9; i >= 0; i-- ) {
      if ( n - data[i] >= 0 ) {
	n-= data[i];
	num.push_back(data[i]);
      }
    }
    for ( int i = num.size()-1; i >= 0; i-- ) {
      if ( i == 0 ) cout << num[i] << endl;
      else cout << num[i] << " ";
    }
  }

  return 0;
}

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

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int W;
int weights[10] ={1,2,4,8,16,32,64,128,256,512};
int main()
{
  while(cin>>W){
    if(cin.eof())
      break;
    int type[10]={0};
    int first = 100;
    for(int j = 9;j >=0;j--){
      if(W-weights[j] >=0){
	W -=weights[j];
	type[j] = 1;
	if(first ==100)
	  first =j;
      }
    }
      for(int i = 0;i <=first;i++){
	if(type[i] ==1){
	  cout <<weights[i];
	  if(i !=first){
	  cout <<" ";
	  }
	}
	if(i ==first)
	  cout <<endl;
      }
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<memory.h>
using namespace std;
const int g[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
int f[10] = { 0 };
vector<int> p;
int main()
{
	int n;
	while (cin >> n){
		p.clear();
		memset(f, 0, sizeof(f));
		
		
		while (n != 0){
			for (int i = 9; i >= 0; i--){
				if (n - g[i] >= 0 && f[i] == 0){
					n -= g[i];
					f[i] = 1;
					p.push_back(g[i]);
				}
			}
		}
		for (int i = p.size() - 1; i >= 1; i--){
			cout << p[i] << " ";
		}
		cout << p[0] << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
int n;
int g;
while(cin >>n){
g=1;
while(g<1000){
if(n%(2*g)==g&&n!=g){cout <<g<<" "; n=n-g;}
else if(n%(2*g)==g&&n==g){cout <<g<<endl; n=n-g;}
g=g*2;}
}
}

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 << " ";
						}
					}
				}
				cout << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n)
	{
		bitset<10> o = n;

		rep(i, 10)
			if(o[i])
				cout << pow(2.0, i) << " ";
		cout << endl;
	}
}

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

bool used[10], ans[10], endR;
int bundo[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

void init(){ for(int i = 0; i < 10; i++) used[i] = false; endR = false;}

void copyAns(){
  for(int i = 0; i < 10; i++) ans[i] = used[i];
}

void dfs(int i, int w){
  if(w == 0) { copyAns(); endR = true; return; }
  if(i == 10 || w < 0 || endR) return;

  if(!used[i]){
    used[i] = true;
    dfs(i + 1, w - bundo[i]);
  }
  used[i] = false;
  dfs(i + 1, w);
}

int main(void){
  int w;
  while(cin >> w){
    init();
    dfs(0, w);
    for(int i = 0; i < 10; i++){
      if(ans[i]) cout << bundo[i];
      if(ans[i] && i < 9) cout << " ";
    }
    cout << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,wei[10],ka=1,temp,ba[10];
  for(int i=0;i<10;i++){
    wei[i]=ka;
    ka*=2;
  }
   while(cin>>n){
     temp=-1;
    for(int i=0;i<10;i++){
      ba[i]=0;
    }
    for(int i=9;i>=0;i--){
      if(n!=0){
	if(n-wei[i]>=0){
	  n-=wei[i];
	  ba[i]=wei[i];
	}
      }if(n==0){
	break;
      }
    }
    for(int i=0;i<10;i++){
      if(ba[i]!=0){
	temp++;
      }
    }
    for(int i=0;i<10;i++){
      if(ba[i]!=0){
	cout<<ba[i];
	if(temp>0){
	  cout<<" ";
	  temp--;
	}
      }
    }
    cout<<endl;
  }
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int x;
  while(cin>>x) {
    int a=0;
    for (int i=0; x>>i; i++) {
      if (1&(x>>i)) {
        if (a) cout << " ";
        cout << (1<<i);
        a=1;
      }
    }
    cout << endl;
  }
}