Language: C++

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	int w;
	int[] h;

	void run(){
		for(;;){
			n=sc.nextInt();
			w=sc.nextInt();
			if((n|w)==0){
				break;
			}
			h=new int[20];
			int vMax=0;
			int hMax=0;
			for(int i=0; i<n; i++){
				int v=sc.nextInt();
				h[v/w]++;
				vMax=Math.max(vMax, v);
				hMax=Math.max(hMax, h[v/w]);
			}
			int m=vMax/w+1;
			double ans=0;
			debug("test");
			for(int i=0; i<m; i++){
				double a=(double)(m-1-i)/(m-1);
				double b=(double)h[i]/hMax;
				ans+=a*b;
				debug("i", i);
				debug("a", a);
				debug("b", b);
			}
			ans+=0.01;
			println(""+ans);
		}
	}

	void debug(Object... os){
	// System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		try{
			// System.setIn(new FileInputStream("in.txt"));
		}catch(Throwable e){
			e.printStackTrace();
		}
		new Main().run();
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.lang.*;
      | ^~~~~~
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.math.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.io.*;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:9: error: 'Scanner' does not name a type
    7 |         Scanner sc=new Scanner(System.in);
      |         ^~~~~~~
a.cc:14:12: error: expected unqualified-id before '[' token
   14 |         int[] h;
      |            ^
a.cc:48:20: error: 'Object' has not been declared
   48 |         void debug(Object... os){
      |                    ^~~~~~
a.cc:48:30: error: expansion pattern 'int' contains no parameter packs
   48 |         void debug(Object... os){
      |                              ^~
a.cc:52:20: error: 'String' has not been declared
   52 |         void print(String s){
      |                    ^~~~~~
a.cc:56:22: error: 'String' has not been declared
   56 |         void println(String s){
      |                      ^~~~~~
a.cc:60:15: error: expected ':' before 'static'
   60 |         public static void main(String[] args){
      |               ^~~~~~~
      |               :
a.cc:60:33: error: 'String' has not been declared
   60 |         public static void main(String[] args){
      |                                 ^~~~~~
a.cc:60:42: error: expected ',' or '...' before 'args'
   60 |         public static void main(String[] args){
      |                                          ^~~~
a.cc:68:2: error: expected ';' after class definition
   68 | }
      |  ^
      |  ;
a.cc: In member function 'void Main::run()':
a.cc:18:27: error: 'sc' was not declared in this scope
   18 |                         n=sc.nextInt();
      |                           ^~
a.cc:23:25: error: 'h' was not declared in this scope
   23 |                         h=new int[20];
      |                         ^
a.cc:29:38: error: 'Math' was not declared in this scope
   29 |                                 vMax=Math.max(vMax, v);
      |                                      ^~~~
a.cc:44:35: error: invalid operands of types 'const char [1]' and 'double' to binary 'operator+'
   44 |                         println(""+ans);
      |                                 ~~^~~~
      |                                 |  |
      |                                 |  double
      |                                 const char [1]
a.cc: In member function 'void Main::print(int)':
a.cc:53:17: error: 'System' was not declared in this scope
   53 |                 System.out.print(s);
      |                 ^~~~~~
a.cc: In member function 'void Main::println(int)':
a.cc:57:17: error: 'System' was not declared in this scope
   57 |                 System.out.println(s);
      |                 ^~~~~~
a.cc: In static member function 'static void Main::main(int*)':
a.cc:63:24: error: 'Throwable' does not name a type
   63 |                 }catch(Throwable e){
      |                        ^~~~~~~~~
a.cc:64:25: error: 'e' was not declared in this scope
   64 |                         e.printStackTrace();
      |                         ^
a.cc:66:27: error: expected ';' before '.' token
   66 |                 new Main().run();
      |                           ^