Language: C++

//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
const int MAX=1e5+5;

int n,size[MAX],id[MAX],ans1[MAX],ans2[MAX];
ll tot,a[MAX];
map<ll,int> num;
vi v[MAX];

bool cmp(int x,int y)
{
	return a[x]>a[y];
}

void dfs(int x,int fa,int d)
{
	tot+=(ll)d;
	rept(i,0,v.size()) if (v[x][i]!=fa) dfs(v[x][i],x,d+1);
}

int main()
{
	cin>>n;
	rept(i,1,n+1)
	{
		cin>>a[i];
		num[a[i]]=i;
	}
	rept(i,1,n+1)
	{
		size[i]=1;
		id[i]=i;
	}
	rept(i,1,n)
	{
		int x=id[i];
		ll w=a[x]-(n-size[x])+size[x];
		if (!num[w] || w>=a[x])
		{
			puts("-1");
			return 0;
		}
		int y=num[w];
		ans1[i]=x;
		ans2[i]=y;
		v[x].pb(y);
		v[y].pb(x);
		size[y]+=size[x];
	}
	dfs(id[n],0,0);
	if (tot!=a[id[n]])
	{
		puts("-1");
		return 0;
	}
	rept(i,1,n+1) cout<<ans1[i]<<" "<<ans[2]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:45:20: error: request for member 'size' in 'v', which is of non-class type 'vi [100005]' {aka 'std::vector<int> [100005]'}
   45 |         rept(i,0,v.size()) if (v[x][i]!=fa) dfs(v[x][i],x,d+1);
      |                    ^~~~
a.cc:19:48: note: in definition of macro 'rept'
   19 | #define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
      |                                                ^
a.cc: In function 'int main()':
a.cc:58:17: error: reference to 'size' is ambiguous
   58 |                 size[i]=1;
      |                 ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:12:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:32:7: note:                 'int size [100005]'
   32 | int n,size[MAX],id[MAX],ans1[MAX],ans2[MAX];
      |       ^~~~
a.cc:64:30: error: reference to 'size' is ambiguous
   64 |                 ll w=a[x]-(n-size[x])+size[x];
      |                              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:32:7: note:                 'int size [100005]'
   32 | int n,size[MAX],id[MAX],ans1[MAX],ans2[MAX];
      |       ^~~~
a.cc:64:39: error: reference to 'size' is ambiguous
   64 |                 ll w=a[x]-(n-size[x])+size[x];
      |                                       ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:32:7: note:                 'int size [100005]'
   32 | int n,size[MAX],id[MAX],ans1[MAX],ans2[MAX];
      |       ^~~~
a.cc:75:17: error: reference to 'size' is ambiguous
   75 |                 size[y]+=size[x];
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:32:7: note:                 'int size [100005]'
   32 | int n,size[MAX],id[MAX],ans1[MAX],ans2[MAX];
      |       ^~~~
a.cc:75:26: error: reference to 'size' is ambiguous
   75 |                 size[y]+=size[x];
      |                          ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:32:7: note:                 'int size [100005]'
   32 | int n,size[MAX],id[MAX],ans1[MAX],ans2[MAX];
      |       ^~~~
a.cc:83:43: error: 'ans' was not declared in this scope; did you mean 'ans2'?
   83 |         rept(i,1,n+1) cout<<ans1[i]<<" "<<ans[2]<<endl;
      |                                           ^~~
      |                                           ans2