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

int main(void){
	int N, ans;
	while(cin >> N){
		for(int i = 0; i < 10; i++){
			if(N & 1){
				ans = 1 << i;
				cout << ans;
				if(N >> 1)
					cout << ' ';
			}
			N >>= 1;
		}
		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 (flag) cout << " ";
  if (wigth & i) cout << i << endl;
  else cout << endl;

  return 0;
}

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

using namespace std;

int main()
{
	int wei[11];
	int sinn[11];
	int omosa=1;
	int n;
	for(int i=0;i<=10;i++){
		wei[i]=omosa;
		omosa*=2;
	}
	while(cin>>n){
		for(int i=0;i<=10;i++){
			sinn[i]=n%2;
			n/=2;
		}
		for(int i=0;i<10;i++){
			if(sinn[i]==1)cout<<wei[i]<<' ';
		}
		cout<<'\n';
	}
	return 0;
}

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

using namespace std;
const int V[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
int n;

void solve(){
    vector<int> w;
    for(int i=0; i<10; i++){
        int f = n/V[i];
        if(f!=0){
            n -= V[i];
            w.push_back(V[i]);
        }
    }
    for(int i=w.size()-1; i>=0; i--){
        if(i==0){
            cout<< w[i];
        }else{
            cout<< w[i]<< " ";
        }

    }
    cout<<endl;
}
int main(){
    while(cin>>n){
        solve();
    }
    return 0;
}

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

int main()
{
    int n,weight;
	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};
	
		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}
		for(int i=0; i<10 ; i++){
			if(flag[i]!=0){
				cout << w[i] << " ";
			}
		}
		cout << endl << endl;
	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

int main(void){
	int n, i;
	bool f;
	while(scanf("%d",&n) != EOF){
		f = false;
		for(i = 0;n >> i;i++){
			if(1 << i & n){
				if(f){
					printf(" ");
				}
				f = true;
				printf("%d",1 << i);
			}
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
	int we[10] = { 1,2,4,8,16,32,64,128,256,512 };
	int n;
	vector<int>v;
	vector<int>::iterator pv=v.begin();
	while (cin >> n) {
		int h = 9;
		while (n == 0) {
			if (n - we[h] >= 0) {
				n -= we[h];
				v.push_back(h);
			}
			h--;
		}
		for (int i = v.size(); i >-1; i--) {
			int x = v[i];
			cout << we[x];
			if (i != 0) { cout <<" "; }
			else { cout << endl; }
		}
	}
	return 0;
}

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

using std::cout;

int main()
{
    int weight;
    while (std::cin >> weight) {
        std::vector<int> list;
        for (int bundou = 1; bundou <= 512; bundou *= 2) {
            if (weight % (bundou * 2) != 0) {
                list.push_back(bundou);
                weight -= bundou;
            }
            if (weight == 0) {
                break;
            }
        }

        for (auto i = 0; i < list.size(); i++) {
            if (i != 0) {
                cout << " ";
            }
            cout << list.at(i);
        }
        cout << std::endl;
    }

    return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t;
    while(std::cin>>t){
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=std::stoi(s);
        for(int i=0;i<s.size();i++){if(num%10){std::cout<<pow(2,(double)(i)); if(pow(2,i)*2<t)std::cout<<" ";}num/=10;}
    std::cout<<std::endl;
    }
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int n, s;
int main() {
	while (cin >> n) {
		s = 0;
		for (int i = 0; i < 31; i++) {
			if (n % 2 == 1) {
				if (s) { cout << ' '; }
				cout << pow(2, i); s++;
				n = (n - 1) / 2;
			}
		}
		cout << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a;

signed main() {
	while (scanf("%d",&a)!=EOF) {
		vector<int> r;
		rep(i,30) if (a>>i&1) r.push_back(1<<i);
		rep(i,r.size()) cout << r[i] << bln(i,r.size());
	}
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int n;
	while (cin >> n) {
		bool a[1100] = {};
		int maxl = 0;
		for (int i = 512; i >= 1; i /= 2) {
			if (n >= i) {
				n -= i;
				a[i] = true;
				maxl = max(maxl, i);
			}
		}
		for (int i = 1; i <= 512; i *= 2) {
			if (a[i]) {
				if (i == maxl) {
					cout << i << endl;
				}
				else {
					cout << i << " ";
				}
			}
		}
	}
}