#include <iostream> #include <fstream> #include <vector> #include <cmath> using namespace std; int n; vector <int> v; void magie (int n) { if (n != 1) { if (n % 2 == 0) magie (n / 2); else { magie (n / 2); v.push_back (n / 2 + 1); } } v.push_back(n); } void scrie () { int x = v.size(); cout << x << '\n'; for (int i = 0; i < x; i++) cout << v[i] << ' '; cout << '\n'; } int main () { cin >> n; magie (n); scrie (); return 0; }