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>
using namespace std;




int main(){
	int weight[10];
	weight[1] = 1;
	for(int i = 2;i<=9;i++)weight[i]=2*weight[i-1];
	while(true)
	{
	int object;
	cin >> object;
	if (cin.eof())break;
	for(int i =1;i <=9;i++){
		if((object % 2)==1)
			{
			cout << weight[i] ;
			if( i != 9 ) cout << " ";
			}
		object = object /2;
		}
	cout << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main () {
    int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    int x;
    while(cin>>x){
        for(int i=0; i<1023; i++){
            int bit =i;
            int sum =0;
            for(int j=0; j<10; j++){
                if(bit&1==1){
                    sum+=weight[j];
                }
                bit=bit>>1;
            }
            
            if(sum == x){
                int flag = 0;
                for(int j=0; j<10; j++){
                    if(i&1==1&&flag==0){
                        cout<<weight[j];
                        flag++;
                    }else if(i&1==1){
                        cout<<" "<<weight[j];
                    }
                    i=i>>1;
                }
                cout<<endl;
                break;
            }
            
            
            
        }
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  bool f = 0;
  int n, i;
  while (cin >> n) {
    f = 0;
    for (i = 0; i < 10; i++) {
      if (f) {
        cout << ' ';
        f = 0;
      }
      if (n & 1 << i) {
        cout << (1 << i);
        f = 1;
      }
    }
    cout << endl;
  }
  return 0;
}

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

int main(){
	int n;
	while( scanf(" %d", &n) != EOF ){
		int use[10]={0};
		int count=0, m=0;
		for(int i=9; i>=0; --i){
			if(n >= (int)pow(2.0, i)){
				use[i]=1;
				n-=(int)pow(2.0, i);
				++count;
			}
		}
				
		for(int i=0; i<10; ++i){
			if(use[i]==1){
				printf("%d", (int)pow(2.0, i));
				if(m<count-1){
					printf(" ");
					++m;
				}
			}
		} 
	
		printf("\n");
	}

	return 0;
}

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

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

int main() 
{
  int wigth;
  cin >> wigth;
  int i = 1;
  bool flag = false;
  while (i < 256) {
    if (wigth & i) {
      if (flag) cout << " ";
      cout << i;
      flag = true;
    }
    i *= 2;
  }
  if (wigth & i) {
    if (flag) cout << " ";
    cout << i << endl;
  }else cout << endl;

  return 0;
}

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

  while(cin >> n){
    ans.clear();
    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<iostream>
using namespace std;

int main() {
  int d;

  while(cin>>d){
    int a=1;
    while(true){
      if(d==0) break;
      if(d%2==1) {
	cout<<a;
	d--;
	if(d>0) cout<<" ";
      }
      d/=2;
      a*=2;
    }
    cout<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){

int m,w[10];

while(cin>>m){
	
	for(int i=0;i<10;i++)w[i]=0;
	
	for(int i=9;i>=0;i--)if(m>=pow(2,i)){w[i]=1;m-=pow(2,i);}
	
	for(int i=0;i<10;i++)if(w[i]==1)cout<<pow(2,i)<<" ";
	cout<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int p2[10] = {512,256,128,64,32,16,8,4,2,1},n;
  vector<int> v;
  while(cin>>n){
    for(int i=0;i<10;i++){
      if(n>=p2[i])n-=p2[i],v.push_back(p2[i]);
    }
    sort(v.begin(),v.end());
    vector<int>::iterator it=v.begin();
    for(;it!=v.end();it++){
      cout<<*it;
      (it+1==v.end())?cout<<endl:cout<<" ";
    }
    v.clear();
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>

using namespace std;



int main () {
	int n;
	
	while(cin>>n){
		bool m[10]={false};
		int i=512,j=9;
		while(n!=0){
			if (n>=i) {
				m[j]=true;
				n%=i;
				
			}
			i/=2;
			j--;
		}
		
		for (int k=0; k<10; k++) {
			if (m[k]) {
				cout << pow(2, (double)k) <<' ';
			}
		
		}
		
		cout << endl;
		
		
	}
}

C++: #include <cstdio>
#include <cmath>
#include <vector>
#define pb push_back
using namespace std;
int main(void)
{
	int n,b;
	vector<int> vec;
	while(scanf("%d",&n)!=EOF)
	{
		b=n;
		vec.clear();
		while(b>0)
		{
			vec.pb(b%2);
			b/=2;
		}
		int size = vec.size();
		for(int i=0;i<size;i++)
		{
			if(vec[i])
			{
				printf("%d",(int)(pow(2,i)));
				(i==size-1) ? printf("\n") : printf(" ");
			}
			else
			{
				if(i==size-1)printf("\n");
			}
		}
	}
	return 0;
}

C++: 
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>
#include <climits>
#include <set>

using namespace std;

double sq(double x){return x*x;}

int main(){
	int n;
	while(cin>>n){
		for (int i = 0; i < 10; i++)
		{
			if(n & (1 << i)) printf("%d ",1 << i);
		}
		puts("");
	}


	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

vector< bool > w( 9, 0 );

int main()
{
    int weight;
    while( scanf( "%d\n", &weight ) != EOF )
    {
        for( int i = 8; i >= 0; i-- )
        {
            if( pow( 2, i ) <= weight )
            {
                weight %= ( int ) pow( 2, i );
                w[i] = 1;
            }
        }
        for( int i = 0; i < 9; i++ )
        {
            if( w[i] )
            {
                printf( "%.0lf ", pow( 2 , i ) );
            }
        }
        printf( "\n" );
    }
    return 0;
}

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

int main(){
	while (true)
	{
		int R[10], S[10], n;
		string str;
		R[0] = 1;
		S[0] = 0;
		for (int i = 1; i < 10; i++) {
			R[i] = R[i - 1] * 2;
			S[i] = 0;
		}
		cin >> n;
		if (cin.eof() || n == 0) { break; }
		for(int i=9;i>=0;i--){
			if(n>=R[i]){
				n -= R[i];
				S[i] += 1;
			}
		}
		for(int i=0;i<10;i++){
			if (S[i] == 1) {
				str += to_string(R[i]);
				str += " ";
			}
		}
		cout << str << endl;
	}
	return 0;
}