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<cmath>
#include<iostream>

using namespace std;

int main(void){
	int cnt=0,j;
	double weight,hun,i;
	double dou[10];

	while(cin>>weight){
		for(i=9;i>=0;i--){
			hun=pow(2,i);
			if(weight>=hun){
				weight-=hun;
				dou[cnt]=hun;
				cnt++;
			}
		}
		cout<<dou[cnt-1];
		for(j=cnt-2;j>=0;j--)
			cout<<' '<<dou[j];
		cout<<endl;
		cnt=0;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef vector<int>V;
int main(void){
	int n,m;
	int box[10]={512,256,128,64,32,16,8,4,2,1};
	int sum;
	V v;
	int i;
	while(1){
		cin>>n;
		if(cin.eof())	break;
		m=0;
		v.clear();
		while(1){
			if(n==0||m==10)	break;
			if(n-box[m]>=0){
				//cout<<box[m]<<endl;
				n-=box[m];
				v.push_back(box[m]);
			}
			//cout<<"N="<<n<<"M="<<m<<endl;
			m++;
		}
		reverse(v.begin(),v.end());
		for(i=0;i<(int)v.size();i++){
			if(i)	cout<<" ";
			cout<<v[i];
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){
    int data[10] = {1,2,4,8,16,32,64,128,256,512};
    int ch[10];
    int sta;
    while(cin >> sta){
        memset(ch,0,sizeof(ch));
        for(int i=9;i>=0;i--){
            if(sta >= data[i]){
                sta -= data[i];
                ch[i] = 1;
            }
        }
        for(int i=0;i<10;i++){
            if(ch[i] == 1){
                cout << data[i] << " ";
            }
        }
        cout << endl;
    }
}

C++: //AOJ 0031

#include<stdio.h>
#include<iostream>
#include<vector>

using namespace std;

int main(){

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



	vector<int> input;

	int num;

	while(cin>>num){

		for(int j=0;j<10;j++){

			if(num%2==1){
				printf("%d ",data[j]);
			}
			num/=2;
		}

		printf("\n");
	}

	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    while(cin>>x){
        bool first=true;
        for(int w=1; w<1024; w<<=1){
            if(w&x){
                if(!first) cout<<' ';
                else first=false;
                cout<<w;
            }
        }
        cout<<'\n';
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int weights[10] = { 1,2,4,8,16,32,64,128,256,512 };
bool have[10] = { false,false,false,false,false,false,false,false,false,false };
int main() {
	int w;
	while (cin >> w) {
		int now = 0;
		int tmp = 0;
		for (int i = 0; i < 10; i++)have[i] = false;
		while (tmp < w) {
			tmp += weights[now];
			have[now] = true;
			now++;
		}
		while (tmp != w) {

			if (have[now]) {
				if (tmp - weights[now] >= w) {
					tmp -= weights[now];
					have[now] = false;
					now--;
				}
				else now--;
			}
			else {
				now--;
			}
		}
		for (int i = 0; i < 10; i++) {
			if (have[i]) {
				if (i != 10)cout << weights[i] << ' ';
				else cout << weights[i];
			}
		}
		cout << endl;
	}
}

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, cnt = 0;

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

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

	return 0;
}

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

using namespace std;

const int w[10]={1,2,4,8,16,32,64,128,256,512};
int c[10];
int main(void){
	int n;
	int a;
	while(~scanf("%d",&n)){
		bool b=false;
		for(a=0;a<=9;a++)c[a]=0;
		for(a=9;a>=0;a--){
			if(n>=w[a])c[a]=1,n-=w[a];
			if(n==0)break;
		}
		for(a=0;a<=9;a++){
			if(c[a]==1){
				if(b==true)cout << " " << w[a];
				if(b==false){
					cout << w[a];
					b=true;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 100000
int main(){
int w;
bool ans[10];
for(int i=0;i<11;i++){
ans[i]=0;
}
while(cin>>w){
for(int i=0;i<11;i++){
ans[i]=0;
}
for(int i=10;i--;){
if(w>=pow(2,i)){
ans[i]=1;
w=w-pow(2,i);
}
}
int i=0;
for(;i<11;i++){
if(ans[i]){
cout<<pow(2,i);
break;
}
}i++;
for(;i<11;i++){
if(ans[i]){
cout<<" "<<pow(2,i);
}
}cout<<endl;
}
return 0;
}

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

int main() {

  int n;

  while( cin >> n ) {

    bool flag = false;

    for ( int i = 1; i <= 512; i*=2 ) {

      if ( n % (i*2) != 0 ) {
	if ( flag ) cout << " ";
	flag = true;
	cout << i;
	n -= i;
      }

    }

    cout << endl;

  }

  return 0;

}

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

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
int n;

void solve() {
    int a=1;
    bool f=false;
    rep(i,10) {
        if((n>>i)&1) {
            if(f) cout<<" "<<a;
            else {
                cout<<a;
                f=true;
            }

        }
        a<<=1;
    }
    cout<<endl;

}
int main() {
    while(cin>>n) {
        solve();
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> ans;
  int n, flag;
  while(cin >> n){
    ans.clear();
    flag=0;
    if(n > 1023) return 0;
    for(int i=512; i >= 1; i /= 2){
      if(n - i >= 0){
	n -= i;
	ans.push_back(i);
      }
    }
    sort(ans.begin(), ans.end());
    vector<int>::iterator it = ans.begin();
    while( it != ans.end() ){
      if(flag == 0) {
	cout << *it;
	flag = 1;
      }
      else
	cout << " " << *it;
      ++it;
    }
    cout << endl;
    
  }
  return 0;
}