Go: 
package main

import (
	"fmt"
	"math"
)

func solve(n int) int {
	i := 0
	for {
		if val := math.Pow(2, float64(i)); val*2 > float64(n) {
			return int(val)
		}
		i++
	}
}

func main() {
	for {
		var n int
		_, err := fmt.Scan(&n)
		if err != nil {
			break
		}

		res := []int{}
		for {
			val := solve(n)
			res = append(res, val)
			n -= val

			if n <= 0 {
				break
			}
		}

		for i := range res {
			if i != 0 {
				fmt.Print(" ")
			}
			fmt.Print(res[len(res)-i-1])
		}
		fmt.Println()
	}
}

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	int n;
	int tai[] = {512,256,128,64,32,16,8,4,2,1};
	while(scanf("%d",&n)==1){
		vector<int> sol;
		for(int x=0;x<10 && n>0;++x){
			if(n-tai[x]>=0){
				n -= tai[x];
				sol.push_back(tai[x]);
			}
		}
		for(int x=sol.size()-1;x>0;--x){
			cout<<sol[x]<<" ";
		}
		cout<<sol[0]<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	vector<int> weights;
	vector<int> use;
	weights.push_back(1);
	weights.push_back(2);
	weights.push_back(4);
	weights.push_back(8);
	weights.push_back(18);
	weights.push_back(32);
	weights.push_back(64);
	weights.push_back(128);
	weights.push_back(256);
	int w;

	while(cin>>w,!cin.eof()) {
		while(w!=0){
			for(int i=0; i<weights.size(); i++){
				if(w == 0) break;
				if(weights.at(i) > w){
					w -= weights.at(i-1);
					use.push_back(weights.at(i-1));
					break;
				}
			}
		}
		sort(use.begin(), use.end());
		for(int i=0; i<use.size()-1; i++){
			cout<<use[i]<<" ";
		}
		cout<<use[use.size()-1]<<endl;
		use.clear();
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 100000



int main(){
	int w;
	bool ans[10];
	for(int i=0;i<11;i++){
		ans[i]=0;
	}
	while(cin>>w){
		
		for(int i=0;i<11;i++){
			ans[i]=0;
		}
		for(int i=10;i--;){
			if(w>=pow(2,i)){
				ans[i]=1;
				w=w-pow(2,i);
			}
		}
		
		int i=0;
		for(;i<11;i++){
			if(ans[i]){
				cout<<pow(2,i);
				break;
			}
		}i++;
		for(;i<11;i++){
			if(ans[i]){
				cout<<" "<<pow(2,i);
			}
		}cout<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    while(cin>>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 <stdio.h>
int main(){
	int a;
	int weight[10]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	while(~scanf("%d",&a)){
		bool t[10];
		for(int i=9;i>-1;i--) t[i]=false;
		for(int i=9;i>-1;i--){
			if(weight[i]<=a){
				a-=weight[i];
				t[i]=true;
			}
		}
		for(int i=0;i<10;i++){
			if(t[i]){
				printf("%d",weight[i]);
				break;
			}
		}
		for(int i=0;i<10;i++){
			if(t[i]) printf(" %d",weight[i]);
		}
		printf("\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int weight[10]={1,2,4,8,16,32,64,128,256,512,};
bool weightFlag[10];
int main(){
    int n;
    while(cin>>n){
        if(n>=weight[9]){
            n-=weight[9];
            weightFlag[9]=true;
        }
        if(n>=weight[8]){
            n-=weight[8];
            weightFlag[8]=true;
        }
        if(n>=weight[7]){
            n-=weight[7];
            weightFlag[7]=true;
        }
        if(n>=weight[6]){
            n-=weight[6];
            weightFlag[6]=true;
        }
        if(n>=weight[6]){
            n-=weight[6];
            weightFlag[6]=true;
        }
        if(n>=weight[5]){
            n-=weight[5];
            weightFlag[5]=true;
        }
        if(n>=weight[4]){
            n-=weight[4];
            weightFlag[4]=true;
        }
        if(n>=weight[3]){
            n-=weight[3];
            weightFlag[3]=true;
        }
        if(n>=weight[2]){
            n-=weight[2];
            weightFlag[2]=true;
        }
        if(n>=weight[1]){
            n-=weight[1];
            weightFlag[1]=true;
        }
        if(n>=weight[0]){
            n-=weight[0];
            weightFlag[0]=true;
        }
        for(int i=0;i<10;i++){
            if(weightFlag[i]){
                cout<<weight[i];
                for(int j=i+1;j<10;j++){
                    if(weightFlag[j]){
                        cout<<' ';
                        break;
                    }
                }
            }
        }
        cout<<endl;
        for(int i=0;i<10;i++) weightFlag[i]=false;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(void)
{
int x;
while(cin>>x)
{
int a[10]={1,2,4,8,16,32,64,128,256,512};
int b[10]={0};

int j=0;
for(int i=9;i>=0;i--)
{
	if(x>=a[i])
	{
	x-=a[i];
	b[j]=a[i];
	j++;
	if(x==0)break;
	}
}
for(int i=9;i>=0;i--)
{
(b[i]!=0)cout<<b[i]<<(i==0?"\n":" ");
}
}
return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int w;
	while(cin>>w)
	{
		bool flag=0;
		for(int i=1;i<=w;i*=2)
		{
			if(w%(i*2)>0)
			{
				if(flag)
				{
					cout<<' ';
				}
				cout<<i;
				flag=1;
				w-=i;
			}
		}
		cout<<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(pow(2,i)*2<t)std::cout<<" ";}num/=10;}
    std::cout<<std::endl;
    }
}

C++: #include <stdio.h>
#include <math.h>
int main(void)
{
	int nisin[10]={0};
	int n,i;
	while(scanf("%d",&n) != EOF)
	{
		int count=0,count2=0;
		for(i=0;;i++)
		{
			nisin[i] = n%2;
			n /= 2;
			if(n==0)break;
		}
		for(i=0;i<10;i++)
		{
			if(nisin[i])count++;
		}
		for(i=0;i<9;i++)
		{
			if(nisin[i])
			{
				printf("%d",(int)(pow(2,i)));
				count2++;
				if(count2==count)printf("\n");
				else printf(" ");
			}
		}
	}
	return 0;
}

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

int main() {
	for(int n; cin >> n;) {
		vector<int> ans;

		for(int bit = 1; bit <= n; bit <<= 1) {
			if(bit & n) ans.emplace_back(bit);
		}

		for(unsigned i = 0; i < ans.size(); ++i) {
			cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");
		}
	}

	return EXIT_SUCCESS;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int n;
    int w[10];
    w[0]=1;
    for (int i=1;i<10;++i) {
        w[i]=w[i-1]<<1;
    }
    while (scanf("%d",&n)!=EOF) {
        int tmp=0;
        stack<int> st;
        for (int i=9;i>=0;--i) {
            if (w[i]<=n) {
                st.push(w[i]);
                n-=w[i];
                tmp++;
            }
        }
        for (int i=0;i<tmp-1;++i) {
            printf("%d ",st.top());
            st.pop();
        }
        printf("%d\n",st.top());
    }
    return 0;
}

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

int ans[10];
int count=0;
int weight;
int temp[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main(){
	while(scanf("%d", &weight) != EOF){
		count = 0;
		for(int i=9; 0 <= i; i--){
			if(temp[i] <= weight){
				weight -= temp[i];
				ans[count] = temp[i];
				count++;
			}
			if(weight == 0) break;
		}
		for(int i=count-1; 0 <= i; i--){
			if(i != 0) cout << ans[i]  << ' ';
			else cout << ans[i] << endl;
		}
	}
}