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

using namespace std;

bool a[10];

    int main(){

    int N;
    int i=0;
    
    while(cin>>N)
    {
        
        i = 0;
        for(int j=0;j<10;j++)
        {
            a[j] = 0;
        }
        
        for(int k=9;k>-1;k--){
            
            if(i+(pow(2,k)) <= N){
                i += pow(2,k);
                a[k] = 1;
            }
        }
        
        bool last = false;
        for(int k=0;k<10;k++){
            
            if(a[k] ==1)
            {
                if(last){
                    cout<<" ";
                }
                last = true;
                cout<<pow(2,k);    
            }        
        }
 
        cout<<endl;
    }
}

C++: #include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
	int n;
	while(cin >> n)
	{
		stringstream stream;
		for(int i = 0; n; i++)
		{
			if(n & 1)
				stream << (1 << i) << ' ';
			n >>= 1;
		}

		string str = stream.str();
		str.erase(str.length() - 1);
		cout << str << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	int n;
	while(cin>>n){
		rep(i,10){
			if(1&(n>>i)){
				cout<<pow(2,i)<<" ";
			}
		}
		cout<<endl;
	}
    return 0;
}

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

int main()
{
	int ln;
	int weit[] = {1,2,4,8,16,32,64,128,256,512};
	bool fl;
	int n;

	
	while (cin >> n)
	{
		ln = 0;
		fl = 0;
		bool two[20] = { 0 };
		while (n)
		{
			two[ln] = n % 2;
			n /= 2;

			ln++;
		}

		int i;
		for (i = 0; i < ln; i++)
		{
			if (two[i]==1)
			{
				if (fl)
				{
					cout << " ";
				}
				fl = true;
				cout << weit[ i ];
			}
		}
		cout << endl;
	}

	return 0;
}

C++: 
#include <iostream>

using namespace std;

int main() {
    int N;
    while(cin >> N) {
        bool first = true;
        for(int i = 1; i < N; i <<= 1) {
            if(N & i) {
                if(!first) cout << ' ';
                cout << i;
                first = false;
            }
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;


int main(int argc, char const* argv[])
{
	unsigned long weight;
	int count = 0;
	while( cin >> weight ){
		count = 0;
		bitset<16> a( weight );
		for( int i = 0;i < 10;i++ ){
			if( a[i] == 1 ){ cout << ( ( count == 0 ) ? "" : " " ) << ( 1 << i ); count++;}
		}
		cout << endl;
	}
	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};

	int num;

	while(cin>>num){
		int tmp=0;
		for(int j=0;j<10;j++){

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

			printf("\n");
		}

	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int w,j;
  int h[10]={1,2,4,8,16,32,64,128,256,512};
  while(cin>>w){
    if(w%2!=0){
      cout << h[0] << ' ';
      w -= 1;
    }
    for(int i=1;i<10;i++){
      if(w==h[i]){
	cout << h[i] << endl;
	w = 0;
	break;
      }
    }
    if(w!=0){
      j = 1;
      while(w!=0){
	cout << h[j];
	w -= h[j];
	j++;
	if(w==0) cout << endl;
	else cout << ' ';
      }
    }
  }
    return 0;
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;

int ans[101][10];

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int m;
	while(scanf("%d",&m) != EOF){
		for(int j = 0; j < 10; j++){
			if((m / pow(2,j)) % 2 == 1){
				printf("%d ",pow(2,j));
			}
		}
		printf("\n");
	}
	
	///////////////////////////////////
	//Sleep(200000);///////////////////// 提出するときは必ず外す！
	///////////////////////////////////
	return 0;

}

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

int main(void) {
  int weight[10];
  weight[0] = 1;
  for (int i = 1; i < 10; i++) {
    weight[i] = weight[i-1]*2;
  }

  int w;
  while (cin >> w) {
    vector<int> used_weight;
    int pos = 9;
    while (w > 0) {
      if (w - weight[pos] >= 0) {
        w -= weight[pos];
        used_weight.push_back(weight[pos]);
      }
      pos--;
    }

    for (int i = used_weight.size()-1; i >= 0; i--) {
      cout << used_weight[i] << (i?" ":"");
    }
    cout << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w;
  while (~scanf("%d",&w))
  {
    string str = "";
    FOR(i,0,9) if(w>>i & 1)
    {
      char tmp[256];
      sprintf(tmp,"%d ",1<<i);
      str += tmp;
    }
    str[str.size()-1] = '\n';
    printf("%s",str.c_str());
  }
  return 0;
}

C++: #include<cstdio>
bool first = true;
void write(int n){
  if(first){
    first=false;
    printf("%d",n);
  }else{
    printf(" %d",n);
  }
}
int main(){
  int n;
  while(scanf("%d",&n)>0){
    first = true;
    if(n&0x1)write(0x1);
    if(n&0x2)write(0x2);
    if(n&0x4)write(0x4);
    if(n&0x8)write(0x8);
    if(n&0x10)write(0x10);
    if(n&0x20)write(0x20);
    if(n&0x40)write(0x40);
    if(n&0x80)write(0x80);
    if(n&0x100)write(0x100);
    if(n&0x200)write(0x200);
    printf("\n");
  }
}

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

int main() {
	int g;
	int num[]={1,2,4,8,16,32,64,128,256,512};
	stack<int> ans;
	while(cin>>g){
		for(int i=9;i>=0;i--){
			if(g>=num[i]){
				g-=num[i];
				ans.push(num[i]);
			}
		}while(!ans.empty()){
			cout << ans.top() << " ";
			ans.pop();
		}cout<<endl;
	}
}

C++: #include <iostream>
using namespace std;
int main() {
    int n;
    while (cin >> n) {
        int d = 1;
        while (n != 0) {
            if (n & 1) {
                cout << d << " ";
            }
            n = n >> 1;
            d = d << 1;
        }
        cout << endl;
    }
    return 0;
}