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 <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

int w;
stack <int> st;

int main(){
	while(cin>>w){
		rep(i,10){
			if(w>=(int)pow(2.0,(double)9-i)){
				w-=(int)pow(2.0,(double)9-i);
				st.push((int)pow(2.0,(double)9-i));
			}
		}
		cout<<st.top();
		st.pop();
		while(!st.empty()){
			cout<<" "<<st.top();
			st.pop();
		}
		cout<<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 < 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<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
int main(void) {
    int a;
    bool p[10];
    int w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    while(cin >> a) {
        REP(i,10) p[i] = false;
        for(int i=9;i>=0;i--) {
            if(a-w[i] >= 0) {
                p[i] = true;
                a = a-w[i];
            } else {
                p[i] = false;
            }
        }
        int k;
        REP(i,10) {
            if(p[i]) k = i;
        }
        REP(i,10) {
            if(p[i]) {                                                                               
                cout << w[i];
                if(i != k) cout << " ";
            }

            if(i == k) cout << endl;
        }
    }
}

C++: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int n;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>n){
		rep(i,10)if(n>>i & 1){
			cout<<(1<<i)<<" ";
		}
		cout<<endl;
	}
}

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

using namespace std;

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

main(){
  int n;
  int i,j,temp;
  while(cin >> n){
    int c[15]={0};
    for(i=9;n!=0;i--){
      if(bun[i]<=n){
	n-=bun[i];
	c[i]=1;
      }
    }
    for(i=0;i<10;i++){
      if(c[i]==1){
	cout << bun[i];
      }
      if(c[i+1]==1){
	cout <<' ';
      }
    }
    puts("");
  }
}

C++: #include<iostream>
using namespace std;
int main(){
  int w;
  int B[10]={1,2,4,8,16,32,64,128,256,512};
  while(cin>>w){
    int u[10],c=0;
    for(int i=9;i>-1;i--){
      if(w>=B[i]){
	w-=B[i];
	u[c]=B[i];
	c++;
      }
    }
    for(int i=c-1;i>-1;i--){
      cout<<u[i];
      if(i!=0)cout<<" ";
    }
    cout<<"\n";
  }
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(all(v),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    string s = "";
    rep(i,10){
      if(n & (1 << i)){
        s += to_string(1<<i)+ " ";
      }
    }
    s.resize(s.size()-1);
    cout << s <<endl;
  }
  return 0;
}

C++: #include <stdio.h>

int main(){
  int n;
  int i;
  while(scanf("%d", &n)!=EOF){
    for(i=0;i<10;i++){
      if(n&1){
        printf("%d", 1<<i);
        if(i!=9) printf(" ");
      }
      n >>= 1;
    }
    printf("\n");
  }
}