#include <bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin >> T;
while(T--)
{
int ans;
int x;
cin >> x;
int low1;
int low0;
int cnt1;
low1 = low0 = -1;
cnt1 = 0;
bool fir1 = false;
bool fir0 = false;
for(int i = 0; i <= 31; i++)
{
int t = (x>>i) & 1;
if(!t && !fir0)
{
fir0 = true;
low0 = i;
}
if(t)
{
cnt1 ++;
if(!fir1)
{
low1 = i;
fir1 = true;
}
}
}
if(cnt1 > 1)
{
ans = (1<<low1);
}
else
{
ans = (1 << low1) + (1 << low0);
}
printf("%d\n", ans);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int H[50];
void process()
{
for(int i = 0; i <= 35; i++)
{
H[((long long)1 << i)%37] = i;
}
}
int main()
{
process();
int T;
cin >> T;
while(T--)
{
int ans;
int num_even = 0;
int minn = INT_MAX;
int buf;
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
scanf("%d", &buf);
if(H[(buf & (-buf))%37] != 0)
{
num_even ++;
}
minn = min(minn, H[(buf & (-buf))%37]);
}
if(minn == 0)
ans = num_even;
else
ans = num_even-1+minn;
printf("%d\n", ans);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define N 200010
char buf[N];
int cnt[300];
int main()
{
int T;
cin >> T;
while(T--)
{
char ans;
memset(cnt, 0, sizeof(cnt));
int n;
scanf("%d", &n);
for(int i = 1; i <= 2*n+1; i++)
{
scanf("%s", buf+1);
int len = strlen(buf+1);
for(int j = 1; j <= len; j++)
{
int p = buf[j];
cnt[p] = (cnt[p]+1) % 2;
}
}
for(int i = 'a'; i <= 'z'; i++)
{
if(cnt[i]&1 == 1)
{
ans = i;
break;
}
}
printf("%c\n", ans);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define N 200010
int s[N];
int main()
{
int T;
cin >> T;
while(T--)
{
long long ans = 0;
int n, k;
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; i++)
{
scanf("%d", s+i);
}
if(k >= n)
{
for(int i = 1; i <= n; i++)
{
ans += s[i];
}
ans += (long long)(k-1) * n;
ans -= (long long)n * (n-1) / 2;
}
else
{
long long tmp = 0;
int l = 1;
int r = k;
for(int i = 1; i <= r; i++) tmp += s[i];
ans = tmp;
while(r+1 <= n)
{
tmp-=s[l++];
tmp+=s[++r];
ans = max(tmp, ans);
}
ans += (long long)k*(k-1)/2;
}
printf("%lld\n", ans);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > pq;
int n, m;
int edge[600];
void ask(int k, bool tag)
{
printf("? ");
for(int i = 1; i <= k-1; i++)
{
if(tag) putchar('0');
else putchar('1');
}
if(tag) putchar('1');
else putchar('0');
for(int i = k+1; i <= m; i++)
{
if(tag) putchar('0');
else putchar('1');
}
putchar('\n');
fflush(stdout);
}
void que()
{
printf("? ");
for(int i = 1; i <= m; i++)
{
printf("%d", edge[i]);
}
putchar('\n');
fflush(stdout);
}
int main()
{
int ans = 0;
scanf("%d%d", &n, &m);
for(int i = 1; i <= m; i++)
{
int buf = 0;
ask(i, true);
scanf("%d", &buf);
pq.push(make_pair(buf, i));
}
for(int i = 1; i <= m; i++) edge[i] = 1;
que();
int res;
int last;
scanf("%d", &res);
last = res;
for(int i = 1; i <= m-1; i++)
{
pair<int, int>t;
t = pq.top();
pq.pop();
edge[t.second] = 0;
que();
scanf("%d", &res);
if(last - res < t.first);//并不需要干什么事情
else
{
ans += t.first;
}
last = res;
}
ans += pq.top().first;
printf("! ");
printf("%d", ans);
fflush(stdout);
return 0;
}