// Autókódolás.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
using namespace std;
int main()
{
int a,uj=0,n=1,egyesek=0,kisebb,nagyobb,ke=0,ne=0,kisebberedeti,nagyobberedeti;
cin >> a;
kisebb = a-1;
nagyobb = a+1;
kisebberedeti = kisebb;
nagyobberedeti = nagyobb;
while (a > 0)
{
if (a % 2 == 1)
egyesek++;
a = a / 2;
n=n*10;
}
while (ke != egyesek)
{
n = 1;
ke = 0;
while (kisebb > 0)
{
if (kisebb % 2 == 1)
ke++;
kisebb = kisebb / 2;
n = n * 10;
}
//cout << ke;
if (ke == egyesek)
{
cout << kisebberedeti<<endl;
}
kisebberedeti--;
if (kisebberedeti < 0) {
cout << "-1"<<endl;
break;
}
kisebb = kisebberedeti;
}
while (ne != egyesek)
{
n = 1;
ne = 0;
while (nagyobb > 0)
{
if (nagyobb % 2 == 1)
ne++;
nagyobb = nagyobb / 2;
n = n * 10;
}
//cout << ke;
if (ne == egyesek)
{
cout << nagyobberedeti;
}
nagyobberedeti++;
nagyobb = nagyobberedeti;
}
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file