Language: C++

#include<cstdio>
#include<iostream>
#include<cstring>
#include<unordered_map>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll d[N];
unordered_map<ll,vector<int> > p;
ll cnt[N],sum[N],n,r[N];
vector<pair<int,int> > w;
bool comp(int a,int b){
	return d[a]>d[b];
}
int main(){
	freopen("a.in","r",stdin);
	cin>>n;
	for (int i=1;i<=n;i++)scanf("%lld",&d[i]),r[i]=i,p[d[i]].push_back(i),cnt[i]=1;
	sort(r+1,r+n+1,comp);
	for (int i=1;i<n;i++){
		ll x=r[i],s=d[x]-(n-2*cnt[x]),y;
		if (p[s].empty()||s>=d[x]){
			cout<<-1<<endl;
			return 0;
		}
		y=p[s].back();
		w.push_back(make_pair(x,y));
		cnt[y]+=cnt[x];
		sum[y]+=sum[x]+cnt[x];
	}
	if (sum[r[n]]!=d[r[n]]){
		cout<<-1<<endl;
		return 0;
	}
	for (int i=0;i<n-1;i++)printf("%d %d\n",w[i].first,w[i].second);
}#include<cstdio>
#include<iostream>
#include<cstring>
#include<unordered_map>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll d[N];
unordered_map<ll,vector<int> > p;
ll cnt[N],sum[N],n,r[N];
vector<pair<int,int> > w;
bool comp(int a,int b){
	return d[a]>d[b];
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)scanf("%lld",&d[i]),r[i]=i,p[d[i]].push_back(i),cnt[i]=1;
	sort(r+1,r+n+1,comp);
	for (int i=1;i<n;i++){
		ll x=r[i],s=d[x]-(n-2*cnt[x]),y;
		if (p[s].empty()||s>=d[x]){
			cout<<-1<<endl;
			return 0;
		}
		y=p[s].back();
		w.push_back(make_pair(x,y));
		cnt[y]+=cnt[x];
		sum[y]+=sum[x]+cnt[x];
	}
	if (sum[r[n]]!=d[r[n]]){
		cout<<-1<<endl;
		return 0;
	}
	for (int i=0;i<n-1;i++)printf("%d %d\n",w[i].first,w[i].second);
}

Compiler output:
a.cc:38:2: error: stray '#' in program
   38 | }#include<cstdio>
      |  ^
a.cc:38:3: error: 'include' does not name a type
   38 | }#include<cstdio>
      |   ^~~~~~~
a.cc:46:11: error: redefinition of 'const int N'
   46 | const int N=1e5+10;
      |           ^
a.cc:9:11: note: 'const int N' previously defined here
    9 | const int N=1e5+10;
      |           ^
a.cc:47:4: error: redefinition of 'll d [100010]'
   47 | ll d[N];
      |    ^
a.cc:10:4: note: 'll d [100010]' previously declared here
   10 | ll d[N];
      |    ^
a.cc:48:32: error: redefinition of 'std::unordered_map<long long int, std::vector<int> > p'
   48 | unordered_map<ll,vector<int> > p;
      |                                ^
a.cc:11:32: note: 'std::unordered_map<long long int, std::vector<int> > p' previously declared here
   11 | unordered_map<ll,vector<int> > p;
      |                                ^
a.cc:49:4: error: redefinition of 'll cnt [100010]'
   49 | ll cnt[N],sum[N],n,r[N];
      |    ^~~
a.cc:12:4: note: 'll cnt [100010]' previously declared here
   12 | ll cnt[N],sum[N],n,r[N];
      |    ^~~
a.cc:49:11: error: redefinition of 'll sum [100010]'
   49 | ll cnt[N],sum[N],n,r[N];
      |           ^~~
a.cc:12:11: note: 'll sum [100010]' previously declared here
   12 | ll cnt[N],sum[N],n,r[N];
      |           ^~~
a.cc:49:18: error: redefinition of 'll n'
   49 | ll cnt[N],sum[N],n,r[N];
      |                  ^
a.cc:12:18: note: 'll n' previously declared here
   12 | ll cnt[N],sum[N],n,r[N];
      |                  ^
a.cc:49:20: error: redefinition of 'll r [100010]'
   49 | ll cnt[N],sum[N],n,r[N];
      |                    ^
a.cc:12:20: note: 'll r [100010]' previously declared here
   12 | ll cnt[N],sum[N],n,r[N];
      |                    ^
a.cc:50:24: error: redefinition of 'std::vector<std::pair<int, int> > w'
   50 | vector<pair<int,int> > w;
      |                        ^
a.cc:13:24: note: 'std::vector<std::pair<int, int> > w' previously declared here
   13 | vector<pair<int,int> > w;
      |                        ^
a.cc:51:6: error: redefinition of 'bool comp(int, int)'
   51 | bool comp(int a,int b){
      |      ^~~~
a.cc:14:6: note: 'bool comp(int, int)' previously defined here
   14 | bool comp(int a,int b){
      |      ^~~~
a.cc:54:5: error: redefinition of 'int main()'
   54 | int main(){
      |     ^~~~
a.cc:17:5: note: 'int main()' previously defined here
   17 | int main(){
      |     ^~~~