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 <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
V vi;

int main(){
	while (cin >> n){
		for (int i = 9; i >= 0; i--){
			if (n >= pow(2, i)){
				n -= pow(2, i);
				vi.push_back(pow(2, i));
				if (n == 0)break;
			}
		}
		sort(ALL(vi));
		REP(i, vi.size()){
			cout << vi[i];
			if (i == vi.size() - 1)cout << endl;
			else cout << " ";
		}
		vi.clear();
	}
}

C++: #include <stddef.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int g;
  vector<int> v;
  while (cin >> g) {
    v.clear();
    for (int i = 0; i < 10; i++)
      if (g & (1 << i)) v.push_back(1 << i);
    cout << v[0];
    for (size_t i = 1; i < v.size(); i++)
      cout << ' ' << v[i];
    cout << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(void)
{
    int h[10], w;
    vector<int> ans;
    rep(i, 10) {
        h[i] = pow(2.0, (double)i);
    }
    
    while (cin >> w) {
        ans.clear();
        for (int i = 9; i >= 0; i--) {
            if (w == 1) {
                ans.push_back(h[0]);
                break;
            }
            else if (h[i] <= w){
                ans.push_back(h[i]);
                w -= h[i];
            }
        }
        
        for (int i = (int)ans.size() - 1; i >= 0; i--) {
            cout << ans[i];
            i == 0 ? cout << endl : cout << " ";
        }
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int weight[11],n,co[11],a=0;
    for(int i=0;i<11;i++)weight[i]=exp2(i);
    while(cin>>n){
        for(int i=0;i<11;i++)co[i]=0;
        for(int i=10;i>=0;i--){
            if(n>=weight[i]){
                co[i]=1;
                n-=weight[i];
            }
        }
        for(int i=0;i<11;i++){
            if(co[i]==1&&a==0){
                cout<<weight[i];
                a=1;
            }
            else if(co[i]==1)cout<<" "<<weight[i];
        }
        cout<<endl;
        a=0;
    }
}

C++: #include<stdio.h>
int main()
{
	int n,i,l[16],j;
	while(scanf("%d",&n)!=EOF){
		j=0;
		for(i=1024;i>0;i/=2){
			if(i<=n){
				l[j]=i;
				n-=i;
				j++;
			}
		}
		for(i=j-1;i>=0;i--){
			printf("%d",l[i]);
			if(i==0){
				printf("\n");
			}else{
				printf(" ");
			}
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main () {
  int w;

  while(cin >> w){
    bool space = false;

    for(int r = 0; r < 10; r++){
      if(w >> r & 1 == 1) {
        if(space)
          cout << ' ';
        else
          space = true;
        cout << (1 << r);
      }
    }

    cout << endl;
  }

}

C++: #include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	while(cin>>n){
		for (int i = 0; i < 11; ++i) {
			if(n%2){
				if(i!=0){
					cout<<' ';
					cout<<pow(2,i);
				}else{
					cout<<pow(2,i);
				}
			}
			if(n==1)break;
			n=n/2;
		}
		cout<<endl;
	}
return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t; std::cin>>t;
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=stoi(s);
    for(int i=0;i<s.size();i++){if(num%10)std::cout<<pow(2,(double)(i))<<" "; num/=10;}
    std::cout<<std::endl;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,r,n) for(int i=r;i<(int)n;i++)
using namespace std;
int in(){int x;cin>>x;return x;}

string s[10]={"1","2","4","8","16","32","64","128","256","512"};
int ss[10]={1,2,4,8,16,32,64,128,256,512};

string ans[1200];
void sss(string z,int y,int l)
{
	ans[y]=z;
	if(l==10)return ;
	sss(z,y,l+1);
	if(z!="")z+=" ";
	z+=s[l];
	y+=ss[l];
	sss(z,y,l+1);
	return ;

}


int main ()
{
	int a;
	sss("",0,0);	
	while(scanf("%d",&a)!=EOF)
	{
		cout<<ans[a]<<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int main(){
  vector<int> ar;
  int g[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int n;
  while(cin >> n){
    for(int i=9;i>=0;i--){
      if(n>=g[i]){
	n -= g[i];
	ar.push_back( g[i] );
      }
    }
    for(int i=ar.size()-1;i>=0;i--){
      if(i != 0)cout << ar[i] << ' ';
      else cout << ar[i] << endl;
    }
    ar.clear();
  }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main(){
    int n;
    while(cin>>n){
        for(int i=0;n;i++){
            if(n&1)
                cout<<pow(2,i)<<(n>>1?' ':'\n');
            // cout<<i<<" "<<n<<endl;
            n>>=1;
            // cout<<i<<" "<<n<<endl;
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
	int n, c;
	int a[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 516};
	int b[10];
	
	while (scanf("%d", &n) != EOF){
		c = 0;
		for (int i = 9; 0 <= i; i--){
			if (n >= a[i]){
				n -= a[i];
				b[c] = a[i];
				c++;
			}
		}
		reverse(b, b + c);
		for (int i = 0; i < c; i++){
			printf("%d", b[i]);
			if (i < c - 1){
				printf(" ");
			}
		}
		
		printf("\n");
	}
	return (0);
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,h;
	while(cin>>n){
		h=1;
	for(int i=0;i<10;i++){
		if(n%(h*2)!=0){
			n-=h;
			cout<<h<<" ";
		}
		h*=2;
	}
	cout<<endl;
	}
	return 0;
}

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

C++: n,k;main(a){for(;~scanf("%d",&n);puts())for(k=1;n;n^=a)k=!printf(k+" %d",a=n&-n);}

C++: #include <iostream>
using namespace std;
int factorial(int n){
	if(n==0) return 1 ; else return(2*factorial(n-1)) ;
}
int main(){
	int x;
	while(cin>>x){
		int ans[10]={0};int ptr=0;int sum=0;
		for(int i=9;i>=0;i--){
			if(x==sum) break;
			int temp=factorial(i);
			if(x>=sum+temp) {ans[ptr++]=temp;sum+=temp;};
		};
		for(int i=ptr-1;i>=0;i--){
		if(i!=ptr-1) cout << ' ' ; cout << ans[i] ;
		};
		cout << '\n' ;
	};
}