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>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int sg;
int bn[] = {1,2,4,8,16,32,64,128,256,512};
bool ck[10] ={false};
	while(cin >>  sg){
		rep(i,10){
			if(sg >= bn[9-i]){
				sg -= bn[9-i];
				ck[9-i] = true;
			}
		}
		int cnt=0;
		bool dsw=false;
		rep(i,10)
			if(ck[i]){
				cout << (dsw ? " ":"") << bn[i] ;
				dsw=true;
			}
		cout << endl;
	}
	return 0;
}

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

int main() {
  int x10=0;
  int x2=0;

  while(cin >> x10) {
    for(int i=0;i<10;i++) {
      x2 = x10 % (int)(pow(2,i+1));
      if(x2 != 0){
        if(i == 9) {
          cout << (int)pow(2,i);
          break;
        }
        cout << (int)pow(2,i) << " ";
        x10 -= x2;
      }
    }
    cout << endl;
  }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
#include <string.h>
#include <utility>
#include <cstdio>
#include <set>
#include <map>
#include <assert.h>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

#define ll long long
#define LL long long

int main() {
	int w;
	while (cin >> w) {
		int bun = 1;
		if (w % 2) {
			cout << bun;
			w -= bun;
		}
		bun *= 2;
		while (bun != 1024) {
			if (w % (2 * bun)) {
				cout << ' ' << bun;
				w -= bun;
			}
			bun *= 2;
		}
		cout << endl;
	}
	return 0;
}

C++: #include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

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

int main(){
    stack<int> ans;
    int n;
    while(cin>>n){
        rep(i,10){
            if(n>=hun[i]){
                n-=hun[i];
                ans.push(hun[i]);
            }
        }
        while(ans.size()){
            cout<<ans.top()<<" ";
            ans.pop();
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

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

int main(){
    stack<int> ans;
    int n;
    while(cin>>n){
        rep(i,10){
            if(n>=hun[i]){
                n-=hun[i];
                ans.push(hun[i]);
            }
        }
        while(ans.size()){
            cout<<ans.top()<<" ";
            ans.pop();
        }
        cout<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int n;
  bool w[10];
  bool flg;
  while(cin>>n){
    for(int i=0;i<10;i++)w[i]=false;
    flg=false;
    for(int i=9;i>=0;i--){
      if(n>=(int)pow(2.0,(double)i)){w[i]=true; n-=(int)pow(2.0,(double)i);}
    }
    for(int i=0;i<10;i++){
      if(w[i]){
	if(!flg){flg=true;
cout<<(int)pow(2.0,(double)i);
	}
	else{
	  cout<<' '<<(int)pow(2.0,(double)i);
	}
      }
    }
    cout<<endl;
  }
}

C++: #include <iostream>

using namespace std;

int main()
{
	int w;
	while (cin >> w) {
		for (int weight = 1; w>0; w>>=1, weight<<=1) {
			if ((w&1)==1) cout << weight << " ";
		}
		cout << "\b" << endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    int w;
    while (cin >> w) {
        vector<int> v;
        for (int i = 0; i <= 8; i++) {
            if (w >> i & 1) {
                v.push_back(1<<i);
            }
        }
        for (int i = 0; i < (int)v.size(); i++) {
            if (i > 0) cout << " ";
            cout << v[i];
        }
        cout << endl;
    }
    return 0;
}