Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		w := 512
		weights := make([]int, 10)
		for i := 9; i >= 0; i-- {
			if n >= w {
				weights[i] = w
				n -= w
			}
			w /= 2
		}

		output := []int{}
		for i := 0; i < 10; i++ {
			if weights[i] > 0 {
				output = append(output, weights[i])
			}
		}
		outputStr := fmt.Sprint(output)
		fmt.Println(outputStr[1:(len(outputStr) - 1)])
	}
}

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

using namespace std;

int main(){
	int weight[10] = {1,2,4,8,16,32,64,128,256,512};
	int count[10];
	int n;


	while(cin >> n){
		bool one = 0;
		memset(count,0,sizeof(count));

		while(n != 0){
			int u = 9;
			while(n < weight[u])u--;
			n -= weight[u];
			count[u]++;
		}

		for(int i=0;i<10;i++){
			if(count[i] != 0){
				if(one)printf(" ");
				printf("%d",weight[i]);
				one = 1;
			}
		}
		printf("\n");
	}

}

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

int main(){
	int weight;
	while(cin >> weight){
		vector<int> vi;
		for(int i = 512; weight != 0; i = i / 2){
			if(weight >= i){
				weight -= i;
				vi.push_back(i);
			}
		}
		int size = vi.size();
		if(size > 0){
			cout << vi[size - 1];
			for(int i = size - 2; i >= 0; i--){
				cout << " " << vi[i];
			}
		}
		cout << endl;
	}
	return 0;
}

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

int pow(int number, int count) {
	if (count == 0 )
		return 1;
	return number * pow(number, count - 1);
}

int main(int argc, char *argv[]) {
	const int WeightNumber = 10;
	int weight[WeightNumber];
	// Make Weight
	for (int i = 0; i < 10; i++) {
		weight[i] = pow(2, i);
	}
	// Load
	int rcv;
	while (EOF != fscanf(stdin, "%d", &rcv)) {
		vector<int> answer;
		// Find Heaviest Weight
		int max_weight_ar_number;
		for (int i = 0; i < WeightNumber; i++) {
			if (weight[i] > rcv) {
				max_weight_ar_number = i;
				break;
			}
		}
		// Get Weight
		for (int i = max_weight_ar_number; i >= 0; i--) {
			if (rcv >= weight[i]) {
				rcv -= weight[i];
				answer.push_back(weight[i]);
			}
			if (rcv == 0) {
				break;
			}
		}
		// Print Result
		sort(answer.begin(), answer.end());
		const int loop_max = static_cast<int>(answer.size());
		for (int i = 0; i < loop_max ; i++) {
			if (i == loop_max - 1)
				printf("%d\n", answer[i]);
			else
				printf("%d ", answer[i]);
		}
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int two[15]={},n,cnt=-1,check[15]={},last=0;
	for(int i=0;i<11;i++){
		two[i]=1;
		for(int j=0;j<i;j++)two[i]*=2;
	}
	while(cin>>n){
		cnt=0;
		last=0;
		for(int i=0;i<10;i++){
			check[i]=0;
			if(n<two[i+1]){
				cnt=i;
				break;
			}
		}
		for(int i=cnt;i>=0;i--){
			if(n%2==1)check[i]++;
			n/=2;
		}
		for(int i=0;i<10;i++)if(check[i]==1)last=i;
		for(int i=0;i<10;i++){
			if(check[i]==1&&last!=i)cout<<two[i]<<" ";	
			else if(i==last)cout<<two[i]<<endl;
		}
	}
	}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    int n;
    while(cin >> n) {
        vector<int> v;
        while(n != 0) {
            v.pb(n % 2);
            n /= 2;
        }
        //reverse(v.begin(), v.end());
        rep(i,0,v.size()) (v[i] * pow(2,i) == 0) ? : cout << v[i] * pow(2,i) << " ";
        cout << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
    int M,scale[10];
    scale[0]=1;
    for(int i=1;i<10;i++){
    scale[i] = scale[i-1]*2;
    }
    while(cin >> M){
    int i=0;
    int count=2;
    while(true){
        if(M==0) break;
        if(M % count!=0){
            M -= scale[i];
            cout << scale[i] << " ";
        }
        i++;
        count *= 2;
    }
    cout << endl;
    }
}

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

int main() {
  int w = 0;
  while (cin >> w, w) {
    for(int i = 0; i < 32; i++) {
      if(w & (1<<i)) {
        cout << (1 << i) << " ";
      }
    }
    w = 0;
    cout << endl;
  }
}

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

using namespace std;

int main(void){
	int n;
	while(cin >> n){
		for (int i=0; i<10; i++){
			if (n%2==1){
				cout << (int)pow(2.0,i);
				n = (n-1)/2;
				
			if (n==0){
				cout << endl;
				break;
			}else{
				cout << " ";
			}
			}else{
				n = n/2;
			}
		}
	}



	return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int w;
	while (cin >> w) {
		int i(1),cnt(0);
		while (w) {
			if (w & 1) {
				if (cnt++)cout << " ";
				cout << i;
			}
			i *= 2;
			w >>= 1;
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
    int bunndo[10]={1,2,4,8,16,32,64,128,256,512},n,cnt=0;
    while(cin>>n){
        bool num[10]={0};
        for(int i=9;i>=0;i--){
            if(n-bunndo[i]>=0){
                n=n-bunndo[i];
                num[i]=1;
                if(n==0)break;
            }
        }
        for(int i=0;i<10;i++){
            if(num[i]==1){
                if(cnt==0){
                    cnt=1;
                    cout<<bunndo[i];
                }else{
                    cout<<" "<<bunndo[i];
                }
            }
        }
        cnt=0;
        cout<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(void)
{
int x;
while(cin>>x)
{
int a[10]={1,2,4,8,16,32,64,128,256,512};
int b[10]={0};

int j=0;
for(int i=9;i>=0;i--)
{
	if(x>=a[i])
	{
	x-=a[i];
	b[j]=a[i];
	j++;
	if(x==0)break;
	}
}
for(int i=9;i>=0;i--)
{
if(b[i]==0)continue;
else if(b[i]!=0)cout<<b[i]<<(i==0?"\n":" ");
}
}
return 0;
}

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

int main(){
	int n;
	int a[]={1,2,4,8,16,32,64,128,256,512};
	while(cin>>n){
		vector<int> x;
		for(int i=0;i<10;i++){
			if(n/a[10-i-1]==1){
				//cout<<a[10-1-i]<<endl;
				n-=a[10-i-1];
				x.push_back(a[10-i-1]);
				if(n==0)break;
			}
		}
		
		for(int i=0;i<x.size()-1;i++){
			cout<<x[i]<<" ";
		}
		cout<<x[x.size()-1]<<endl;
	}
	return 0;
}