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>
using namespace std;

int main() {
  int w = 0;
  while (cin >> w, w) {
    for(int i = 0; i < 32; i++) {
      if(w & (1<<i)) {
        cout << (1 << i) << " ";
      }
    }
    w = 0;
    cout << endl;
  }
}

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

using namespace std;

int main(void){
	int n;
	while(cin >> n){
		for (int i=0; i<10; i++){
			if (n%2==1){
				cout << (int)pow(2.0,i);
				n = (n-1)/2;
				
			if (n==0){
				cout << endl;
				break;
			}else{
				cout << " ";
			}
			}else{
				n = n/2;
			}
		}
	}



	return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int w;
	while (cin >> w) {
		int i(1),cnt(0);
		while (w) {
			if (w & 1) {
				if (cnt++)cout << " ";
				cout << i;
			}
			i *= 2;
			w >>= 1;
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
    int bunndo[10]={1,2,4,8,16,32,64,128,256,512},n,cnt=0;
    while(cin>>n){
        bool num[10]={0};
        for(int i=9;i>=0;i--){
            if(n-bunndo[i]>=0){
                n=n-bunndo[i];
                num[i]=1;
                if(n==0)break;
            }
        }
        for(int i=0;i<10;i++){
            if(num[i]==1){
                if(cnt==0){
                    cnt=1;
                    cout<<bunndo[i];
                }else{
                    cout<<" "<<bunndo[i];
                }
            }
        }
        cnt=0;
        cout<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(void)
{
int x;
while(cin>>x)
{
int a[10]={1,2,4,8,16,32,64,128,256,512};
int b[10]={0};

int j=0;
for(int i=9;i>=0;i--)
{
	if(x>=a[i])
	{
	x-=a[i];
	b[j]=a[i];
	j++;
	if(x==0)break;
	}
}
for(int i=9;i>=0;i--)
{
if(b[i]==0)continue;
else if(b[i]!=0)cout<<b[i]<<(i==0?"\n":" ");
}
}
return 0;
}

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

int main(){
	int n;
	int a[]={1,2,4,8,16,32,64,128,256,512};
	while(cin>>n){
		vector<int> x;
		for(int i=0;i<10;i++){
			if(n/a[10-i-1]==1){
				//cout<<a[10-1-i]<<endl;
				n-=a[10-i-1];
				x.push_back(a[10-i-1]);
				if(n==0)break;
			}
		}
		
		for(int i=0;i<x.size()-1;i++){
			cout<<x[i]<<" ";
		}
		cout<<x[x.size()-1]<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n)
	{
		bitset<10> o = n;

		rep(i, 10)
			if(o[i])
				cout << pow(2.0, i) << (pow(2.0, i+1) < n ? " " : "");

		cout << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main() {
    int M,scale[10];
    scale[0]=1;
    for(int i=1;i<10;i++){
    scale[i] = scale[i-1]*2;
    }
    while(cin >> M){
    int i=0;
    int count=2;
    while(true){
        if(M==0) break;
        if(M % count!=0){
            M -= scale[i];
            if(M != 0){
            cout << scale[i] << " ";
            }
            else{
            cout << scale[i] <<endl;
            }
        }
        i++;
        count *= 2;
    }
    }
}

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

int main() {
  int d,a;

  while(cin>>d){
    a=1;
    for(;a<=d;a=a<<1) {
      if(a&d) cout<<a;
      if(d/a>2) cout<<" ";
    }
    cout<<endl;

    /*
    a=1;
    for(;d>0;) {
      if(d%2==1) {
	cout<<a;
	d--;
	if(d>0) cout<<" ";
      }
      d/=2;
      a*=2;
    }
    cout<<endl;
    */
  }

}

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

using namespace std;

int main()
{
	vector<int> bd;
	int n, cont;
	int weight[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

	while(1){
		bd.clear();
		cont = 0;
		cin >> n;

		if(cin.eof())    break;

		while(n != 0){
			bd.push_back(n % 2);	
			n /= 2;
			cont++;
		}

		for(int i = 0; i < cont; i++){
			if(bd[i] == 1){
				cout << weight[i];
				if(i+1 != cont)
					cout << " ";
			}
		}

		cout << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

string ans;

void func(int cnt,int w,string s){
 	if(cnt>=10){
 		if(w==0){
 			ans=s;
 		}
 	}else{
 		func(cnt+1,w,s);
 		s+=cnt+'0';
 		func(cnt+1,w-pow(2,cnt),s);
 	}
 }

int main(){
	int n;
	string s;
	while(cin>>n){
		s="";
		func(0,n,s);
		rep(i,ans.size()){
			cout<<pow(2,(int)(ans[i]-'0'));
			if(i==(ans.size()-1)){
				cout<<endl;
			}else{
				cout<<" ";
			}
		}
	}
	return 0;
}

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

using namespace std;

int main(void){
    int i,j,k,l;
    int n;
    int weight[10]={1,2,4,8,16,32,64,128,256,512};
    int weight_f[10];
    
    while(cin>>n){
    
    memset(weight_f,0,sizeof(weight_f));
    
    for(i=9;i>=0;i--){
        if(n-weight[i]>=0){
            n=n-weight[i];
            weight_f[i]=1;
        }
    }
    i=0;
    while(true){
        if(weight_f[i]==1){
            cout<<weight[i];
        }
        i++;
        break;
    }
    for(j=i;j<10;j++){
        if(weight_f[j]==1){
            cout<<" "<<weight[j];
        }
    }
    cout<<endl;
    }
    return(0);
}

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++;
			}
		}
		for(j=cnt-1;j>=0;j--)
			cout<<dou[j]<<' ';
		cout<<endl;
		cnt=0;
	}

	return 0;
}

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

int main()
{
	int w;

	while (cin >> w){
		for (int i = 1; i <= 512; i *= 2){
			if (w % (i * 2) != 0){ // next check
				cout << i;
				w -= i;
				if (w != 0){
					cout << " ";
				}
			}
			if (w == 0){
				cout << endl;
				break;
			}
		}
	}

	return (0);
}