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

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

int main(){
  int n;
  while(cin>>n){
    int last = -1;
    for(int i=0;i<10 && (1<<i) <= n;i++){
      if(( (1<<i) & n )>>i == 0x1){
	if(last !=-1){
	  cout<<last<<" ";
	}
	last = (1<<i);
      }
    }
    if(last != -1)
      cout<<last;
    cout<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	int n;
	int tai[] = {512,256,128,64,32,16,8,4,2,1};
	while(scanf("%d",&n)==1){
		vector<int> sol;
		for(int x=0;x<10 && n>0;++x){
			if(n-tai[x]>=0){
				n -= tai[x];
				sol.push_back(tai[x]);
			}
		}
		for(int x=sol.size()-1;x>0;--x){
			cout<<sol[x]<<" ";
		}
		cout<<sol[0]<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	vector<int> weights;
	vector<int> use;
	weights.push_back(1);
	weights.push_back(2);
	weights.push_back(4);
	weights.push_back(8);
	weights.push_back(18);
	weights.push_back(32);
	weights.push_back(64);
	weights.push_back(128);
	weights.push_back(256);
	int w;

	while(cin>>w,!cin.eof()) {
		while(w!=0){
			for(int i=0; i<weights.size(); i++){
				if(w == 0) break;
				if(weights.at(i) > w){
					w -= weights.at(i-1);
					use.push_back(weights.at(i-1));
					break;
				}
			}
		}
		sort(use.begin(), use.end());
		for(int i=0; i<use.size()-1; i++){
			cout<<use[i]<<" ";
		}
		cout<<use[use.size()-1]<<endl;
		use.clear();
	}
	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>
#include<vector>
using namespace std;

int main(){
    int n;
    while(cin>>n){
        vector<int>vec;
        for(int i=512;i>0;i=i>>1){
            if(n>=i){
                n-=i;
                vec.push_back(i);
            }
        }
        for(int i=0;i<vec.size();i++)
            cout<<vec[vec.size()-1-i]<<" ";
        cout<<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]);
				break;
			}
		}
		for(int i=0;i<10;i++){
			if(t[i]) printf(" %d",weight[i]);
		}
		printf("\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int weight[10]={1,2,4,8,16,32,64,128,256,512,};
bool weightFlag[10];
int main(){
    int n;
    while(cin>>n){
        if(n>=weight[9]){
            n-=weight[9];
            weightFlag[9]=true;
        }
        if(n>=weight[8]){
            n-=weight[8];
            weightFlag[8]=true;
        }
        if(n>=weight[7]){
            n-=weight[7];
            weightFlag[7]=true;
        }
        if(n>=weight[6]){
            n-=weight[6];
            weightFlag[6]=true;
        }
        if(n>=weight[6]){
            n-=weight[6];
            weightFlag[6]=true;
        }
        if(n>=weight[5]){
            n-=weight[5];
            weightFlag[5]=true;
        }
        if(n>=weight[4]){
            n-=weight[4];
            weightFlag[4]=true;
        }
        if(n>=weight[3]){
            n-=weight[3];
            weightFlag[3]=true;
        }
        if(n>=weight[2]){
            n-=weight[2];
            weightFlag[2]=true;
        }
        if(n>=weight[1]){
            n-=weight[1];
            weightFlag[1]=true;
        }
        if(n>=weight[0]){
            n-=weight[0];
            weightFlag[0]=true;
        }
        for(int i=0;i<10;i++){
            if(weightFlag[i]){
                cout<<weight[i];
                for(int j=i+1;j<10;j++){
                    if(weightFlag[j]){
                        cout<<' ';
                        break;
                    }
                }
            }
        }
        cout<<endl;
        for(int i=0;i<10;i++) weightFlag[i]=false;
    }
    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--)
{
(b[i]!=0)cout<<b[i]<<(i==0?"\n":" ");
}
}
return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int w;
	while(cin>>w)
	{
		bool flag=0;
		for(int i=1;i<=w;i*=2)
		{
			if(w%(i*2)>0)
			{
				if(flag)
				{
					cout<<' ';
				}
				cout<<i;
				flag=1;
				w-=i;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t;
    while(std::cin>>t){
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=std::stoi(s);
        for(int i=0;i<s.size();i++){if(num%10){std::cout<<pow(2,(double)(i)); if(pow(2,i)*2<t)std::cout<<" ";}num/=10;}
    std::cout<<std::endl;
    }
}

C++: #include <stdio.h>
#include <math.h>
int main(void)
{
	int nisin[10]={0};
	int n,i;
	while(scanf("%d",&n) != EOF)
	{
		int count=0,count2=0;
		for(i=0;;i++)
		{
			nisin[i] = n%2;
			n /= 2;
			if(n==0)break;
		}
		for(i=0;i<10;i++)
		{
			if(nisin[i])count++;
		}
		for(i=0;i<9;i++)
		{
			if(nisin[i])
			{
				printf("%d",(int)(pow(2,i)));
				count2++;
				if(count2==count)printf("\n");
				else printf(" ");
			}
		}
	}
	return 0;
}