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>
#include <stack>

using namespace std;

int main() {
	int W;
	while (cin >> W) {
		stack<int> ans;
		for (int i = 512; i >= 1; i /= 2) {
			if (W - i >= 0) {
				W -= i;
				ans.push(i);
			}
			if (W == 0)
				break;
		}
		int ifs = 1;
		while (ans.empty() != true) {
			if (ifs == 0)
				cout << " ";
			cout << ans.top(); ans.pop();
			ifs = 0;
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n,b[10],f,i;
while(cin>>n){
for(i=0;i<10;i++){b[i]=n%2;n/=2;}
for(f=0,n=1,i=0;i<10;i++){
if(b[i]==1){
if(f==0){cout<<n;f=1;}
else cout<<" "<<n;
}
n*=2;
}
cout<<endl;
}
return 0;
}

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 num[10]={0}; 
  
 int main()
 {
   int N;
   while(cin>>N)
   {
     int count=0;
     while(N)
     {
       num[count++]=N%2;
       N/=2;        
     }      
     for(int i=0;i<count-1;i++) cout<<num[i]<<" "
     cout<<num[count-1]<<endl;           
   }
   //while(1);     
   return 0;  
 }

C++: #include<iostream>
using namespace std;
main(){
	for(int W,i,f;cin>>W;cout<<endl)
		for(i=f=1;W/i;i*=2)
			W&i&&(cout<<" "+f<<i,f=0);
}

C++: #include<iostream>

using namespace std;

void conv(int n, int a[10])
{
	for(int i=0;i<10;i++)
	{
		a[i]=n%2;
		n=n/2;
	}
}

int pow(int x, int n)
{
	int ans=1;
	for(int i=0;i<n;i++)
	{
		ans*=x;
	}
	return ans;
}

int main(void)
{
	int w;
	while(cin>>w)
	{
		int a[10];
		conv(w,a);
		int tmp=0;
		for(int i=0;i<10;i++)
		{	
			if(a[i]==1)
			{
				if(tmp!=0)
				{
					cout<<" ";
				}
				cout<<pow(2,i);
				tmp++;
			}
		}
		cout<<endl;
	}
}

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

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

int main()
{
    int in_data;
    while(cin >> in_data)
    {
        int gram_num = 0;
        bool is_used[10] = {};
        for(int i=9; i>=0; i--)
        {
            if(gram_num + WEIGHTS[i] <= in_data)
            {
                gram_num += WEIGHTS[i];
                is_used[i] = true;
            }
        }
        for(int i=0; i<9; i++)
        {
            if(is_used[i])
            {
                cout << WEIGHTS[i]  << " ";
            }
        }
        if(is_used[9])
        {
            cout << WEIGHTS[9];
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

void solve();

int main() {

   solve();

   return 0;

}

/*void solve() {＃３

   vector<int> S;
   vector<int> T;
   int n;   //Sの個数
   int q;   //Tの個数
   int ans=0;
   int buf;

   cin >> n;

   for (int i = 0; i < n; i++) {
      
      cin >> buf;
      S.push_back(buf);

   }

   cin >> q;

   for (int i = 0; i < q; i++) {

      cin >> buf;
      T.push_back(buf);

   }

   //Sをソート

   sort(S.begin(),S.end());

   for (vector<int>::iterator i=T.begin();i<T.end();i++){  //Tの各値をSから探す。あったらans＋＋

      if(binary_search(S.begin(),S.end(),*i)){ans++;}

   }

   cout << ans << endl;

}*/

void solve() {

   int in;
   vector<int> input;
   vector<string> ans;
   int w[10];
   int now=0; //今何問目？
   char c=' ';
   string buf;

   for (int i = 0; i < 10; i++) {

      w[i]=(int)pow(2,i);

   }

   while (true) {

      getline(cin,buf);

      if(buf[0] == EOF) break;

   }


   for (vector<int>::iterator itr=input.begin();itr<input.end();itr++) {

      for (int i = 9; i >= 0; i--) {

         if (*itr > w[i]) {

            *itr-=w[i];
            ans[now]+=to_string(w[i]);
            ans[now]+=c;
         }

         ans[now].pop_back();       //ここ2行で整形
         ans[now].push_back('\n');

      }

      now++;

   }

   for (vector<string>::iterator itr = ans.begin(); itr < ans.end(); itr++) {

      cout << *itr;

   }

}

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


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

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

int main(){
	int div=512;
	int weight[10];
	int W;
	while(cin>>W){
      div=512;
		for(int i=0;i<10;i++){
			weight[i]=W/div;
            W=W%div;
			div=div/2;
		}
      int flag=0;
		for(int j=0;j<10;j++){
                      int a=1;
          if(weight[9-j]>0){

            for(int k=0;k<j;k++){
              a=a*2;
            }
            if(flag==1){cout<<" ";}
		cout <<a;
            flag=1;
		}

        }
 	cout<<endl;     
}
  return 0;
    }

C++: #include <iostream>

using namespace std;

int main()
{
    int input;
    const int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    bool check[10];

    while (cin >> input) {
        for (int i = 0; i < 10; i++)
            check[i] = false;

        int tmp = input;
        for (int i = 0; tmp != 0; i++) {
            if (tmp % 2)
                check[i] = true;
            tmp /= 2;
        }

        for (int i = 0; i < 10; i++)
            if (check[i])
                cout << weight[i] << " ";
        cout << "\b\n";
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  while ( true )
  {
    bool  init = true;
    int   D;

    if ( !( cin >> D ) )  break ;

    for ( int mask = 1; mask <= 0x200; mask <<= 1 )
    {
      if ( D & mask )
      {
        if ( !init )
        {
          cout << " ";
        }
        cout << mask;
        init = false;
      }
    }
    cout << endl;
  }

  return ( 0 );
}

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

int input,i;


int main(){
	while(cin>>input){
		string ans("");
		while(1){
			if(input%2==0) ans.insert(ans.begin(),'0');
			else ans.insert(ans.begin(),'1');
			input/=2;
			if(input==0) break;
		}
		if(ans[ans.length()-1]=='1'){
			cout<<"1"<<" ";
		}
		//ans.pop_back();
		i=2;
		while(1){
			if(i==ans.length()+1) break;
			if(ans[ans.length()-i]=='1'&&i!=ans.length()){
				cout<<(int)pow(2.0,i)/2<<" ";
			}
			if(ans[ans.length()-i]=='1'&&i==ans.length()){
				cout<<(int)pow(2.0,i)/2;
			}
			//ans.pop_back();
			i++;
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void)
{
	unsigned int n;
	char buf[256];
	int ans[10];
	
	
	while (fgets(buf, 256, stdin) != NULL){
		n = atoi(buf);
		
		int count = 0;
		for (int i = 0; i < 10; i++){
			if ((n & (1 << i)) != 0){
				ans[count++] = 1 << i;
			}
		}
		printf("%d", ans[0]);
		for (int i = 1; i < count; i++){
			printf(" %d", ans[i]);
		}
		puts("");
	}
	
	return (0);
}