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 <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

const int INF = 1e9;

int main() {
    int n;
	while (scanf("%d", &n) != EOF) {
		vector<int> list;
		int x = 512;
		while (n > 0) {
			if (n >= x) {
				list.push_back(x);
				n -= x;
			}
			x >>= 1;
		}
		reverse(all(list));
		for (int i = 0; i < list.size(); i++) {
			if (i > 0) cout << " ";
			cout << list[i];
		}
		cout << endl;
	}
}

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


int main(void){

	while (true){
		int n;
		cin>>n;
		if (cin.eof()) break;
		bool f=false;
		int i=1;
		while (n>0){
			if (n%2==1){
				if (f) cout<<" ";
				else f=true;
				cout<<i;
			}
			n/=2;
			i*=2;
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){
  int w,we[9]={1,2,4,8,16,32,64,128,256},i;
  queue<int> k;
  while(cin>>w){

    while(w!=0){
      k.push(w%2);
      w=w/2;
    }
    i=0;
    while(k.size()){
      if(k.front()==1&&k.size()>=2)cout<<we[i]<<" ";
      else if(k.front()==1)cout<<we[i]<<endl;
      k.pop();
      i++;
    }
  }
  return 0;
}

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

using namespace std;

int main() {
	vector<int> weights;
	vector<int> use;
	weights.push_back(1);
	weights.push_back(2);
	weights.push_back(4);
	weights.push_back(8);
	weights.push_back(16);
	weights.push_back(32);
	weights.push_back(64);
	weights.push_back(128);
	weights.push_back(256);
	weights.push_back(512);
	int w;

	while(cin>>w,!cin.eof()) {
		while(w!=0){
			for(int i=0; i<weights.size(); i++){
				if(w == 0) break;
				if(w >= 512 ){
					w -= 512;
					use.push_back(512);
				}
				else if(weights.at(i) > w){
					w -= weights.at(i-1);
					use.push_back(weights.at(i-1));
					break;
				}
			}
		}
		sort(use.begin(), use.end());
		for(int i=0; i<use.size()-1; i++){
			cout<<use[i]<<" ";
		}
		cout<<use[use.size()-1]<<endl;
		use.clear();
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define PI 3.141592653

bool cross(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4){
    double a,b,c,d;
    
    a=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1);
    b=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2);
    c=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3);
    d=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4);
    
    if((c<0)^(d<0))
        return true;
    else
        return false;
}

int main(){
    int w;
    
    while(EOF!=scanf("%d",&w)){
        
        bool f = true;
        
        for(int i=0;i<9;i++){
    
            if(w & (1 << i)){
                printf(f ? "%d" : " %d",(int)pow(2,i));
                f=false;
            }
        }
        
        printf("\n");
    }
    
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	while(cin>>n){
		for (int i = 0; i < 11; ++i) {

			if(n%2){
				if(i!=0){
					cout<<" "<<pow(2,i);
				}else{
					cout<<pow(2,i);
				}
			}
			if(n==1)break;
			n=n/2;
		}
		cout<<endl;
	}
return 0;
}

C++: #include <cstdio>

using namespace std;

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<stdio.h>
int ex(int n)
{
    if(n == 0)return 1;
    return ex(n - 1) * 2;
}
int main()
{
    int n;
    while(scanf("%d",&n) != -1)
    {
        int mem[10] = {0};
        for(int i = 9; i >= 0; i--)
        {
            if(n >= ex(i))mem[i] = 1,n -= ex(i);
        }
        for(int i = 0; i < 10; i++)
        {
            if(mem[i] == 1)printf(" %d",ex(i));
        }
        printf("\n");
    }
    return 0;
}

C++: //AOJ 0031

#include<stdio.h>
#include<iostream>
#include<vector>

using namespace std;

int main(){

	int data[10]={1,2,4,8,16,32,64,128,256,512};



	vector<int> input;

	int num;

	while(cin>>num){
		input.push_back(num);
	}

	for(int i=0;i<input.size();i++){

		int tmp = input[i];

		for(int j=0;j<10;j++){

			if(tmp%2==1){
				printf("%d ",data[j]);
			}
			tmp/=2;
		}

		printf("\n");
	}

	return 0;
}

C++: #include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n;
	while (cin >> n) {
		rep (i, 1 << 10) {
			int sum = 0;
			rep (j, 10) {
				if (i >> j & 1) {
					sum += pow(2, j);
				}
			}
			if (sum == n) {
				bool First = true;
				rep (j, 10) {
					if (i >> j & 1) {
						if (!First)
							cout << " ";
						else
							First = false;
						cout << pow(2, j);
					}
				}
				cout << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main() {
	int n;
	int w[10];
	int b[10];
	
	while (cin >> n) {
		for (int i=9;i>=0;i--){
			w[i] = pow(2,i);
			if (n >= w[i]) {
				n = n - w[i];
				b[i] = 1;
			}
			else { b[i] = 0; }
		}
		for (int i = 0; i <= 8; i++) {
			if (b[i]==1) {
				cout << w[i] << " ";
			}
		}
		if (b[9] == 1) {
			cout << w[9];
		}
		cout << endl;
	}
}

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

int main()
{
    int n,weight;
	int w[10]={1,2,4,8,16,32,64,128,256,512};
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
	
		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}
		for(int i=0; i<10 ; i++){
			if(flag[i]!=0){
				cout << w[i] <<" ";
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int input,temp,a;
int print[11];

int main()
{
	while(scanf("%d",&input)!= EOF)
	{
	a=10;
	temp=512;
	for(int z=0;z<11;z++)
	{
		print[z]=0;
	}
	while(temp>=1)
	{
		if(input<temp)
		{
			temp=temp/2;
		}
		else if(temp<=input&&temp!=1)
		{
			input-=temp;
			print[a]=temp;
			a--;
			temp/=2;
		}
		else
		{
			input-=temp;
			print[a]=temp;
			a--;
			temp=0;
			break;
		}
	}
	for(int z=0;z<11;z++)
	{
		if(print[z]!=0)
		printf("%d ",print[z]);
	}
	printf("\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int W;
	while(cin>>W)
	{
		bool flag=0;
		for(int i=1;i<=W;i*=2)
		{
			if(W/i%2>0)
			{
				if(flag)
				{
					cout<<' ';
				}
				cout<<i;
				flag=1;
			}
		}
		cout<<endl;
	}
	return 0;
}