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 <string>
#include <stack>
#include <algorithm>
#include <stdio.h>

using namespace std;

int v[] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
int w;
stack<int> spent;

int main(void) {
    while(~scanf("%d", &w)) {
        for(int i = 0; i < 10; i++) {
            if(w >= v[i]) {
                w -= v[i];
                spent.push(v[i]);
            }
        }
        while(!spent.empty()) {
            if(spent.size() == 1) {
                cout << spent.top();
            } else {
                cout << spent.top() << " ";
            }
            spent.pop();
        }
        cout << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;

int N;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

bool W_b[10] = { false };
int W[] = { 1, 2, 4, 8 ,16, 32, 64, 128, 256, 512 };

void input(void) {
	CI N;
	return;
}


int main(void) {
	int nn = 0;
	while (CI N) {
		for (int i = 9; i >= 0; i--) {
			if (W[i] <= N) {
				N -= W[i];
				W_b[i] = true;
				nn++;
			}
		}
		int x = 0;
		for (int i = 0; i < 10; i++) {
			if (W_b[i] == true) {
				x++;
				CO W[i];
				if (x < nn)CO " ";
				W_b[i] = false;
			}
		}
		CO "\n";
	
		nn = 0;
	}
	

	
	return 0;
}

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

using namespace std;

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

int main()
{
    Solution();
    return 0;
}

C++: #include<iostream>
#include<vector>
int n=1024;
std::vector<int> g;

int main(){
	int a;
	while(std::cin>>a){
		int n_=0;
		bool f=true;
		while(1){
			if(n<a&&f)g.push_back(n),a-=n,n_=n,f=false;
			else if(n<a)g.push_back(n),a-=n;
			else n/=2;
			if(a==1){
				g.push_back(1);
				break;
			}
			//std::cout<<a<<" "<<n<<std::endl;
		}
		
		for(auto it = g.rbegin();it!=g.rend();++it){
			std::cout<<*it;
			if(*it!=n_)std::cout<<" ";
			//if(++it!=g.rend())std::cout<<" ";
		}
		std::cout<<std::endl;
		n=1024;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> ans;
  int n;
  while(cin >> n){
    ans.clear();
    if(n > 1023) return 0;
    for(int i=512; i >= 1; i /= 2){
      if(n - i >= 0){
	n -= i;
	ans.push_back(i);
      }
    }
    sort(ans.begin(), ans.end());
    vector<int>::iterator it = ans.begin();
    while( it != ans.end() ){
      cout << *it << " ";
      ++it;
    }
    cout << endl;
    
  }
  return 0;
}

C++: #include<stdio.h>
int main(){
int a,x[12],k,i;
while(scanf("%d",&a)!=EOF){
k=0;
if(a>=512){
x[k++]=512;
a-=512;
}
if(a>=256){
x[k++]=256;
a-=256;
}
if(a>=128){
x[k++]=128;
a-=128;
}
if(a>=64){
x[k++]=64;
a-=64;
}
if(a>=32){
x[k++]=32;
a-=32;
}
if(a>=16){
x[k++]=16;
a-=16;
}
if(a>=8){
x[k++]=8;
a-=8;
}
if(a>=4){
x[k++]=4;
a-=4;
}
if(a>=2){
x[k++]=2;
a-=2;
}
if(a>=1){
x[k++]=1;
a-=1;
}
if(a==0)
for(i=k-1;i>=0;i--)
printf("%d ",x[i]);
printf("\n");
}
return 0;
}

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

int main(){
    int n;
    int i;
    while(cin >> n){
        i = 1;
        for(int j=0;j<10;j++){
            if(n & 1){
                cout << i;
                cout << " ";
            }
            i <<= 1;
            n >>= 1;
        }
        cout << endl;
    }
    return 0;
}

C++: #include<cstdio>
using namespace std;
int main(void)
{
	int n;
	bool kari = 0;
	int a[10] = {1,2,4,8,16,32,64,128,256,512};
	while(scanf("%d",&n) != EOF)
	{
		bool flag[10] = {0};
		for(int i = 9;i >= 0;i--)
		{
			if(a[i] <= n)
			{
				n -= a[i];
				flag[i] = 1;
			}
		}
		for(int i = 0;i < 10;i++)
		{
			if(flag[i] == 1)
			{
				printf("%d",a[i]);
				for(int j = i+1;j < 10;j++)
				{
					if(flag[j] == 1) kari = 1;
				}
				if(kari == 1) printf(" ");
				else printf("\n");
				kari = 0;
			}
		}
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a, i;
  while(cin>>a){
    for(i=0;i<=9;i++){
      if(a&1<<i){
        cout<<(1<<i);
        if(a<2<<i)break;
        cout<<' ';
      }
    }
    cout<<endl;
  }
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	int weight;
	int n[10];
	int arr[10];
	vector<int> ans;

	for(int i=0,j=1;j<=512;j*=2){
		arr[i++]=j;
	}
	while(cin>>weight){
		ans.clear();
		for(int i=9;i>-1;i--){
			if(weight<=1){
				if(weight==1){
					ans.push_back(weight);
					break;
				}
			}else if(weight>=arr[i]){
				weight-=arr[i];
				ans.push_back(arr[i]);
			}
		}
		for(int i=ans.size()-1;i>-1;i--){
			cout<<ans[i];
			(i==0)? cout<<endl:cout<<" "; 
		}
	}
	return 0;
}

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;
	string s ;

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

		for (int i = 0; i < 10; i++){
			if (m % 2 == 1) {
				cout << s << buf;
				s = " ";
			}
			m >>= 1;
			buf *= 2;
		}
		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()-1; i>=0; i--){
        cout<<" "<< w[i];
    }
    cout<<endl;
}
int main(){
    while(cin>>n){
        solve();
    }
    return 0;
}