Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		w := 512
		weights := make([]int, 10)
		for i := 9; i >= 0; i-- {
			if n >= w {
				weights[i] = w
				n -= w
			}
			w /= 2
		}

		output := []int{}
		for i := 0; i < 10; i++ {
			if weights[i] > 0 {
				output = append(output, weights[i])
			}
		}
		outputStr := fmt.Sprint(output)
		fmt.Println(outputStr[1:(len(outputStr) - 1)])
	}
}

C++: #include <cstdio>

int main() {
    int n = 0;

    while (scanf("%d", &n) != EOF) {
        int t = 1;

        for (int i = 0; i < 10; ++i) {
            if ((n & t) == t) {
                if (i != 0) {
                    printf(" ");
                }
                printf("%d", t);
            }

            t *= 2;
        }
        printf("\n");
    }

    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int w[10] = {1,2,4,8,16,32,64,128,256,512};
	int n;
	while(cin>>n){
		vector<int> num;
		int b=n;
		for(int i=0;i<10;i++){
			if(b==0) break;
			if(b>=w[9-i]){
				num.push_back(w[9-i]);
				b -= w[9-i];
			}else if(b==w[9-i]) break;			
		}
		for(int j=1;j<=num.size();j++){
			if(j!=1) cout<<" ";
			cout<<num[num.size()-j];
		}
		cout<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n){
		vector<int>out;
		rep(i,10)if(n>=pow(2,9-i)){
			out.pb(pow(2,9-i));
			n-=pow(2,9-i);
		}
		sort(all(out));
		rep(i,out.size()){
			if(i)cout<<" ";
			cout<<out[i];
		}
		cout<<endl;
	}
}

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

int main()
{
    int n;
    while (cin >> n)
    {
	int w=1,f=0;
	for (int i=0;i<10;i++)
	{
	    if (n&w)
	    {
		if (f==1)
		    cout << " ";
		f=1;
		cout << w;
	    }
	    w*=2;
	}
	cout << endl;
    }
    return 0;
}

C++: #include <cstdio>
int main(){int n,s;while(scanf("%d",&n)+1){for(s=1;n;s*=2){n&s&&printf("%d%c",s,n-s?32:10);n-=n&s;}}}

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