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 <iostream>
#include <cmath>

using namespace std;

int main(void){
  int w;
  int i=0;

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

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){
	
	int n;
	while(cin >> n){
		int w = 512;
		vector<bool> ans(10, false);
		for(int i = 9; i >= 0; i--){
			if(n >= w){
				ans[i] = true;
				n -= w;
			}
			w = w >> 1;
		}
		w = 1;
		bool f = false;
		rep(i, 10){
			if(ans[i]){
				if(f) cout << " ";
				cout << w;
				f = true;
			}
			w = w << 1;
		}
		cout << endl;
	}

	
	return 0;
}

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

int main(){
  int n, i, elm;
  int isFirst;

  while(cin>>n){
    elm=1; isFirst=1;
    for(i=0; i<10; i++){
      if(n%2==1){
        if(!isFirst) printf(" ");
        isFirst=0;
        printf("%d", elm);
      }
      n=n>>1; elm=elm<<1;
    }
    printf("\n");
  }

  return 0;
}

C++: #include <iostream>

int main()
{
	int weight;
	while (std::cin >> weight) {
		int scale_weight = 1;
		bool printed_any = false;
		while (weight > 0) {
			if ((weight & scale_weight) != 0) {
				weight -= scale_weight;
				if (printed_any) {
					std::cout << ' ';
				}
				std::cout << scale_weight;
				printed_any = true;
			}
			scale_weight *= 2;
		}
		std::cout << std::endl;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    vector<int> ans;
    for(int i=512; i>=1; i/=2){
      if(n>=i){
	n-=i;
	ans.push_back(i);
      }
    }
    for(int i=ans.size()-1; i>=0; i--){
      if(i!=ans.size()-1) cout <<" ";
      cout <<ans[i];
    }
    cout <<endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>

int output(int t,int a[10]);

int main()
{
	int n,t;
	while(scanf("%d",&n)!=EOF)
	{
		if(n>=1024||n<0)
		{
		}
		else
		{
			int a[10]={0};
			double x=0;
			t=0;

			for(x;x<10;x++)
			{
				int y;
				y=pow(2,x);

				if(n%(2*y)==y)
				{
					a[t]=y;
					t++;
					n-=y;
				}
				if(n==0)
				{
					for(int z=0;z<t;z++)
					{
						if(z==(t-1))
						{
							printf("%d\n",a[z]);
						}
						else
						{
							printf("%d ",a[z]);
						}
					}
					break;
				}
			}
		}
	}
}

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;
			break;
		}
		}
		for(int i=cnt;i>=last;i--){
			if(check[i]==1&&last!=i)cout<<two[cnt-i]<<" ";	
			else if(i==last)cout<<two[cnt]<<endl;
		}
	}
}

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

const vector<int> v = {1, 2, 4, 8, 16, 32, 64, 32, 64, 128, 256, 512};

int main() {
  int n;
  vector<int> sum(1024, 0);
  for (int i = 0; i < 1024; ++i) {
    for (int j = 0; j < 10; ++j) {
      if ((i >> j) & 1) sum[i] += v[j];
    }
  }
  while (cin >> n) {
    int pos = 0;
    for (int i = 0; i < 1024; ++i) {
      pos = i;
      if (sum[i] == n) break;
    }
    bool ok = false;
    for (int i = 0; i < 10; ++i) {
      if ((sum[pos] >> i) & 1) {
        if (ok) {
          cout << ' ';
        } else {
          ok = true;
        }
        cout << (1 << i);
      }
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
  int n;
  while(cin >> n){
    vector<int> ar;
    int flg = 0;
    for(int i = 1024 ; i>=1; i /=2){
   
      if(n >= i&&flg == 0){
	cout << i;
	flg = 1;
	n-=i; 
	continue;
      }
      if(n >= i&&flg == 1){
	cout << " " << i;
	n-=i; 
      }
    }
  }
  return 0;
}

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

int main(){
	int w, g[10];
	vector<int> ans;

	for(int i=0,j=1 ; j<=512 ; j*=2, i++){
		g[i] = j;
	}

	while(cin >> w){
		ans.clear();
		for(int i=9 ; i>=0 ; i--){
			if(w<=1){
				if(w==1)ans.push_back( w ); 
				break;
			}
			else if(g[i]<=w){
				w -= g[i];
				ans.push_back( g[i] ); 
			}
		}
		for(int i=ans.size()-1 ; i>=0 ; i--){
			cout << ans[i] ;
			if(i==0) cout << endl;
			else cout << " ";
		}
	}
	
	return 0;
}

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

int main() {
  int g;
  vector<int> v;
  while (cin >> g) {
    while (g) {
      int i = 1;
      while (g >= i * 2) {
        i *= 2;
      }
      v.push_back(i);
      g -= i;
    }
    
    for (int i = v.size() - 1; i >= 0; i--) {
      if (!i) {
        cout << v.at(i) << endl;
      } else {
        cout << v.at(i) << " ";
      }
    }
    v.clear();
  }
}

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

using namespace std;

int main(){
  vector<int> weightarray;
  int weight;
  while(cin>>weight){
    weightarray.push_back(weight);
  }
  
  for(auto weight:weightarray){
    for(int i=0;i<sizeof(weight)*8;i++){
      int bit=1<<i;
      if(weight&bit){
        cout<<bit<<" ";
      }
    }
    cout<<endl;
  }
}

C++: //AOJ 0031

#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 <iostream>
#include <string>
#include <sstream>
using namespace std;

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

int main()
{
    int in_data;
    while(cin >> in_data)
    {
        int gram_num = 0;
        bool is_used[10] = {};
        stringstream ss;
        string ans;
        for(int i=9; i>=0; i--)
        {
            if(gram_num + WEIGHTS[i] <= in_data)
            {
                gram_num += WEIGHTS[i];
                is_used[i] = true;
            }
        }
        for(int i=0; i<10; i++)
        {
            if(is_used[i])
            {
                ss << std::to_string(WEIGHTS[i]) <<  " ";
            }
        }
        ans = ss.str();
        ans.pop_back();
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  char *line = NULL;
  size_t buffer_size = 0;
  while (getline(&line, &buffer_size, stdin) > 0) {
    int weight = atoi(line);

    vector<int> counter_weights;
    for (int i = 0; weight != 0 && i < 10; ++i) {
      int mask = 1 << i;
      if (weight & mask) { counter_weights.push_back(mask); }
      weight &= ~mask;
    }
    for (auto iter = counter_weights.begin();
         iter != counter_weights.end();
         ++iter) {
      printf("%d%c", *iter, iter + 1 == counter_weights.end() ? '\n' : ' ');
    }
  }
  free(line);

  return 0;
}