#include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } struct UnionFind { vector data; UnionFind(int size) : data(size, -1) {} bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; int sum; void dfs(int v, vector> &g, vector &col, int c){ sum++; assert(col[v] == -1); col[v] = c; for(int to: g[v]){ if(col[to] == -1) dfs(to, g, col, c^1); else { assert(col[to] != col[v]); } } } int popcount(int x){ int ans = 0; for(int i = 0; i <= 30; i++){ if(x&(1<> n; vector a(n); for(int i = 0; i < n; i++) cin >> a[i]; vector> g(n); UnionFind uf(n); for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++){ int x = a[i]^a[j]; if(popcount(x) == 1) { g[i].push_back(j); g[j].push_back(i); uf.unionSet(i, j); } } } vector> components(n); for(int i = 0; i < n; i++){ int r = uf.root(i); components[r].push_back(i); } vector col(n, -1); int ans = 0; for(int i = 0; i < n; i++){ if(uf.root(i) == i){ dfs(i, g, col, 0); vector cnt(2); for(int v: components[i]) cnt[col[v]]++; ans += max(cnt[0], cnt[1]); } } for(int c: col) assert(c != -1); assert(sum == n); cout << ans << endl; }