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 <cstdlib>

#define TRUE 1
#define FALSE 0

int use_num[10];

int get_input(void) {
    int i;
    std::cin >> i;
    if (std::cin.fail()) 
        exit(0);
    return i;
}

int power(int m, int n) {
    int acc = 1;
    for (int i = 0; i < n; i++) {
        acc *= m;
    }
    return acc;
}    

void solve(int weight) {
    for (int i = 9; i >= 0; i--) {
        if (power(2, i) > weight) {
            use_num[i] = FALSE;
        } else {
            use_num[i] = TRUE;
            weight -= power(2, i);
        }
    }
}

void output(void) {
    // find last TRUE elem
    int last;
    for (int i = 0; i <= 9; i++) {
        if (use_num[i] == TRUE) {
            last = i;
        }
    }

    for (int i = 0; i < last; i++) {
        if (use_num[i] != FALSE) {
            std::cout << power(2, i) << ' ';
        }
    }
    if (use_num[last] != FALSE) {
        std::cout << power(2, last);
    }
    std::cout << std::endl;
}

int main(void) {
    int weight;
    while (weight = get_input()) {
        solve(weight);
        output();
    }
    return 0;
}

C++: #include <iostream>

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int w;

    while (std::cin >> w) {
        for (int i = 0; i < 9; ++i) {
            int num = 1 << i;
            if (w & num) {
                w -= num;
                std::cout << num;

                if (w) {
                    std::cout << " ";
                }
            }
        }
        std::cout << std::endl;
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int w[10]={1,2,4,8,16,32,64,128,256,512};
  int n;
  while(cin>>n){
    for(int i=0;;i++){
      if (n%2) cout<<w[i];
      n/=2;
      if(!n)break;
      cout<<" ";
    }
    cout<<endl;
  }
  return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int weight;
  int item[10] = {1, 2, 4, 8, 16, 32,
                  64, 128, 256, 512};
  vector< vector<int> > result;
  while (cin >> weight) {
    vector<int> r;
    for (int i = 10; i > 0; i--)
      if (weight >= item[i-1]) {
        r.push_back(item[i-1]);
        weight -= item[i-1];
      }
    result.push_back(r);
  }

  for (int i = 0; i < result.size(); i++) {
    vector<int> r = result[i];
    for (int j = r.size(); j > 0; j--) {
      if (j != r.size())
        cout << ' ';
      cout << r[j-1];
    }
    cout << endl;
  }
  return 0;
}

C++: //Weight

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

bool g[65];

//?????????????????£??°??????????????°?????°??????
int count_bits(unsigned x){
    int count = 0;
    while(x){
        if(x & 1U) count++;
        x >>= 1;
    }
    return count;
}

//unsinged??????bit??°?????????
int int_bit(void){
    return count_bits(~0U);
}
//??£??°?????????????????§?????????????????????????????¨??????????°??????????????????????????´?????????????
void createArray(unsigned x){
    int n = int_bit();
    for(int i = 0; i < n; i++){
        if((x >> i) & 1U) g[i] = true; 
    }
}

int main(void){

    int i = 9;
    unsigned int x;
    int dp[10][10]; // i?????????????????????????????????weight
    //Dp??§???
    
    while((scanf("%d", &x)) != EOF){
       for(int i = 0; i < 65; i++) g[i] = false;
       createArray(x);
       
       //flag????????£???????????????????°???????????????¨???????????????
       for(int i = 0, j = 0; i < 10; i++) {
           if(g[i]) {
               if(j) printf(" ");
               printf("%d", (int)pow(2.0, (double)i));
               j++;
           }
       }
       putchar('\n');
       
    }
    
    return 0;
}

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

int main() {
	int N, S;
	vector<int> v(10, 1);
	for (int i = 0; i < 10; i++) {
		int& p = v.at(i);
		for (int j = 0; j < i; j++) {
			p *= 2;
		}
		//cout << p << endl;
	}
	
	int n;
	while (cin >> n) {
		bitset<10> bs(n);
		int c = bs.count();

		for (int i = 0; i < 10; i++) {
			if (bs.test(i)) {
				cout << v.at(i);
				c--;

				if (!c) {
					cout << endl;
					break;
				}
				else {
					cout << ' ';
				}
			}
		}
	}
}

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

int main()
{
	int w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int g;
	bool flag[10];
	bool fl;
	
	while (cin >> g){
		for (int i = 0; i < 10; i++){
			flag[i] = false;
		}
		
		for (int i = 9; i >= 0; i--){
			if (g >= w[i]){
				flag[i] = true;
				g -= w[i];
			}
		}
		
		fl = false;
		for (int i = 0; i < 10; i++){
			if (flag[i] == true){
				if (fl == true){
					cout << " ";
				}
				cout << w[i];
				if (fl == false){
					fl = true;
				}
			}
		}
		cout << endl;
	}
	
	return (0);
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int weights[] = {1,2,4,8,16,32,64,128,256,512,1024};
int main(){
	int n,a[10],b,c;
	while(cin >> n){
		b = 0;
		c = 11;
		while(n != 0){
			for(int i = 0;i < c;++i){
				if(n < weights[i]){
					n -= weights[i - 1];
					a[b] = i - 1;
					c = i;
					++b;
					break;
				}
			}
		}
		sort(a,a+b);
		for(int i = 0;i < b;++i){
			if(i == 0) cout << weights[a[i]];
			else cout << " " << weights[a[i]];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;


int main(int argc, char const* argv[])
{
	unsigned long weight;
	while( cin >> weight ){
		bitset<16> a( weight );
		for( int i = 0;i < 10;i++ ){
			if( a[i] == 1 ) cout << ( ( i == 0 ) ? "" : " " ) << ( 1 << i );
		}
		cout << endl;
	}
	return 0;
}

C++: //0031
//include-------------------------------------
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<stack>

using namespace std;

//typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MP make_pair

//repetition-----------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

//constant-------------------------------------
const double PI = acos(-1.0);

//cout,cin-------------------------------------
#define COUT(x) cout<<(x)<<endl;
#define CIN(x) cin>>(x);

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

int main(){

	int w;
	while (1){
		stack <int> st;
		CIN(w)
		for (int i = 10; i >= 0; i--){
			if (w >= weight[i]) {
				st.push(weight[i]);
				w -= weight[i];
			}
		}

		while (st.top()!=0){
			cout << st.top();
			st.pop();
			if (st.size() != 0) cout << " ";
		}
		cout << endl;
	}

	return 0;

}

C++: #include <iostream>
using namespace std;
int main(){
  int w[10]={1,2,4,8,16,32,64,128,256,512};
  int n;
  while(cin>>n){
    for(int i=0;n>0;n/=2,i++)
      if (n%2) cout<<w[i]<<" ";
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int n;
    while (cin >> n){
    	int i;
    	for(i=1; i <= 512; i *= 2){
    		if ((i&n) != 0) {
    			cout << i;
    			break;
    		}
    	}
    	for(i = i*2; i <= 512; i *= 2){
    		if ((i&n) != 0) cout << ' ' << i;
    	}
    	cout << endl;
    }
}