Language: C++

import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();

        int n = scan.nextInt();

        int[] a = new int[n];

        for(int i = 0;i < n;i++){
            a[i] = scan.nextInt();
        }

        int now = 0;
        int[][] b = new int[h][w];
        for(int i = 0;i < h;i++){
            if(i % 2 == 0){
                for(int j = 0;j < w;j++){
                if(a[now] == 0)
                    now++;
                b[i][j] = now + 1;
                if(now < n)
                    a[now]--;
                }
            }else{
                for(int j = w - 1;j >= 0;j--){
                    if(a[now] == 0)
                        now++;
                    b[i][j] = now + 1;
                    if(now < n)
                        a[now]--;
                }
            }
        }
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                System.out.printf("%d ",b[i][j]);
            }
            System.out.println();
        }
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:11: error: expected ':' before 'static'
    3 |     public static void main(String[] args){
      |           ^~~~~~~
      |           :
a.cc:3:29: error: 'String' has not been declared
    3 |     public static void main(String[] args){
      |                             ^~~~~~
a.cc:3:38: error: expected ',' or '...' before 'args'
    3 |     public static void main(String[] args){
      |                                      ^~~~
a.cc:44:2: error: expected ';' after class definition
   44 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:4:9: error: 'Scanner' was not declared in this scope
    4 |         Scanner scan = new Scanner(System.in);
      |         ^~~~~~~
a.cc:5:17: error: 'scan' was not declared in this scope
    5 |         int h = scan.nextInt();
      |                 ^~~~
a.cc:10:12: error: structured binding declaration cannot have type 'int'
   10 |         int[] a = new int[n];
      |            ^~
a.cc:10:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:10:12: error: empty structured binding declaration
a.cc:10:15: error: expected initializer before 'a'
   10 |         int[] a = new int[n];
      |               ^
a.cc:13:13: error: 'a' was not declared in this scope
   13 |             a[i] = scan.nextInt();
      |             ^
a.cc:17:12: error: structured binding declaration cannot have type 'int'
   17 |         int[][] b = new int[h][w];
      |            ^~
a.cc:17:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:17:12: error: empty structured binding declaration
a.cc:17:14: error: expected initializer before '[' token
   17 |         int[][] b = new int[h][w];
      |              ^
a.cc:21:20: error: 'a' was not declared in this scope
   21 |                 if(a[now] == 0)
      |                    ^
a.cc:23:17: error: 'b' was not declared in this scope
   23 |                 b[i][j] = now + 1;
      |                 ^
a.cc:25:21: error: 'a' was not declared in this scope
   25 |                     a[now]--;
      |                     ^
a.cc:29:24: error: 'a' was not declared in this scope
   29 |                     if(a[now] == 0)
      |                        ^
a.cc:31:21: error: 'b' was not declared in this scope
   31 |                     b[i][j] = now + 1;
      |                     ^
a.cc:33:25: error: 'a' was not declared in this scope
   33 |                         a[now]--;
      |                         ^
a.cc:39:17: error: 'System' was not declared in this scope
   39 |                 System.out.printf("%d ",b[i][j]);
      |                 ^~~~~~
a.cc:39:41: error: 'b' was not declared in this scope
   39 |                 System.out.printf("%d ",b[i][j]);
      |                                         ^
a.cc:41:13: error: 'System' was not declared in this scope
   41 |             System.out.println();
      |             ^~~~~~