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<cmath>
using namespace std;

int main(){
	int n,a[10],c;
	
	while(cin>>n){
		c=0;
		for(int i=0;i<10;i++) a[i]=0;
		for(int i=9;i>=0;i--){
			if(n>=pow(2,i)){
				n-=pow(2,i);
				a[i]++;
			}
		}
		for(int i=0;i<10;i++){
			if(a[i]!=0){
				if(c!=0) cout << " ";
				cout << pow(2,i);
				c++;
			}
		}
		cout << endl;
	}
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a;
  int i = 0;
  while (cin >> a) {
    while (1) {
      a -= pow(2, i);
      if (a == 0) {
        for (int j = 0; j <= i; j++) {
          cout << pow(2, j) << ' ';
        }
        cout << endl;
        i = 0;
        break;
      } else {
        i++;
      }
    }
  }
  return 0;
}

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

int main() {
    int weight;
    while (cin >> weight) {
        for (int i = 0; weight > 0; weight /= 2, i++) {
            if (weight % 2 == 1) {
                cout << pow(2, i) << " ";
            }
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int N;
	while (cin >> N) {
		vector<int>ans;
		while (N != 0) {
			if (N - 512 >= 0) {
				N -= 512;
				ans.push_back(512);
			} else if (N - 256 >= 0) {
				N -= 256;
				ans.push_back(256);
			} else if (N - 128 >= 0) {
				N -= 128;
				ans.push_back(128);
			} else if (N - 64 >= 0) {
				N -= 64;
				ans.push_back(64);
			} else if (N - 32 >= 0) {
				N -= 32;
				ans.push_back(32);
			} else if (N - 16 >= 0) {
				N -= 16;
				ans.push_back(16);
			} else if (N - 8 >= 0) {
				N -= 8;
				ans.push_back(8);
			} else if (N - 4 >= 0) {
				N -= 4;
				ans.push_back(4);
			} else if (N - 2 >= 0) {
				N -= 2;
				ans.push_back(2);
			} else {
				N--;
				ans.push_back(1);
			}
		}

		SORT(ans);
		REP(i, ans.size()) {
			cout << ans[i] << " ";
		}
		cout << "\n";
	}
	return 0;
}

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

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

C++: #include <iostream>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n){
    int s=0,a[10],k=0;
    for(int i=512;i>0;i/=2)if(n>=i){
        a[k++]=i;
	n-=i;
      }
    for(int i=k-1;i>=0;i--,s++){
      if(!s)cout<<a[i];
      else cout<<' '<<a[i];
    }
    cout<<endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int weight[10];
	weight[0] = 1;
	for(int i = 1; i < 10; i++){
		weight[i] = weight[i-1]*2;
	}
	int n;
	while(cin >> n){
		vector<int> ans;
		for(int i = 10; i >= 0; i--){
			if(weight[i] <= n){
				n -= weight[i];
				ans.pb(weight[i]);
			}
			if(n == 0)break;
		}
		for(int i = ans.size()-1; i > 0; i--){
			//if(i == 1)cout << ans[i] << endl;
			//else 
				cout << ans[i] << " ";
		}
	}


	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<bitset>
#include<sstream>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int x;
    bool first;
    int i;
    int g;
    while(cin >> x){
        first = true;
        g = 1;
        int ans[10] = {0};
        for(i = 0; x > 1; i++){
            ans[i] = x % 2;
            x /= 2;
        }ans[i] = x;
        rep(j,10){
            if(ans[j] == 1 && first == true){
                cout << g;
                first = false;
            }else if(ans[j] == 1){
                cout << " " << g;
            }g *= 2;
        }cout << endl;
    }
}

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

int main() {
	ios :: sync_with_stdio(false);
	for(int n; cin >> n; ) {
		for(int i = 0; i < 10; i ++) if((n >> i) & 1) {
			n -= (1 << i);
			cout << (1 << i) << (n ? ' ' : '\n');
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int n;
    int w[10];
    w[0]=1;
    for (int i=1;i<10;++i) {
        w[i]=w[i-1]<<1;
    }
    while (scanf("%d",&n)!=EOF) {
        int tmp=0;
        stack<int> st;
        for (int i=9;i>=0;--i) {
            if (w[i]<=n) {
                st.push(w[i]);
                n-=w[i];
                tmp++;
            }
        }
        for (int i=0;i<tmp;++i) {
            printf("%d ",st.top());
            st.pop();
        }
        printf("\n");
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;




int main(){


	int n,m;
	while (cin >> n){
		stack<int> stack;
		m = 512;
		while (m){
			if (n >= m){
				stack.push(m);
				n -= m;
			}
			m /= 2;
		}
		int k(0);
		if (!stack.empty()){
			k += stack.top();
			cout << stack.top();
			stack.pop();
		}
		while (!stack.empty()){
			cout << " ";
			k += stack.top();
			cout << stack.top();
			stack.pop();
		}
		cout << ":::::::"  << k;
		cout << endl;
	}
	return 0;
}