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>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

int V[10] = { 1,2,4,8,16,32,64,128,256,512 };
bool judge[10] = { false };

int main() {

	int n;

	while (cin >> n, n) {
		REPR(i,9) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		REP(i,10) {
			if (i != 0 && judge[i] == true)cout << " " << V[i];
			if (i == 0 && judge[i] == true)cout << V[i];
			judge[i] = false;
		}
		cout << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstdint>

int main()
{
	std::uint16_t weight_of_obj;
	while (std::cin >> weight_of_obj) {
		std::vector<std::uint16_t> weights;
		std::uint16_t weight = 1;
		while (weight_of_obj != 0) {
			if ((weight_of_obj & 1) == 1) {
				weights.push_back(weight);
			}
			weight_of_obj >>= 1;
			weight *= 2;
		}
		std::copy(weights.begin(), weights.end() - 1,
				std::ostream_iterator<std::uint16_t>(std::cout, " "));
		std::cout << weights.back() << std::endl;
	}

	return 0;
}

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

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
#include <cstdio>
#include <stack>
using namespace std;

// Weight(0031)
int main()
{
	int n;
	const int pow2[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	while (cin >> n) {
		vector<int> ans(10, 0);
		int p_i = 9;
		while (p_i >= 0) {
			if (n >= pow2[p_i]) {
				n -= pow2[p_i];
				ans[p_i] = 1;
			}
			--p_i;
		}

		for (unsigned int i = 0; i < ans.size(); ++i) {
			if (ans[i])
				cout << pow2[i] << " ";
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#include <string>

#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;




int main(){
  int n;


  while (std::cin >> n) {
    int weight[10]={0};

    for(int j=9;j>=0;j--){
      if(n>=pow(2,j)){
        weight[j]=1;
        n-=pow(2,j);
      }
    }

    // for(int i=0;i<9;i++){
    //   if(weight[i]==1){
    //     std::cout << pow(2,i)<<" ";
    //   }
    // }
    // if(weight[9]==1){
    //   std::cout << "512" << '\n';
    // }

    int flag;
    int count=0;
    for(int i=9;i>=0;i--){
      if(count==2)break;
      if(weight[i]==1){
        flag=i;
        count++;
      }
    }

    if(count==1){
      std::cout << pow(2,flag) << '\n';
    }else{
      for(int i=0;i<=flag;i++){
        if(weight[i]==1){
          std::cout << pow(2,i) << " ";
        }
      }
      for(int i=9;i>=0;i--){
        if(weight[i]==1){
          std::cout << pow(2,i) << '\n';
          break;
        }
      }

    }



  }
}

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

int main()
{
    int n,weight;
	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};
	
		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}
		for(int i=0; i<10 ; i++){
			if(flag[i]!=0){
				cout << w[i] ;
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int w;
        if(!(cin >> w))
            return 0;

        int tmp = 1;
        bool first = true;
        while(w > 0){
            if(w % 2 == 1){
                if(first)
                    first = false;
                else
                    cout << ' ';
                cout << tmp;
            }
            w /= 2;
            tmp *= 2;
        }
        cout << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
	int w;
	while (cin >> w) {
		bool first_output = true;
		for (int weight = 1; w>0; w>>=1, weight<<=1) {
			if ((w&1)==1) {
				if (!first_output) cout << " ";
				cout << weight;
				first_output = false;
			}
		}
		cout << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int now[10]={0};
	int max=0;
	bool brank=false;
	while(cin>>n){
		for(int i=512;i>=1;i/=2){
			if(n>=i){n-=i;now[max]=i;max++;}
		}
		while(max>=1){
			if(brank==true)cout<<" ";
			if(brank==false)brank=true;
			cout<<now[max-1];
			max--;
		}
		brank=false;
	}
}

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

int main(){
	int n;
	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(); i++){
			cout << ans[i] << " ";
		}
		cout << endl;
	}
}

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

int main(){
    int n;
    while(cin>>n,n!=EOF){
        vector<int>vec;
        for(int i=512;i>0;i=i>>1){
            if(n>=i){
                n-=i;
                vec.push_back(i);
            }
        }
        for(int i=0;i<vec.size();i++)
            cout<<vec[vec.size()-1-i]<<" ";
        cout<<endl;
    }
    return 0;
}

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