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

int main(){
    int data[10] = {1,2,4,8,16,32,64,128,256,512};
    int ch[10];
    int mem;
    int sta;
    while(cin >> sta){
        mem = 0;
        memset(ch,0,sizeof(ch));
        for(int i=9;i>=0;i--){
            if(sta >= data[i]){
                if(mem == 0) mem = i;
                sta -= data[i];
                ch[i] = 1;
            }
        }
        for(int i=0;i<10;i++){
            if(mem == i) cout << data[i] << endl;
            else if(ch[i] == 1){
                cout << data[i] << " ";
            }
        }
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int field[10][10];

int H = 10;
int W = 10;

bool ng(int y, int x) {
	return y < 0 || H <= y || x < 0 || W <= x;
}

int main() {
	int n;
	while (cin >> n) {
		rep(i, 12) {
			int n2 = 1 << i;
			// dump((n >> i) & 1);
			if (((n >> i) & 1) == 0) continue;
			n ^= n2;
			// dump(n);
			if (n == 0) {
				cout << n2 << endl;
				break;
			}
			else cout << n2 << " ";
		}
	}


	return 0;
}

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

using namespace std;



int main () {
	int n;
	
	while(cin>>n){
		bool m[10]={false};
		int i=512,j=9,max=0;
		while(n!=0){
			if (n>=i) {
				m[j]=true;
				n%=i;
				if(j>max)max=j;
			}
			
			i/=2;
			j--;
		}
		
		for (int k=0; k<10; k++) {
			if (m[k]) {
				cout << (int)pow(2, (double)k);
				if (k!=max) {
					cout << ' ';
				}
			}
		
		}
		
		cout << endl;
		
		
	}
}

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 << endl;
	}
	return 0;
}

C++: #include <cstdio>

int main(){
  int n;
  while(~scanf("%d",&n)){
    bool f=false;
    for(int i=0; i<10; i++)
      if(n>>i&1)
	if(f)
	  printf(" %d",1<<i);
	else{
	  f=true;
	  printf("%d",1<<i);
	}
    printf("\n");
  }
}

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

int main(){
	int n;
	while(cin >> n){
		bool first = true;
		for(int i = 0; i <= 9; i++){
			if((n >> i) & 1){
				if(!first){
					cout << " ";
				}
				cout << (1<<i);
				first = false;
			}
		}
		cout << endl;
	}

	return 0;
}

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

int w[10];

void a(int x, int y){
  if(x==0)return;
  if(x%2==1){
    w[y]=1;
  }
  else{
    w[y]=0;
  }
  a(x/2, y+1);
}

int main(){
  int n;
  while(cin>>n){
    bool flag=false;
    for(int i=0; i<10; i++)w[i]=0;
    a(n, 0);
    for(int i=0; i<10; i++){
      if(w[i]==1){
        if(flag)cout << ' ';
        cout << (int)pow(2.0, i);
        flag=true;
      }
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
	int w=-1,m=-1;
	while(cin >> m)
	{
		if(w>0) cout << endl;
		
		w=1;
		while(m)
		{
			if(m&1) cout << (w==1?"":" ") << w;
			m = m>>1;
			w = w<<1;
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#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 INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

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

int main() {

	int n;

	while (cin >> n, n) {
		for (int i = 9; i >= 0; i--) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		for (int i = 0; i < 10; i++) {
			if (i != 0 && judge[i] == true)cout << " " << V[i];
			if (i == 0 && judge[i] == true)cout << V[i];
			judge[i] = false;
		}
		cout << endl;
	}

	return 0;
}

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

int input,i;


int main(){
	while(cin>>input){
		string ans("");
		while(1){
			if(input%2==0) ans.insert(ans.begin(),'0');
			else ans.insert(ans.begin(),'1');
			input/=2;
			if(input==0) break;
		}
		if(ans[ans.length()-1]=='1'){
			cout<<"1"<<" ";
		}
		ans.pop_back();
		i=2;
		while(1){
			if(ans.empty()==1) break;
			if(ans[ans.length()-1]=='1'){
				cout<<(int)pow(2.0,i)/2<<" ";
			}
			ans.pop_back();
			i++;
		}
		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{
						
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
		for(int m=1;m<11;m++){
		if(d[m]!=0){
			std::cout<<d[m]<<" ";
		}
	}
	std::cout<<std::endl;
	}
	return 0;
}