Language: C++

#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0)
using namespace std;
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE << '\n';
    SetConsoleTextAttribute(hConsole, 7);
#endif
}
#else
#define print(x) 0
#endif
struct pair_hash
{
    template<typename T1, typename T2>
    size_t operator () (const pair<T1, T2> &p) const
    {
        auto h1 = hash<T1> {}(p.first);
        auto h2 = hash<T2> {}(p.second);
        return h1 ^ h2;
    }
};
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
//ifstream fin(".in");
//ofstream fout(".out");
void die()
{
    cout << "NO";
    exit(0);
}
const int NMAX = 2 * 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

int h, w, n;
int v[NMAX];
pair<int, int> cur;
bool dir;
int sol[105][105];
int index = 1;

int main()
{
    FASTIO;
    cin >> h >> w >> n;
    for1(i, n) cin >> v[i];
    cur = mp(1, 1);
    while(v[n])
    {
        if(v[index] == 0) index++;
        sol[cur.first][cur.second] = index;
        print(cur.first);
        print(cur.second);
        print("\n");
        v[index]--;
        if(dir == 0)
        {
            cur.second++;
            if(cur.second == w + 1)
            {
                cur.second = w;
                dir = 1;
                cur.first++;
            }
        }
        else
        {
            cur.second--;
            if(cur.second == 0)
            {
                cur.second = 1;
                dir = 0;
                cur.first++;
            }
        }
    }
    for1(i, h) for1(j, w) cout << sol[i][j] << " \n"[j == w];

    return 0;
}


Compiler output:
a.cc:57:5: error: 'int index' redeclared as different kind of entity
   57 | int index = 1;
      |     ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:67:13: error: invalid types 'int [200005][<unresolved overloaded function type>]' for array subscript
   67 |         if(v[index] == 0) index++;
      |             ^
a.cc:67:32: error: no post-increment operator for type
   67 |         if(v[index] == 0) index++;
      |                                ^~
a.cc:68:38: error: cannot resolve overloaded function 'index' based on conversion to type 'int'
   68 |         sol[cur.first][cur.second] = index;
      |                                      ^~~~~
a.cc:72:10: error: invalid types 'int [200005][<unresolved overloaded function type>]' for array subscript
   72 |         v[index]--;
      |          ^