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 <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+65){
			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>
#include<stack>
using namespace std;

int main() {
	int g;
	int num[]={1,2,4,8,16,32,64,128,256,512};
	stack<int> ans;
	while(cin>>g){
		for(int i=9;i>=0;i--){
			if(g>=num[i]){
				g-=num[i];
				ans.push(num[i]);
			}
		}for(int i=ans.size();i>0;i--){
			cout<<ans.top();
			ans.pop();
			if(i!=1)cout<<" ";
		}cout<<endl;
	}
}

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

int main()
{
    int n;
	int w[10]={1,2,4,8,16,32,64,128,256,512};
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
	
		// n - w[i] で引けた配列番号を flag[i] で記憶

		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}

		// flag[i] が 0 でなければ w[i] を表示

		if(flag[0]!=0){
			cout << w[0];
		}
		for(int i=1; i<=9 ; i++){
			if(flag[i]!=0){
				cout << " " << w[i];
			}
		}
		
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int cnt[10];
  int flag=0;
  int t[10] = {1,2,4,8,16,32,64,128,256,512};
  while(cin>>n){
    flag = 0;
    for(int i=0;i<10;i++){
      cnt[i] = 0;
    }
    for(int i=9;i>=0;i--){
      if(n - t[i] >= 0 && flag==0){
	n = n - t[i];
	cnt[i]+=2;
	flag=1;
      }else if(n - t[i] >= 0 && flag==1){
	n = n - t[i];
	cnt[i]++;
      }
      if(n == 0) break;
    }
    for(int i=0;i<10;i++){
      if(cnt[i] == 1){
	cout<<t[i]<<" ";
      }else if(cnt[i] == 2){
	cout<<t[i]<<endl;
      }
    }
    
  }
  
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, n) for(int i = 0; i <= n; i++)
#define MREP(i, n) for(int i = n; i >= 0; i--)

using namespace std;

int main(){
	int input;
	int tmp = 1, n = 9;
	bool fact[10];
	
	PREP(i, n){
		tmp *= (!i) ? 1 : 2;
		fact[i] = false;
	}

	while(cin >> input){
		MREP(i, n){
			if(tmp <= input){
				input -= tmp;
				fact[i] = true;
			}
			if(input == 0) break;
			tmp /= 2;
		}
		PREP(i, n){
			tmp *= (!i) ? 1 : 2;
			if(fact[i] == true){
				cout << tmp;
				if(i != n) cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<cstdio>
main(){int d,a;for(;a=1,~scanf("%d",&d);)for(;a<=d;a<<=1)if(a&d)printf((d/a>2)?"%d ":"%d\n",a);}

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

using namespace std;

int main(){
  int i,j,n;
  int a[10];
  int we[10]={1,2,4,8,16,32,64,128,256,512};
   
  while(cin>>n){
    i=0; 
    while(n!=1){
      a[i]=n%2;
      i++;
      n/=2;
    }
    a[i]=1;
    while(i!=9){
      i++;
      a[i]=0;    
    }
    i=0;
    for(j=0;j<10;j++){
      if(i&&a[j]==1)cout<<" ";
      if(a[j]==1){
	cout<<we[j];
	i=1;
      }
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){

  int a[10], b[10], g, cnt;

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

  fill(b, b+10, 0);
  cnt = 0;
  while(cin >> g){
    for(int i=9; i>=0 && g != 0; i--){
      if(a[i] <= g){
        b[i] = 1;
        g -= a[i];
        cnt++;
      }
    }

    for(int i=0; i<10; i++){
      if(b[i] == 1){
        cnt--;
        cout << a[i] << (cnt? " " : "");
        b[i] = 0;
      }
    }
    cout << endl;

  }

  return 0;

}

C++: #include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int x;
    while(cin>>x){
        for(int i=0;i<15;i++){
            if(x&1){
                cout<<pow(2,i);
                x=x>>1;
                if(x)cout<<' ';
            }
            else x=x>>1;
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

const int INF = 1e9;

int main() {
    int n;
	while (scanf("%d", &n) != EOF) {
		vector<int> list;
		int x = 512;
		while (n > 0) {
			if (n >= x) {
				list.push_back(x);
				n -= x;
			}
			x >>= 1;
		}
		reverse(all(list));
		for (int i = 0; i < list.size(); i++) {
			if (i > 0) cout << " ";
			cout << list[i];
		}
		cout << endl;
	}
}

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


int main(void){

	while (true){
		int n;
		cin>>n;
		if (cin.eof()) break;
		bool f=false;
		int i=1;
		while (n>0){
			if (n%2==1){
				if (f) cout<<" ";
				else f=true;
				cout<<i;
			}
			n/=2;
			i*=2;
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){
  int w,we[9]={1,2,4,8,16,32,64,128,256},i;
  queue<int> k;
  while(cin>>w){

    while(w!=0){
      k.push(w%2);
      w=w/2;
    }
    i=0;
    while(k.size()){
      if(k.front()==1&&k.size()>=2)cout<<we[i]<<" ";
      else if(k.front()==1)cout<<we[i]<<endl;
      k.pop();
      i++;
    }
  }
  return 0;
}