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 u64 = uint64_t;
  int main() {
    std::mt19937_64 gen{0};
    int n;
    scanf("%d", &n);
    std::vector<int> primes;
    std::vector<bool> removed(n + 1);
    std::vector<u64> hashes(n + 1);
    for (int d = 2; d <= n; ++d) {
      if (!removed[d]) {
        primes.push_back(d);
        hashes[d] = gen();
      }
      for (int p : primes) {
        if (d * p > n) {
          break;
        }
        removed[d * p] = true;
        hashes[d * p] = hashes[d] ^ hashes[p];
        if (d % p == 0) {
          break;
        }
      }
    }
    std::map<u64, int> lookup;
    u64 target = 0;
    for (int d = 2; d <= n; ++d) {
      hashes[d] ^= hashes[d - 1];
      target ^= hashes[d];
      lookup[hashes[d]] = d;
    }
    bool ok = target == 0;
    std::fill(removed.begin(), removed.end(), false);
    if (!ok) {
      for (int i = 1; i <= n && !ok; ++i) {
        if (hashes[i] == target) {
          ok = removed[i] = true;
        }
      }
    }
    if (!ok) {
      for (int i = 1; i <= n && !ok; ++i) {
        auto iterator = lookup.find(target ^ hashes[i]);
        if (iterator != lookup.end()) {
          ok = removed[i] = removed[iterator->second] = true;
        }
      }
    }
    if (!ok) {
      assert(n % 2 == 1);
      removed[2] = removed[(n - 1) >> 1] = removed[n] = true;
    }
    int m = n - std::count(removed.begin(), removed.end(), true);
    printf("%d\n", m);
    for (int i = 1; i <= n; ++i) {
      if (!removed[i]) {
        printf("%d ", i);
      }
    }
    puts("");
  }
  