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 <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int W;
int weights[10] ={1,2,4,8,16,32,64,128,256,512};
int main()
{
  while(cin>>W){
    if(cin.eof())
      break;
    int type[10]={0};
    for(int j = 10;j >=0;j--){
      if(W-weights[j] >=0){
	W -=weights[j];
	type[j] = 1;
      }
    }
      for(int i = 0;i <10;i++){
	if(type[i] ==1){
	  cout <<weights[i];
	  if(i !=9)
	    cout <<" ";
	}else if(i ==9)
	  cout <<endl;
      }
  }
  return 0;
}

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

using namespace std;

string IntToString(int number) {
	stringstream ss;
	ss << number;
	return ss.str();
}

int main(void) {
	int in;
	int omori[] = {512,256,128,64,32,16,8,4,2,1};
	int i;
	string ret;

	while(true) {
		cin >> in;
		if(cin.eof()) { break; }
		ret = "";
		for(i = 0; i < 10; i++) {
			if(omori[i] <= in) {
				in -= omori[i];
				ret = IntToString(omori[i]) + ((ret=="")?(""):(" ")) + ret;
			}
			if(in == 0) { break; }
		}
		cout << ret << endl;
	}

	return 0;
}

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

int main()
{
	int n, count = 0, sum = 1;
	int ans[100][9] = { 0 }, data[100] = { 0 }, ansdata[100] = {0};
	for (int a = 0; a <= 10; a++) {
		data[a+1] = sum;
		sum = sum * 2;
	}
	while (cin >> n) {
		int data2, count2 = 0;
		for (int a = 0; a <= 10; a++) {
			if (n < data[a + 1]) {
				sum = data[a];
				data2 = a;
				ans[count][count2] = a;
				count2++;
				break;
			}
		}
		for (int a = data2-1; a > 0; a--) {
			sum = sum + data[a];
			if (sum > n) {
				sum = sum - data[a];
			}
			else {
				ans[count][count2] = a;
				count2++;
			}
			if (sum == n) {
				break;
			}
		}
		ansdata[count] = count2;
		count++;
	}
	for (int a = 0; a < count; a++) {
		for (int b = ansdata[a]-1; b>=0; b--) {
			cout << data[ans[a][b]]<< " ";
		}
		cout << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	int n;
	for(;cin>>n;){
		int k=1;
		while(n){
			if(n&1){
				cout<<k;
				cout<<(n!=1?' ':'\n');
			}
			n/=2;
			k*=2;
		}
	}
	return 0;
}

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

void solve( int w, int* g, bitset<10> b, int i )
{
    if( i == 10 )
    {
        int sum = 0;
        int p;                              //prsentation error回避
        for( int j = 0; j < 10; j++ )
        {
            if( b[j] == 1 )
            {
                sum += g[j];
                p = j;
            }
        }
        if( w == sum )
        {
            for( int j = 0; j < 10; j++ )
            {
                if( b[j] == 1 )
                {
                    cout << g[j];
                    if( p != j )
                        cout << " ";
                }
            }
        }
        return;
    }
    b[i] = 0;
    solve( w, g, b, i + 1 );

    b[i] = 1;
    solve( w, g, b, i + 1 );

}

int main()
{
    int a = 1, w, g[10];
    bitset<10> b;

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

    while( cin >> w )
    {
        solve( w, g, b, 0 );
        cout << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin >> n){
    int ans[100]={},cnt=0;
    while(n){
      ans[cnt]=n%2;
      n/=2;
      cnt++;
    }
    int tmp=1;
    bool f=true;
    for(int i=0;i<cnt;i++){
      if(ans[i]>0){
        if(!f){
          cout << " ";
        }
        cout << ans[i]*tmp;
        f=false;
      }
      tmp*=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){
                for(int j=0; j<10; j++){
                    if(i&1==1){
                        cout<<weight[j]<<" ";
                    }
                    i=i>>1;
                }
                cout<<endl;
                break;
            }
            
            
            
        }
    }
    return 0;
}

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

int main(){
  int w[]={512,256,128,64,32,16,8,4,2,1};
  int n;
  while(cin>>n){
    stack<int> a;
    for(int i=0;i<10;i++){
      if(n>=w[i]){
	a.push(w[i]);
	n-=w[i];
      }
    }
    cout<<a.top();
    a.pop();
    while(!a.empty()){
      cout<<' '<<a.top();
      a.pop();
    }
    cout<<endl;
  }
  return 0;
}

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

int main(void){
	int n;
	while(cin>>n){
		int m[10]={0};
		int i=0;
		for(int max = 1024;max /= 2;max<1){
			if(n>=max){
//				cout<<max<<" "<<n<<endl;
				n=n-max;
				m[i++]=max;
//				cout<<max<<endl;
			}
		}
		
		sort(m,m+10);
		for(i=0;i<10;i++)
			if(m[i]!=0){
				cout<<m[i];
				break;
			}
		for(int j=i+1;j<10;j++)
			if(m[j]!=0)cout<<" "<<m[j];
		cout<<endl;
	}
}

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%2==1){
                    sum+=weight[j];
                }
                bit=bit/2;
            }
            
            if(sum == x){
                int flag = 0;
                for(int j=0; j<10; j++){
                    if(i%2==1&&flag==0){
                        cout<<weight[j];
                        flag++;
                    }else if(i%2==1){
                        cout<<" "<<weight[j];
                    }
                    i=i/2;
                }
                cout<<endl;
                break;
            }
            
            
            
        }
    }
    return 0;
}