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 <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int n, tmp, *array, tmp2;
	
	while(cin >> n){
		array = (int *)calloc(10, sizeof(int));
		tmp2 = 0;
		while(n > 0){
			tmp = 1;
			while(n >= tmp){
				tmp *= 2;
			}
			tmp /= 2;
			array[tmp2++] = tmp;
			n -= tmp;
		}
		tmp2--;
		cout << array[tmp2];
		for(int i = tmp2 - 1; i >= 0; i--){
			cout << " " << array[i];
		}
		cout << endl;
		free(array);
	}
	
	return 0;
}

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

int main() {
    int n;
    int weights[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
    
    while (cin >> n) {
        vector<int> result;
        for (int i = 0; i != 10; ++i) {
            if (n - weights[i] >= 0) {
                n -= weights[i];
                result.push_back(weights[i]);
            }
        }
        sort(result.begin(), result.end());

        for (int i = 0; i != result.size()-1; ++i) {
            cout << result[i] << " ";
        }
        cout << result[result.size()-1];
        cout << endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(void){
	int w;
	char s[100];
	int st = 0;
	int i = 0;
	while(scanf("%d", &w) != EOF){
		st = i = 0;
		while(10 > i){
			if(w & 1 == 1){
				st += sprintf(s+st, "%d ", 1<<i);
			}
			w >>= 1;
			i++;
		}
		s[st - 1] = '\0';
		puts(s);
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


int main(){
	int w[] = {1,2,4,8,16,32,64,128,256,512};
	int n;
	while(cin >> n){
		int flag[10], num[10];
		int end = 0;
		for(int i = 0;i < 10;i++){
			flag[i] = 0;
			num[i] = 0;
		}
		num[0] = n;
		for(int i = 0;i < 10;i++){
			flag[i] = num[i] % 2;
			num[i+1] = num[i] / 2;
			if(num[i+1] == 0) break;
		}
		for(int i = 0;i < 10;i++){
			if(flag[i] == 1) end = i; 
		}
		for(int i = 0;i < 10;i++){
			if(i == end) cout << w[i] << endl;
			else if(flag[i] == 1) cout << w[i] << " ";
		}

	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cassert>
using namespace std;
int main(){
  int n,index,bg;
  vector<int> dp[1024];
  for(int i=1;i<=1023;i++){
    if(!dp[i].empty())continue;
    if(i == 1 || i == 2 || i == 4 || i == 8 || i == 16 || i == 32 || i == 64 || i == 128 || i == 256 || i == 512){
      dp[i].push_back(i);
      continue;
    }  
    bg = i-1;
    for(int j=1;j<bg;j++){
      index = bg+j;
      for(int k=0;k<dp[j].size();k++){
	dp[index].push_back(dp[j][k]);
      }
      for(int k=0;k<dp[bg].size();k++){
	dp[index].push_back(dp[bg][k]);
      }
    }
  }

  while(cin >> n){
    assert(n<=1023);
    for(int i=0;i<dp[n].size();i++){
      cout << dp[n][i];
      i==dp[n].size()-1?cout << endl:cout << " ";
    }
  }
  return 0;
}

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

using namespace std;

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


	return 0;
}

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 <iostream>
#include <sstream>

using namespace std;

string IntToString(int number) {
	stringstream ss;
	ss << number;
	return ss.str();
}

int main(void) {
	int in;
	int omori[] = {512,256,128,64,32,16,8,4,2,1};
	int i;
	string ret;

	while(!cin.eof()) {
		cin >> in;
		ret = "";
		for(i = 0; i < 10; i++) {
			if(omori[i] <= in) {
				in -= omori[i];
				ret = IntToString(omori[i]) + ((ret=="")?(""):(" ")) + ret;
			}
			if(in == 0) { break; }
		}
		cout << ret << endl;
	}

	return 0;
}

C++: using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
int bun[]={1,2,4,8,16,32,64,128,256,512};
int main()
{
	int x;
	while(cin>>x){
		for(int i=0;i<10;i++){
			if((x>>i)&1)printf(bun[i]>x/2?"%d\n":"%d ",bun[i]);
		}
	}
    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 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++) cout<<num[i]<<" ";
     cout<<num[count-1]<<endl;           
   }
   //while(1);     
   return 0;  
 }

C++: #include<iostream>
#include<cmath>
using namespace std;
 
int main(){
    int n,a[10],c;
     
    while(cin>>n){
        c=0;
        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){
                if(c!=0) cout << " ";
                cout << pow(2,i);
                c++;
            }
        }
        cout << endl;
    }
}

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

using namespace std;

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

bool tukauka[10];//大きい順

int n,owari;
int main(){
	while(cin >> n){
		for(int i = 0;i < 10; i++) {
			if(n >= omosa[i]){
				tukauka[i] = true;
				n -= omosa[i];
			}
		}
		for(int i=9;i!=0;i--){
			if(tukauka[i])owari=i;
		}
		for(int i = 0; i < 10; i++) {
			if( i==9-owari) {
				cout << omosa[9 - i] ;
			}else if(tukauka[9 - i]){
				cout<< omosa [9 - i]<<" ";
			}
		}
		cout << endl;
		for(int i=0;i<10;i++)tukauka[i]=false;
                owari=0;
	}
	return 0;
}