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>

using namespace std;

int main() {
    int n, w[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
    while (cin >> n) {
        int s = 0;
        vector<int> vec;
        while (n > 0) {
            if (n % 2 == 1) {
                vec.push_back(w[s]);
            }
            n /= 2;
            s++;
        }
        for (int i = 0; i < vec.size() - 1; i++) {
            cout << vec[i] << " ";
        }
        cout << vec[vec.size() - 1] << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t;
    while(std::cin>>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<iostream>
#include<algorithm>
#include<functional>

using namespace std;

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

bool tukauka[10];//大きい順

int n,owari;
int main(){
	while(cin >> n){
		for(int i = 0;i < 10; i++) {
			if(n >= omosa[i])tukauka[i] = true, n -= omosa[i],owari=i;
		}
		for(int i = 0; i < 10; i++) {
			if(tukauka[9 - i]&&i==owari) {
				cout << omosa[9 - i] ;
			}else {
				cout<< omosa [9 - i]<<" ";
			}
		}
		cout << endl;
		for(int i=0;i<10;i++)tukauka[i]=false;
	}
	return 0;
}

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

int main() {
	int m;
	vector<int> M,N;
	vector<vector<int>> POW;
	while (cin >> m) 
		M.push_back(m);
	for (int i = 0; i < M.size(); i++) {
		int mi = M[i];
		for (int j = 0; j < 10; j++) {
			if (pow(2, j) <= mi && mi < pow(2, j + 1)) {
				N.push_back(j); mi -= pow(2, j);
				if (mi == 0)break;
				else j = -1;
			}
		}
		sort(N.begin(), N.end());
		POW.push_back(N); N.clear();
	}
	for (int i = 0; i < POW.size(); i++) {
		for (int j = 0; j < POW[i].size(); j++) {
			if (j != POW[i].size() - 1)cout << pow(2, POW[i][j]) << " ";
			else cout << pow(2,POW[i][j]) << endl;
		}
	}
	return 0;
}

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

int
main(void)
{
	char line[80];

	int w;

	int f[10];
	int u[10];

	int k = 512;
	for (int& d : f) {
		d = k;
		k >>= 1;
	}

	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			break;
		}
		if (sscanf(line, "%d", &w) != 1) {
			break;
		}

		int p;
		for (p = 0; p < 10; p++) {
			if (w >= f[p]) {
				break;
			}
		}

		memset(u, 0, sizeof u);

		int t = f[p];
		u[p] = 1;
		p++;

		while (true) {
			if (t == w) {
				break;
			} else if (t > w) {
				t -= f[p-1];
				u[p-1] = 0;
			}

			t += f[p];
			u[p] = 1;
			p++;
		}

		const char* sp = "";
		for (int i = 9; i >= 0; i--) {
			if (u[i]) {
				printf("%s%d", sp, f[i]);
				if (*sp == 0) {
					sp = " ";
				}
			}
		}
		printf("\n");

	}

	return 0;
}

C++: #include <iostream>
 
int main(){
    int a,b,c;
    int d[10];
     
     
    while(std::cin>>a){
        for(b=1;b<=10;b++){
        d[b]=0;
        }
         
        for(b=0;b<2;b++){
            if(a==b){
                d[1]=b;
            }else{
                for(c=0;c<3;c=c+2){
                    if(a==b+c){
                        d[1]=b;
                        d[2]=c;
                         
                         
                    }else{
                        for(int e=0;e<5;e=e+4){
            if(a==b+c+e){
                d[1]=b;
                d[2]=c;
                        d[3]=e;
                     
            }else{
                for(int f=0;f<9;f=f+8){
                    if(a==b+c+e+f){
                        d[1]=b;
                        d[2]=c;
                        d[3]=e;
                        d[4]=f;
                         
                    }else{
                        for(int g=0;g<17;g=g+16){
            if(a==b+c+e+f+g){
                d[1]=b;
                d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                         
            }else{
                for(int h=0;h<33;h=h+32){
                    if(a==b+c+e+f+g+h){
                        d[1]=b;
                        d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                         
                     
                    }else{
                        for(int i=0;i<65;i=i+64){
            if(a==b+c+e+f+g+h+i){
                d[1]=b;d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                        d[7]=i;
                         
            }else{
                for(int j=0;j<129;j=j+128){
                    if(a==b+c+e+f+g+h+i+j){
                        d[1]=b;
                        d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                        d[7]=i;
                        d[8]=j;
                         
                    }else{
                        for(int k=0;k<257;k=k+256){
            if(a==b+c+e+f+g+h+i+j+k){
                d[1]=b;
                d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                        d[7]=i;
                        d[8]=j;
                        d[9]=k;
                         
            }else{
                for(int l=0;l<513;l=l+512){
                    if(a==b+c+e+f+g+h+i+j+k+l){
                        d[1]=b;
                        d[2]=c;
                        d[3]=e;
                        d[4]=f;
                        d[5]=g;
                        d[6]=h;
                        d[7]=i;
                        d[8]=j;
                        d[9]=k;
                        d[10]=l;
                    }                }
            }
             
        }
                    }
                }
            }
             
        }
                    }
                }
            }
             
        }
                    }
                }
            }
             
        }
                    }
                }
            }
             
        }
        int n=0;
        for(int m=1;m<11;m++){
        if(d[m]!=0&&n==0)
        {
            std::cout<<d[m];
            n++;
        }
        else if(d[m]!=0){
            std::cout<<" "<<d[m];
        }
    }
    std::cout<<std::endl;
    }
    return 0;
}