Language: C++

#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
 
using namespace std;
 
const ll INF = 1e9;
 
vector < pair <ll, ll> > v;
 
ll n, sz[1000000];
 
vector <ll> g[1000000];
 
int main () 
{
    cin >> n;
    
    for (ll i = 0; i < n; i++)
    {
	ll d;
	scanf ("%lld", &d);
	
	v.emplace_back (d, i);
    }
    
    sort (v.begin (), v.end ());
    
    for (ll i = n - 1; i; i--)
    {
	ll x = v[i].second, d = v[i].first;
	
	v.pop_back ();
	
	sz[x] = 1;
	
	for (ll to : g[x])
	    sz[x] += sz[to];
	
	ll k = upper_bound (v.begin (), v.end (), make_pair (d + 2 * sz[x] - n, -1)) - v.begin ();
	
	if (k == v.size () || v[k].first != d + 2 * sz[x] - n)
	{
	    cout << -1;
	    return 0;
	}
	
	g[v[k].second].push_back (x);
    }
    
    for (ll i = 0; i < n; i++)
	for (ll to : g[i])
	{
	    printf ("%lld %lld\n", i + 1, to + 1);
	}
}

Compiler output:
a.cc:11:7: error: 'll' does not name a type
   11 | const ll INF = 1e9;
      |       ^~
a.cc:13:16: error: 'll' was not declared in this scope
   13 | vector < pair <ll, ll> > v;
      |                ^~
a.cc:13:20: error: 'll' was not declared in this scope
   13 | vector < pair <ll, ll> > v;
      |                    ^~
a.cc:13:22: error: template argument 1 is invalid
   13 | vector < pair <ll, ll> > v;
      |                      ^
a.cc:13:22: error: template argument 2 is invalid
a.cc:13:24: error: template argument 1 is invalid
   13 | vector < pair <ll, ll> > v;
      |                        ^
a.cc:13:24: error: template argument 2 is invalid
a.cc:15:1: error: 'll' does not name a type
   15 | ll n, sz[1000000];
      | ^~
a.cc:17:9: error: 'll' was not declared in this scope
   17 | vector <ll> g[1000000];
      |         ^~
a.cc:17:11: error: template argument 1 is invalid
   17 | vector <ll> g[1000000];
      |           ^
a.cc:17:11: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:21:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   21 |     cin >> n;
      |            ^
      |            yn
a.cc:23:10: error: 'll' was not declared in this scope
   23 |     for (ll i = 0; i < n; i++)
      |          ^~
a.cc:23:20: error: 'i' was not declared in this scope
   23 |     for (ll i = 0; i < n; i++)
      |                    ^
a.cc:25:11: error: expected ';' before 'd'
   25 |         ll d;
      |           ^~
      |           ;
a.cc:26:25: error: 'd' was not declared in this scope
   26 |         scanf ("%lld", &d);
      |                         ^
a.cc:28:11: error: request for member 'emplace_back' in 'v', which is of non-class type 'int'
   28 |         v.emplace_back (d, i);
      |           ^~~~~~~~~~~~
a.cc:31:13: error: request for member 'begin' in 'v', which is of non-class type 'int'
   31 |     sort (v.begin (), v.end ());
      |             ^~~~~
a.cc:31:25: error: request for member 'end' in 'v', which is of non-class type 'int'
   31 |     sort (v.begin (), v.end ());
      |                         ^~~
a.cc:33:10: error: 'll' was not declared in this scope
   33 |     for (ll i = n - 1; i; i--)
      |          ^~
a.cc:33:24: error: 'i' was not declared in this scope
   33 |     for (ll i = n - 1; i; i--)
      |                        ^
a.cc:35:11: error: expected ';' before 'x'
   35 |         ll x = v[i].second, d = v[i].first;
      |           ^~
      |           ;
a.cc:37:11: error: request for member 'pop_back' in 'v', which is of non-class type 'int'
   37 |         v.pop_back ();
      |           ^~~~~~~~
