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<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int a[10]={};
		if(n>=512){
			a[1]=512;
			n-=512;
		}
		if(n>=256){
			a[2]=256;
			n-=256;
		}
		if(n>=128){
			a[3]=128;
			n-=128;
		}
		if(n>=64){
			a[4]=64;
			n-=64;
		}
		if(n>=32){
			a[5]=32;
			n-=32;
		}
		if(n>=16){
			a[6]=16;
			n-=16;
		}
		if(n>=8){
			a[7]=8;
			n-=8;
		}
		if(n>=4){
			a[8]=4;
			n-=4;
		}
		if(n>=2){
			a[9]=2;
			n-=2;
		}
		if(n==1){
			cout<<1<<" ";
		}
		int i;
		for(i=9;i>0;i--){
			if(a[i]!=0){
				cout<<a[i];break;
			}
		}
		i--;
		for(;i>0;i--){
			if(a[i]!=0){
				cout<<" "<<a[i];
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
int n;
int g;
while(cin >>n){
g=1;
while(g<1000){
if(n%(2*g)==g&&n!=0){cout <<g<<" "; n=n-g;}
else if(n%(2*g)==g&&n==g){cout <<g<<endl; n=n-g;}
g=g*2;}
}
}

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[x.size()-1-i]<<" ";
		}
		cout<<x[0]<<endl;
	}
	return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int wei[10]={1,2,4,8,16,32,64,128,256,512},kai[10];
	int w,i,j;
	while(scanf("%d",&w)!=EOF)
	{
		i=9;  j=0;
		while(0==0)
		{
			if(w-wei[i]>0){
				w-=wei[i];
				kai[j]=wei[i];
				j++;
			}
			else if(w-wei[i]==0){
				kai[j]=wei[i];
				for(i=j;i>0;i--)
					printf("%d ",kai[i]);
				printf("%d\n",kai[0]);
				break;
			}

			i--;
		}
	}
	return 0;
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int W;
int weights[10] ={1,2,4,8,16,32,64,128,256,512};
int main()
{
  while(cin>>W){
    int type[10]={0};
    for(int j = 10;j >=0;j--){
      if(W-weights[j] >=0){
	W -=weights[j];
	type[j] = 1;
      }
    }
      for(int i = 0;i <10;i++){
	if(type[i] ==1){
	  cout <<weights[i];
	  if(i !=9)
	    cout <<" ";
	}else if(i ==9)
	  cout <<endl;
      }
  }
  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]<<flush;
        }
        i++;
        break;
    }
    for(j=i;j<10;j++){
        if(weight_f[j]==1){
            cout<<" "<<weight[j]<<flush;
        }
    }
    cout<<endl;
    }
    return(0);
}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }





int main() {
	int in;
	while (cin >> in) {
		bitset<10> b(in);
		for_(i, 0, 10) if (b[i]) cout << pow(2, i) << " ";
		cout << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
V vi;

int main(){
	while (cin >> n){
		for (int i = 9; i >= 0; i--){
			if (n >= pow(2, i)){
				n -= pow(2, i);
				vi.push_back(pow(2, i));
				if (n == 0)break;
			}
		}
		sort(ALL(vi));
		REP(i, vi.size()){
			cout << vi[i];
			if (i == vi.size() - 1)cout << endl;
			else cout << " ";
		}
		vi.clear();
	}
}

C++: #include <stddef.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int g;
  vector<int> v;
  while (cin >> g) {
    v.clear();
    for (int i = 0; i < 10; i++)
      if (g & (1 << i)) v.push_back(1 << i);
    cout << v[0];
    for (size_t i = 1; i < v.size(); i++)
      cout << ' ' << v[i];
    cout << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(void)
{
    int h[10], w;
    vector<int> ans;
    rep(i, 10) {
        h[i] = pow(2.0, (double)i);
    }
    
    while (cin >> w) {
        ans.clear();
        for (int i = 9; i >= 0; i--) {
            if (w == 1) {
                ans.push_back(h[0]);
                break;
            }
            else if (h[i] <= w){
                ans.push_back(h[i]);
                w -= h[i];
            }
        }
        
        for (int i = (int)ans.size() - 1; i >= 0; i--) {
            cout << ans[i];
            i == 0 ? cout << endl : cout << " ";
        }
    }

    return 0;
}