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>
 
int main(){
    int a,b,c;
    int d[10];
     
     
    while(std::cin>>a){
        for(b=1;b<=10;b++){
        d[b]=0;
        }
         
        for(b=0;b<2;b++){
            if(a==b){
                d[1]=b;
            }else{
                for(c=0;c<3;c=c+2){
                    if(a==b+c){
                        d[1]=b;
                        d[2]=c;
                         
                         
                    }else{
                        for(int e=0;e<5;e=e+4){
            if(a==b+c+e){
                d[1]=b;
                d[2]=c;
                        d[3]=e;
                     
            }else{
                for(int f=0;f<9;f=f+8){
                    if(a==b+c+e+f){
                        d[1]=b;
                        d[2]=c;
                        d[3]=e;
                        d[4]=f;
                         
                    }else{
                        for(int g=0;g<17;g=g+16){
            if(a==b+c+e+f+g){
                d[1]=b;
                d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                         
            }else{
                for(int h=0;h<33;h=h+32){
                    if(a==b+c+e+f+g+h){
                        d[1]=b;
                        d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                         
                     
                    }else{
                        for(int i=0;i<65;i=i+64){
            if(a==b+c+e+f+g+h+i){
                d[1]=b;d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                        d[7]=i;
                         
            }else{
                for(int j=0;j<129;j=j+128){
                    if(a==b+c+e+f+g+h+i+j){
                        d[1]=b;
                        d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                        d[7]=i;
                        d[8]=j;
                         
                    }else{
                        for(int k=0;k<257;k=k+256){
            if(a==b+c+e+f+g+h+i+j+k){
                d[1]=b;
                d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                        d[7]=i;
                        d[8]=j;
                        d[9]=k;
                         
            }else{
                for(int l=0;l<513;l=l+512){
                    if(a==b+c+e+f+g+h+i+j+k+l){
                        d[1]=b;
                        d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                        d[7]=i;
                        d[8]=j;
                        d[9]=k;
                        d[10]=l;
                    }                }
            }
             
        }
                    }
                }
            }
             
        }
                    }
                }
            }
             
        }
                    }
                }
            }
             
        }
                    }
                }
            }
             
        }
        int n=0;
        for(int m=1;m<11;m++){
        if(d[m]!=0&&n==0)
        {
            std::cout<<d[m];
            n++;
        }
        else if(d[m]!=0){
            std::cout<<" "<<d[m];
        }
    }
    std::cout<<std::endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;
stack<int> sta;

int main()
{
  int w;
  int wei[10]={512,256,128,64,32,16,8,4,2,1};
  int i,j;

  while(scanf("%d",&w)!=EOF){

    rep(i,10){
      if(wei[i]<=w){
	sta.push(wei[i]);
	w-=wei[i];
      }
    }

    while(1){
      cout<<sta.top();
      sta.pop();
      if(sta.size()==0)break;
      cout<<" ";
    }//while1
    cout<<endl;

  }
}

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

int main(){
	int n,a[10];
	
	while(cin>>n){
		for(int i=0;i<10;i++) a[i]=0;
		for(int i=9;i>=0;i--){
			if(n>=pow(2,i)){
				n-=pow(2,i);
				a[i]++;
			}
		}
		for(int i=0;i<10;i++){
			if(a[i]!=0) cout << pow(2,i) << " ";
		}
		cout << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

int main(){
  int i,in;
  char to[12];
  int w[10] = {1,2,4,8,16,32,64,128,256,512};

  while(cin >> in){
    vector<int> ans;
    for(i=0;in;i++){ to[i] = in%2; in /= 2;}
    rep(i,12) if(to[i] == 1) ans.push_back(w[i]);
    rep(i,ans.size()){
      cout << ans[i];
      (i == ans.size()-1) ? cout << endl : cout << " ";
    }
  }


  return 0;
}

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

int twopow(int n)
{
	int ans = 1;
	for(int i=0;i<n;i++){
		ans *= 2;
	}
	return ans;
}

int main()
{
	int n;
	while(cin >> n){
		bool o[10] = {0};
		int mn=n;
		for(int i=0;i<10;i++){
			o[i] = (mn%2==1);
			mn/=2;
		}
		bool flag=false;
		for(int i=0;i<10;i++){
			if(o[i]==1){
				if(flag==true)
					cout << " ";
				flag = true;
				cout << twopow(i);
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
void solve(int n){
	bool exist = false;
	for(int i = 0 ; i < 11; i++){
		if(n & 1 << i){
			if(exist)cout << " ";
			cout << (1 << i);
			exist = true;
		}
	}
	cout << endl;
}
int main(){
	int n;
	while(cin >> n){
		solve(n);
	}

	return 0;
}

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

int main(int argc, const char * argv[])
{
    int cu[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
    int g, j = 0, cu2[10] = {0};
    scanf("%d", &g);
    
    for (int i = 0; i < 11; i++) {
        if ((g - cu[i]) < 0) {
            g -= cu [i - 1];
            cu2[j] = cu[i - 1];
            i = 0; j++;
        }
        if (g == 0) break;
    }
    for (int i = 0; i < j / 2; i++) {
        int tmp;
        tmp = cu2[j - 1 - i];
        cu2[j - 1 - i] = cu2[i];
        cu2[i] = tmp;
    }
    
    for (int i = 0; i < j; i++) {
        printf("%d ", cu2[i]);
    }
    puts("");
    
    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)cout<<b[i]<<(i==0?"\n":" ");
}
}
return 0;
}