Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	weight := []int{512, 256, 128, 64, 32, 16, 8, 4, 2, 1}

	for sc.Scan() {
		var wgt []int
		i, _ := strconv.Atoi(sc.Text())

		if i > 1023 {
			i = 1023
		}

		bin := fmt.Sprintf("%010b", i)

		for i := 9; i >= 0; i-- {
			if bin[i] == '1' {
				wgt = append(wgt, weight[i])
			}
		}

		for i := 0; i < len(wgt); i++ {
			if i == len(wgt)-1 {
				fmt.Printf("%d\n", wgt[i])
			} else {
				fmt.Printf("%d ", wgt[i])
			}

		}
	}

}

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

C++: #include <iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){

    int ans[1000];
    int p = 0;

    int m = n;
    for(int i = 2 ; i < m ; i*=2){
      if(i*2 > m)m = i;
    }

    for(int i = m ;i > 0; i/=2 ){
      if(n - i >= 0 ){
	ans[p++] = i;
	n -= i;
      }
    }
  for(int i = p - 1 ; i > 0 ; i-- ){
    cout << ans[i] << " ";
  }
  cout <<ans[0]<< endl;

  }
  }

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t; std::cin>>t;
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=std::stoi(s);
    for(int i=0;i<s.size();i++){if(num%10)std::cout<<pow(2,(double)(i))<<" "; num/=10;}
    std::cout<<std::endl;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int data[10];
    data[0] = 1;
    REP(i,1,10) data[i] = data[i-1] * 2;
    while(true) {
        int n;
        cin >>n;
        if(n==EOF) break;

        bool check[10];
        rep(i, 10) check[i] = false;
        for(int i=9; i>=0; --i) {
            if(n>=data[i]) {
                n -= data[i];
                check[i] = true;
            }
        }

        bool check2 = false;
        rep(i, 10) {
            if(check[i]) {
                if(check2) cout << " ";
                else check2 = true;
                cout << data[i];
            }
        }
        cout << endl;
    }
    return 0;
}