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 <cstdio>

int main() {
    int n = 0;

    while (scanf("%d", &n) != EOF) {
        int t = 1;

        for (int i = 0; i < 10; ++i) {
            if ((n & t) == t) {
                if (i != 0) {
                    printf(" ");
                }
                printf("%d", t);
            }

            t *= 2;
        }
        printf("\n");
    }

    return 0;
}

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

int main()
{
	int n;
	while (cin >> n) {
		bool flag = false;
		for (int i = 0; i < 10; i++) {
			if (n & (1 << i)) {
				if (flag) {
					cout << ' ';
				}
				cout << (1 << i);
				flag = true;
			}
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
  int x;
  while (scanf("%d ", &x) == 1) {
    int omori = 512;
    while (x != 0) {
      if (x >= omori) {
	x -= omori;
	cout << omori << " ";
	omori /= 2;
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>

int main(){
	int a,b,c=1;
	int d[10];
	
	
	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;
					}else{
						
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
		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>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#include <string>

#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;




int main(){
  int n;


  while (std::cin >> n) {
    int weight[10]={0};

    for(int j=9;j>=0;j--){
      if(n>=pow(2,j)){
        weight[j]=1;
        n-=pow(2,j);
      }
    }

    for(int i=0;i<9;i++){
      if(weight[i]==1){
        std::cout << pow(2,i)<<" ";
      }
    }
    if(weight[9]==1){
      std::cout << "512" << '\n';
    }

  }
}

C++: #include <iostream>

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

void solve()
{
	int w;
	while(cin >> w)
	{
		bool flag[10];
		int sumcount = 0;
		for(int i = 0; i < 10; ++i)
		{
			flag[i] = false;
		}
		for(int i = 9; i >= 0; --i)
		{
			if(w >= weight[i])
			{
				w -= weight[i];
				flag[i] = true;
				++sumcount;
			}
		}
		int count = 0;
		for(int i = 0; i < 10; ++i)
		{
			if(flag[i] && sumcount > count + 1)
			{
				cout << weight[i] << " ";
				++count;
			}
			else if(flag[i] && sumcount == count + 1)
			{
				cout << weight[i];
			}
		}
		cout << endl;
	}
}

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

C++: #include <bits/stdc++.h>
 
using namespace std;
 
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++) 
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
 
int main(void)
{
  int pw[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
  int n;
  
  while (cin >> n){
    vi li;
    int cnt = 0;
    REP(i, 10){
      if (n - pw[i] >= 0){
        n -= pw[i];
        li.pb(pw[i]);
        cnt++;
      }
    }
    sort(all(li));
    REP(i, cnt){
      cout << li[i] << " ";
    }
    cout << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n) {
    vector<int> ans;
    for (int i = 0; i < 10; i++) {
      if (n >> i & 1) ans.emplace_back(1 << i);
    }
    for (int i = 0; i < (int)ans.size(); i++) {
      cout << ans[i] << " \n"[i + 1 == (int)ans.size()];
    }
  }

  return 0;
}

C++: #include <iostream>


int main(void)
{
	int n=0;
	while(std::cin >> n){
		bool first=true;
		for(int i=0; i<10; i++)
			if(n & (1 << i))
			{
				if(first)
				{
					std::cout << (n&(1 << i)) << std::flush;
					first = false;
				}
				else
					std::cout << " " << (n&(1<<i)) << std::flush;
			}
		std::cout << std::endl;
	}
	return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    bool f = false;
    for (int i = 0; i < 10; i++) {
      if (n & (1 << i)) {
        if (f) cout << " ";
        cout << pow(2, i);
        f = true;
      }
    }
    cout << endl;
  }
}