Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		first := true
		beki := 1
		for num != 0 {
			if num % 2 == 1 {
				if !first {
					fmt.Print(" ")
				}
				fmt.Print(beki)
				first = false
			}
			num /= 2
			beki *= 2
		}
		fmt.Println()
	}
}

C++: #include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int main(){
  vector<int> ar;
  int g[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int n;
  while(cin >> n){
    for(int i=9;i>=0;i--){
      if(n>=g[i]){
	n -= g[i];
	ar.push_back( g[i] );
      }
    }
    for(int i=ar.size()-1;i>=0;i--){
      if(i != 0)cout << ar[i] << ' ';
      else cout << ar[i] << endl;
    }
  }
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	int w;

	while ( cin >> w )
	{
		set<int> weights;

		for ( int i = 9; 0 <= i; i-- )
		{
			int weight = pow( 2, i );

			if ( weight <= w )
			{
				w -= weight;
				weights.insert( weight );
			}
		}

		for ( set<int>::iterator it = weights.begin(); it != weights.end(); )
		{
			cout << *it;

			if ( ++it == weights.end() )
			{
				cout << endl;
			}
			else
			{
				cout << ' ';
			}
		}
	}
	
	return 0;
}

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

using namespace std;

int main()
{
	int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int gram;
	vector<int> ans;
	while(cin>>gram){
		for(int i=9;i>=0;i--){
			if(gram >= weight[i]){
				ans.push_back(i);
				gram -= weight[i];
			}
		}
		
		for(size_t i=ans.size()-1;i>=0;i--){
			cout<<weight[ ans[i] ];
			if(i != 0) cout<<' ';
		}
		cout<<endl;
		ans.clear();
		
	}
	return 0;
}

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

int main(void){
    int n;
    int weight[10];
    bool flag;
    while(cin>>n){
        for(int i=0;i<10;i++){
            weight[i]=0;
        }
        flag=false;
        for(int i=9;i>=0;i--){
            if(pow(2,i)<=n){
                weight[i]=1;
                n-=pow(2,i);
            }
        }
        for(int i=0;i<10;i++){
            if(flag==false and weight[i]==1){
                flag=true;
                cout<<pow(2,i);
            }
            else if(weight[i]==1){
                cout<<" "<<pow(2,i);
            }
        }
        cout<<endl;
    }
}

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

int main(int argc, const char * argv[])
{
    int cu[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
    int g, j, cu2[10];
    while (cin >> g) {
        for (int i = 0; i < 10; i++)
            cu2[i] = 0;
        j = 0;
        for (int i = 0; i < 11; i++) {
            if ((g - cu[i]) < 0) {
                g -= cu [i - 1];
                cu2[j] = cu[i - 1];
                i = 0; j++;
            }
            if (g == 0) break;
        }
        for (int i = 0; i < j / 2; i++) {
            int tmp;
            tmp = cu2[j - 1 - i];
            cu2[j - 1 - i] = cu2[i];
            cu2[i] = tmp;
        }
        for (int i = 0; i < j; i++) {
            printf("%d", cu2[i]);
            if (i + 1 < j)
                printf(" ");
        }
        puts("");
    }
    return 0;
}

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

int main(){
	int n;
	while(cin >> n){ 
		int weight[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		for(int i = 9; i >= 0; i--){
			if(n >= pow(2, i)){
				n -= pow(2, i);
				weight[i] = 1;
			}
		}

		int i;
		for(i = 0; i < 10; i++){
			if(weight[i]){
				cout << pow(2, i);
				i++;
				break;
			}
		}
		for(; i < 10; i++){
			if(weight[i]){
				cout << " " << pow(2, i);
			}
		}
		cout << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int kaizyo(int x){
    if(x==1)return x;
    else return x*kaizyo(x-1);
}


int main() {
    int n;
    vi ans;
    vi v;
    rep(i,0,10)v.pb(pow(2,i));
    
    while(cin>>n){
        for(int i=9;i>=0;i--){
            if(n>=v[i]){
                n-=v[i];
                ans.pb(v[i]);
            }
        }
    
        for(int i=ans.size()-1;i>=0;i--){
            if(i==0)cout<<ans[i];
            else cout<<ans[i]<<" ";
        }
        cout<<endl;
        ans.clear();
    }
  
    return 0;
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[10]={1,2,4,8,16,32,64,128,256,512}; 
  
 int main()
 {
   int N;
   while(cin>>N)
   {
     int count=0;
     int num[10]={0};
     while(N)
     {
       num[count++]=N%2;
       N/=2;        
     }      
     for(int i=0;i<count-1;i++)
     {
       if(num[i]) cout<<arr[i]<<" ";
     }
     if(num[count-1]) cout<<arr[count-1]<<endl;
     else cout<<endl;           
   }
   //while(1);     
   return 0;  
 }

C++: #include<iostream>
using namespace std;
int weight[10]={1,2,4,8,16,32,64,128,256,512,};
bool weightFlag[10];
int main(){
    int n,dummy=0;
    while(cin>>n){
        if(n>=weight[9]){
            n-=weight[9];
            weightFlag[9]=true;
        }
        if(n>=weight[8]){
            n-=weight[8];
            weightFlag[8]=true;
        }
        if(n>=weight[7]){
            n-=weight[7];
            weightFlag[7]=true;
        }
        if(n>=weight[6]){
            n-=weight[6];
            weightFlag[6]=true;
        }
        if(n>=weight[6]){
            n-=weight[6];
            weightFlag[6]=true;
        }
        if(n>=weight[5]){
            n-=weight[5];
            weightFlag[5]=true;
        }
        if(n>=weight[4]){
            n-=weight[4];
            weightFlag[4]=true;
        }
        if(n>=weight[3]){
            n-=weight[3];
            weightFlag[3]=true;
        }
        if(n>=weight[2]){
            n-=weight[2];
            weightFlag[2]=true;
        }
        if(n>=weight[1]){
            n-=weight[1];
            weightFlag[1]=true;
        }
        if(n>=weight[0]){
            n-=weight[0];
            weightFlag[0]=true;
        }
        for(int i=0;i<10;i++){
            if(weightFlag[i]){
                cout<<weight[i];
                if(i!=9){
                    cout<<' ';
                }
            }
        }
        cout<<endl;
        for(int i=0;i<10;i++) weightFlag[i]=false;
    }
    return 0;
}