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: import java.util.HashSet;
  import java.util.Scanner;
  
  public class Main {
      public static void main(String[] args) {
          Scanner myScanner=new Scanner(System.in);
          int n= myScanner.nextInt();
          if(n==1 || n==2 || n==3 ){
              System.out.println(1+"\n"+1);
          }
          /*
  
          else if(n==27){
              System.out.println(25);
              System.out.print("1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 25 26 27 ");
          }
  
           */
          /*
  
           else if(n==867){
              System.out.println(865);
              for (int i = 1; i <= 867; i++) {
                  if(n!= || n!=  ){
                      System.out.print(i+" ");
                  }
              }
          }
  
           */
  
          else{
              HashSet<Integer> numbers=new HashSet<>();
              for (int i = 0; i < n; i++) {
                  numbers.add(i+1);
              }
              switch (n%4){
                  case 0:
                      System.out.println(n-1);
                      numbers.remove(n/2);
                      break;
                      //best
                  case 1:
                      /*
                      double b=Math.sqrt((n*1.0));
                      double c=Math.sqrt((n-1)/2);
                      if((int)b==b && (int)c==c){
                          System.out.println(n);
  
                      }
                      else if((int)b==b){
                          System.out.println(n-1);
                          numbers.remove((n-1)/2);
                      }
                      else if((int)c==c){
                          System.out.println(n-1);
                          numbers.remove(n);
                      }
                      else{
                          System.out.println(n-2);
                          numbers.remove((n-1)/2);
                          numbers.remove(n);
                      }
  
                       */
                      System.out.println(n-2);
                      numbers.remove((n-1)/2);
                      numbers.remove(n);
                      break;
                  case 2:
  
                      double a=Math.sqrt((n+2)/4);
                      if((int)a==a) {
                          System.out.println(n - 1);
                          numbers.remove((n/2)+1);
                      }
                      else{
                          System.out.println(n-2);
                          numbers.remove(n/2);
                          numbers.remove(2);
                      }
  
                      break;
                      //
                  case 3:
                      double d=Math.sqrt(n/3);
                      double e=(d-1)/2;
                      double g=Math.sqrt((n+1));
                      if(n%3==0 && (int)d==d && (int)e==e ){
                          System.out.println(n-2);
                          numbers.remove(n-2);
                          numbers.remove((n-5)/2);
                      }
                      else if((int)g==g){
                          System.out.println(n-2);
                          numbers.remove(n);
                          numbers.remove((n+1)/2);
                      }
                      else{
                          System.out.println(n-3);
                          numbers.remove((n-1)/2);
                          numbers.remove(n);
                          numbers.remove(2);
                      }
                      break;
              }
              for (int i = 1; i <= n; i++) {
                  if(numbers.contains(i)){
                      System.out.print(i+" ");
                  }
              }
          }
  
      }
  
  
  }
  