Language: C++

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


int N;
constexpr int Nmax = 100000;
vector<plint> D;
vector<int> to[Nmax];

plint dfs(int now, int prev)
{
    lint d = 0, subtreesz = 1;
    for (auto nxt : to[now]) if (nxt != prev)
    {
        plint pa = dfs(nxt, now);
        d += pa.first + pa.second;
        subtreesz += pa.second;
    }
    return plint(d, subtreesz);
}

int main()
{
    cin >> N;
    D.resize(N);
    REP(i, N)
    {
        cin >> D[i].first;
        D[i].second = i;
    }

    sort(D.begin(), D.end());

    map<lint, vector<pint>> ma;

    IREP(i, N)
    {
        lint Dnow, id_now;
        tie(Dnow, id_now) = D[i];

        int stsz = 1;
        if (ma.count(Dnow))
        {
            for (auto pa : ma[Dnow])
            {
                to[id_now].push_back(pa.first);
                to[pa.first].push_back(id_now);
                stsz += pa.second;
            }
            ma.erase(Dnow);
        }
        ma[Dnow + 2 * stsz - N].push_back(pint(id_now, stsz));
    }

    vector<pint> res;
    REP(s, N) for (auto t : to[s]) if (s < t) res.push_back(pint(s, t));

    if (res.size() != N - 1 || dfs(D[0].second, -1).first != D[0].first) cout << -1 << endl, exit(0);
    for (auto pa : res) cout << pa.first + 1 << " " << pa.second + 1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:22: error: 'pint' was not declared in this scope; did you mean 'uint'?
   41 |     map<lint, vector<pint>> ma;
      |                      ^~~~
      |                      uint
a.cc:41:22: error: template argument 1 is invalid
a.cc:41:22: error: template argument 2 is invalid
a.cc:41:26: error: template argument 2 is invalid
   41 |     map<lint, vector<pint>> ma;
      |                          ^~
a.cc:41:26: error: template argument 4 is invalid
a.cc:49:16: error: request for member 'count' in 'ma', which is of non-class type 'int'
   49 |         if (ma.count(Dnow))
      |                ^~~~~
a.cc:51:30: error: invalid types 'int[lint {aka long long int}]' for array subscript
   51 |             for (auto pa : ma[Dnow])
      |                              ^
a.cc:57:16: error: request for member 'erase' in 'ma', which is of non-class type 'int'
   57 |             ma.erase(Dnow);
      |                ^~~~~
a.cc:59:11: error: invalid types 'int[lint {aka long long int}]' for array subscript
   59 |         ma[Dnow + 2 * stsz - N].push_back(pint(id_now, stsz));
      |           ^
a.cc:62:16: error: template argument 2 is invalid
   62 |     vector<pint> res;
      |                ^
a.cc:63:51: error: request for member 'push_back' in 'res', which is of non-class type 'int'
   63 |     REP(s, N) for (auto t : to[s]) if (s < t) res.push_back(pint(s, t));
      |                                                   ^~~~~~~~~
a.cc:65:13: error: request for member 'size' in 'res', which is of non-class type 'int'
   65 |     if (res.size() != N - 1 || dfs(D[0].second, -1).first != D[0].first) cout << -1 << endl, exit(0);
      |             ^~~~
a.cc:66:20: error: 'begin' was not declared in this scope
   66 |     for (auto pa : res) cout << pa.first + 1 << " " << pa.second + 1 << endl;
      |                    ^~~
a.cc:66:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:66:20: error: 'end' was not declared in this scope
   66 |     for (auto pa : res) cout << pa.first + 1 << " " << pa.second + 1 << endl;
      |                    ^~~
a.cc:66:20: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~