Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	weight := []int{512, 256, 128, 64, 32, 16, 8, 4, 2, 1}

	for sc.Scan() {
		var wgt []int
		i, _ := strconv.Atoi(sc.Text())

		if i > 1023 {
			i = 1023
		}

		bin := fmt.Sprintf("%010b", i)

		for i := 9; i >= 0; i-- {
			if bin[i] == '1' {
				wgt = append(wgt, weight[i])
			}
		}

		for i := 0; i < len(wgt); i++ {
			if i == len(wgt)-1 {
				fmt.Printf("%d\n", wgt[i])
			} else {
				fmt.Printf("%d ", wgt[i])
			}

		}
	}

}

C++: #include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

class STACK{

public:
	STACK(){
		index = 0;
	}
	void push(int data){
		array[index++] = data;
	}
	int pop(){
		index--;
		return array[index];
	}
	bool isEmpty(){
		return index == 0;
	}
	int getIndex(){
		return index;
	}

private:
	int array[10];
	int index;
};

int main(){
	int w;
	STACK stack;

	while(scanf("%d",&w) != EOF){
		for(int i = 512; i>= 1; i /= 2){
			if(w>=i){
				stack.push(i);
				w -= i;
			}
		}

		while(!stack.isEmpty()){
				if(stack.getIndex() == 1){
					printf("%d\n",stack.pop());
				}else{
					printf("%d ",stack.pop());
				}
		}
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
const int a[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
vector<int> solve(int n){
	vector<int> ans;
	int res = n;
	while(res != 0){
		for (int i = 0; i < 10; i++) {
			if(n - a[i] < 0){
				continue;
			}
			if((n - a[i]) < res) {
				res = n - a[i];
			}
		}
		ans.push_back(n - res);
		n = res;
	}
	return ans;
}
int main(void) {
	vector<int> ans;
	int n;
	while(cin >> n) {
		ans = solve(n);
		for(int i = 0; i < ans.size()-1; ++i){
			cout << ans[i] << " ";
		}
		cout << ans.back() << endl;
	}
	return 0;
}

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

using namespace std;

int main(void){

  int w[10];
  for( int i = 0 ; i < 10 ; i++ ){
    w[i] = pow( (double)2 , i );
  }

  int thing;
  while( cin >> thing ){

    int h[10];
    int j = 0;
    int cnt = 0;

    for( int i = 9 ; i >= 0 ; i-- ){
      thing -= w[i];
      if( thing < 0 ){
        thing += w[i];
      }
      else {
        h[j++] = i;
        cnt++;
      }
      if( thing == 0 ){
        for( int i = cnt - 1 ; i >= 0 ; i-- ){
          if(i) cout << w[h[i]] << " ";
          else cout << w[h[i]] << endl;
        }
      }
      }
  end:;
  }
  return 0;
}

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

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

int main() {
  int w = 0;
  ostringstream oss;
  while(cin >> w, w) {
    for (int i = 0; i < 32; i++) {
      if (w & (1<<i)) {
        oss << (1<<i);
        oss << " ";
      }
    }
    string out = oss.str();
    cout << out.substr(0, out.length() - 1) << endl;
    w = 0;
  }
}

C++: #include<iostream>
using namespace std;
int main(){
int n,b[10],f,i;
while(cin>>n){
for(i=0;i<9;i++){b[i]=n%2;n/=2;}
for(f=0,n=1,i=0;i<9;i++){
if(b[i]==1){
if(f==0){cout<<n;f=1;}
else cout<<" "<<n;
}
n*=2;
}
cout<<endl;
}
return 0;
}

C++: #include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int main(){
  int n;
  while(~scanf("%d",&n)){
    int b = 1;
    bool flag = false;
    while(n){
      if(n&1){
        if(!flag){
          cout<<b;
          flag = true;
        }else{
          cout<<" "<<b;
        }
      }
      b<<=1;
      n>>=1;
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>

int main(){
	int a,b,c=1;
	int d[10];
	
	
	while(std::cin>>a){
		for(b=1;b<=10;b++){
		d[b]=0;
	}
		
		for(b=0;b<2;b++){
			if(a==b){
				d[1]=b;
			}else{
				for(c=0;c<3;c=c+2){
					if(a==b+c){
						d[1]=b;
						d[2]=c;
						
						
					}else{
						for(int e=0;e<5;e=e+4){
			if(a==b+c+e){
				d[1]=b;
				d[2]=c;
						d[3]=e;
					
			}else{
				for(int f=0;f<9;f=f+8){
					if(a==b+c+e+f){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						
					}else{
						for(int g=0;g<17;g=g+16){
			if(a==b+c+e+f+g){
				d[1]=b;
				d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						
			}else{
				for(int h=0;h<33;h=h+32){
					if(a==b+c+e+f+g+h){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						
					
					}else{
						for(int i=0;i<65;i=i+64){
			if(a==b+c+e+f+g+h+i){
				d[1]=b;d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						
			}else{
				for(int j=0;j<129;j=j+128){
					if(a==b+c+e+f+g+h+i+j){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						
					}else{
						for(int k=0;k<257;k=k+256){
			if(a==b+c+e+f+g+h+i+j+k){
				d[1]=b;
				d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						d[9]=k;
						
			}else{
				for(int l=0;l<513;l=l+512){
					if(a==b+c+e+f+g+h+i+j+k+l){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						d[9]=k;
						d[10]=l;
					}else{
						
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
		for(int m=1;m<11;m++){
		if(d[m]!=0){
			std::cout<<d[m]<<" ";
		}
	}
	std::cout<<std::endl;
	}
}

C++: #include <iostream>

using namespace std;

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

int main(){
  int n;
  while (cin >> n) {
    for (int i = 0; n > 0; i++) {
      if (n % 2)
        (n < 2) ? cout << w[i] << endl : cout << w[i] << " ";
      n = n / 2;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>

int main()
{
	const int weight[] = {1,2,4,8,16,32,64,128,256,512}; 

	std::vector<int> answer;

	int n;

	while(std::cin >> n)
	{
		for(size_t i=0; i<10; ++i)
		{
			if(n/weight[9-i])
			{

				answer.push_back(weight[9-i]);

				n = n%weight[9-i];
			}
		}

		for(size_t i=0; i<answer.size()-1; ++i)
		{
			std::cout << answer[answer.size()-1-i] << ' ';
		}

		std::cout << answer[0] << '\n';

		answer.clear();
	}

}

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

using namespace std;

int main(void){
    int i,j,k,l;
    int n;
    int weight[10]={1,2,4,8,16,32,64,128,256,512};
    int weight_f[10];
    
    while(cin>>n){
    
    memset(weight_f,0,sizeof(weight_f));
    
    for(i=9;i>=0;i--){
        if(n-weight[i]>=0){
            n=n-weight[i];
            weight_f[i]=1;
        }
    }
    i=0;
    while(true){
        if(weight_f[i]==1){
            cout<<weight[i]<<flush;
            break;
        }
        i++;
    }
    for(j=i+1;j<10;j++){
        if(weight_f[j]==1){
            cout<<" "<<weight[j]<<flush;
        }
    }
    cout<<endl;
    }
    return(0);
}