a.cc:39:9: error: 'sz' was not declared in this scope
   39 |         sz[x] = 1;
      |         ^~
a.cc:39:12: error: 'x' was not declared in this scope
   39 |         sz[x] = 1;
      |            ^
a.cc:41:16: error: expected ';' before 'to'
   41 |         for (ll to : g[x])
      |                ^~~
      |                ;
a.cc:44:11: error: expected ';' before 'k'
   44 |         ll k = upper_bound (v.begin (), v.end (), make_pair (d + 2 * sz[x] - n, -1)) - v.begin ();
      |           ^~
      |           ;
a.cc:44:12: error: 'k' was not declared in this scope
   44 |         ll k = upper_bound (v.begin (), v.end (), make_pair (d + 2 * sz[x] - n, -1)) - v.begin ();
      |            ^
a.cc:44:31: error: request for member 'begin' in 'v', which is of non-class type 'int'
   44 |         ll k = upper_bound (v.begin (), v.end (), make_pair (d + 2 * sz[x] - n, -1)) - v.begin ();
      |                               ^~~~~
a.cc:44:43: error: request for member 'end' in 'v', which is of non-class type 'int'
   44 |         ll k = upper_bound (v.begin (), v.end (), make_pair (d + 2 * sz[x] - n, -1)) - v.begin ();
      |                                           ^~~
a.cc:44:62: error: 'd' was not declared in this scope
   44 |         ll k = upper_bound (v.begin (), v.end (), make_pair (d + 2 * sz[x] - n, -1)) - v.begin ();
      |                                                              ^
a.cc:44:90: error: request for member 'begin' in 'v', which is of non-class type 'int'
   44 |         ll k = upper_bound (v.begin (), v.end (), make_pair (d + 2 * sz[x] - n, -1)) - v.begin ();
      |                                                                                          ^~~~~
a.cc:44:98: error: expected ')' before ';' token
   44 |         ll k = upper_bound (v.begin (), v.end (), make_pair (d + 2 * sz[x] - n, -1)) - v.begin ();
      |                                                                                                  ^
      |                                                                                                  )
a.cc:41:13: note: to match this '('
   41 |         for (ll to : g[x])
      |             ^
a.cc:46:13: error: 'k' was not declared in this scope
   46 |         if (k == v.size () || v[k].first != d + 2 * sz[x] - n)
      |             ^
a.cc:46:20: error: request for member 'size' in 'v', which is of non-class type 'int'
   46 |         if (k == v.size () || v[k].first != d + 2 * sz[x] - n)
      |                    ^~~~
a.cc:46:45: error: 'd' was not declared in this scope
   46 |         if (k == v.size () || v[k].first != d + 2 * sz[x] - n)
      |                                             ^
a.cc:52:13: error: 'k' was not declared in this scope
   52 |         g[v[k].second].push_back (x);
      |             ^
a.cc:55:10: error: 'll' was not declared in this scope
   55 |     for (ll i = 0; i < n; i++)
      |          ^~
a.cc:55:20: error: 'i' was not declared in this scope
   55 |     for (ll i = 0; i < n; i++)
      |                    ^
a.cc:56:16: error: expected ';' before 'to'
   56 |         for (ll to : g[i])
      |                ^~~
      |                ;
a.cc:60:1: error: expected primary-expression before '}' token
   60 | }
      | ^
a.cc:59:10: error: expected ';' before '}' token
   59 |         }
      |          ^
      |          ;
   60 | }
      | ~         
a.cc:60:1: error: expected primary-expression before '}' token
   60 | }
      | ^
a.cc:59:10: error: expected ')' before '}' token
   59 |         }
      |          ^
      |          )
   60 | }
      | ~         
a.cc:56:13: note: to match this '('
   56 |         for (ll to : g[i])
      |             ^
a.cc:60:1: error: expected primary-expression before '}' token
   60 | }
      | ^