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>

int main()
{
	int a;
	while( std::cin >> a ){
		int i = 0;
		while( a > 0 ){
			if( a & 1 ) std::cout << ( 1 << i ) << ( ( a >> 1 ) & -( a >> 1 ) ? " " : "" );
			a >>= 1;
			i++;
		}
		
		std::cout << std::endl;
	}

 	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	int	w;
	while (scanf("%d", &w) != EOF)
	{
		vector<int> v;
		for (int i = 0; i < 10; ++i)
		{
			if (w & 1 << i)
				v.push_back(1<<i);
		}
		for (int i = 0; i < v.size()-1; ++i)
			printf("%d ", v[i]);
		printf("%d\n", v[v.size()-1]);
	}
	return 0;
}

C++: #include <stdio.h>

int main(){
	int i,w,g[10] = {1,2,4,8,16,32,64,128,256,512};
	while(scanf("%d",&w) != EOF){
		if(w % 2 == 1) {
			printf("1");
			w--;
		}
		for(i = 1;i < 10;i++){
			if(w % (g[i] * 2) == g[i]) {
				printf(" %d",g[i]);
				w -= g[i];
			}
			if(!w) break;
		}
		printf("\n");
	}
	return 0;
}

C++: #include<iostream>
int main()
{
	auto powor_of_two = [](int n)
	{
		int result = 1;
		for (int i = 0; i < n; i++)
		{
			result *= 2;
		}
		return result;
	};
	for (int w; std::cin >> w;)
	{
		for (int i = 0; i < 10; i++)
		{
			int bit = w & 1;
			if (bit == 1)
			{
				std::cout << powor_of_two(i);
			}
			w >>= 1;
			if (w != 0)
			{
				std::cout << ' ';
			}
			else
			{
				std::cout << std::endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int w;
	while (cin >> w) {
		for (int weight = 1; w>0; w>>=1, weight<<=1) {
			if ((w&1)==1) cout << weight << " ";
		}
		cout << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>

int main(){
  int n;
  int i;
  while(scanf("%d", &n)!=EOF){
    for(i=0;i<10;i++){
      if(n&1){
        printf("%d", 1<<i);
        if(n>>1) printf(" ");
      }
      n >>= 1;
    }
    printf("\n");
  }
  return 0;
}

C++: // 2012/10/28 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int obj;
		cin >> obj;

		if(cin.eof())
			break;

		bool spc = false;

		for(int i=0; i<10; i++){
			if(obj%2==1){
				if(spc){
					cout << ' ';
				}

				int wgt = 1;
				for(int j=0; j<i; j++){
					wgt *= 2;
				}
				cout << wgt;

				spc = true;
			}

			obj /= 2;
		}

		cout << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
	int targ, square[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	vector<int> num;
	while(cin >> targ)
	{
		if(targ == 0) break;

		for(int i = 9; i >= 0; i--)
		{
			if(targ >= square[i])
			{
				num.push_back(i);
				targ -= square[i];
			}
		}

		for(int i = num.size()-1; i >= 0; i--)
		{
			cout << square[ num[i] ];
			if(i != 0) cout <<" ";
			else cout << endl;
		}
		num.clear();
	}
}

C++: #include<cstdio>
using namespace std;
int main(void)
{
	int n;
	bool kari = 0;
	int a[10] = {1,2,4,8,16,32,64,128,256,512};
	bool flag[10] = {0};
	while(scanf("%d",&n) != EOF)
	{
		for(int i = 9;i >= 0;i--)
		{
			if(a[i] <= n)
			{
				n -= a[i];
				flag[i] = 1;
			}
		}
		for(int i = 0;i < 10;i++)
		{
			if(flag[i] == 1)
			{
				printf("%d",a[i]);
				for(int j = i+1;j < 10;j++)
				{
					if(flag[j] == 1) kari = 1;
				}
				if(kari == 1) printf(" ");
				else printf("\n");
				kari = 0;
			}
		}
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
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 <bits/stdc++.h>

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v, T b=0){ return accumulate(v.begin(), v.end(), b); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(){}
  int solve(){
  }
};

int main()
{
  int n;
  while (~scanf("%d", &n)){
    vector<int> v;
    for (int i = 0; i < 10; i++){
      static const int ws[] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
      if (n >= ws[i]){
        v.push_back(ws[i]);
        n -= ws[i];
      }
    }
    revs(v);
    show(v);
  }
  return (0);
}

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

int main(){
	int g;
	vector<int> v;
	while(cin>>g){
		v.clear();
		for(int i=0;i<10;i++)
			if(g&1<<i)v.push_back(1<<i);
		cout<<v[0];
		for(int i=1;i<v.size();i++)
			cout<<' '<<v[i];
		cout<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cmath>
#include <stack>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int arr[] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
    while(scanf("%d", &n) != EOF) {
        stack<int> s;
        for (int i = 0; i < 10; i++) {
            if (arr[i] <= n) { n-= arr[i]; s.push(arr[i]); }
        }
        int idx = 0;
        while (!s.empty()) {
            if (idx) printf(" ");
            printf("%d", s.top()); s.pop();
            idx++;
        }
        printf("\n");
    }

    return 0;
}