Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	weight := []int{512, 256, 128, 64, 32, 16, 8, 4, 2, 1}

	for sc.Scan() {
		var wgt []int
		i, _ := strconv.Atoi(sc.Text())

		if i > 1023 {
			i = 1023
		}

		bin := fmt.Sprintf("%010b", i)

		for i := 9; i >= 0; i-- {
			if bin[i] == '1' {
				wgt = append(wgt, weight[i])
			}
		}

		for i := 0; i < len(wgt); i++ {
			if i == len(wgt)-1 {
				fmt.Printf("%d\n", wgt[i])
			} else {
				fmt.Printf("%d ", wgt[i])
			}

		}
	}

}

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;
}

C++: #include <iostream>

using namespace std;

int main() {
  int weight;
  while (cin >> weight) {
    bool flag = false;
    for (int b = 1; b <= 512; b *= 2) {
      if (b & weight) {
        if (flag) cout << ' ';
        cout << b;
        flag = true;
      }
    }
    cout << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int n, s;
int main() {
	while (true) {
		cin >> n; s = 0; if (!n) { break; }
		for (int i = 1; i < 31; i++) {
			if ((n / (int)pow(2, i)) % 2 == 1) {
				if (s) { cout << ' '; }
				cout << pow(2, i - 1); s++;
			}
		}
		cout << endl;
	}
}

C++: #include <iostream>

using namespace std;

int w;
void solve(){
  int cnt=0;
  for(int i = 0; i < 10; i++){
    if(w & (1<<i)){
      if(cnt)cout << " ";
      cnt++;
      cout << (1<<i);
    }
  }
  cout << endl;
}
int main(){
  while(cin >> w){
    solve();
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
int main(){
  int n;
  //ostream_iterator<int> out_it(cout, " ");
  while(cin >> n){
    int b = 1;
    vector<int> ans;
    while(n > 0){
      if((n & 1) == 1){
	ans.push_back(b);
      }
      b <<= 1;
      n >>= 1;
    }
    //copy(ans.begin(), ans.end(), out_it);
    for(int i = 0; i < ans.size() - 1; ++i){
      cout << ans[i] << " ";
    }
    cout << ans.back() << endl;
  }
  return 0;
}