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<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;
}

C++: #include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    int weight;
    while(cin >> weight)
{
        vector<int> vi;
        for(int i = 512; weight != 0; i = i / 2)
{
            if(weight >= i)
{
                weight -= i;
                vi.push_back(i);
            }
        }
        int size = vi.size();
        if(size > 0)
{
            cout << vi[size - 1];
            for(int i = size - 2; i >= 0; i--)
{
                cout << " " << vi[i];
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(void)
{
int n;
while (scanf("%d", &n) != EOF){
int i;
if ((n & 1) != 0) {
printf("1");
}
for (i = 1; i < 20; i++)
{
if (((n >> i) & 1) != 0
printf(" %d", 2 << i);
}
}
puts("");
}

C++: #include <iostream>

using namespace std;

void solve()
{
	int weight[10];
	int c = 1;
	for(int i = 0; i < 10; ++i)
	{
		weight[i] = c;
		c *= 2;
	}
	int w;
	while(cin >> w)
	{
		bool useWeight[10] = {false};
		int lastPoint = 0;
		for(int i = 9; i >= 0; --i)
		{
			if(w >= weight[i])
			{
				w -= weight[i];
				useWeight[i] = true;
				if(lastPoint < i)
				{
					lastPoint = i;
				}
			}
		}
		for(int i = 0; i < lastPoint; ++i)
		{
			if(useWeight[i])
			{
				cout << weight[i];
				cout << " ";
			}
		}
		cout << weight[lastPoint] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
using namespace std;
int main() {
  int n;
  while(cin>>n) {
    for(int i=0; i<10; i++) {
      if(n&1) {
	cout << (1<<i);
	cout << (n ? ' ' : '\n');
      }
      n >>= 1;
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;

vi dec2binv(int n){
	vi x;
	while (n>0){
		if (n%2==1) x.push_back(1);
		else x.push_back(0);
		n/=2;
	}
	if (x.empty()) x.push_back(0);
	return x;
}

int main(void){

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

	while (true){
		int n;
		cin>>n;
		if (cin.eof()) break;
		vi tmp = dec2binv(n);
		for (int i=0; i<int(tmp.size()); i++){
			if (tmp[i]==1) cout<<weight[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,r,n) for(int i=r;i<(int)n;i++)
using namespace std;
int in(){int x;cin>>x;return x;}
string s[10]={"1","2","4","8","16","32","64","128","256","512"};
int ss[10]={1,2,4,8,16,32,64,128,256,512};
string ans[1200];
bool fis=false;
void sss(string z,int y,int l)
{
	ans[y]=z;
	if(l==10)return ;
	sss(z,y,l+1);
	if(l!=0)z+=" ";
	z+=s[l];
	y+=ss[l];
	sss(z,y,l+1);
	return ;

}


int main ()
{
	fis=false;
	int a;
	sss("",0,0);	
	while(scanf("%d",&a)!=EOF)
	{
		cout<<ans[a]<<endl;
	}

	return 0;
}

C++: #include <stdio.h>
int main(){
	int a;
	int weight[10]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	while(~scanf("%d",&a)){
		bool t[10];
		for(int i=9;i>-1;i--) t[i]=false;
		for(int i=9;i>-1;i--){
			if(weight[i]<=a){
				a-=weight[i];
				t[i]=true;
			}
		}
		for(int i=0;i<10;i++){
			if(t[i]) printf("%d ",weight[i]);
		}
		printf("\n");
	}
	return 0;
}