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>
#include<iostream>
#include <vector>
#include <cstdio>
#include<algorithm>
#include <utility>
#include<string>
using namespace std;
int main() {
	int  count=0,w, weight[10] = { 512,256,128,64,32,16,8,4,2,1 };
	bool bo[10] = { false };
	while (cin >> w) {
		for (int i = 0; i < 10; i++) {
			if (w == 0) {
				break;
			}
			if (w >= weight[i]) {
				w -= weight[i];
				count++;
				bo[i] = true;
			}
		}
		for (int i = 9; i >= 0; i--) {
			if (bo[i] && count == 1) {
				cout << weight[i] << endl;
				bo[i] = false;
				count = 0;
			}
			else if (bo[i]) {
				count--;
				cout << weight[i] << " ";
				bo[i] = false;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int g[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int w;
  vector<int> sum;
  
  while(cin >> w) {
    sum.clear();
    for(int i = 9 ; i >= 0 ; i--) {
      if(g[i] <= w) {
	w -= g[i];
	sum.push_back(g[i]);
      }
    }
    sort(sum.begin(), sum.end());
    for(int i = 0 ; i < sum.size() ; i++) {
      if(i != sum.size()-1) cout << sum[i] << ' ';
      else cout << sum[i] << endl;
    }
  } 
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int main() {
	for (int n; cin >> n; ) {
		for (int i = 0; (n >> i); i++) if ((n >> i) & 1) cout << (1 << i) <<' ';
		cout << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>

int main()
{
	int n;
	int i;
	int weight[]={1,2,4,8,16,32,64,128,256,512};
	bool isFirsttime;

	while(scanf("%d", &n)!=EOF){
		isFirsttime=true;
		for(i=0; i<10; i++){
			if(n%2==1){
				if(isFirsttime){ printf("%d", weight[i]); isFirsttime=false; }
				else printf(" %d", weight[i]);
			}
			n = n>>1;
		}
		printf("\n");
	}

	return 0;
}

C++: #include <cstdio>
#include <queue>
using namespace std;

int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main(void)
{
    int sum;
    priority_queue < int, vector<int>, greater<int> > ans;
    
    while (scanf("%d", &sum) != EOF) {
        for (int i = 9; 0 <= i; i--){
            if (sum <= 1){
                if (sum == 1){
                    ans.push(sum);
                    break;
                }
            }
            else if (weight[i] <= sum){
                sum -= weight[i];
                ans.push(weight[i]);
            }
        }
        while (!ans.empty()){
            printf("%d", ans.top());
            ans.pop();
            if (ans.empty()) printf("\n");
            else printf(" ");
        }
    }
    
    return (0);
}

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

int main(){
    int n;
    while(scanf("%d",&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()-1;i++)
            cout<<vec[vec.size()-1-i]<<" ";
        cout<<vec[0]<<endl;
    }
    return 0;
}

C++: #include<stdio.h>
int ex(int n)
{
    if(n == 0)return 1;
    return ex(n - 1) * 2;
}
int main()
{
    int n;
    while(scanf("%d",&n) != -1)
    {
        int mem[10] = {0};
        for(int i = 9; i >= 0; i--)
        {
            if(n >= ex(i))mem[i] = 1,n -= ex(i);
        }
        n = 0;
        for(int i = 0; i < 10; i++)
        {
            if(n != 0)printf(" ");
            if(mem[i] == 1)printf("%d",ex(i)),n++;
        }
        printf("\n");
    }
    return 0;
}

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

using namespace std;

const int weight[] = {1,2,4,8,16,32,64,128,256,512};

int main(){
  int req,i,n;
  stack<int> st;
  while(cin >> req) {
    n=0;
    for(i=9;i>=0;i--){
      if(req >= n + weight[i]) {
	n += weight[i];
	st.push(weight[i]);
      }
    }
    while(st.size()){
      n = st.top(); st.pop();
      cout << n;
      if(st.size()) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main(){
	int f[9]={2,4,8,16,32,64,128,256,512};
	int s[9]={0};
	int w,i,h=0;
	while(scanf("%d",&w)!=EOF){
		for(h=0,i=0;i<9;i++){s[i]=0;}
		if(w%2==1){h+=1;printf("1 ");}
		for(i=0;i<9;i++){
			if(w>h){h+=f[i];s[i]=1;}
			if(w<h){h-=f[i-1];s[i-1]=0;}
			if(w==h){break;}
		}
		for(i=0;i<9;i++){
			if(s[i]==1){
				printf("%d ",f[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main() {

	int weight;
	int temp[10];
	temp[9] = 512;
	vector<int> ans;

	for (int i = 8; i >= 0; i--)
		temp[i] = temp[i + 1] / 2;

	while (cin >> weight) {

		ans.clear();

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

			if (weight - temp[i] >= 0) {

				weight -= temp[i];
				ans.push_back(temp[i]);

			}
		}

		for (int i = ans.size() - 1; i > 0; i--)
			cout << ans[i] << " ";

		cout << ans[0] << "\n";

	}
	return 0;

}

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

int main(){
  int w;
  int b[10]={0};

  while(std::cin >> w){
    for(int i=0;i<10;i++){
      b[i] = 0;
    }
    for(int i=9;i>=0;i--){
      if(w>=std::pow(2,i)){
        w = w - std::pow(2,i);
        b[i] = 1;
      }
    }
    for(int i=0;i<10;i++){
      if(b[i] == 1){
        std::cout << std::pow(2,i) << ' ';
      }
    }
    std::cout << std::endl;
  }
}

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

int x;

void func(int p2, int y, int first)
{
	int flag = 0;
	
	if (y == 0) {
		return;
	}
	
	if (y >= p2) {
		func(p2 / 2, y - p2, 0);
		flag = 1;
	}
	else {
		func(p2 / 2, y, first);
	}
	
	if (flag == 1) {
		cout << p2;
		if (first) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}
}

int main()
{
	while (cin >> x) {
		func(512, x, 1);
	}
	
	return 0;
}