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 argc, char *argv[]) {
  int weight;
  int item[10] = {1, 2, 4, 8, 16, 32,
                  64, 128, 256, 512};
  vector< vector<int> > result;
  while (cin >> weight) {
    vector<int> r;
    for (int i = 10; i > 0; i--)
      if (weight >= item[i-1]) {
        r.push_back(item[i-1]);
        weight -= item[i-1];
      }
    result.push_back(r);
  }

  for (int i = 0; i < result.size(); i++) {
    vector<int> r = result[i];
    for (int j = r.size(); j > 0; j--) {
      if (j != r.size())
        cout << ' ';
      cout << r[j-1];
    }
    cout << endl;
  }
  return 0;
}

C++: //Weight

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

bool g[65];

//?????????????????£??°??????????????°?????°??????
int count_bits(unsigned x){
    int count = 0;
    while(x){
        if(x & 1U) count++;
        x >>= 1;
    }
    return count;
}

//unsinged??????bit??°?????????
int int_bit(void){
    return count_bits(~0U);
}
//??£??°?????????????????§?????????????????????????????¨??????????°??????????????????????????´?????????????
void createArray(unsigned x){
    int n = int_bit();
    for(int i = 0; i < n; i++){
        if((x >> i) & 1U) g[i] = true; 
    }
}

int main(void){

    int i = 9;
    unsigned int x;
    int dp[10][10]; // i?????????????????????????????????weight
    //Dp??§???
    
    while((scanf("%d", &x)) != EOF){
       for(int i = 0; i < 65; i++) g[i] = false;
       createArray(x);
       
       //flag????????£???????????????????°???????????????¨???????????????
       for(int i = 0, j = 0; i < 10; i++) {
           if(g[i]) {
               if(j) printf(" ");
               printf("%d", (int)pow(2.0, (double)i));
               j++;
           }
       }
       putchar('\n');
       
    }
    
    return 0;
}

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

int main() {
	int N, S;
	vector<int> v(10, 1);
	for (int i = 0; i < 10; i++) {
		int& p = v.at(i);
		for (int j = 0; j < i; j++) {
			p *= 2;
		}
		//cout << p << endl;
	}
	
	int n;
	while (cin >> n) {
		bitset<10> bs(n);
		int c = bs.count();

		for (int i = 0; i < 10; i++) {
			if (bs.test(i)) {
				cout << v.at(i);
				c--;

				if (!c) {
					cout << endl;
					break;
				}
				else {
					cout << ' ';
				}
			}
		}
	}
}

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

int main()
{
	int w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int g;
	bool flag[10];
	bool fl;
	
	while (cin >> g){
		for (int i = 0; i < 10; i++){
			flag[i] = false;
		}
		
		for (int i = 9; i >= 0; i--){
			if (g >= w[i]){
				flag[i] = true;
				g -= w[i];
			}
		}
		
		fl = false;
		for (int i = 0; i < 10; i++){
			if (flag[i] == true){
				if (fl == true){
					cout << " ";
				}
				cout << w[i];
				if (fl == false){
					fl = true;
				}
			}
		}
		cout << endl;
	}
	
	return (0);
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int weights[] = {1,2,4,8,16,32,64,128,256,512,1024};
int main(){
	int n,a[10],b,c;
	while(cin >> n){
		b = 0;
		c = 11;
		while(n != 0){
			for(int i = 0;i < c;++i){
				if(n < weights[i]){
					n -= weights[i - 1];
					a[b] = i - 1;
					c = i;
					++b;
					break;
				}
			}
		}
		sort(a,a+b);
		for(int i = 0;i < b;++i){
			if(i == 0) cout << weights[a[i]];
			else cout << " " << weights[a[i]];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;


int main(int argc, char const* argv[])
{
	unsigned long weight;
	while( cin >> weight ){
		bitset<16> a( weight );
		for( int i = 0;i < 10;i++ ){
			if( a[i] == 1 ) cout << ( ( i == 0 ) ? "" : " " ) << ( 1 << i );
		}
		cout << endl;
	}
	return 0;
}

C++: //0031
//include-------------------------------------
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<stack>

using namespace std;

//typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MP make_pair

//repetition-----------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

//constant-------------------------------------
const double PI = acos(-1.0);

//cout,cin-------------------------------------
#define COUT(x) cout<<(x)<<endl;
#define CIN(x) cin>>(x);

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

int main(){

	int w;
	while (1){
		stack <int> st;
		CIN(w)
		for (int i = 10; i >= 0; i--){
			if (w >= weight[i]) {
				st.push(weight[i]);
				w -= weight[i];
			}
		}

		while (st.top()!=0){
			cout << st.top();
			st.pop();
			if (st.size() != 0) cout << " ";
		}
		cout << endl;
	}

	return 0;

}

C++: #include <iostream>
using namespace std;
int main(){
  int w[10]={1,2,4,8,16,32,64,128,256,512};
  int n;
  while(cin>>n){
    for(int i=0;n>0;n/=2,i++)
      if (n%2) cout<<w[i]<<" ";
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int n;
    while (cin >> n){
    	int i;
    	for(i=1; i <= 512; i *= 2){
    		if ((i&n) != 0) {
    			cout << i;
    			break;
    		}
    	}
    	for(i = i*2; i <= 512; i *= 2){
    		if ((i&n) != 0) cout << ' ' << i;
    	}
    	cout << endl;
    }
}

C++: //#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>
//#include <map>

using namespace std;


int main(){

	int m, buf;

	while (cin >> m){
		buf = 1;

		for (int i = 0; i < 10; i++){
			if (m % 2 == 1) cout << buf << " ";
			m >>= 1;
			buf *= 2;
		}
		cout << endl;

	}

	return 0;
}

C++: #include <cstdio>
int main(){int n,s;while(scanf("%d",&n)){for(s=1;n;s*=2){n&s&&printf("%d%c",s,n-s?32:10);n-=n&s;}}}

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

int main(void){
	int omori[10]={1,2,4,8,16,32,64,128,256,512},a;
	stack<int> st; 
	int kari;
	while(cin>>a){
		for(int i=9; 0<=i; i--)
		{
			if(a-omori[i]>-1)
			{
				st.push(omori[i]);
				a=a-omori[i];
			}
		}
		while(1)
		{
			if (st.empty())break;
			cout << st.top()<<" ";
			st.pop();
		}
		cout<<endl;
	}
	return 0;
}