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>
using namespace std;

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

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

using namespace std;

int main(){
  int n;
  while(cin >> n){
    if(cin.eof())break;
    vector<int> ar;
    int flg = 0;   
    for(int i = 512 ; i>=1; i/=2){

      if(n >= i&&flg == 0){
	cout << i;
	flg = 1;
	n-=i; 
	continue;
      }
      if(n >= i&&flg == 1){
	cout <<" "<< i;
	n-=i; 
      }
    }
    cout << endl;
  }
  return 0;
}

C++: // #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <set>
using namespace std;

int main(){
	int n;
	set<int> ansset;
	while (cin >> n, !cin.eof()){
		ansset.clear();
		for (int i = 9; i >= 0; i--){
			int hundou = pow(2, i);
			if (n >= hundou){
				ansset.insert(hundou);
				n -= hundou;
			}
		}
		// output
		set<int>::iterator it = ansset.begin();
		while (it != ansset.end()){
			cout << *it;
			++it;
			if (it != ansset.end())	
				cout << " ";
		}
		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 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[num[i]]<<" ";
     }
     if(num[count-1]) cout<<arr[num[count-1]]<<endl;
     else cout<<endl;           
   }
   //while(1);     
   return 0;  
 }

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

int main(){
	int n,f[10],flag;
	while (cin >> n){
		flag = 0;
		for (int i = 0; i < 10; i++) f[i] = 0;
		for (int i = 0; n; i++){
			f[i] = n % 2;
			n /= 2;
		}
		for (int i = 0; i < 10; i++){
			if (f[i]) {
				if(!flag){
					cout << (int)pow(2.0, i);
					flag = 1;
				}
				else cout << " " << (int)pow(2.0, i);
			}
		}
		cout << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main() {
  int a, i;
  while(cin>>a) {
    for(i=0;i<=9;i++) {
      if(a&1<<i){
        cout<<(1<<i);
        if(a<2<<i)break;
        cout<<' ';
      }
    }
    cout<<endl;
  }
}

C++: #include<iostream>

using namespace std;

int bekijou(int);

int main(){

  int in,data[10];

  while(cin >> in){

    for(int i = 0; i < 10; i++) data[i] = 0;

    for(int i = 0;i < 10; i++){
      data[i] = in % 2;
      in /= 2;
    }
    int out = 0;

    for(int i = 0; i < 10; i++){
      if(data[i] == 1 && out == 0){
	cout << bekijou(i);
	out++;
      }else if(data[i] == 1){
	cout << " " << bekijou(i);
      }
    }
    cout << endl;
  }
  return 0;
}
  
int bekijou(int n){
  int ret = 1;

  for(int i = 0; i < n; i++){
    ret *= 2;
  }

  return ret;
}

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

int main(){
	int n;
	int ans[10] = {};
	while(cin >> n){
		while(n >= 512){
			n -= 512;
			ans[9]++;
		}
		while(n >= 256){
			n -= 256;
			ans[8]++;
		}
		while(n >= 128){
			n -= 128;
			ans[7]++;
		}
		while(n >= 64){
			n -= 64;
			ans[6]++;
		}
		while(n >= 32){
			n -= 32;
			ans[5]++;
		}
		while(n >= 16){
			n -= 16;
			ans[4]++;
		}
		while(n >= 8){
			n -= 8;
			ans[3]++;
		}
		while(n >= 4){
			n -= 4;
			ans[2]++;
		}
		while(n >= 2){
			n -= 2;
			ans[1]++;
		}
		while(n >= 1){
			n -= 1;
			ans[0]++;
		}

		for(int i = 0; i < 10; i++){
			if(ans[i] == 0) continue;
			cout << pow(2, i);
			if(i < 9) cout << " ";
		}
		cout << endl;


	}


}

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

int main(){
	int n;
	int ary[] = { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };

	while (cin >> n){
		vector<int> v;
		for (int i = 0; i < 10; i++){
			if (n >= ary[i]){
				n -= ary[i];
				v.push_back(ary[i]);
			}
		}
		for (auto i = v.rbegin(); i < v.rend(); i++){
			if (i != v.rbegin()) cout << " ";
			cout << *i;
		}
		cout << endl;
		n = 0;
	}
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

int w;
stack <int> st;

int main(){
	while(cin>>w){
		rep(i,10){
			if(w>=(int)pow(2.0,(double)9-i)){
				w-=(int)pow(2.0,(double)9-i);
				st.push((int)pow(2.0,(double)9-i));
			}
		}
		cout<<st.top();
		st.pop();
		while(!st.empty()){
			cout<<" "<<st.top();
			st.pop();
		}
		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();

	while( 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<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
int main(void) {
    int a;
    bool p[10];
    int w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    while(cin >> a) {
        REP(i,10) p[i] = false;
        for(int i=9;i>=0;i--) {
            if(a-w[i] >= 0) {
                p[i] = true;
                a = a-w[i];
            } else {
                p[i] = false;
            }
        }
        int k;
        REP(i,10) {
            if(p[i]) k = i;
        }
        REP(i,10) {
            if(p[i]) {                                                                               
                cout << w[i];
                if(i != k) cout << " ";
            }

            if(i == k) cout << endl;
        }
    }
}