Go: 
package main

import (
	"fmt"
	"math"
)

func solve(n int) int {
	i := 0
	for {
		if val := math.Pow(2, float64(i)); val*2 > float64(n) {
			return int(val)
		}
		i++
	}
}

func main() {
	for {
		var n int
		_, err := fmt.Scan(&n)
		if err != nil {
			break
		}

		res := []int{}
		for {
			val := solve(n)
			res = append(res, val)
			n -= val

			if n <= 0 {
				break
			}
		}

		for i := range res {
			if i != 0 {
				fmt.Print(" ")
			}
			fmt.Print(res[len(res)-i-1])
		}
		fmt.Println()
	}
}

C++: #include<iostream>

using namespace std;

void conv(int n, int a[10])
{
	for(int i=0;i<10;i++)
	{
		a[i]=n%2;
		n=n/2;
	}
}

int pow(int x, int n)
{
	int ans=1;
	for(int i=0;i<n;i++)
	{
		ans*=x;
	}
	return ans;
}

int main(void)
{
	int w;
	while(cin>>w)
	{
		int a[10];
		conv(w,a);
		for(int i=0;i<10;i++)
		{
			if(a[i]==1)
			{
				cout<<pow(2,i)<<" ";
			}
		}
		cout<<endl;
	}
}

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--){
        cout<< w[i]<<" ";
    }
    cout<<endl;
}
int main(){
    while(cin>>n){
        solve();
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	int a;
	while(cin>>a){
		int w[10]={},j=0;
		while(a){
			rep(i,0,10){
				if(pow(2,i)<=a && a<pow(2,i+1)){
					a-=pow(2,i);
					w[i]++;
				}
			}
		}
		rep(i,0,10){
			if(w[i]){
				if(j==0){
					cout<<pow(2,i);
					j++;
				}else cout<<" "<<pow(2,i);
			}
		}
		cout<<endl;
	}
}

C++: #include <iostream>

using namespace std;

void k(int a, int* b)
{
	bool flag[10] = {};
	bool isFirst = true;

	for (int i = 9; i >= 0; i--)
	{
		if (a - b[i] >= 0)
		{
			a = a - b[i];
			flag[i] = true;
		}
	}

	for (int i = 0; i < 10; i++)
	{
		if (flag[i])
		{
			if (isFirst)
			{
				isFirst = false;
			}
			else
			{
				cout << " ";
			}
			cout << b[i];
		}
	}
	cout << endl;
}
int main()
{
	int a;
	int weights[10];

	weights[0] = 1;
	for (int i = 1; i < 10; i++)
	{
		weights[i] = weights[i - 1] * 2;
	}

	while (cin >> a)
	{
		k(a, begin(weights));
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int h[10]={1,2,4,8,16,32,64,128,256,512};
  int o,hk;
  while(cin>>o){
    hk = true;
    int w[1023][10]={0};
    for(int i=0;i<10;i++){
      if(h[i]>o) break;
      for(int j=o;j>=0;j--){
	if(j==0) w[h[i]][0] = h[i];
	else if(w[j][0]!=0&&j+h[i]<=o){
	  for(int n=0;n<10;n++){
	    if(w[j][n]==0){
	      for(int m=0;m<n;m++) w[j+h[i]][m] = w[j][m];
	      w[j+h[i]][n] = h[i];
	      break;
	    }
	  }
	}
	if(j==0) w[h[i]][0] = h[i];
      }
    }
      for(int i=0;i<10;i++){
	if(w[o][i]==0) break;
	if(hk!=true) cout << ' ';
	cout << w[o][i];
	if(hk==true) hk = false;
      }
      cout << endl;
  }
  return 0;
}

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 = 256; 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<vector>

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

int main(){

	int n;
	while (std::cin >> n){

		std::vector<int> res;

		for (int i = 9; i >= 0; i--){
			if (n >= bun[i]){
				res.push_back(bun[i]);
				n -= bun[i];
			}
		}

		for (int i = res.size() - 1; i >= 0; i--){
			if (i == 0)std::cout << res[i] << std::endl;
			else std::cout << res[i] << " ";
		}
	}

	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+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;
      }
    }
    
  }
  
}