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>
using namespace std;
int main(){
  int n;
  while(cin >> n){

    int ans[1000];
    int p = 0;

    int m = n;
    for(int i = 2 ; i < m ; i*=2){
      if(i*2 > m)m = i;
    }

    for(int i = m ;i > 0; i/=2 ){
      if(n - i >= 0 ){
	ans[p++] = i;
	n -= i;
      }
    }
  for(int i = p - 1 ; i >= 0 ; i-- ){
    cout << ans[i] << " ";
  }
  cout << endl;

  }
  }

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	vector <int> W;
//	cut here before submit 
//	freopen("testcase.w", "r", stdin);
	string str = "";
	int i;
	for (i = 1; i <= 512; i *= 2){
		W.push_back(i);
	} // end for

	sort (W.begin(), W.end(), greater<int>() );
	int size = W.size();

	while (getline (cin, str ) ){
		vector <int> res;
		int wight = 0;
		stringstream ss(str);
		ss >> wight;
	
		for (i = 0; i < size; ++i){
			if (wight < W[i]){
				continue;
			}else if (wight == W[i]){
				res.push_back(W[i]);
				break;
			}else{	// if (wight > W[i])
				res.push_back(W[i]);
				wight -= W[i];
			} // end if
		} // end for

		sort (res.begin(), res.end() );

		for (i = 0; i < res.size(); ++i){
			cout << res[i];
			if (i != res.size() - 1){
				cout << ' ';
			} // end if
		} // end for
		cout << endl;
	} // end while

		
	return 0;
}

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

int main(){
	int n, a[] = {1,2,4,8,16,32,64,128,256,512};
	bool r[10];
	while(cin >> n){
		fill(r, r+10, false);
		for(int s = 9;0 < n && 0 <= s;s--){
			if(n >= a[s]){r[s] = true;n -= a[s];}
		}
		bool f = false;
		for(int i = 0;i < 10;i++){
			if(r[i] == true){
				if(f == true)cout << " ";
				cout << a[i];f = true;
			}
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;
const int V[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
int n;

void solve(){
    vector<int> w;
    for(int i=0; i<10; i++){
        int f = n/V[i];
        if(f!=0){
            n -= V[i];
            w.push_back(V[i]);
        }
    }
    for(int i=w.size()-2; i>=0; i--){
        cout<<" "<< w[i];
    }
    cout<<endl;
}
int main(){
    while(cin>>n){
        solve();
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

template <class Type>
Type power(Type X, int Y)
{
	Type Ans = 1;

	if (Y >= 0)
	{
		for (int i = 0; i < Y; i++)
		{
			Ans *= X;
		}
	}
	else
	{
		for (int i = 0; i < (-Y); i++)
		{
			Ans /= X;
		}
	}

	return Ans;
}

int main()
{
	int N;

	while (cin >> N)
	{
		for (int i = 0; i < 10; i++)
		{
			if ((N / power<int>(2, i)) % 2 == 1)
			{
				cout << power<int>(2, i) << ' ';
			}
		}

		cout << endl;
	}

	return 0;
}

C++: #include <iostream>
 
int main(){
    int a,b,c;
    int d[11];
     
     
    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;
}

C++: #include<iostream>

int main()
{
	int a;
	while( std::cin >> a ){
		int i = 0;
		while( a > 0 ){
			if( a & 1 ) std::cout << ( 1 << i ) << ( ( a >> 1 ) & -( a >> 1 ) ? " " : "" );
			a >>= 1;
			i++;
		}
		
		std::cout << std::endl;
	}

 	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	int	w;
	while (scanf("%d", &w) != EOF)
	{
		vector<int> v;
		for (int i = 0; i < 10; ++i)
		{
			if (w & 1 << i)
				v.push_back(1<<i);
		}
		for (int i = 0; i < v.size()-1; ++i)
			printf("%d ", v[i]);
		printf("%d\n", v[v.size()-1]);
	}
	return 0;
}