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>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n;
	while (cin >> n) {
		ostringstream oss;
		for (int i = 0; n; i++) {
			if (n & 1)oss << pow(2, i) << ' ';
			n >>= 1;
		}
		oss.str().pop_back();
		cout << oss.str() << endl;
	}
	return 0;
}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0031&lang=jp

#include <algorithm>
#include <iostream>
#include <vector>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <math.h>
#include <iomanip>
#include <sstream>

using namespace std;

//テ」ツδ榲」ツつッテ」ツδュテ・ツョツ堙ァツセツゥ
#define ALL(v) (v).begin(),(v).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define SORT(x) sort(begin(x),end(x))
#define SELECT_SORT(x, n) sort(begin(x),begin(x)+n)
#define SWAP(type, a, b) do {type tmp = a; a = b; b = tmp;} while (0)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))

//テ・ツョツ堙ヲツ閉ー
#define INF 2000000000000
#define MAX 10

//DEBUGテァツ板ィ
#define BAR() cout << "----------------------------" << endl;
#define DUMP(v) (cerr << #v << ": " << v << endl)
#define PRINT(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

vector<int> weight;

void binary(int x)
{
	int y,i,ans;
	ans=0;
	i=0;
	bool first=true;
	while (x>0)
	{
		y=x%2;
		ans=ans+y*pow(10,i);
		if(y){
			if(first){
				cout << weight[i]; first=false;
			}else{
				cout << " " << weight[i];
			}
		}
		x=x/2;
		i=i+1;
	}
	return;
}

int main()
{
	weight.push_back(1);
	for(int i=1; i<10; ++i){
		weight.push_back(weight[i-1]*2);
	}
	
	int obj;
	
	while(cin >> obj)
	{
		
		binary(obj);
		cout << endl;
	}
	
}

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

int main()
{
	int weight, j, i;
	MakeTable();

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

	return 0;
}

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

int main(){

  int n;

  while(cin >> n){

    int z = 512,a[100] = {0},count = 0,count2 = 0;

    for(int i=10;i>0;i--){

      if(n - z >= 0){
	n -= z;
	a[i] = z;
	count++;
      }
      z /= 2;
    }

    for(int i=1;i<=10;i++){

      if(a[i] != 0){
	cout << a[i];
	count2++;

	if(count2 == count) break;
	cout << " ";

      }
    }

    cout << endl;

  }
}

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

using namespace std;

int main() {
	int a;
	while (cin >> a) {
		int p[10] = {0};
		int count = a;
		int han;
		while (count != 0) {
			//hantei = 0;
			for (int i = 9; i >= 0; i--) {
				if (count >= (int)pow(2,i)) {
					count -= (int)pow(2,i);
					p[i] = 1;
					//hantei = 1;
					break;
				}
			}
		}
		for (int i = 0; i < 10; i++) {
			if (p[i] == 1) {
				cout << (int)pow(2,i);
				han = i+1;
				break;
			}
		}

		for (int i = han; i < 10; i++) {
			if (p[i] == 1) {
				cout << " " << (int)pow(2,i);
			}
		}

		cout << endl;
	}
	return 0;
}

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

int main() {
	for(int n; cin >> n;) {
		vector<int> ans;

		for(int bit = 1; bit < n; bit <<= 1) {
			if(bit & n) ans.emplace_back(bit);
		}

		for(unsigned i = 0; i < ans.size(); ++i) {
			cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");
		}
	}

	return EXIT_SUCCESS;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

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

C++: #include <iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){
	int flag = 1;
	for(int i = 0;i < 10;i++){	  
	  if((n & (1<<i)) && flag){
		flag = 0;
		cout << (1<<i);
	  }else if((n & (1<<i)) && !flag){
		cout << " " << (1<<i);
	  }


	}
	cout << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int a;
	int b=512;
	int c[10]={0};
	int d=0;
        while(cin>>a){

            int i=0;
            if (a>=512){
                a-=512;
                c[i]=512;
                i++;
            }
            if (a>=256){
                a-=256;
                c[i]=256;
                i++;
            }
            if (a>=128){
                a-=128;
                c[i]=128;
                i++;
            }
            if (a>=64){
                a-=64;
                c[i]=64;
                i++;
            }
            if (a>=32){
                a-=32;
                c[i]=32;
                i++;
            }
            if (a>=16){
                a-=16;
                c[i]=16;
                i++;
            }
            if (a>=8){
                a-=8;
                c[i]=8;
                i++;
            }
            if (a>=4){
                a-=4;
                c[i]=4;
                i++;
            }
            if (a>=2){
                a-=2;
                c[i]=2;
                i++;
            }
            if (a>=1){
                a-=1;
                c[i]=1;
                i++;
            }

            for(i-=1;i>=0;i--){
                cout<<c[i]<<" ";

            }
            cout<<endl;
        }
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define gt first
#define gc second.first
#define gr second.second
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,g;
	while(scanf("%d",&n)!=EOF){
		g = 1;
		while(n > 0){
			if(n%2){
				cout << g << ((n/2)?" ":"\n");
			}
			n /= 2;
			g *= 2;
		}
	}
}