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 <string>
using namespace std;

int main()
{
    int n,weight;
	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};
	
		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}
		for(int i=0; i<10 ; i++){
			if(flag[i]!=0){
				cout << w[i] <<" ";
			}
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int input,temp,a;
int print[11];

int main()
{
	while(scanf("%d",&input)!= EOF)
	{
	a=10;
	temp=512;
	for(int z=0;z<11;z++)
	{
		print[z]=0;
	}
	while(temp>=1)
	{
		if(input<temp)
		{
			temp=temp/2;
		}
		else if(temp<=input&&temp!=1)
		{
			input-=temp;
			print[a]=temp;
			a--;
			temp/=2;
		}
		else
		{
			input-=temp;
			print[a]=temp;
			a--;
			temp=0;
			break;
		}
	}
	for(int z=0;z<11;z++)
	{
		if(print[z]!=0)
		printf("%d ",print[z]);
	}
	printf("\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int W;
	while(cin>>W)
	{
		bool flag=0;
		for(int i=1;i<=W;i*=2)
		{
			if(W/i%2>0)
			{
				if(flag)
				{
					cout<<' ';
				}
				cout<<i;
				flag=1;
			}
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    while(cin >> n){
        int p = 1;
        bool f = false;
        while(n){
            if(n & 1){ if(f) cout << " "; cout << p; f = true; }
            p *= 2; n >>= 1;
        }
        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<=512; i*=2) {
            if (n & i) {
                if (first) {
                    first = false;
                    cout << i;
                } else {
                    cout << " " << i;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(void) {
  int i, j, k, w;
  while( scanf("%d", &w) != EOF ) {
    int now = 1, f = 1;
    while(w) {
       if(w % 2) {
         if(f) {
           printf("%d", now);
           f = 0;
         } else printf(" %d", now);
       }
       w /= 2, now *= 2;
    }
    printf("\n");
  }
  return 0;
}

C++: 5
7
127

C++: #include<iostream>

using namespace std;

bool a[10];

int main(){
    
    int N;
    int i=0;
    
    while(!cin.eof())
    {
        cin>>N;
        
        for(j=0;j<10;j++)
        {
            a[j]=0;
        }
        
        i=0;
        
        if(i+512 <= N){
            i += 512;
            a[9] = 1;
        }

        if(i+256 <= N){
            i += 256;
            a[8] = 1;
        }
        
        if(i+128 <= N){
            i += 128;
            a[7] = 1;
        }
        
        if(i+64 <= N){
            i += 64;
            a[6] = 1;
        }
        
        if(i+32 <= N){
            i += 32;
            a[5] = 1;
        }
        
        if(i+16 <= N){
            i += 16;
            a[4] = 1;
        }
        
        if(i+8 <= N){
            i += 8;
            a[3] = 1;
        }
        
        if(i+4 <= N){
            i += 4;
            a[2] = 1;
        }
        
        if(i+2 <= N){
            i += 2;
            a[1] = 1;
        }
        
        if(i+1 <= N){
            i += 1;
            a[0] = 1;
        }
        
        cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<" "<<a[5]
            <<" "<<a[6]<<" "<<a[7]<<" "<<a[8]<<" "<<a[9]<<" "<<endl;
    }
}

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

using namespace std;

int main()
{
  while (true) {
    int omori = 512, x;
    scanf("%d", &x);
    do {
      if (x % omori == 0) {
	x -= omori;
	cout << omori << " ";
	omori /= 2;
      }
    } while (x != 0);
  }
  return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int data[10];
    data[0] = 1;
    REP(i,1,10) data[i] = data[i-1] * 2;
        int n;
    while(cin>>n) {

        bool check[10];
        rep(i, 10) check[i] = false;
        for(int i=9; i>=0; --i) {
            if(n>=data[i]) {
                n -= data[i];
                check[i] = true;
            }
        }

        bool check2 = false;
        rep(i, 10) {
            if(check[i]) {
                if(check2) cout << " ";
                else check2 = true;
                cout << data[i];
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(){
  int n;
  int i;
  while(scanf("%d", &n)!=EOF){
    for(i=0;i<10;i++){
      if(n&1){
        printf("%d", 1<<i);
        if(i!=9) printf(" ");
        n-1;
      }
      n /= 2;
    }
    puts("");
  }
}

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