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++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
int v[30];
int main(){
  v[0]=1;
  for(int i=1;i<10;i++){
    v[i]=v[i-1]*2;
  }
  int s;
  while(cin>>s){
    vector<int> b;

    for(int i=9;i!=-1;i--){
      if(s==0)break;
      if(s>=v[i]){
        b.push_back(v[i]);
        s-=v[i];

      }
    }
    sort(b.begin(),b.end());
    for(int i=0;i<b.size()-1;i++){
      if(b[i])cout<<b[i]<<" ";
    }
    cout<<b[b.size()-1]<<endl;
    
  }

  return 0;
}

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

int main()
{

	int weight = 0;
	while (std::cin >> weight)
	{
		std::bitset<10> bit(weight);
		int count = bit.count();

		for (int i = 0; i < 10; i++)
		{
			if (bit[i])
			{
				std::cout << std::pow(2, i);
				count--;
				if (count != 0)
				{
					std::cout << " ";
				}
			}
		}
		std::cout << std::endl;
		
	}

	return 0;
}

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) {
    for (int i = 0; i <= 9; i++) {
        if (use_num[i] != FALSE) {
            std::cout << power(2, i) << ' ';
        }
    }
    std::cout << std::endl;
}

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

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

using namespace std;

int main() {
	vector<int> v;
	vector<int> ans;
	int temp;
	while(1) {
		cin >> temp;
		if(cin.eof()) {
			//cout << "EOF" << endl;
			break;
		}
		v.push_back(temp);
	}
	for(auto it = v.begin(); it != v.end(); it++) {
		int weight = 512;
		for(int i=0;i<10;i++) {
			if(*it >= weight) {
				ans.push_back(weight);
				*it -= weight;
			}
			weight /= 2;
		}
		sort(ans.begin(), ans.end());
		for(auto ans_it = ans.begin(); ans_it != ans.end(); ans_it++) {
			cout << *ans_it;
			if(it - ans.begin() < 10) {
				cout << " ";
			}
		}
		cout << endl;
		ans.clear();
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  
  int n,b;
  int a[10],i;
  while(cin >> n){
    fill_n(a,10,1024);
    b = 512;
    i=0;
    
    while(n != 0){
      if(n >= b){
	a[i] = b;
	i++;
	n -= b;
      }
      if(b == 1) b--;
      else b /= 2;
    }
    sort(a,a+10);
    for(int j = 0;j < i;j++){
      if(j == i-1) cout << a[j] << endl;
      else cout << a[j] << ' ';
    }
  }

  return (0);
}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){

int m,w[10];

while(cin>>m){
	int k=0;
	for(int i=0;i<10;i++)w[i]=0;
	
	for(int i=9;i>=0;i--)if(m>=pow(2,i)){w[i]=1;m-=pow(2,i);}
	
	for(int i=0;i<10;i++){
		if(w[i]==1&&k==0){cout<<pow(2,i);k=1;}
		else if(w[i]==1)cout<<" "<<pow(2,i);
	}
	cout<<endl;
	}
	return 0;
}

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

int main()
{
    int n,weight;
	int w[10]={1,2,4,8,16,32,64,128,256,512};
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
	
		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}
		for(int i=0; i<10 ; i++){
			if(flag[i]!=0){
				cout << w[i] << " ";
			}
		}
		//cout << endl;
	}
	return 0;
}

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

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

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

int main() {
    int n;
    while(cin >> n) {
        vector<int> res;
        for(int i=0; i<10; ++i) {
            if(n & (1 << i)) {
                res.push_back(1 << i);
            }
        }
        for(int i=0; i<res.size(); ++i) {
            cout << res[i] << " \n"[i == res.size()-1] << flush;
        }
    }
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, n) for(int i = 0; i <= n; i++)
#define MREP(i, n) for(int i = n; i >= 0; i--)

using namespace std;

int main(){
	int input;
	int tmp = 1, n = 9;
	bool fact[10];
	
	PREP(i, n){
		tmp *= (!i) ? 1 : 2;
		fact[i] = false;
	}

	while(cin >> input){
		MREP(i, n){
			if(tmp <= input){
				input -= tmp;
				fact[i] = true;
			}
			if(input == 0) break;
			tmp /= 2;
		}
		tmp = 1;
		PREP(i, n){
			tmp *= (!i) ? 1 : 2;
			if(fact[i] == true){
				fact[i] = false;
				cout << tmp;
				if(i != n) cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

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

main(){
  int n;
  int i,j,temp;
  int t;
  while(cin >> n){
    int c[15]={0};
    for(i=9;n!=0;i--){
      if(bun[i]<=n){
	n-=bun[i];
	c[i]=1;
      }
    }
    t=0;
    for(i=0;i<10;i++){
      if(c[i]==1){
	if(t==1){
	  cout << ' ';
	}
	cout << bun[i];
	t=1;
      }
    }
    puts("");
  }
}