Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		first := true
		beki := 1
		for num != 0 {
			if num % 2 == 1 {
				if !first {
					fmt.Print(" ")
				}
				fmt.Print(beki)
				first = false
			}
			num /= 2
			beki *= 2
		}
		fmt.Println()
	}
}

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

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

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    vector<int> ans;
    if (n % 2 == 1) {
      n -= 1;
      ans.push_back(1);
    }
    int t = 2;
    while (n) {
      if ((int)log2(n) == log2(n)) {
        ans.push_back(n);
        break;
      }
      n -= t;
      ans.push_back(t);
      t *= 2;
    }
    REP(i, ans.size()) {
      cout << ans[i] << SPACE;
    }
    cout << endl;
  }
	return 0;
}
// END   //////////////////////////////////////////////////////////////

C++: #include <iostream>

using namespace std;

int main()
{
    int input;
    const int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    bool check[10];

    while (cin >> input) {
        for (int i = 0; i < 10; i++)
            check[i] = false;

        int tmp = input;
        for (int i = 0; tmp != 0; i++) {
            if (tmp % 2)
                check[i] = true;
            tmp /= 2;
        }

        for (int i = 0; i < 10; i++)
            if (check[i])
                cout << weight[i] << " ";
        cout << '\b' << endl;
    }

    return 0;
}

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