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

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    bool f = false;
    for(int i=1; i<=512; i*=2){
      if(n%2){
	if(f){cout <<" ";}
	cout <<i;
	f = true;
      }
      n/=2;
    }
    cout <<endl;
  }
  return 0;
}

C++: /*
AizuOnline A0031
Weight
*/
#include <stdio.h>


main()
{
  int weight;
  int fundou;
  
  while(EOF !=scanf("%d",&weight))
    {  for(fundou=1;fundou <= 512;fundou <<= 1)
         if(weight & fundou)
           printf("%d ",fundou);
       printf("\n");
    }

return(0);
}

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

int main(int argc, const char * argv[])
{
    int cu[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
    int g, j, cu2[10];
    while (cin >> g) {
        for (int i = 0; i < 10; i++) {
            cu2[i] = 0;
        }
        j = 0;
        for (int i = 0; i < 11; i++) {
            if ((g - cu[i]) < 0) {
                g -= cu [i - 1];
                cu2[j] = cu[i - 1];
                i = 0; j++;
            }
            if (g == 0) break;
        }
        for (int i = 0; i < j / 2; i++) {
            int tmp;
            tmp = cu2[j - 1 - i];
            cu2[j - 1 - i] = cu2[i];
            cu2[i] = tmp;
        }
        for (int i = 0; i < j; i++) {
            printf("%d ", cu2[i]);
        }
        puts("");
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int i=0, s=0;
		while(n){
			s+=(n%2)*pow(10, i);
			n/=2;
			i++;
		}
		i=0;
		while(s){
			if(s%10){
				if(s/10)	cout<<pow(2, i)<<" ";
				else	cout<<pow(2,i)<<endl;
			}
			s/=10;
			i++;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
	int weight;
	int i;
	int a[8];
	int cu;
	int cnt = 0;

	while (scanf("%d", &weight) != EOF){
		for (i = 0; i < 8; i++) a[i] = 0;
		cnt = 0;
		cu = 512;
		i = 0;
		while (weight != 0){
			while (cu > weight) cu /= 2;
			a[i++] = cu;
			weight -= cu;
			cnt++;
		}
		sort(a, a + cnt);
		printf("%d", a[0]);
		for (i = 1; i < cnt; i++){
			printf(" %d", a[i]);
		}
		printf("\n");
	}

	return (0);
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, n) for(int i = 0; i <= n; i++)
#define MREP(i, n) for(int i = n; i >= 0; i--)

using namespace std;

int main(){
	int input;
	int tmp = 1, n = 9;
	bool fact[10];
	
	PREP(i, n){
		tmp *= (!i) ? 1 : 2;
		fact[i] = false;
	}

	while(cin >> input){
		MREP(i, n){
			if(tmp <= input){
				input -= tmp;
				fact[i] = true;
			}
			if(input == 0) break;
			tmp /= 2;
		}
		tmp = 1;
		PREP(i, n){
			tmp *= (!i) ? 1 : 2;
			if(fact[i] == true){
				fact[i] = false;
				cout << tmp;
				if(i != n) cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	unsigned o;

	while ( cin >> o ){
		bool first = true;
		for ( int i = 0; i < 10; ++i ){
			if ( o & 1 << i ){
				if ( first ){
					cout << ( 1 << i );
					first = false;
				}else{
					cout << " " << ( 1 << i );
				}
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main() {
  int w;
  while (cin >> w) {
    vector<int> ans;
    for (int i = 512; i >= 1; i /= 2)
      if (i <= w)
        ans.push_back(i), w -= i;

    reverse(ans.begin(), ans.end());

    for (int i = 0; i < ans.size(); ++i)
      if (i == ans.size() - 1)
        cout << ans[i] << endl;
      else
        cout << ans[i] << ' ';
  }
}