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 <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;

const int M = 512;

int main(void){
    for(int w; cin >> w; cout << endl)
        for(int a = 1; a <= M; a *= 2)
            if(a & w) cout << (a - 1 ? " ":"") << a;

    return 0;
}

C++: #include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int n, c;
	int a[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 516};
	int b[10];
	
	while (scanf("%d", &n) != EOF){
		c = 0;
		for (int i = 9; 0 <= i; i--){
			if (n >= a[i]){
				n -= a[i];
				b[c] = a[i];
				c++;
			}
		}
		sort(b, b + c);
		for (int i = 0; i < c; i++){
			printf("%d", b[i]);
			if (i < c - 1){
				printf(" ");
			}
		}
		
		printf("\n");
	}
	return (0);
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t;
    while(std::cin>>t,t){
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=std::stoi(s);
    for(int i=0;i<s.size();i++){if(num%10)std::cout<<pow(2,(double)(i)); if(i!=s.size()-1)std::cout<<" "; num/=10;}
    std::cout<<std::endl;
    }
}

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

using namespace std;

int main()
{
	int n;
	while(scanf("%d",&n)!=EOF){
		vector<int> v;
		for(int i=512;1<=i;i/=2){
			if(n<i) continue;
			n-=i;
			v.push_back(i);
			if(n<=0)break;
		}
		for(int i=v.size()-1;0<=i;i--){
			printf("%d",v[i]);
			if(i==0)printf("\n");
			else printf(" ");
		}
	}
	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 <= 8; i++) {
        if (use_num[i] != FALSE) {
            std::cout << power(2, i) << ' ';
        }
    }
    if (use_num[9] != FALSE) {
        std::cout << power(2, 9);
    }
    std::cout << std::endl;
}

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

C++: #include<stdio.h>
#include<stdlib.h>
#include<string.h>

int i,j,k;
int n,flag[15],a=1,b=1;

int main(){
	while(scanf("%d",&n)!=EOF){
		while(n>=1)flag[a]=n%2*b,n/=2,a++,b*=2;
		for(i=1;i<11;i++)if(flag[i]!=0)printf("%d ",flag[i]);
		printf("\b\n");
		for(i=1;i<11;i++)flag[i]=0;a=1;b=1;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  int n;
  while(cin>>n) {
    for(int i=0; i<10; i++) {
      if(n&1) {
	cout << (1<<i);
	if(n>>1) cout << " ";
      }
      n >>= 1;
    }
    cout << endl;
  }
  return 0;
}

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

const int N = 10;

int main()
{
	int w[N];
	w[0] = 1;
	for(int i=1; i<N; i++){
		w[i] = w[i-1]*2;
	}
	int n;
	while(cin>>n){
		vector<int> all;
		for(int i=N-1; i>=0; i--){
			if(w[i]<=n){
				all.push_back(w[i]);
				n -= w[i];
			}
			if(n == 0) break;
		}
		for(int i=all.size()-1; i>=0; i--){
			if(i!=all.size()-1) cout<<" ";
			cout<<all[i];
		}
		cout<<endl;
	}
	return 0;
}

C++: //
//
//
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int a[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int sample = 129;
	vector<int> ans;
	int res = sample;
	while(res != 0){
		for (int i = 0; i < 10; i++) {
			if(sample - a[i] < 0){
				continue;
			}
			if((sample - a[i]) < res) {
				res = sample - a[i];
			}
		}
		ans.push_back(sample - res);
		sample = res;
	}
	for(int i = 0; i < ans.size()-1; ++i){
		cout << ans[i] << " ";
	}
	cout << ans.back() << endl;
	return 0;
}

C++: #include <stdio.h>

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;
 
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()-1;i++) cout<<res[i]<<" ";
		cout<<res[res.size()-1]<<endl;

	}

	return 0;
}

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

int main(){
	while (true)
	{
		int R[10], S[10], n, z=0;
		string str;
		R[0] = 1;
		S[0] = 0;
		for (int i = 1; i < 10; i++) {
			R[i] = R[i - 1] * 2;
			S[i] = 0;
		}
		cin >> n;
		if (cin.eof() || n == 0) { break; }
		for(int i=9;i>=0;i--){
			if(n>=R[i]){
				n -= R[i];
				S[i] += 1;
			}
		}
		for(int i=0;i<10;i++){
			if (S[i] == 1 && z==0) {
				str += to_string(R[i]);
				z = 1;
			}
			else if(S[i] == 1){
				str += " ";
				str += to_string(R[i]);
			}
		}
		cout << str << endl;
	}
	return 0;
}

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

int main()
{
	int nishin[] = {1,2,4,8,16,32,64,128,256,512};
	int n;
	vector<int> result;

	while(cin >> n) {
		result.clear();
		while(true) {
			if(n<=0) break;
			if(n%2 == 1) result.push_back(1);
			else		 result.push_back(0);
			n /= 2;
		}

		for(int i=0;i<result.size();i++) {
			if(result[i] == 1 && i<result.size()-1) 
				cout << pow(2,i) << ' ';
			else if(result[i] == 1)
				cout << pow(2,i);
		}
		cout << '\n';
	}

	return 0;
}

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

int main(){
	
	int n;
	
	while(cin>>n){
		int s[11]={0};
		int j=0;
	for(int i=9;i>=0;i--){
		if(n-pow(2,i)>=0){
		n=n-pow(2,i);
		s[j++]=pow(2,i);
	}
	}
		if(j>0){
		cout<<s[--j];
	for(int i=j-1;i>=0;i--)
		cout<<" "<<s[i];
		cout<<endl;
	}
	}
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

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

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

using namespace std;

int main(void)
{
    int a;
    while ( scanf("%d", &a) != EOF) {
        for (int i = 0; i < 10; i++) {
            if ((a&1) == 1) {
                cout << (1<<i) << " ";
            }
            a >>= 1;
        }
        puts("");
    }
    return 0;
}