Language: C++


import java.util.Scanner;
import java.util.Arrays;

class Main{
        public static void main(String[] args){
                Scanner scanner=new Scanner(System.in);
                int N=scanner.nextInt();
                int[] a=new int[N+1];
                for(int i=0;i<N;i++){
                        a[i]=scanner.nextInt();
                }
                a[N]=-1;
                Arrays.sort(a);
                int[] b=new int[a.length];
                int n=1;
                int j=0;
                for(int i=0;i<a.length-1;i++){
                        if(a[i+1]==-1){
                                b[j]=n;
                        }else{
                                if(a[i]==a[i+1]){
                                        n++;
                                }else{
                                        b[j++]=n;
                                        n=1;
                                }
                        }
                }
                int sum=0;
                for(int i=0;i<b.length-2;i++){
                        if(n<(sum=b[i]+b[i+1]+b[i+2])){
                                n=sum;
                        }
                }
                System.out.println(n);
        }
}

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Arrays;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:15: error: expected ':' before 'static'
    6 |         public static void main(String[] args){
      |               ^~~~~~~
      |               :
a.cc:6:33: error: 'String' has not been declared
    6 |         public static void main(String[] args){
      |                                 ^~~~~~
a.cc:6:42: error: expected ',' or '...' before 'args'
    6 |         public static void main(String[] args){
      |                                          ^~~~
a.cc:38:2: error: expected ';' after class definition
   38 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:7:17: error: 'Scanner' was not declared in this scope
    7 |                 Scanner scanner=new Scanner(System.in);
      |                 ^~~~~~~
a.cc:8:23: error: 'scanner' was not declared in this scope
    8 |                 int N=scanner.nextInt();
      |                       ^~~~~~~
a.cc:9:20: error: structured binding declaration cannot have type 'int'
    9 |                 int[] a=new int[N+1];
      |                    ^~
a.cc:9:20: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:9:20: error: empty structured binding declaration
a.cc:9:23: error: expected initializer before 'a'
    9 |                 int[] a=new int[N+1];
      |                       ^
a.cc:11:25: error: 'a' was not declared in this scope
   11 |                         a[i]=scanner.nextInt();
      |                         ^
a.cc:13:17: error: 'a' was not declared in this scope
   13 |                 a[N]=-1;
      |                 ^
a.cc:14:17: error: 'Arrays' was not declared in this scope
   14 |                 Arrays.sort(a);
      |                 ^~~~~~
a.cc:15:20: error: structured binding declaration cannot have type 'int'
   15 |                 int[] b=new int[a.length];
      |                    ^~
a.cc:15:20: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:15:20: error: empty structured binding declaration
a.cc:15:23: error: expected initializer before 'b'
   15 |                 int[] b=new int[a.length];
      |                       ^
a.cc:20:33: error: 'b' was not declared in this scope
   20 |                                 b[j]=n;
      |                                 ^
a.cc:25:41: error: 'b' was not declared in this scope
   25 |                                         b[j++]=n;
      |                                         ^
a.cc:31:31: error: 'b' was not declared in this scope
   31 |                 for(int i=0;i<b.length-2;i++){
      |                               ^
a.cc:36:17: error: 'System' was not declared in this scope
   36 |                 System.out.println(n);
      |                 ^~~~~~