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 n,d[10]={512,256,128,64,32,16,8,4,2,1};
	bool a[10];
	while(cin>>n){
		for(int i=0;i<10;i++){
			a[i]=false;
			while(d[i]<=n){n-=d[i];a[i]=true;}
		}
		
		for(int i=9;i>=0;i--)
			if(a[i]==true)cout<<d[i]<<" ";
		cout<<endl;
	}

}

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

int main() {
  int g;
  vector<int> v;
  while (cin >> g) {
    while (g != 0) {
      int i = 1;
      while (g >= i * 2) {
        i *= 2;
      }
      v.push_back(i);
      g -= i;
    }
    reverse(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
      if (i == v.size() - 1) {
        cout << v.at(i) << endl;
      } else {
        cout << v.at(i) << " ";
      }
    }
    v.clear();
  }
}

C++: #include <iostream>

int main(int argc, const char * argv[])
{
    int cu[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    int g, j = 0, cu2[10] = {0};
    scanf("%d", &g);
    
    for (int i = 0; i < 10; 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 <stdio.h>
  int main(){
   int x[10]={1,2,4,8,16,32,64,128,256,512};
   int n,i,sum=0;
    while(scanf("%d",&n) != EOF){
		int y[10]={};
     for(i=9;i>=0;i--){
		 if(n>=x[i]){  n -= x[i]; y[i]=1; sum++;}
       }
      for(i=0;i<10;i++){
		  if(y[i]==1) {sum--; if(sum!=0){printf("%d ",x[i]);}
		  else{printf("%d\n",x[i]);
		  }}}
	  sum=0;
}
return 0;
}

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

int weight[10];
weight[1]=1;
for(int i = 2;i<=9;i++)weight[i]=2*weight[i-1];


int main(){
	while(true)
	{
	int object;
	cin >> object;
	if (cin.eof())break;
	for(int i =1;int <=9;i++){
		if(object%2==1)
			{
			cout << weight[i] ;
			if( i != 9 ) cout << " ";
			}
		}
	cout << endl;
	}
	
	return 0;
}

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

int main(){
  int a;
  int count = 0;
  std::vector<int> v;
  std::vector<std::vector<int> > x;
  while(std::cin >> a){
    v.push_back(a);
    count++;
  }
  int i;
  for(i = 0; i < count; i++){
    int data;
    data = v[i];
    int j;
    std::vector<int> w;
    for(j = 0; j < 10; j++){
      if(data == 0){
        break;
      }
      if(std::pow(2,9-j) <= data){
        w.push_back(std::pow(2,9-j));
        data -= std::pow(2,9-j);
      }
    }
    std::sort(w.begin(),w.end());
    x.push_back(w);
   }
  int k;
  for(k =0; k<count; k++){
    int l;
    for(l = 0; l<x[k].size(); l++){
      std::cout << x[k][l];
      if(l + 1 < x[k].size()){
        std::cout << " ";
      }
    }
    std::cout << "\n";
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	while(cin>>n){
		for (int i = 0; i < 11; ++i) {

			if(n%2){
				if(i!=0){
					cout<<' '<<pow(2,i);
				}else{
					cout<<pow(2,i);
				}
			}
			if(n==1)break;
			n=n/2;
		}
		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(i!=s.size())std::cout<<" ";} num/=10;}
    std::cout<<std::endl;
    }
}

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

int main()
{
	int w,m,f;
	while(cin >> m)
	{
		f=w=1;
		while(m)
		{
			if(m&1)
			{
				cout << (f?"":" ") << w; f=0;
			}
			m = m>>1;
			w = w<<1;
		}
		cout << endl;
	}
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[10]={1,2,4,8,16,32,64,128,256,512}; 
  
 int main()
 {
   int N;
   while(cin>>N)
   {
     int count=0;
     int num[10]={0};
     while(N)
     {
       num[count++]=N%2;
       N/=2;        
     }      
     for(int i=0;i<count-1;i++)
     {
       if(num[i]) cout<<arr[i]<<" ";
     }
     if(num[count-1]) cout<<arr[i]<<endl;
     else cout<<endl;           
   }
   //while(1);     
   return 0;  
 }

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

typedef complex<double> P;

int main(){
	int n;
	while(cin>>n){
		bool f = true;
		for(int i = 0 ; i < 10 ; i++){
			if( !(n>>i&1) ) continue;
			if(!f) cout << " ";
			cout << (1<<i);
			f = false;
		}
		cout << endl;
	}
			
}

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

int main()
{
	int w=-1,m=-1;
	while(cin >> m)
	{
		w=1;
		while(m)
		{
			if(m&1) cout << w << " ";
			m = m>>1;
			w = w<<1;
		}
		cout << endl;
	}
}

C++: #include<iostream>
using namespace std;
int a[10] = {1,2,4,8,16,32,64,128,256,512};
int weight,b[11];


int main(){
  while(cin >> weight){
    int l = 0;
    for(int i = 0;i<10;i++)
      b[i] = 0;
    while(weight != 0){
      for(int i =9;i>=0;i--){
	if(weight >= a[i]){
	  weight = weight - a[i];
	  b[i] = 1;
	}
      }
    }
    for(int i=0;i<10;i++){
     
      if(b[i] == 1){
	   if(l != 0) cout << " ";
	   cout << a[i]; l++;
	}

    }
    cout << endl;
  }
}

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

int main() {
	int weight;

	while (cin >> weight) {
		vector<int> list;
		
		for (int i = 0;weight != 0;i++) {
			int candidate = pow(2, 9 - i);

			if (weight >= candidate) {
				list.push_back(candidate);
				weight -= candidate;
			}
		}

		int max = list.size() - 1;

		for (int j = 0;j < max; j++) {
			if (j != 0)cout << " ";
			cout << list.at(max - j);
		}
		cout << endl;
	}
	
	return 0;
}

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

using namespace std;

array< int, 10 > weight_array{ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
array< int, 1024 > sum_table;
array< array< int, 10 >, 1024 > bit_table;

void MakeTable()
{
	int i = 0, j = 0, tmp = 0;
	for ( i = 0 ; i < 1023 ; i++ )
	{
		tmp = i;
		for ( j = 0 ; j < 9 ; j++ )
		{
			sum_table[i] = ( tmp % 2 ) * weight_array[j] + sum_table[i];
			bit_table[i][j] = tmp % 2;
			tmp = tmp >> 1;
		}
	}
}

int main()
{
	int weight, j, i;
	MakeTable();

	cin >> weight;
	for ( i = 0 ; i < 1024 ; i++ )
	{
		if ( sum_table[i] == weight )
		{
			for ( j = 0 ; j < 10 ; j++ )
			{
				if ( bit_table[i][j] == 1 )
				{
					cout << weight_array[j];
				}
			}
			break;
		}
	}

	return 0;
}

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