Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		first := true
		beki := 1
		for num != 0 {
			if num % 2 == 1 {
				if !first {
					fmt.Print(" ")
				}
				fmt.Print(beki)
				first = false
			}
			num /= 2
			beki *= 2
		}
		fmt.Println()
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	vector<int> a;
	while(cin>>n){
		if(n>=512){
			n-=512;
			a.push_back(512);
		}
		if(n>=256){
			n-=256;
			a.push_back(256);
		}
		if(n>=128){
			n-=128;
			a.push_back(128);
		}
		if(n>=64){
			n-=64;
			a.push_back(64);
		}
		if(n>=32){
			n-=32;
			a.push_back(32);
		}
		if(n>=16){
			n-=16;
			a.push_back(16);
		}
		if(n>=8){
			n-=8;
			a.push_back(8);
		}
		if(n>=4){
			n-=4;
			a.push_back(4);
		}
		if(n>=2){
			n-=2;
			a.push_back(2);
		}
		if(n==1){
			a.push_back(1);
		}
		sort(a.begin(),a.end());
		cout<<a[0];
		for(int i=1;i<a.size();i++){
			cout<<" "<<a[i];
		}
		cout<<endl;
		a.clear();
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n,flg;
int main(){
  
  while(cin>>n){
    flg=0;
    for(int i=1;n>0;i*=2){
      
      if(n&1){
	if(flg>0)cout<<' ';
	cout<<i;
	flg=1;
      }
      n=n>>1;
    }
    cout<<endl;
  }
  return 0;
}

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

int main()
{
    int n;
	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};
	
		// n - w[i] で引けた配列番号を flag[i] で記憶

		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}

		// flag[i] が 0 でなければ w[i] を表示

		for(int i=0; i<9 ; i++){
			if(flag[i]!=0){
				cout << w[i] <<" ";
			}
		}
		if(flag[10]!=0){
			cout << w[10];
		}
		cout << endl;
	}
	return 0;
}

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

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

int V[10] = { 1,2,4,8,16,32,64,128,256,512 };
bool judge[10] = { false };

int main() {

	int n;

	while (cin >> n) {
		REPR(i,9) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		REP(i,10) {
			if (i != 0 && judge[i] == true)cout << " " << V[i];
			if (i == 0 && judge[i] == true)cout << V[i];
			judge[i] = false;
		}
		cout << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main(){
  int p2[10] = {512,256,128,64,32,16,8,4,2,1},n;
  vector<int> v;
  while(cin>>n){
    for(int i=0;i<10;i++){
      if(n-p2[i]>=0)n-=p2[i],v.push_back(p2[i]);
    }
    vector<int>::iterator it=v.begin();
    while(it!=v.end()){
      cout<<*it<<endl;
      it++;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  int w;

  while ( cin >> w )
    {
      for ( auto i = 0; i < 10; ++i )
        {
          if ( (w >> i) & 1 )
            {
              if ( i ) cout << " ";
              cout << (1 << i);
            }
        }
      cout << endl;
    }
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

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

C++: #include <cstdio>

int main() {
    int n = 0;

    while (scanf("%d", &n) != EOF) {
        int t = 1;
        bool firstIn = true;

        for (int i = 0; i < 10; ++i) {
            if ((n & t) == t) {
                if (!firstIn) {
                    printf(" ");
                }
                printf("%d", t);
                firstIn = false;
            }

            t *= 2;
        }
        printf("\n");
    }

    return 0;
}

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

void func(int p2, int y)
{
	int flag = 0;
	
	if (y == 0) {
		return;
	}
	
	if (y >= p2) {
		y -= p2;
		flag = 1;
	}
	
	func(p2 / 2, y);
	
	if (flag == 1) {
		cout << p2;
	}
	if (y != x) {
		cout << ' ';
	}
}

int main()
{
	while (cin >> x) {
		func(512, x);
		cout << endl;
	}
	
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>

typedef long long ll;
using namespace std;

typedef pair<int,int> P;

int main()
{
	int n;
	queue<int> que;
	while(~scanf("%d",&n)){
		for(int i = 0; i < 10; i++){
			if((n >> i) & 1) que.push(pow(2,(double)i));
		}

		while(!que.empty()){
			printf("%d%s",que.front(),que.size() == 1 ? "\n" : " ");
			que.pop();
		}
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<30
using namespace std;

int main(){
  int n;
   vector<int> dp[1024];
  
  for(int i=1;i<=1023;i++){
    if(i == 1 || i == 2 || i == 4 || i == 8 || i == 16 || i == 32 || i == 64 || i == 128 || i == 256 || i == 512){
      dp[i].push_back(i);
      continue;
    }
    if(dp[i].empty()){
      int index,bg;
      bg = i-1;
      for(int j=1;j<bg;j++){
	index = bg+j;
	for(int k=0;k<dp[j].size();k++){
	  dp[index].push_back(dp[j][k]);
	}
	for(int k=0;k<dp[bg].size();k++){
	  dp[index].push_back(dp[bg][k]);
	}
      }
    }
  }

  while(cin >> n){
    assert(n<=1023);
    for(int i=0;i<dp[n].size();i++){
      cout << dp[n][i];
      i==dp[n].size()-1?cout << endl:cout << " ";
    }


  }
    return 0;
}

C++: #include <iostream>

using namespace std;

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