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 <cstdio>
#include <iostream>

using namespace std;

int vis[10];
int gs[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main() {
	int n;
	while (scanf("%d", &n) != EOF) {
		for (int i=0; i<10; ++i) vis[i] = 0;
		for (int i=9; i>=0; --i) {
			if (n >= gs[i]) {
				vis[i] = 1;
				n -= gs[i];
			}
			if (n <= 0) break;
		}
		int cs = 0;
		for (int i=0; i<10; ++i) {
			if (vis[i]) printf (cs++ ? " %d" : "%d", gs[i]);
		}
		printf ("\n");
	}
	return 0;
}

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

int main(void){
	int n;
	while(cin>>n){
		vector<int> s;
		for(int i=512;i>0;i>>=1){
			if(n>=i){
				n-=i;
				s.push_back(i);
			}
		}
		for(int it=s.size()-1;it>=0;it--){
			if(it!=0)cout<<s[it]<<" ";
			else cout<<s[it];
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){
    const int w[10]={1,2,4,8,16,32,64,128,256,512};
    int n;
    
    while(cin >> n){
        int nw[10]={0};
        int cnt=0;
        
        for(int i = 0 ; w[i] <= n ; i++){
            nw[i] = w[i];
            cnt++;
        }
        
        int sum = 0;
        int nnw[10]={0};
        int k = 0;
        int m = n;
        for(int i = 0 ; i < cnt ; i++){
            for(int j = cnt-1 ; j >= 0 ; j--){
                
                if(sum == n) break;
                
                if(nw[j] <= m){
                    nnw[k++] = nw[j];
                    sum += nw[j];
                    m -= nw[j];
                }
            }
            if(sum == n) break;
        }
        sort(nnw,nnw+k);
        
        for(int i = 0 ; i < k ; i++){
            if(i == 0) cout << nnw[i];
            else cout << ' ' << nnw[i];
        }
        cout << endl;
    }

    return 0;
}

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

int main(){
    int n;
    while(cin>>n,n){
        vector<int>vec;
        for(int i=512;i>0;i=i>>1){
            if(n>=i){
                n-=i;
                vec.push_back(i);
            }
        }
        for(int i=0;i<vec.size();i++)
            cout<<vec[vec.size()-1-i]<<" ";
        cout<<endl;
    }
    return 0;
}

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

int main()
{
	int n, count = 0, sum = 1;
	static int ans[100][9] = { 0 };
	int data[100] = { 0 }, ansdata[100] = {0};
	for (int a = 0; a <= 10; a++) {
		data[a+1] = sum;
		sum = sum * 2;
	}
	while (cin >> n) {
		int data2, count2 = 0;
		for (int a = 0; a <= 10; a++) {
			if (n < data[a + 1]) {
				sum = data[a];
				data2 = a;
				ans[count][count2] = a;
				count2++;
				break;
			}
		}
		for (int a = data2-1; a > 0; a--) {
			sum = sum + data[a];
			if (sum > n) {
				sum = sum - data[a];
			}
			else {
				ans[count][count2] = a;
				count2++;
			}
			if (sum == n) {
				break;
			}
		}
		ansdata[count] = count2;
		count++;
	}
	for (int a = 0; a < count; a++) {
		for (int b = ansdata[a]-1; b>=0; b--) {
			cout << data[ans[a][b]];
			if (b != 0)
				cout << " ";
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>

int main()
{
    int w;
    while (std::cin >> w) {
        bool top = true;
        for (int i = 1; i <= 512; i <<= 1) {
            if (w & i) {
                if (top) top = false;
                else std::cout << " ";
                std::cout << (w & i);
            }
        }
        std::cout << std::endl;
    }
}

C++: #include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int N;
	while (cin >> N) {
		vector<int>ans;
		while (N != 0) {
			if (N - 512 >= 0) {
				N -= 512;
				ans.push_back(512);
			} else if (N - 256 >= 0) {
				N -= 256;
				ans.push_back(256);
			} else if (N - 128 >= 0) {
				N -= 128;
				ans.push_back(128);
			} else if (N - 64 >= 0) {
				N -= 64;
				ans.push_back(64);
			} else if (N - 32 >= 0) {
				N -= 32;
				ans.push_back(32);
			} else if (N - 16 >= 0) {
				N -= 16;
				ans.push_back(16);
			} else if (N - 8 >= 0) {
				N -= 8;
				ans.push_back(8);
			} else if (N - 4 >= 0) {
				N -= 4;
				ans.push_back(4);
			} else if (N - 2 >= 0) {
				N -= 2;
				ans.push_back(2);
			} else {
				N--;
				ans.push_back(1);
			}
		}

		SORT(ans);
		cout << ans[0];
		REP2(i, 1, ans.size()) {
			cout << ' ' << ans[i];
		}
		cout << "\n";
	}
	return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int pow(int i)
{
    int ans = 1;
    rep(j, i) ans *= 2;
    return ans;
}

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

C++: #include <iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){

    int ans[1000];
    int p = 0;

    int m = n;
    for(int i = 2 ; i < m ; i*=2){
      if(i*2 > m)m = i;
    }

    for(int i = m ;i > 0; i/=2 ){
      if(n - i >= 0 ){
	ans[p++] = i;
	n -= i;
      }
    }
  for(int i = p - 1 ; i >= 0 ; i-- ){
    cout << ans[i] << " ";
  }
  cout << endl;

  }
  }

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	vector <int> W;
//	cut here before submit 
//	freopen("testcase.w", "r", stdin);
	string str = "";
	int i;
	for (i = 1; i <= 512; i *= 2){
		W.push_back(i);
	} // end for

	sort (W.begin(), W.end(), greater<int>() );
	int size = W.size();

	while (getline (cin, str ) ){
		vector <int> res;
		int wight = 0;
		stringstream ss(str);
		ss >> wight;
	
		for (i = 0; i < size; ++i){
			if (wight < W[i]){
				continue;
			}else if (wight == W[i]){
				res.push_back(W[i]);
				break;
			}else{	// if (wight > W[i])
				res.push_back(W[i]);
				wight -= W[i];
			} // end if
		} // end for

		sort (res.begin(), res.end() );

		for (i = 0; i < res.size(); ++i){
			cout << res[i];
			if (i != res.size() - 1){
				cout << ' ';
			} // end if
		} // end for
		cout << endl;
	} // end while

		
	return 0;
}

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

int main(){
	int n, a[] = {1,2,4,8,16,32,64,128,256,512};
	bool r[10];
	while(cin >> n){
		fill(r, r+10, false);
		for(int s = 9;0 < n && 0 <= s;s--){
			if(n >= a[s]){r[s] = true;n -= a[s];}
		}
		bool f = false;
		for(int i = 0;i < 10;i++){
			if(r[i] == true){
				if(f == true)cout << " ";
				cout << a[i];f = true;
			}
		}
		cout << endl;
	}
	return 0;
}