description: Let's call a set of positive integers a_1, a_2, ..., a_k quadratic if the product of the factorials of its elements is a square of an integer, i. e. ∏_{i=1}^{k} a_i! = m^2, for some integer m.
  
  You are given a positive integer n.
  
  Your task is to find a quadratic subset of a set 1, 2, ..., n of maximum size. If there are multiple answers, print any of them.
  
  Input
  
  A single line contains a single integer n (1 ≤ n ≤ 10^6).
  
  Output
  
  In the first line, print a single integer — the size of the maximum subset. In the second line, print the subset itself in an arbitrary order.
  
  Examples
  
  Input
  
  
  1
  
  
  Output
  
  
  1
  1 
  
  
  Input
  
  
  4
  
  
  Output
  
  
  3
  1 3 4 
  
  
  Input
  
  
  7
  
  
  Output
  
  
  4
  1 4 5 6 
  
  
  Input
  
  
  9
  
  
  Output
  
  
  7
  1 2 4 5 6 7 9 
solution: #include <bits/stdc++.h>
  using namespace std;
  long long i, j, k, n, m, t, p[1005000], f[1005000], g[1005000], x, y,
      no[1005000], res;
  map<long long, long long> mp;
  void show() {
    cout << res << '\n';
    for (i = 1; i <= n; i++)
      if (!no[i]) cout << i << ' ';
    exit(0);
  }
  int main() {
    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() + 1);
    uniform_int_distribution<long long> lim(1, 1e18);
    ios::sync_with_stdio(0);
    for (i = 1; i <= 1000000; i++) f[i] = lim(rng);
    for (i = 2; i <= 1000000; i++)
      if (!p[i])
        for (j = i; j <= 1000000; j += i) p[j] = i;
    cin >> n;
    if (p[n] == n) n--;
    res = n;
    for (i = 1; i <= n; i++) {
      for (j = i; j - 1; j /= p[j]) {
        x ^= f[p[j]];
        if ((n + 1 - i) & 1) y ^= f[p[j]];
      }
      mp[x] = i;
      g[i] = x;
    }
    if (!y) show();
    if (mp.count(y)) {
      res--;
      no[mp[y]] = 1;
      show();
    }
    for (i = 1; i <= n; i++) {
      if (mp.count(g[i] ^ y)) {
        res -= 2;
        no[mp[g[i] ^ y]] = no[i] = 1;
        show();
      }
    };
    y ^= g[n];
    n--;
    res = n;
    for (i = 1; i <= n; i++) {
      if (mp.count(g[i] ^ y)) {
        res -= 2;
        no[mp[g[i] ^ y]] = no[i] = 1;
        show();
      }
    };
  }
  