Language: C++

using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

i32 ans[100][100];

void solve() {
    indef(i32, h, w);
    indef(i32, n);
    queue<i32> a;
    times(n, i){
        a.push(get(i32));
    }
    i32 t = 0, c = 0;
    times(h, i) {
        times(w, j) {
            i32 jj = even(i) ? j : w-j-1;
            if (t == 0) {
                t += a.front();
                a.pop();
                c++;
            }
            t--;
            ans[i][jj] = c;
        }
    }
    times(h, i) {
        times(w-1, j) {
            cout << ans[i][j] << " ";
        }
        cout << ans[i][w-1] << endl;
    }
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    //cout << fixed << setprecision(9);
    solve();
    return 0;
}

Compiler output:
a.cc:1:75: error: 'string' does not name a type
    1 | using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
      |                                                                           ^~~~~~
a.cc:2:35: error: 'vector' does not name a type
    2 | template <typename T> using vec = vector<T>; void in() { }
      |                                   ^~~~~~
a.cc: In function 'void in(T&&, TS&& ...)':
a.cc:3:67: error: 'cin' was not declared in this scope; did you mean 'in'?
    3 | template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
      |                                                                   ^~~
      |                                                                   in
a.cc: In function 'void out(T&&)':
a.cc:4:41: error: 'cout' was not declared in this scope; did you mean 'out'?
    4 | template <typename T> void out(T &&x) { cout << x << "\n"; }
      |                                         ^~~~
      |                                         out
a.cc: In function 'void out(T&&, TS&& ...)':
a.cc:5:68: error: 'cout' was not declared in this scope; did you mean 'out'?
    5 | template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
      |                                                                    ^~~~
      |                                                                    out
a.cc: At global scope:
a.cc:22:7: error: 'i64' does not name a type; did you mean 'u64'?
   22 | const i64 MOD = 1000000007ll;
      |       ^~~
      |       u64
a.cc:23:7: error: 'f64' does not name a type; did you mean 'u64'?
   23 | const f64 EPS = 1e-10;
      |       ^~~
      |       u64
a.cc:25:1: error: 'i32' does not name a type; did you mean 'u32'?
   25 | i32 ans[100][100];
      | ^~~
      | u32
a.cc: In function 'void solve()':
a.cc:28:11: error: 'i32' was not declared in this scope; did you mean 'u32'?
   28 |     indef(i32, h, w);
      |           ^~~
a.cc:6:23: note: in definition of macro 'indef'
    6 | #define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
      |                       ^
a.cc:28:16: error: 'h' was not declared in this scope
   28 |     indef(i32, h, w);
      |                ^
a.cc:6:41: note: in definition of macro 'indef'
    6 | #define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
      |                                         ^~~~~~~~~~~
a.cc:28:19: error: 'w' was not declared in this scope
   28 |     indef(i32, h, w);
      |                   ^
a.cc:6:41: note: in definition of macro 'indef'
    6 | #define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
      |                                         ^~~~~~~~~~~
a.cc:29:16: error: expected ';' before 'n'
   29 |     indef(i32, n);
      |                ^
a.cc:6:25: note: in definition of macro 'indef'
    6 | #define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
      |                         ^~~~~~~~~~~
a.cc:29:16: error: 'n' was not declared in this scope; did you mean 'in'?
   29 |     indef(i32, n);
      |                ^
a.cc:6:41: note: in definition of macro 'indef'
    6 | #define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
      |                                         ^~~~~~~~~~~
a.cc:30:5: error: 'queue' was not declared in this scope
   30 |     queue<i32> a;
      |     ^~~~~
a.cc:30:16: error: 'a' was not declared in this scope
   30 |     queue<i32> a;
      |                ^
