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 <vector>
using namespace std;
 
int main()
{
    int weight;
    while(cin >> weight)
{
        vector<int> vi;
        for(int i = 512; weight != 0; i = i / 2)
{
            if(weight >= i)
{
                weight -= i;
                vi.push_back(i);
            }
        }
        int size = vi.size();
        if(size > 0)
{
            cout << vi[size - 1];
            for(int i = size - 2; i >= 0; i--)
{
                cout << " " << vi[i];
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <stdio.h>

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

C++: #include <iostream>

using namespace std;

void solve()
{
	int weight[10];
	int c = 1;
	for(int i = 0; i < 10; ++i)
	{
		weight[i] = c;
		c *= 2;
	}
	int w;
	while(cin >> w)
	{
		bool useWeight[10] = {false};
		int lastPoint = 0;
		for(int i = 9; i >= 0; --i)
		{
			if(w >= weight[i])
			{
				w -= weight[i];
				useWeight[i] = true;
				if(lastPoint < i)
				{
					lastPoint = i;
				}
			}
		}
		for(int i = 0; i < lastPoint; ++i)
		{
			if(useWeight[i])
			{
				cout << weight[i];
				cout << " ";
			}
		}
		cout << weight[lastPoint] << endl;
	}
}

int main()
{
	solve();
	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);
	cout << (n ? ' ' : '\n');
      }
      n >>= 1;
    }
    cout << endl;
  }
  return 0;
}

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

vi dec2binv(int n){
	vi x;
	while (n>0){
		if (n%2==1) x.push_back(1);
		else x.push_back(0);
		n/=2;
	}
	if (x.empty()) x.push_back(0);
	return x;
}

int main(void){

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

	while (true){
		int n;
		cin>>n;
		if (cin.eof()) break;
		vi tmp = dec2binv(n);
		for (int i=0; i<int(tmp.size()); i++){
			if (tmp[i]==1) cout<<weight[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,r,n) for(int i=r;i<(int)n;i++)
using namespace std;
int in(){int x;cin>>x;return x;}
string s[10]={"1","2","4","8","16","32","64","128","256","512"};
int ss[10]={1,2,4,8,16,32,64,128,256,512};
string ans[1200];
bool fis=false;
void sss(string z,int y,int l)
{
	ans[y]=z;
	if(l==10)return ;
	sss(z,y,l+1);
	if(l!=0)z+=" ";
	z+=s[l];
	y+=ss[l];
	sss(z,y,l+1);
	return ;

}


int main ()
{
	fis=false;
	int a;
	sss("",0,0);	
	while(scanf("%d",&a)!=EOF)
	{
		cout<<ans[a]<<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]);
		}
		printf("\n");
	}
	return 0;
}