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;
  using ull = unsigned long long;
  const int N = 1e6 + 5;
  mt19937_64 rnd(time(0));
  int n, K, flag[N], pr[N], cnt;
  ull H[N], sum;
  unordered_map<ull, int> pos;
  int main() {
    scanf("%d", &n);
    K = n >> 1;
    flag[0] = flag[1] = 1, H[1] = 0;
    for (int i = 2; i <= n; i++) {
      if (!flag[i]) pr[++cnt] = i, H[i] = rnd();
      for (int j = 1; j <= cnt && i * pr[j] <= n; j++) {
        flag[i * pr[j]] = 1, H[i * pr[j]] = H[i] ^ H[pr[j]];
        if (i % pr[j] == 0) break;
      }
    }
    for (int i = 2; i <= n; i++) H[i] ^= H[i - 1], sum ^= H[i];
    if (sum == 0) {
      printf("%d\n", n);
      for (int i = 1; i <= n; i++) printf("%d ", i);
      return 0;
    }
    for (int i = 1; i <= n; i++)
      if (H[i] == sum) {
        printf("%d\n", n - 1);
        for (int j = 1; j <= n; j++)
          if (j != i) printf("%d ", j);
        return 0;
      }
    for (int i = 1; i <= n; i++) {
      if (pos.count(sum ^ H[i])) {
        int p = pos[sum ^ H[i]];
        printf("%d\n", n - 2);
        for (int j = 1; j <= n; j++)
          if (j != i && j != p) printf("%d ", j);
        return 0;
      }
      pos[H[i]] = i;
    }
    printf("%d\n", n - 3);
    for (int i = 1; i <= n; i++)
      if (i != 2 && i != K && i != n) printf("%d ", i);
    return 0;
  }
  