Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MN 100005
int T,n,id[MN];
ll a[MN];
map<ll,int>rea,cnt;
struct node{int x,y;};
vector<node>sc;
bool cmp(int x,int y){return a[x]>a[y];}
int main(){
//	freopen("test.in","r",stdin);
//	freopen("mysol.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),rea[a[i]]=i,cnt[a[i]]=1,id[i]=i;
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<n;i++){
		int t=id[i];ll tmp=a[t]-n+2*cnt[a[t]];
		if(rea[tmp]&&tmp<a[t]){
			cnt[tmp]+=cnt[a[t]];
			sc.push_back((node){t,rea[tmp]});
		}
		else return 0*puts("-1");
	}
	for(int i=0;i<sc.size();i++)printf("%d %d\n",sc[i].x,sc[i].y);
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MN 100005
int T,n,id[MN];
ll a[MN];
map<ll,int>rea,cnt;
struct node{int x,y;};
vector<node>sc;
bool cmp(int x,int y){return a[x]>a[y];}
int main(){
//	freopen("test.in","r",stdin);
//	freopen("mysol.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),rea[a[i]]=i,cnt[a[i]]=1,id[i]=i;
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<n;i++){
		int t=id[i];ll tmp=a[t]-n+2*cnt[a[t]];
		if(rea[tmp]&&tmp<a[t]){
			cnt[tmp]+=cnt[a[t]];
			sc.push_back((node){t,rea[tmp]});
		}
		else return 0*puts("-1");
	}
	for(int i=0;i<sc.size();i++)printf("%d %d\n",sc[i].x,sc[i].y);
}



Compiler output:
a.cc:32:5: error: redefinition of 'int T'
   32 | int T,n,id[MN];
      |     ^
a.cc:5:5: note: 'int T' previously declared here
    5 | int T,n,id[MN];
      |     ^
a.cc:32:7: error: redefinition of 'int n'
   32 | int T,n,id[MN];
      |       ^
a.cc:5:7: note: 'int n' previously declared here
    5 | int T,n,id[MN];
      |       ^
a.cc:32:9: error: redefinition of 'int id [100005]'
   32 | int T,n,id[MN];
      |         ^~
a.cc:5:9: note: 'int id [100005]' previously declared here
    5 | int T,n,id[MN];
      |         ^~
a.cc:33:4: error: redefinition of 'll a [100005]'
   33 | ll a[MN];
      |    ^
a.cc:6:4: note: 'll a [100005]' previously declared here
    6 | ll a[MN];
      |    ^
a.cc:34:12: error: redefinition of 'std::map<long long int, int> rea'
   34 | map<ll,int>rea,cnt;
      |            ^~~
a.cc:7:12: note: 'std::map<long long int, int> rea' previously declared here
    7 | map<ll,int>rea,cnt;
      |            ^~~
a.cc:34:16: error: redefinition of 'std::map<long long int, int> cnt'
   34 | map<ll,int>rea,cnt;
      |                ^~~
a.cc:7:16: note: 'std::map<long long int, int> cnt' previously declared here
    7 | map<ll,int>rea,cnt;
      |                ^~~
a.cc:35:8: error: redefinition of 'struct node'
   35 | struct node{int x,y;};
      |        ^~~~
a.cc:8:8: note: previous definition of 'struct node'
    8 | struct node{int x,y;};
      |        ^~~~
a.cc:36:13: error: redefinition of 'std::vector<node> sc'
   36 | vector<node>sc;
      |             ^~
a.cc:9:13: note: 'std::vector<node> sc' previously declared here
    9 | vector<node>sc;
      |             ^~
a.cc:37:6: error: redefinition of 'bool cmp(int, int)'
   37 | bool cmp(int x,int y){return a[x]>a[y];}
      |      ^~~
a.cc:10:6: note: 'bool cmp(int, int)' previously defined here
   10 | bool cmp(int x,int y){return a[x]>a[y];}
      |      ^~~
a.cc:38:5: error: redefinition of 'int main()'
   38 | int main(){
      |     ^~~~
a.cc:11:5: note: 'int main()' previously defined here
   11 | int main(){
      |     ^~~~