a.cc:31:14: error: expected ';' before 'i'
   31 |     times(n, i){
      |              ^
a.cc:8:30: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                              ^
a.cc:31:14: error: 'i' was not declared in this scope; did you mean 'in'?
   31 |     times(n, i){
      |              ^
a.cc:8:37: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                                     ^
a.cc: In lambda function:
a.cc:32:20: error: 'i32' is not captured
   32 |         a.push(get(i32));
      |                    ^~~
a.cc:7:20: note: in definition of macro 'get'
    7 | #define get(t) []{ t x; cin >> x; return x; }()
      |                    ^
a.cc:7:17: note: the lambda has no capture-default
    7 | #define get(t) []{ t x; cin >> x; return x; }()
      |                 ^
a.cc:32:16: note: in expansion of macro 'get'
   32 |         a.push(get(i32));
      |                ^~~
a.cc:28:11: note: '<typeprefixerror>i32' declared here
   28 |     indef(i32, h, w);
      |           ^~~
a.cc:6:23: note: in definition of macro 'indef'
    6 | #define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
      |                       ^
a.cc:7:25: error: 'cin' was not declared in this scope; did you mean 'in'?
    7 | #define get(t) []{ t x; cin >> x; return x; }()
      |                         ^~~
a.cc:32:16: note: in expansion of macro 'get'
   32 |         a.push(get(i32));
      |                ^~~
a.cc:7:32: error: 'x' was not declared in this scope
    7 | #define get(t) []{ t x; cin >> x; return x; }()
      |                                ^
a.cc:32:16: note: in expansion of macro 'get'
   32 |         a.push(get(i32));
      |                ^~~
a.cc: In function 'void solve()':
a.cc:34:8: error: expected ';' before 't'
   34 |     i32 t = 0, c = 0;
      |        ^~
      |        ;
a.cc:35:14: error: expected ';' before 'i'
   35 |     times(h, i) {
      |              ^
a.cc:8:30: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                              ^
a.cc:35:14: error: 'i' was not declared in this scope; did you mean 'in'?
   35 |     times(h, i) {
      |              ^
a.cc:8:37: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                                     ^
a.cc:36:18: error: expected ';' before 'j'
   36 |         times(w, j) {
      |                  ^
a.cc:8:30: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                              ^
a.cc:36:18: error: 'j' was not declared in this scope
   36 |         times(w, j) {
      |                  ^
a.cc:8:37: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                                     ^
a.cc:37:16: error: expected ';' before 'jj'
   37 |             i32 jj = even(i) ? j : w-j-1;
      |                ^~~
      |                ;
a.cc:38:17: error: 't' was not declared in this scope
   38 |             if (t == 0) {
      |                 ^
a.cc:41:17: error: 'c' was not declared in this scope
   41 |                 c++;
      |                 ^
a.cc:43:13: error: 't' was not declared in this scope
   43 |             t--;
      |             ^
a.cc:44:13: error: 'ans' was not declared in this scope
   44 |             ans[i][jj] = c;
      |             ^~~
a.cc:44:20: error: 'jj' was not declared in this scope
   44 |             ans[i][jj] = c;
      |                    ^~
a.cc:44:26: error: 'c' was not declared in this scope
   44 |             ans[i][jj] = c;
      |                          ^
a.cc:47:14: error: expected ';' before 'i'
   47 |     times(h, i) {
      |              ^
a.cc:8:30: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                              ^
a.cc:47:14: error: 'i' was not declared in this scope; did you mean 'in'?
   47 |     times(h, i) {
      |              ^
a.cc:8:37: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                                     ^
a.cc:48:20: error: expected ';' before 'j'
   48 |         times(w-1, j) {
      |                    ^
a.cc:8:30: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                              ^
a.cc:48:20: error: 'j' was not declared in this scope
   48 |         times(w-1, j) {
      |                    ^
a.cc:8:37: note: in definition of macro 'times'
    8 | #define times(n, i) for (i32 i = 0; i < (n); ++i)
      |                                     ^
a.cc:49:13: error: 'cout' was not declared in this scope; did you mean 'out'?
   49 |             cout << ans[i][j] << " ";
      |             ^~~~
      |             out
a.cc:49:21: error: 'ans' was not declared in this scope
   49 |             cout << ans[i][j] << " ";
      |                     ^~~
a.cc:51:9: error: 'cout' was not declared in this scope; did you mean 'out'?
   51 |         cout << ans[i][w-1] << endl;
      |         ^~~~
      |         out
a.cc:51:17: error: 'ans' was not declared in this scope
   51 |         cout << ans[i][w-1] << endl;
      |                 ^~~
a.cc:51:32: error: 'endl' was not declared in this scope
   51 |         cout << ans[i][w-1] << endl;
      |                                ^~~~
a.cc: At global scope:
a.cc:55:1: error: 'i32' does not name a type; did you mean 'u32'?
   55 | i32 main()
      | ^~~
      | u32