#include #include #include using namespace std; int n, a[10001]; int main() { cin >> n; for (int i = 0; i < n; i++) { unsigned long long c; cin >> c; unsigned long long m = (1LL << 63); int pos = 0; for (int j = 0; j < 64; j++) { unsigned long long res = m&c; if (res == m) { pos = j; break; } m >>= 1; } pos = 63- pos; unsigned int count = 0; while (c) { c &= (c - 1); count++; } unsigned long long r=0; for (int j = 0; j <= pos; j++) { if (count != 0) { r = r << 1; r = r | 1LL; count--; } else { r = r << 1; } } cout << r<<" "; } return 0; }