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 <algorithm>
#include <vector>

using namespace std;

void output(int num){
  static vector<int> vec;
  if(num == -1){
    bool flag=true;
    reverse(vec.begin(),vec.end());
    for(int buf : vec){
      if(flag){
        flag=false;
        cout << buf;
      }
      else
        cout << " " << buf;     
    }
    cout << endl;
    vec.clear();
  }
  else
    vec.push_back(num);
}

void func(int weight){
  if(weight > 0){
    int buf=1;
    while(buf <= weight)
      buf <<= 1;
    buf >>=1;
    output(buf);
    func(weight-buf);
  }
}

int main(){
  int buf;
  while(cin >> buf){
    func(buf);
    output(-1);
  }
  return 0;
}

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

int main(){
	int i, j, input, weight;
	while(cin>>input){
		i=1;
		while(true){
			weight = 1;
			if(input%2){
				for(j=1;j<i;j++){
					weight *= 2;
				}
				cout << weight;
				if(input/2 == 0){
					cout << endl;
					break;
				}
				cout << " ";
			}
			input /= 2;
			i++;
		}
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

bool a[10];

int main(){
    
    int N;
    int i=0;
    
    while(!cin.eof())
    {
        cin>>N;
        
        for(i=0;i<11;i++)
        {
            a[i]=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 <stack>
using namespace std;

int main(void){
	int omori[10]={1,2,4,8,16,32,64,128,256,512},a;
	stack<int> st; 
	int kari;
	while(cin>>a){
		for(int i=9; 0<=i; i--)
		{
			if(a-omori[i]>-1)
			{
				st.push(omori[i]);
				a=a-omori[i];
			}
		}
		while(1)
		{
			cout << st.top();
			st.pop();
			if (st.empty())break;
			else cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int n, m;
	while (cin >> n ) {
		bool f = false;
		for (int i = 1; i < 1024; i <<= 1) {
			if (i&n) {
				if (f)cout << " ";
				cout << i;
				f = true;
			}
		}
		cout << endl;
	}
	return 0;
}

C++: using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
int bun[]={1,2,4,8,16,32,64,128,256,512};
int main()
{
	int x;
	while(cin>>x){
		for(int i=0;i<10;i++){
			if((x>>i)&1)printf(bun[i]>x/2?"%d\n":"%d ",bun[i]);
		}
	}
    return 0;
}

C++: #define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 10
#define MIN -100001
#define _MAX 10
int main(void)
{
	int x, n[MAX] = { 1,2,4,8,16,32,64,128,256,512 }, cou = 0, m[MAX];
	while (scanf_s("%d", &x) != EOF) {
		for (int i = MAX - 1; i >= 0; --i) {
			if (x >= n[i]) {
				x -= n[i];
				m[cou] = n[i]; ++cou;
			}
		}
		for (int i = cou - 1; i >= 0; --i) {
			if (i != cou - 1) printf(" ");
			printf("%d", m[i]);
		}
		printf("\n");
		cou = 0;
	}
}