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++: import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		while(scan.hasNext()){
			int w = scan.nextInt();
			int i = 1;
			StringBuffer sb = new StringBuffer();
			sb.setLength(0);
			while(w / 2 > 1){
				if(w % 2 == 1){
					sb.append(i).append(' ');
				}
				w /= 2;
				i = i << 1;
			}
			sb.append(i);
			String s = sb.toString().trim();
			System.out.printf("%s\n", s);
		}
	}
}

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

using namespace std;

// 問題に出てくる分銅の質量は2のn乗
// 下位のビットから1ビットずつ確認していく

int main() {
	int w;
	while (cin >> w) {
		string weights;

		// 対応するビットが1になっている確認。
		// 対応していたら値を出力する
		for (int bit = 1; bit < 1024; bit <<= 1) {
			if (bit & w) {
				weights.append(to_string(bit));
				weights.push_back(' ');
			}
		}
		// 最後のスペースを改行に置き換え
		weights.back() = '\n';
		cout << weights;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define PI 3.141592653

bool cross(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4){
    double a,b,c,d;
    
    a=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1);
    b=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2);
    c=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3);
    d=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4);
    
    if((c<0)^(d<0))
        return true;
    else
        return false;
}

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

C++: #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	while( cin >> n ){
		int s = 512;
		stack<int> st;
		while( n != 0 ){
			if( n - s >= 0 ){
				st.push(s);
				n -= s;
				s /= 2;
			}
			else{
				s /= 2;
			}

		}

		while( !st.empty() ){
			cout << st.top() << " ";
			st.pop();
		}
		cout << endl;
	}
	ret 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
        int w;
        int ans[10];

        while (cin >> w) {
                int cnt = 0;
                for (int i = 1; w; i*=2) {
                        if (w % 2) {
                                ans[cnt++] = i;
                        }
                        w /= 2;
                }
                for (int i = 0; i < cnt; i++) {
                        cout << ans[i];
                        if (i < cnt - 1) {
                                cout << " ";
                        }
                }
                cout << endl;
        }

        return 0;
}

C++: #include <stdio.h>

int quo,rem;

void divide_by_2(int x) {

  quo=x/2;
  rem=x%2;

}

int main(void) {

  int w;

  int count;

  while(scanf("%d",&w)!=EOF) {

    count=1;
    quo=w;

    while(quo>0) {

      divide_by_2(quo);
      
      if(rem==1) printf("%d ",count);

      count*=2;

    }

    puts("");

  }

  return 0;

}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  unsigned int n;
  int p;
  bool f;
  while(cin>>n){
    p=1;
    f=false;
    while(n!=0){
      if(n&1==1){
	if(f){
	  cout<<" ";
	}
	else{
	  f=true;
	}
	cout<<p;
      }
      n=n>>1;
      p*=2;
    }
    cout<<endl;
  }
}

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

using namespace std;

int main(){
  int n;
  while(cin >> n){
    if(cin.eof())break;
    vector<int> ar;
    int flg = 0;
    for(int i = 1024 ; i>=1; i /=2){
   
      if(n >= i&&flg == 0){
	cout << i;
	flg = 1;
	n-=i; 
	continue;
      }
      if(n >= i&&flg == 1){
	cout <<" "<< i;
	n-=i; 
      }
    }
  }
  return 0;
}

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

int main() {
  int w;
  while(cin >> w) {
    for(int i = 0, cnt = 0; w; ++i) {
      if(w & (1<<i)) {
	if(cnt) cout << " ";
	++cnt;
	cout << (1<<i);
	w &= ~(1<<i);
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int n;
  int a[10] = {1,2,4,8,16,32,64,128,256,512};
  while (cin >> n) {
    stack<int> s;
    for (int i = 9; i >= 0; i--) {
      if (n >= a[i]) {
        n -= a[i];
        s.push(a[i]);
      }
    }
    int m = s.size() - 1;
    while (m--) {
      cout << s.top() << " ";
      s.pop();
    }
    cout << s.top() << 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;
		int flg = 0;
		while (bun != 1024) {
			if (w % (2 * bun)) {
				if (flg) cout << ' ';
				cout << bun;
				w -= bun;
				flg++;
			}
			bun *= 2;
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

bool a[10];

    int main(){

    int N;
    int i=0;
    
    while(!cin.eof())
    {
        cin>>N;
        for(int k=9;k>-1;k--){
            
            if(i+(pow(2,k)) <= N){
                i += pow(2,k);
                a[k] = 1;
            }
        }
        
        bool last = false;
        for(int k=0;k<10;k++){
            
            if(a[k] ==1)
            {
                if(last){
                    cout<<" ";
                }
                last =true;
                cout<<pow(2,k);    
            }        
        }
 
        cout<<endl;
    }
}

C++: #include <stdio.h>

int quo,rem;

void divide_by_2(int x) {

  quo=x/2;
  rem=x%2;

}

int main(void) {

  int w;

  int count;

  while(scanf("%d",&w)!=EOF) {

    count=1;
    quo=w;

    while(quo>0) {

      divide_by_2(quo);
      
      if(rem==1) printf("%d ",count);

      count*=2;

    }

    printf("\n");

  }

  return 0;

}