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>

using namespace std;

int main()
{
	int weight;
	int i,j;
	int ans[10];
	
	for(;cin >> weight;)
	{
		for(i=0;i<10;i++)
			ans[i]=0;
			
		for(i=0;weight>0;weight/=2,i++)
		{
			ans[i]=weight%2;
		}
		
		if(ans[0]==1)
			cout << "1" ;
		
		for(i=1,j=2;i<10;i++,j*=2)
			if(ans[i]==1)
				cout << " " << j ;
				
		cout << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int weight[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	while(cin >> n){
		int t = 0;
		for(int i = 0; i < 10; i++){
			if(n % 2){
				if(t++) cout << " ";
				cout << weight[i];
			}
			n /= 2;
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n;
  int used[10]={0,0,0,0,0,0,0,0,0,0};
  int omori[10] = {1,2,4,8,16,32,64,128,256,512};

  while( cin >> n){
    int i = 0;
    int f = 0;
    while(n){
      if(n >= omori[9-i]) {n -= omori[9-i];used[i] = omori[9-i];f++;}
      i++;
    }

    for(int j=9;j >= 0;j--){
      if(used[j] != 0 && f == 1){ cout << used[j] << endl;}
      if(used[j] != 0 && f != 1){ cout << used[j] << ' ' << flush;f--;}
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
// #define first first
// #define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;


signed main(){
    int n;
    while(cin >> n){
        vector<int> ans;
        rep(i, 0, 10){
            int t = 1 << i;
            if(n & t){
                ans. push_back(t);
            }
        }
        rep(i, 0, ans.size()){
            if(i != 0) cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
}

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

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

int main(){
    int input,count;
    bool is_use[10];

    while(1){

      cin >> input;

      if(cin.eof()){
        break;
      }

      for(int i=0;i<10;i++){
        is_use[i] = false;
      }

      count = 0;

      for(int i=9;i>=0;i--){
        if(input >= weight[i]){
          input -= weight[i];
          is_use[i] = true;
          count++;
          if(input == 0){
            break;
          }
        }
      }

      for(int i=0; i<10; i++){
        if(is_use[i]){
          count--;
          if(count==0){
            cout << weight[i] << endl;
          }
          else{
            cout << weight[i] << " ";
          }
        }
      }


    }


    return 0;
}

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

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

C++: #include <stdio.h>

int main(void)
{
	int n;
	while (scanf("%d", &n) != EOF){
		int i;
		int flag;

		flag = 0;
		for (i = 0; i < 9; i++){
			if (((n >> i) & 1) != 0){
				if (flag == 0){
					printf("%d", 1 << i);
				}
				else {
					printf(" %d", 1 << i);
				}
				flag = 1;
			}
		}
		puts("");
	}
	return (0);
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> m, ans;
  int n, x=1;
  m.push_back(x);
  for(int i=0; i<9; i++){
    x = x*2;
    m.push_back(x);
  }
  sort(m.begin(), m.end(), greater<int>());

  while(cin >> n){
    ans.clear();
    if(n > 1023) return 0;
    vector<int>::iterator it = m.begin();
    while( it != m.end() ){
      if(n - *it >= 0){
	n = n - *it;
	ans.push_back(*it);
      }
      ++it;
    }
    sort(ans.begin(), ans.end());
    vector<int>::iterator it2 = ans.begin();
    while( it2 != ans.end() ){
      cout << *it2 << " ";
      ++it2;
    }
    cout << endl;
    
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int w,ans[10],wei[10],tot=0;
signed main(void){
		ios::sync_with_stdio(false);
		for(int i=0;i<10;i++)
			wei[i]=1<<i;
		while(cin>>w){
			for(int i=9;i>=0;i--)
				if(w>=wei[i]){
					ans[++tot]=wei[i];
					w-=wei[i];	
				}
			while(tot>1)
				cout<<ans[tot--]<<" ";
			cout<<ans[tot--]<<endl;
		}
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n;
	while(cin>>n)
	{
		bool flag=false;
		for(int cnt = 1; cnt < 1<<10; cnt*=2)
		{
			if(cnt&n)
			{
				if(flag) cout<<" "<<cnt;
				else cout<<cnt;
				flag=true;
			}
		}
		cout<<endl;
	}
  return 0;
}

C++: #include<cstdio>
#include<vector>
using namespace std;
int main(){
    int n;
    while(~scanf("%d",&n)){
        vector<int> ar;
        for(int i=512;i>=1;i/=2){
            if(n>=i){
                ar.push_back(i);
                n-=i;
            }
        }
        for(int i=ar.size()-1;i>0;i--){
            printf("%d ",ar[i]);
        }
        printf("%d",ar[0]);
        printf("\n");
    }
}

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];
	int trueCount = 0;
	
	PREP(i, n){
		tmp *= (!i) ? 1 : 2;
		fact[i] = false;
	}

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

C++: #include <iostream>
#include <vector>
#include <math.h>

int sample;
std::vector<int> weight;
std::vector<int> answer;

void dfs(int i, std::vector<int> choice){
	int sum = 0;
	for(unsigned int j=0; j<choice.size(); j++){
		sum += choice[j];
	}
	if(sum==sample) { answer = choice; }
	if(i>9 || sum > sample) return;

	dfs(i+1, choice);
	choice.insert(choice.end(), weight[i]);
	dfs(i+1, choice);
}

int main(void){
	int i;
	for(i=0;i<10;i++){
		weight.insert(weight.end(), (int)pow(2.0, i));
	}
	while( (std::cin >> sample)!=NULL ){
		answer.clear();
		dfs(0,answer);
		for(unsigned int i=0; i<answer.size(); i++){
			std::cout << answer[i];
			if(i==answer.size()-1) { break; }
			else { std::cout << " "; }
		}
		std::cout << std::endl;
	}
	return 0;
}