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 <math.h>
using namespace std;

int main(){
	int n;
	while(cin >> n){ 
		int weight[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		for(int i = 9; i >= 0; i--){
			if(n >= pow(2, i)){
				n -= pow(2, i);
				weight[i] = 1;
			}
		}

		cout << "1";
		for(int i = 1; i < 10; i++){
			if(weight[i]){
				cout << " " << pow(2, i);
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main()
{
	int m;
	while(cin >> m)
	{
		int w=1;
		while(m)
		{
			if(m&1) cout << (w==1?"":" ") << w;
			m = m>>1;
			w = w<<1;
		}
		cout << endl;
	}
}

C++: #include <iostream>

using namespace std;
int main(void){
    // Here your code !
int n;

while(cin>>n){
bool flag=false;

for(int i=1;i<=512;i=i*2){

if(n%(i*2)!=0){
    if(flag) cout<<" ";
    flag=true;
    cout<<i;
    n=n-i;
}
}

cout<<endl;
}
return 0;
}

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

C++: #include <bits/stdc++.h>

using namespace std;

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

C++: #include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	while(cin>>n){
		for (int i = 0; i < 11; ++i) {

			if(n%2){
				if(i!=0){
					cout<<" "<<pow(2,i);
				}else{
					cout<<pow(2,i);
				}
			}
			if(n==1)break;
			n=n/2;
		}
		cout<<" "<<endl;
	}
}

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

using namespace std;

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

int main() {
	int n;
	while (scanf("%d", &n) != EOF) {
		for (int i=0; i<10; ++i) vis[i] = 0;
		for (int i=9; i>=0; --i) {
			if (n >= gs[i]) {
				vis[i] = 1;
				n -= gs[i];
			}
			if (n <= 0) break;
		}
		int cs = 0;
		for (int i=0; i<10; ++i) {
			if (vis[i]) printf (cs++ ? " %d" : "%d", gs[i]);
		}
		printf ("\n");
	}
	return 0;
}

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

int main(void){
	int n;
	while(cin>>n){
		vector<int> s;
		for(int i=512;i>0;i>>=1){
			if(n>=i){
				n-=i;
				s.push_back(i);
			}
		}
		for(int it=s.size()-1;it>=0;it--){
			if(it!=0)cout<<s[it]<<" ";
			else cout<<s[it];
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){
    const int w[10]={1,2,4,8,16,32,64,128,256,512};
    int n;
    
    while(cin >> n){
        int nw[10]={0};
        int cnt=0;
        
        for(int i = 0 ; w[i] <= n ; i++){
            nw[i] = w[i];
            cnt++;
        }
        
        int sum = 0;
        int nnw[10]={0};
        int k = 0;
        int m = n;
        for(int i = 0 ; i < cnt ; i++){
            for(int j = cnt-1 ; j >= 0 ; j--){
                
                if(sum == n) break;
                
                if(nw[j] <= m){
                    nnw[k++] = nw[j];
                    sum += nw[j];
                    m -= nw[j];
                }
            }
            if(sum == n) break;
        }
        sort(nnw,nnw+k);
        
        for(int i = 0 ; i < k ; i++){
            if(i == 0) cout << nnw[i];
            else cout << ' ' << nnw[i];
        }
        cout << endl;
    }

    return 0;
}

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

int main(){
    int n;
    while(cin>>n,n){
        vector<int>vec;
        for(int i=512;i>0;i=i>>1){
            if(n>=i){
                n-=i;
                vec.push_back(i);
            }
        }
        for(int i=0;i<vec.size();i++)
            cout<<vec[vec.size()-1-i]<<" ";
        cout<<endl;
    }
    return 0;
}

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

int main()
{
	int n, count = 0, sum = 1;
	static int ans[100][9] = { 0 };
	int data[100] = { 0 }, ansdata[100] = {0};
	for (int a = 0; a <= 10; a++) {
		data[a+1] = sum;
		sum = sum * 2;
	}
	while (cin >> n) {
		int data2, count2 = 0;
		for (int a = 0; a <= 10; a++) {
			if (n < data[a + 1]) {
				sum = data[a];
				data2 = a;
				ans[count][count2] = a;
				count2++;
				break;
			}
		}
		for (int a = data2-1; a > 0; a--) {
			sum = sum + data[a];
			if (sum > n) {
				sum = sum - data[a];
			}
			else {
				ans[count][count2] = a;
				count2++;
			}
			if (sum == n) {
				break;
			}
		}
		ansdata[count] = count2;
		count++;
	}
	for (int a = 0; a < count; a++) {
		for (int b = ansdata[a]-1; b>=0; b--) {
			cout << data[ans[a][b]];
			if (b != 0)
				cout << " ";
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>

int main()
{
    int w;
    while (std::cin >> w) {
        bool top = true;
        for (int i = 1; i <= 512; i <<= 1) {
            if (w & i) {
                if (top) top = false;
                else std::cout << " ";
                std::cout << (w & i);
            }
        }
        std::cout << std::endl;
    }
}

C++: #include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

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

	int N;
	while (cin >> N) {
		vector<int>ans;
		while (N != 0) {
			if (N - 512 >= 0) {
				N -= 512;
				ans.push_back(512);
			} else if (N - 256 >= 0) {
				N -= 256;
				ans.push_back(256);
			} else if (N - 128 >= 0) {
				N -= 128;
				ans.push_back(128);
			} else if (N - 64 >= 0) {
				N -= 64;
				ans.push_back(64);
			} else if (N - 32 >= 0) {
				N -= 32;
				ans.push_back(32);
			} else if (N - 16 >= 0) {
				N -= 16;
				ans.push_back(16);
			} else if (N - 8 >= 0) {
				N -= 8;
				ans.push_back(8);
			} else if (N - 4 >= 0) {
				N -= 4;
				ans.push_back(4);
			} else if (N - 2 >= 0) {
				N -= 2;
				ans.push_back(2);
			} else {
				N--;
				ans.push_back(1);
			}
		}

		SORT(ans);
		cout << ans[0];
		REP2(i, 1, ans.size()) {
			cout << ' ' << ans[i];
		}
		cout << "\n";
	}
	return 0;
}