Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		w := 512
		weights := make([]int, 10)
		for i := 9; i >= 0; i-- {
			if n >= w {
				weights[i] = w
				n -= w
			}
			w /= 2
		}

		output := []int{}
		for i := 0; i < 10; i++ {
			if weights[i] > 0 {
				output = append(output, weights[i])
			}
		}
		outputStr := fmt.Sprint(output)
		fmt.Println(outputStr[1:(len(outputStr) - 1)])
	}
}

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

int main()
{
	const int weight[] = {1,2,4,8,16,32,64,128,256,512}; 

	std::vector<int> answer;

	int n;

	while(std::cin >> n)
	{
		for(size_t i=0; i<10; ++i)
		{
			if(n/weight[9-i])
			{

				answer.push_back(weight[9-i]);

				n = n%weight[9-i];
			}
		}

		for(size_t i=0; i<answer.size()-1; ++i)
		{
			std::cout << answer[answer.size()-1-i] << ' ';
		}

		std::cout << answer[0] << '\n';

		answer.clear();
	}

}

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

using namespace std;

int main(void){
    int i,j,k,l;
    int n;
    int weight[10]={1,2,4,8,16,32,64,128,256,512};
    int weight_f[10];
    
    while(cin>>n){
    
    memset(weight_f,0,sizeof(weight_f));
    
    for(i=9;i>=0;i--){
        if(n-weight[i]>=0){
            n=n-weight[i];
            weight_f[i]=1;
        }
    }
    i=0;
    while(true){
        if(weight_f[i]==1){
            cout<<weight[i]<<flush;
            break;
        }
        i++;
    }
    for(j=i+1;j<10;j++){
        if(weight_f[j]==1){
            cout<<" "<<weight[j]<<flush;
        }
    }
    cout<<endl;
    }
    return(0);
}

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

int main() {
    int month, day;
    string weekday[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
    while (cin >> month >> day) {     
        time_t rawtime;
        struct tm * timeinfo;

        time(&rawtime);
        timeinfo = localtime(&rawtime);

        timeinfo->tm_year = 2004-1900;
        timeinfo->tm_mon = month - 1;
        timeinfo->tm_mday = day;
        
        mktime(timeinfo);

        cout << weekday[timeinfo->tm_wday] << endl;
    }
    return 0;
}

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

using namespace std;
int main()
{
    int N;
    while ( !cin.eof() )
    {
        cin >> N;
        vector<int> ans;
        
        for (int a = 0; a < 10; a++)
        {   
            if (N % 2 == 1)
            {
                N = (N - 1) / 2;
                ans.push_back( pow(2,a) );
            }
            else
                N = N / 2;
        }
        
        for (int i = 0; i < ans.size(); i++)
        {
            cout << ans[i] ;
            if (i == ans.size()-1)
                cout << endl;
            else
                cout << " ";
        }
    }
}

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

using namespace std;

template<typename T> string to_string(const T& v) {
  string str;
  for (const auto& i : const_cast<T&>(v)) str += to_string(i) + " ";
  return str.substr(0, max(0, (int)str.size() - 1));
}

#ifdef __MINGW32__

template<> string to_string<int>(const int& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<long>(const long& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<long long>(const long long& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<unsigned int>(const unsigned int& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<unsigned long>(const unsigned long& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<unsigned long long>(const unsigned long long& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<float>(const float& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<double>(const double& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<long double>(const long double& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

#endif

int main() {
  int n;
  while (cin >> n) {
    int t = 1;
    vector<int> res;
    for (; n; n /= 2, t *= 2) if (n % 2) res.emplace_back(t);
    cout << to_string(res) << endl;
  }
}

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

int main(){
	int n;
	int bit[10];
	for(int i=0;i<10;i++){
		int a = 1;
		for(int j=0;j<i;j++) a *= 2;
		bit[i] = a;
	}
	while(cin>>n){
		bool s = false;
		int k[10];
		for(int i=0;i<10;i++){
			k[i] = n%2;
			n = (n-k[i])/2;
			if(k[i]==1){
				if(not s){ s = true; cout << bit[i];}
				else cout << " " << bit[i];
			}
		}
		cout << endl;
	}
}

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

using namespace std;

int main(void) {
	int weight;
	while(cin >> weight) {
		int bundo[10];
		for(int i = 9; i >= 0; i--) {
			if(weight >= pow(2, i)) {
				bundo[i] = 1;
				weight -= pow(2, i);
			} else {
				bundo[i] = 0;
			}
		}
		
		for(int i = 0; i < 8; i++) {
			if(bundo[i] == 1) {
				cout << pow(2, i) << ' ';
			}
		}
		if(bundo[9] == 1) {
			cout << pow(2, 9);
		}
		cout << endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  int w;
  while(cin >> w){
    int a = 1; 

    while(w > 0){
      if(w == 1){
        cout << a;
      } else if(w & 1){
        cout << a << " ";
      }
      w /= 2; a *= 2;
    }
    cout << endl;
  }
}

C++: #include<iostream>

using namespace std;

bool a[10];

int main(){
    
    int N;
    int i=0;
    
    while(!cin.eof())
    {
        cin>>N;
        
        for(int j=0;j<10;j++)
        {
            a[j]=0;
        }
        
        i=0;
        
        if(i+512 <= N){
            i += 512;
            a[9] = 1;
        }

        if(i+256 <= N){
            i += 256;
            a[8] = 1;
        }
        
        if(i+128 <= N){
            i += 128;
            a[7] = 1;
        }
        
        if(i+64 <= N){
            i += 64;
            a[6] = 1;
        }
        
        if(i+32 <= N){
            i += 32;
            a[5] = 1;
        }
        
        if(i+16 <= N){
            i += 16;
            a[4] = 1;
        }
        
        if(i+8 <= N){
            i += 8;
            a[3] = 1;
        }
        
        if(i+4 <= N){
            i += 4;
            a[2] = 1;
        }
        
        if(i+2 <= N){
            i += 2;
            a[1] = 1;
        }
        
        if(i+1 <= N){
            i += 1;
            a[0] = 1;
        }
        
        cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<" "<<a[5]
            <<" "<<a[6]<<" "<<a[7]<<" "<<a[8]<<" "<<a[9]<<" "<<endl;
    }
}

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

int main()
{
	int n, count = 0, sum = 1;
	int ans[100][9], data[100] = {0}, ansdata[100];
	for (int a = 0; a <= 9; a++) {
		data[a+1] = sum;
		sum = sum * 2;
	}
	while (cin >> n) {
		sum = 0;
		int count2 = 0,sin=1;
		for (int a = 0; a <= 9; a++) {
			if (n % 2 == 0 && sin==1) {
				sum = sum - 1;
			}
			sum = sum + data[a + 1];
			ans[count][count2] = a+1;
			if (sum > n) {
				sum = sum - (data[a]);
				count2 = count2 - 1;
				ans[count][count2] = a + 1;
				a--;
			}
			if (n % 2 == 0 && sin == 1) {
				count2--;
				sin = 2;
			}
			count2++;
			if (sum == n)
				break;
		}
		ansdata[count] = count2;
		count++;
	}
	for (int a = 0; a <= count; a++) {
		for (int b = 0; b < ansdata[a]; b++) {
			cout << data[ans[a][b]]<< " ";
		}
		cout << endl;
	}
	return 0;
}