Language: C++

import java.util.*;
import java.io.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
		ArrayList<Integer> page ;

		while (sc.hasNext() ) {
			String key = sc.next();
			int pageIn = sc.nextInt();
			if ( !map.containsKey(key) ) {
				map.put(key, new ArrayList<Integer>() );
			}
			map.get(key).add(pageIn);
		}
		
		
		Iterator it = map.keySet().iterator();
		while (it.hasNext()) {
			String key = (String) it.next();
			ArrayList <Integer> list = map.get(key);
			Collections.sort(list);
			System.out.println(key);
			for(int i = 0; i < list.size(); i++){
				if(i == 0){
					System.out.print(list.get(i));
				}else{
					System.out.print(" " + list.get(i));
				}
			}
			System.out.println();
			
                 }
		
	}

}  

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.io.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:15: error: expected ':' before 'static'
    4 |         public static void main(String[] args) {
      |               ^~~~~~~
      |               :
a.cc:4:33: error: 'String' has not been declared
    4 |         public static void main(String[] args) {
      |                                 ^~~~~~
a.cc:4:42: error: expected ',' or '...' before 'args'
    4 |         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:5:17: error: 'Scanner' was not declared in this scope
    5 |                 Scanner sc = new Scanner(System.in);
      |                 ^~~~~~~
a.cc:6:17: error: 'Map' was not declared in this scope
    6 |                 Map<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
      |                 ^~~
a.cc:6:21: error: 'String' was not declared in this scope
    6 |                 Map<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
      |                     ^~~~~~
a.cc:6:29: error: 'ArrayList' was not declared in this scope
    6 |                 Map<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
      |                             ^~~~~~~~~
a.cc:6:39: error: 'Integer' was not declared in this scope
    6 |                 Map<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
      |                                       ^~~~~~~
a.cc:6:49: error: 'map' was not declared in this scope
    6 |                 Map<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
      |                                                 ^~~
a.cc:6:59: error: 'TreeMap' does not name a type
    6 |                 Map<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
      |                                                           ^~~~~~~
a.cc:6:95: error: expected primary-expression before ')' token
    6 |                 Map<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
      |                                                                                               ^
a.cc:7:36: error: 'page' was not declared in this scope
    7 |                 ArrayList<Integer> page ;
      |                                    ^~~~
a.cc:9:24: error: 'sc' was not declared in this scope
    9 |                 while (sc.hasNext() ) {
      |                        ^~
a.cc:10:32: error: expected ';' before 'key'
   10 |                         String key = sc.next();
      |                                ^~~
a.cc:12:47: error: 'key' was not declared in this scope
   12 |                         if ( !map.containsKey(key) ) {
      |                                               ^~~
a.cc:13:50: error: 'ArrayList' does not name a type
   13 |                                 map.put(key, new ArrayList<Integer>() );
      |                                                  ^~~~~~~~~
a.cc:13:69: error: expected primary-expression before ')' token
   13 |                                 map.put(key, new ArrayList<Integer>() );
      |                                                                     ^
a.cc:15:33: error: 'key' was not declared in this scope
   15 |                         map.get(key).add(pageIn);
      |                                 ^~~
a.cc:19:17: error: 'Iterator' was not declared in this scope
   19 |                 Iterator it = map.keySet().iterator();
      |                 ^~~~~~~~
a.cc:20:24: error: 'it' was not declared in this scope; did you mean 'int'?
   20 |                 while (it.hasNext()) {
      |                        ^~
      |                        int
a.cc:21:32: error: expected ';' before 'key'
   21 |                         String key = (String) it.next();
      |                                ^~~
a.cc:22:45: error: 'list' was not declared in this scope
   22 |                         ArrayList <Integer> list = map.get(key);
      |                                             ^~~~
a.cc:22:60: error: 'key' was not declared in this scope
   22 |                         ArrayList <Integer> list = map.get(key);
      |                                                            ^~~
a.cc:23:25: error: 'Collections' was not declared in this scope
   23 |                         Collections.sort(list);
      |                         ^~~~~~~~~~~
a.cc:24:25: error: 'System' was not declared in this scope
   24 |                         System.out.println(key);
      |                         ^~~~~~