criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=1e5+5;
ll sz[mxn],dis[mxn];
vi adj[mxn];
bool vis[mxn];

void dfs(int u, int p=-1){
	for(int v:adj[u])
		if(v!=p)dis[v]=dis[u]+1,dfs(v,u);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n;
	cin >> n;
	pair<ll,int> dist[n];
	map<ll,int>mp;
	for(int i=0; i<n; i++){
		cin >> dist[i].fi;
		dist[i].se=i;
		sz[i]=1LL;
		mp[dist[i].fi]=i;
	}
	map<ii,bool>edge;
	sort(dist,dist+n);
	for(int i=n-1; i>0; i--){
		int ind = dist[i].se;
		ll next = dist[i].fi-n+2*sz[ind];
		if(mp.find(next)==mp.end()){
			cout << -1 << endl;
			return 0;
		}
		int ptr = mp[next];
		if(ptr==ind){
			cout << -1 << endl;
			return 0;
		}
		sz[ptr] += sz[ind];
		if(ptr>ind)swap(ind,ptr);
		edge[ii(ptr,ind)]=1;
		adj[ind].eb(ptr);
		adj[ptr].eb(ind);
		vis[ind]=1; vis[ptr]=1;
	}
	bool ok=0;
	for(int i=0; i<n&&!ok; i++)
		if(sz[i]==n)ok=1;
	for(int i=0; i<n; i++)
		if(!vis[i])ok=0;
	dfs(dist[0].se);a
	int sum = 0;
	for(int i=0; i<n; i++)sum+=dis[i];
	if(sum!=dist[0].fi)ok=0;
	if(!ok)cout << -1 << endl;
	else{
		for(auto x:edge)
			cout << x.fi.fi+1 << ' ' << x.fi.se+1 << endl;
	}
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Compiler output:
a.cc: In function 'int main()':
a.cc:70:25: error: 'a' was not declared in this scope
   70 |         dfs(dist[0].se);a
      |                         ^
a.cc:72:31: error: 'sum' was not declared in this scope
   72 |         for(int i=0; i<n; i++)sum+=dis[i];
      |                               ^~~
a.cc:73:12: error: 'sum' was not declared in this scope
   73 |         if(sum!=dist[0].fi)ok=0;
      |            ^~~
Language: C++

けんちょんさんの記事を読んだ
ゴールを決めると途中で止まれないので順次確定していくのがポイント

Compiler output:
a.cc:1:1: error: '\U00003051\U00003093\U00003061\U00003087\U00003093\U00003055\U00003093\U0000306e\U00008a18\U00004e8b\U00003092\U00008aad\U00003093\U00003060' does not name a type
    1 | けんちょんさんの記事を読んだ
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#dfeine int long long
#define reg register
#define maxn 200001
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
using namespace std;
map<int, int> mp;
int D[maxn],a[maxn], b[maxn], cnt, n, sum[maxn];
signed main()
{
	n = read();
	for(int i = 1; i <= n; i++) D[i] = read(), mp[D[i]] = i;
	sort(D + 1, D + n + 1);
	for(int i = n; i > 1; i--){
		sum[mp[D[i]]]++;
		int x = D[i] - abs(n - sum[mp[D[i]]] * 2);
		if(!mp[x] || x == D[i]) {printf("-1\n"); return 0;}
		a[++cnt] = mp[D[i]], b[cnt] = mp[x]; sum[mp[x]] += sum[mp[D[i]]];
	}
	for(int i = 1; i < n; i++)
	printf("%lld %lld\n", a[i], b[i]);
	return 0;
}


Compiler output:
a.cc:2:2: error: invalid preprocessing directive #dfeine; did you mean #define?
    2 | #dfeine int long long
      |  ^~~~~~
      |  define
a.cc: In function 'int read()':
a.cc:6:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    6 |     reg int s = 0, t = 0; reg char ch = getchar();
      |             ^
a.cc:6:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    6 |     reg int s = 0, t = 0; reg char ch = getchar();
      |                    ^
a.cc:6:36: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    6 |     reg int s = 0, t = 0; reg char ch = getchar();
      |                                    ^~
Language: C++

#include <bits/stdc++.h>
#define EB emplace_back

typedef long long ll;
typedef std::pair <int, int> pr;
const int N = 100054;

int n;
int o[N], size[N];
int p[N], fc[N], nc[N];
ll D[N];
std::vector <pr> edges;

inline bool Dcmp(const int x, const int y) {return D[x] > D[y];}

inline bool find(ll x, int &ret) {return *D = x, ret = std::lower_bound(o, o + n, 0, Dcmp) - o, D[o[ret]] == x;|

inline void link(int x, int px) {p[x] = px, nc[x] = fc[px], fc[px] = x, size[px] += size[x];}

void dfs(int x, int d) {*D += d; for (int y = fc[x]; y; y = nc[y]) dfs(y, d + 1);}

int main() {
	int i, j, u;
	scanf("%d", &n), std::iota(o, o + n, 1);
	for (i = 1; i <= n; ++i) scanf("%lld", D + i);
	std::sort(o, o + n, Dcmp), std::fill(size + 1, size + (n + 1), 1);
	for (i = 0; i < n - 1; link(u, o[j]), ++i)
		if (u = o[i], !find(D[u] + 2 * size[u] - n, j) || j <= i) return puts("-1"), 0;
	if (dfs(o[i], *D = 0), *D != D[o[i]]) return puts("-1"), 0;
	for (i = 1; i <= n; ++i) if (p[i]) edges.EB(std::minmax(i, p[i]));
	std::sort(edges.begin(), edges.end());
	for (const pr &e : edges) printf("%d %d\n", e.first, e.second);
	return 0;
}

Compiler output:
a.cc: In function 'bool find(ll, int&)':
a.cc:16:112: error: expected primary-expression before '|' token
   16 | inline bool find(ll x, int &ret) {return *D = x, ret = std::lower_bound(o, o + n, 0, Dcmp) - o, D[o[ret]] == x;|
      |                                                                                                                ^
a.cc:18:1: error: expected primary-expression before 'inline'
   18 | inline void link(int x, int px) {p[x] = px, nc[x] = fc[px], fc[px] = x, size[px] += size[x];}
      | ^~~~~~
a.cc:20:24: error: a function-definition is not allowed here before '{' token
   20 | void dfs(int x, int d) {*D += d; for (int y = fc[x]; y; y = nc[y]) dfs(y, d + 1);}
      |                        ^
a.cc:22:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   22 | int main() {
      |         ^~
a.cc:22:9: note: remove parentheses to default-initialize a variable
   22 | int main() {
      |         ^~
      |         --
a.cc:22:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:22:12: error: a function-definition is not allowed here before '{' token
   22 | int main() {
      |            ^
a.cc:34:2: error: expected '}' at end of input
   34 | }
      |  ^
a.cc:16:34: note: to match this '{'
   16 | inline bool find(ll x, int &ret) {return *D = x, ret = std::lower_bound(o, o + n, 0, Dcmp) - o, D[o[ret]] == x;|
      |                                  ^
Language: C++

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+10;
int n, sz[N];
struct _ {
	ll d;
	int id;
	bool operator < (const _ &rhs) const {
		return d<rhs.d;
	}
} a[N];
vector<pii> ans;
vector<int> g[N];

void add(int u, int v) {
	ans.pb(pii(u,v));
	g[u].pb(v),g[v].pb(u);
}

void dfs(int x, int f, int d) {
	a[1].d -= d;
	for (int y:g[x]) if (y!=f) dfs(y,x,d+1);
}

int main() {
	scanf("%d", &n);
	REP(i,1,n) { 
		scanf("%lld",&a[i].d);
		a[i].id = i, sz[i] = 1;
	}
	sort(a+1,a+1+n);
	PER(i,2,n) {
		_ u{a[i].d+2*sz[a[i].id]-n,0};
		auto p = lower_bound(a+1,a+1+n,u);
		if (p->d!=u.d) return puts("-1"),0;
		add(a[i].id,p->id), sz[p->id] += sz[a[i].id];
	}
	dfs(1,0,0);
	if (a[1].d||sz[a[i].id]!=n) return puts("1"),0;
	for (auto &t:ans) printf("%d %d\n",t.x,t.y);
}








Compiler output:
a.cc: In function 'int main()':
a.cc:76:26: error: 'i' was not declared in this scope
   76 |         if (a[1].d||sz[a[i].id]!=n) return puts("1"),0;
      |                          ^
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()
	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];
	}
	for (int i=0;i<n-1;i++)printf("%d %d\n",w[i].first,w[i].second);
}

Compiler output:
a.cc:18:9: error: expected initializer before 'cin'
   18 |         cin>>n;
      |         ^~~
a.cc:19:9: error: expected unqualified-id before 'for'
   19 |         for (int i=1;i<=n;i++)scanf("%lld",&d[i]),r[i]=i,p[d[i]].push_back(i),cnt[i]=1;
      |         ^~~
a.cc:19:22: error: 'i' does not name a type
   19 |         for (int i=1;i<=n;i++)scanf("%lld",&d[i]),r[i]=i,p[d[i]].push_back(i),cnt[i]=1;
      |                      ^
a.cc:19:27: error: 'i' does not name a type
   19 |         for (int i=1;i<=n;i++)scanf("%lld",&d[i]),r[i]=i,p[d[i]].push_back(i),cnt[i]=1;
      |                           ^
a.cc:20:13: error: expected constructor, destructor, or type conversion before '(' token
   20 |         sort(r+1,r+n+1,comp);
      |             ^
a.cc:21:9: error: expected unqualified-id before 'for'
   21 |         for (int i=1;i<n;i++){
      |         ^~~
a.cc:21:22: error: 'i' does not name a type
   21 |         for (int i=1;i<n;i++){
      |                      ^
a.cc:21:26: error: 'i' does not name a type
   21 |         for (int i=1;i<n;i++){
      |                          ^
a.cc:31:9: error: expected unqualified-id before 'for'
   31 |         for (int i=0;i<n-1;i++)printf("%d %d\n",w[i].first,w[i].second);
      |         ^~~
a.cc:31:22: error: 'i' does not name a type
   31 |         for (int i=0;i<n-1;i++)printf("%d %d\n",w[i].first,w[i].second);
      |                      ^
a.cc:31:28: error: 'i' does not name a type
   31 |         for (int i=0;i<n-1;i++)printf("%d %d\n",w[i].first,w[i].second);
      |                            ^
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
#define INF 0x3f3f3f3f3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    int n;
  cin >> n;
  vector<long long> d(n);
  vector<int> weight(n, 1);
  map<long long,int> mp;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    mp[d[i]] = i;
  }
  vector<pair<int,int> > res;
  for (int itt = 0; itt < n - 1; itt++) {
    auto it = mp.rbegin();
    int i = it->second;
    long long want = d[i] - (n - weight[i]) + weight[i];
    if (mp.find(want) == mp.end() || mp[want] == i) {
      cout << -1 << '\n';
      return 0;
    }
    int j = mp[want];
    res.emplace_back(i, j);
    weight[j] += weight[i];
    mp.erase(--mp.end());
  }
  vector<long long> real_dist(n, -1);
  real_dist[0] = 0;
  vector<vector<int> > g(n);
  for (auto &p : res) {
    g[p.first].push_back(p.second);
    g[p.second].push_back(p.first);
  }
  vector<int> que(1, 0);
  for (int b = 0; b < (int) que.size(); b++) {
    for (int j : g[que[b]]) {
      if (real_dist[j] == -1) {
        que.push_back(j);
        real_dist[j] = real_dist[que[b]] + 1;
      }
    }
  }
  if (accumulate(real_dist.begin(), real_dist.end(), 0LL) != d[0]) {
    cout << -1 << '\n';
    return 0;
  }
  for (auto &p : res) {
    cout << p.first + 1 << " " << p.second + 1 << '\n';
  }
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:7: error: 'accumulate' was not declared in this scope
   63 |   if (accumulate(real_dist.begin(), real_dist.end(), 0LL) != d[0]) {
      |       ^~~~~~~~~~
Language: C++

//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
#define INF 0x3f3f3f3f3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    int n;
  cin >> n;
  vector<long long> d(n);
  vector<int> weight(n, 1);
  map<long long,int> mp;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    mp[d[i]] = i;
  }
  vector<pair<int,int>> res;
  for (int itt = 0; itt < n - 1; itt++) {
    auto it = mp.rbegin();
    int i = it->second;
    long long want = d[i] - (n - weight[i]) + weight[i];
    if (mp.find(want) == mp.end() || mp[want] == i) {
      cout << -1 << '\n';
      return 0;
    }
    int j = mp[want];
    res.emplace_back(i, j);
    weight[j] += weight[i];
    mp.erase(--mp.end());
  }
  vector<long long> real_dist(n, -1);
  real_dist[0] = 0;
  vector<vector<int>> g(n);
  for (auto &p : res) {
    g[p.first].push_back(p.second);
    g[p.second].push_back(p.first);
  }
  vector<int> que(1, 0);
  for (int b = 0; b < (int) que.size(); b++) {
    for (int j : g[que[b]]) {
      if (real_dist[j] == -1) {
        que.push_back(j);
        real_dist[j] = real_dist[que[b]] + 1;
      }
    }
  }
  if (accumulate(real_dist.begin(), real_dist.end(), 0LL) != d[0]) {
    cout << -1 << '\n';
    return 0;
  }
  for (auto &p : res) {
    cout << p.first + 1 << " " << p.second + 1 << '\n';
  }
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:7: error: 'accumulate' was not declared in this scope
   63 |   if (accumulate(real_dist.begin(), real_dist.end(), 0LL) != d[0]) {
      |       ^~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
#include <bitset>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:6
*Problem:Distance Sums
*Date:2019-7-12
*Algorithm:Orange Boy's Greedy and Sorting
*Stats:Unknown*/

bool debug=false;


template<typename T1,typename T2> ostream& operator<<(ostream& o,pair<T1,T2> p){
	o<<"{";
	o<<p.first<<","<<p.second;
	o<<"}";
	return o;
}

ll n;
ll d[100005];
map <ll,ll> m;
pair<ll,ll> p[100005];
ll sub[100005];
ll sz[100005];
vector <pair<ll,ll> >res;
 
int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>d[i];
		if(d[i]>n*(n-1)/2){
			cout<<-1;
			return 0;
		}
		m[d[i]]=i;
		p[i].first=d[i];
		p[i].second=i;
		sz[i]=1;
	}
	sort(p,p+n);
	reverse(p,p+n);
	memset(sub,-1,sizeof(sub));
	for(ll i=0;i<n-1;i++)
	{
		ll de=p[i].first;
		ll x=p[i].second;
		sub[x]=n-sz[x]*2;
		if(sub[x]==0){
			cout<<-1;
			return 0;	
		}
		if(m.find(de-sub[x])==m.end()){
			cout<<-1;
			return 0;
		}
		ll par=m[de-sub[x]];
		sz[par]+=sz[x];
		res.push_back(mp(x,par));
	}
	
	
	for(ll i=0;i<n-1;i++)
	{
		cout<<res[i].first+1<<" "<<res[i].second+1<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:89:31: error: 'mp' was not declared in this scope; did you mean 'p'?
   89 |                 res.push_back(mp(x,par));
      |                               ^~
      |                               p
Language: C++

#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << -1 << endl;
  exit(0);
}
void dfs (int crr, int dpt, vector<vector<int>>& grh, long long& cnt) {
  cnt += dpt;
  for (int nxt : grh[crr]) {
    dfs(nxt, dpt + 1, grh, cnt);
  }
}
int main() {
  int n;
  cin >> n;
  vector<pair<long long, int>> di(n);
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    di[i] = {d, i};
  }
  sort(di.begin(), di.end());
  vector<int> sz(n, 1), prt(n);
  vector<vector<int>> grh(n);
  vector<pair<int, int>> edg;
  for (auto it = prev(di.end()); it != di.begin(); it--) {
    auto d = it->first;
    auto i = it->second;
    lont long prtv = d - n + 2 * sz[i];
    auto jt = lower_bound(di.begin(), di.end(), make_pair(prtv, 0));
    if (jt->first != prtv) err();
    auto p = jt->second;
    prt[i] = p;
    grh[p].push_back(i);
    if (i == prt[i]) err();
    sz[prt[i]] += sz[i];
    edg.emplace_back(min(i, prt[i]), max(i, prt[i]));
  }
  long long cnt = 0;
  int rt = di[0].second;
  dfs(rt, 0, grh, cnt);
  if (di[0].first != cnt) err();
  sort(edg.begin(), edg.end());
  for (auto const & e : edg) {
    cout << e.first + 1 << ' ' << e.second + 1 << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'lont' was not declared in this scope; did you mean 'long'?
   29 |     lont long prtv = d - n + 2 * sz[i];
      |     ^~~~
      |     long
a.cc:30:59: error: 'prtv' was not declared in this scope; did you mean 'prt'?
   30 |     auto jt = lower_bound(di.begin(), di.end(), make_pair(prtv, 0));
      |                                                           ^~~~
      |                                                           prt
Language: C++

#include <cstdio>
#include <algorithm>
#include <map>
#define fail return puts("-1"), 0


/*
(u, v)

d(v) sz(v)

d(u) = d(v) + 2 * sz(v) - n

 */

const int N = 1e5 + 5, M = 2e5 + 5;

int n, tot, lnk[N], ter[M], nxt[M], sz[N], fa[N];
long long dep[N], d[N], D[N];
std::map<long long, int> mp;

void add(int u, int v) {
	ter[++tot] = v, nxt[tot] = lnk[u], lnk[u] = tot;
}
void dfs1(int u, int p) {
	sz[u] = 1;
	for (int i = lnk[u]; i; i = nxt[i]) {
		int v = ter[i];
		if (v == p) continue;
		dep[v] = dep[u] + 1;
		dfs1(v, u);
		sz[u] += sz[v];
	}
}
void dfs2(int u, int p) {
	for (int i = lnk[u]; i; i = nxt[i]) {
		int v = ter[i];
		if (v == p) continue;
		D[v] = D[u] - 2 * sz[v] + n;
		dfs2(v, u);
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &d[i]);
		mp[d[i]] = i;
		sz[i] = 1;
	}
	int cnt = 0;
	for (auto it = mp.rbegin(); it != mp.rend(); it++) {
		int v = it->second;
		long long now = it->first;
		long long s = now + 2 * sz[v] - n;
		if (!mp.count(s)) fail;
		int u = mp[s];
		if (u == v) fail;
		fa[v] = u, sz[u] += sz[v];
		add(u, v), add(v, u);
		if (++cnt == n - 1) break;
	}
	dfs1(1, 0);
	D[1] = std::accumulate(dep + 1, dep + n + 1, 0LL);
	dfs2(1, 0);
	for (int i = 1; i <= n; i++) {
		if (D[i] != d[i]) fail;
	}
	for (int i = 1; i <= n; i++) {
		if (fa[i]) printf("%d %d\n", i, fa[i]);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:21: error: 'accumulate' is not a member of 'std'
   63 |         D[1] = std::accumulate(dep + 1, dep + n + 1, 0LL);
      |                     ^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi sz(n, 1);
	vector<pair<ll, int>> v;
	rep(i, n){
		ll x; cin >> x;
		v.emplace_back(x, i);
	}
	sort(all(v));
	vector<pi> ans;
	
	//dbg(v);
	
	for(int i = n - 1; i > 0; i--){
		ll nx = v[i].first - n + 2 * sz[v[i].second];
		auto j = lower_bound(all(v), pair<ll, int>(nx, -1));
		
		//dbg(i, nx);
		
		if(j - v.begin() >= i || j->first != nx){
			cout << -1 << endl;
			return 0;
		}
		ans.emplace_back(j->second, v[i].second);
		sz[j->second] += sz[v[i].second];
	}
	assert(sz[v[i].second] == n);
	
	for(auto i : ans) cout << i.first+1 << " " << i.second+1 << endl;
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106,
                 from a.cc:1:
a.cc: In function 'int main()':
a.cc:43:21: error: 'i' was not declared in this scope
   43 |         assert(sz[v[i].second] == n);
      |                     ^
Language: C++

#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define N 100100
#define INF 1e9+7
ll MOD=1e9+7;

ll n;
struct node{
    ll d;int id;
};
node a[N];
ll s[N];
main(){
    n=lin();
    map<ll,int> m;
    rep(i,n){
        a[i]=node{lin(),i+1};
        m[a[i].d]=a[i].id;
    }
    sort(a,a+n,[](node a,node b){
        return a.d>b.d;
    });
    struct edge{
        int from,to;
        void print(){
            printf("%d %d\n",from,to);
        }
    };
    vector<edge> ans;
    rep(i,n-1){
        ll now=a[i].d;
        ll t=s[a[i].id];
        now-=n-(2+t*2);
        cout<<now<<" "<<a[i].id<<endl;
        if(!m[now]){
            cout<<-1;return 0;
        }
        s[m[now]]+=t+1;
        ans.pb(edge{a[i].id,m[now]});
    }
    else{
        for(auto e:ans){
            e.print();
        }
    }
    return 0;
}   


Compiler output:
a.cc:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:84:5: error: 'else' without a previous 'if'
   84 |     else{
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;
typedef pair<long long, int> pii;
pii ar[MAXn];
long long n, sz[MAXn], root, disroot, d[MAXn], hp3[MAXn];
vector<int> vec[MAXn];
vector<pii> ans;

bool cmp(pii p1, pii p2) {
	return p1.first > p2.first;
}

//long long dfs1(int v, int  par) {
//	long long res = 0;
//	for (int i = 0; i < vec[v].size(); i++)
//		if (vec[v][i] != par) {
//			res += dfs1(vec[v][i], v) + hp3[vec[v][i]];
//			hp3[v] += hp3[vec[v][i]];
//		}
//	hp3[v]++;
//
//	return res;
//	
//}
//
//void dfs2(int v, int par, long long sth) {
//	if (sth != d[v]) {
//		cout << -1;
//		exit(0);
//	}
//	for (int i = 0; i < vec[v].size(); i++) {
//		if (vec[v][i] != par) {
//			dfs2(vec[v][i], v, sth - (hp3[vec[v][i]]) + (hp3[ar[0].second] - hp3[vec[v][i]]));
//			
//		}
//		
//	}
//	
//}
int main() {
	ios::sync_
	cin >> n;
	fill_n(sz, MAXn, 1);
	for (int i = 0; i < n; i++) {
		long long di;
		cin >> di;
		d[i] = di;
		ar[i].first = di;
		ar[i].second = i;
	}
	sort(ar, ar + n);
	for (int i = n - 1; i > 0; i--) {
		long long hp = ar[i].first - n;
		hp += 2LL * sz[ar[i].second];
		int hp2 = lower_bound(ar, ar + n, pii(hp, -1)) - ar;
		if (ar[hp2].first != hp)
			return cout << -1,0;
		sz[ar[hp2].second] += sz[ar[i].second];
		vec[ar[hp2].second].push_back(ar[i].second);
		vec[ar[i].second].push_back(ar[hp2].second);
		ans.push_back(pii(ar[i].second, ar[hp2].second));
	}
//	disroot = dfs1(ar[0].second, -1);
//	dfs2(ar[0].second, -1, disroot);
	if (ans.size() != n - 1)
		return cout << -1,0;
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i].first + 1<< ' ' << ans[i].second + 1<< endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:14: error: 'sync_' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
   42 |         ios::sync_
      |              ^~~~~
Language: C++

#include <bits/stdc++.h>
#include <tr1/unordered_map>

#define For(i, l, r) for (int i = l; i <= r; ++ i)
#define Travel(i, u) for (int i = beg[u], v = to[i]; i; v = to[i = nex[i]])

using namespace std;

typedef long long ll;

inline void File() {
	freopen("f.in", "r", stdin);
	freopen("f.out", "w", stdout);
}

const int N = 1e5 + 10;
int e = 1, beg[N], nex[N << 1], to[N << 1], n;
int ansu[N], ansv[N];
ll sz[N], tmp, dis[N];

struct node { ll v; int id; } P[N];
inline bool cmp(const node &a, const node &b) { return a.v > b.v; }

tr1::unordered_map<ll, int> mp;

inline void add(int x, int y) {
	to[++ e] = y, nex[e] = beg[x], beg[x] = e;
}

inline void dfs1(int u, int l, int rt) {
	dis[rt] += l;
	Travel(i, u) dfs1(v, l + 1, rt);
}

inline void dfs2(int u) {
	Travel(i, u) dis[v] = dis[u] - (sz[v] * 2 - n), dfs2(v);
}

int main() {

	scanf("%d", &n);
	For(i, 1, n) {
		scanf("%lld", &P[i].v); 
		P[i].id = i, mp[P[i].v] = i, sz[i] = 1;
	}

	sort(P + 1, P + 1 + n, cmp);

	for (int i = 1, u, v; i < n; ++ i) {
		u = P[i].id, tmp = P[i].v + 2 * sz[u] - n;
		
		if (n <= sz[u] << 1) return puts("-1"), 0;
		if (!mp.find(tmp)) return puts("-1"), 0;
		
		v = mp[tmp], ansu[i] = u, ansv[i] = v;
		add(v, u), sz[v] += sz[u];
	}	

	int rt = P[n].id; dfs1(rt, 0, rt), dfs2(rt);

	For(i, 1, n) if (dis[P[i].id] ^ P[i].v) return puts("-1"), 0;
	
	For(i, 1, n - 1) printf("%d %d\n", ansu[i], ansv[i]);

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:53:21: error: no match for 'operator!' (operand type is 'std::tr1::_Hashtable<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::_Select1st<std::pair<const long long int, int> >, std::equal_to<long long int>, std::tr1::hash<long long int>, std::tr1::__detail::_Mod_range_hashing, std::tr1::__detail::_Default_ranged_hash, std::tr1::__detail::_Prime_rehash_policy, false, false, true>::iterator')
   53 |                 if (!mp.find(tmp)) return puts("-1"), 0;
      |                     ^~~~~~~~~~~~~
a.cc:53:21: note: candidate: 'operator!(bool)' (built-in)
a.cc:53:21: note:   no known conversion for argument 1 from 'std::tr1::_Hashtable<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::_Select1st<std::pair<const long long int, int> >, std::equal_to<long long int>, std::tr1::hash<long long int>, std::tr1::__detail::_Mod_range_hashing, std::tr1::__detail::_Default_ranged_hash, std::tr1::__detail::_Prime_rehash_policy, false, false, true>::iterator' to 'bool'
Language: C++

#include <algorithm>
#include <cstdio>
#include <cstring>

#define int long long
#define Accepted 0; 

const int Maxv = 100010; 
int d[Maxv], d1[Maxv], u[Maxv], ghostfly233[Maxv], siz[Maxv], cnt, n;  

inline int GldHkkowoSearch(int x) {
     tmp = std::lower_bound(d + 1, d + n + 1, x) - d;

    if (d[tmp] != x) {
        puts("-1"); 
        exit(0); 
    }

    return tmp; 
}

signed main() {
    scanf("%lld", &n); 
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &d[i]); 
        d1[i] = d[i]; 
    }

    std::sort(d + 1, d + n + 1); 
    for (int i = 1; i <= n; i++) 
        ghostfly233[GldHkkowoSearch(d1[i])] = i;       

    for (int i = 1; i <= n; i++)
        siz[i] = 1; 

    for (int i = n; i > 1; i--) {
        u[i] = GldHkkowoSearch(d[i] - n + (siz[i] << 1)); 
        siz[ u[i] ] += siz[i]; 
        cnt += siz[i]; 
    }

    if (cnt != d[1]) {
        puts("-1"); 
        return 0; 
    }

    for (int i = 2; i <= n; i++)
        printf("%lld %lld\n", ghostfly233[i], ghostfly233[ u[i] ]); 

    return Accepted;  
}

Compiler output:
a.cc: In function 'long long int GldHkkowoSearch(long long int)':
a.cc:12:6: error: 'tmp' was not declared in this scope
   12 |      tmp = std::lower_bound(d + 1, d + n + 1, x) - d;
      |      ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using Int = long long;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> d(n);
  for(Int i=0;i<n;i++) cin>>d[i];
  map<Int, Int> r;
  for(Int i=0;i<n;i++) r[d[i]]=i;

  vector<vector<Int> > G(n);
  auto NO=[](){cout<<-1<<endl;exit(0);};
  auto add_edge=[&](Int x,Int y){
		  G[x].emplace_back(y);
		  G[y].emplace_back(x);
		};

  using P = pair<Int, Int>;
  priority_queue<P> pq;
  vector<Int> s(n,1),used(n,0);
  for(Int i=0;i<n;i++) pq.emplace(d[i],i);
  
  while(pq.size()>1u){
    Int x,v;
    tie(x,v)=pq.top();pq.pop();
    
    Int nd=x-(n-s[v])+s[v];
    if(!r.count(nd)) NO();
    
    Int u=r[nd];    
    if(used[u]) NO();
    
    add_edge(v,u);
    s[u]+=s[v];    
    used[v]=1;
  }

  vector<Int> sz(n,1);
  vector<Int> dp1(n,0),dp2(n,0);
  function<Int(Int, Int)> dfs1=
    [&](Int v,Int p){
      for(Int u:G[v]){
	if(u==p) continue;
	dp1[v]+=dfs1(u,v);
	dp1[v]+=sz[u];
	sz[v]+=sz[u];
      }
      return dp1[v];
    };
  
  if(d[i]!=dfs1(0,-1)) NO();
  
  for(Int v=0;v<n;v++)
    for(Int u:G[v]) if(v<u) cout<<v+1<<" "<<u+1<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:8: error: 'i' was not declared in this scope
   54 |   if(d[i]!=dfs1(0,-1)) NO();
      |        ^
Language: C++

  cin>>n;
  LL tmp;
  REP(i,n){
    cin>>tmp;
    d.push_back(tmp);
    init_d.push_back(tmp);
  }
  sort(d.begin(),d.end());
  ind.resize(n);
  REP(i,n){
    int min_ind = distance(d.begin(),lower_bound(d.begin(),d.end(),init_d[i]));
    ind[min_ind] = i+1;
  }
  REP(i,n){
    width.push_back(1);
  }

  vector<vector<int>> tree(n);
  REP(i,n-1){
    LL s = d[n-1-i] - (n - 2*width[n-1-i]);
    //cerr<<s<<endl;
    int min_ind2 = distance(d.begin(),lower_bound(d.begin(),d.end(),s));
    if(d[min_ind2] != s || s > d[n-1-i]){
      cout<<-1<<endl;
      return 0;
     }
    ans.push_back(make_pair(min_ind2,n-1-i));
    tree[min_ind2].push_back(n-1-i);
    //tree[n-1-i].push_back(min_ind2);
    width[min_ind2] += width[n-1-i];
  }
  if(d[0] != dfs(tree,0,0)){
    cout<<-1<<endl;
    return 0;
  }
  
  REP(i,ans.size())
    cout<<ind[ans[i].first]<<" "<<ind[ans[i].second]<<endl;
  return 0;
}


Compiler output:
a.cc:1:3: error: 'cin' does not name a type
    1 |   cin>>n;
      |   ^~~
a.cc:2:3: error: 'LL' does not name a type
    2 |   LL tmp;
      |   ^~
a.cc:3:6: error: expected constructor, destructor, or type conversion before '(' token
    3 |   REP(i,n){
      |      ^
a.cc:8:7: error: expected constructor, destructor, or type conversion before '(' token
    8 |   sort(d.begin(),d.end());
      |       ^
a.cc:9:3: error: 'ind' does not name a type; did you mean 'int'?
    9 |   ind.resize(n);
      |   ^~~
      |   int
a.cc:10:6: error: expected constructor, destructor, or type conversion before '(' token
   10 |   REP(i,n){
      |      ^
a.cc:14:6: error: expected constructor, destructor, or type conversion before '(' token
   14 |   REP(i,n){
      |      ^
a.cc:18:3: error: 'vector' does not name a type
   18 |   vector<vector<int>> tree(n);
      |   ^~~~~~
a.cc:19:6: error: expected constructor, destructor, or type conversion before '(' token
   19 |   REP(i,n-1){
      |      ^
a.cc:32:3: error: expected unqualified-id before 'if'
   32 |   if(d[0] != dfs(tree,0,0)){
      |   ^~
a.cc:37:6: error: expected constructor, destructor, or type conversion before '(' token
   37 |   REP(i,ans.size())
      |      ^
a.cc:39:3: error: expected unqualified-id before 'return'
   39 |   return 0;
      |   ^~~~~~
a.cc:40:1: error: expected declaration before '}' token
   40 | }
      | ^
Language: C

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, 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)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

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; // requiredD -> [(childId, stSz)]

    while (!D.empty())
    {
        lint Dnow, id_now;
        tie(Dnow, id_now) = D.back();
        D.pop_back();

        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));

    // dbg(dfs(D[0].second, -1));
    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:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

void NO(int where = 0) {
  dump(where);
  cout << -1 << endl;
  exit(0);
}

// 解けた〜たぴゃ〜
// D_iは相異なる，まじか〜

const int N = 1e5;
vector<vector<int>> g(N);
using Value = ll;
map<int, Value> dp[N];
map<int, int> sz[N];
int n;
Value dfs(int i, int p, int f = 0) {
  if(dp[i].count(p)) return dp[i][p];
  int cnt = 0;
  Value res = 0;
  if(f || p == -1) {
    // O(deg(i))
    // go only child
    sz[i][p] = 1;
    for(int j : g[i]) if(j != p) {
      cnt++;
      res += dfs(j, i, f);
      res += sz[j][i];
      sz[i][p] += sz[j][i];
    }
  } else {
    // O(1)
    dfs(i, -1, f);
    dfs(p, i, f);
    res = dp[i][-1] - (dp[p][i] + sz[p][i]);
    cnt = g[i].size() - 1;
    sz[i][p] = sz[i][-1] - sz[p][i];
  }
  return dp[i][p] = res;
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<ll> d(n);
  for(int i = 0; i < n; i++) cin >> d[i];
  vector<int> ord(n);
  iota((ord).begin(), (ord).end(), 0);
  sort((ord).begin(), (ord).end(), [&](int i, int j) { return d[i] < d[j]; });
  map<ll, int> mp;
  for(int i = 0; i < n; i++) mp[d[i]] = i;
  auto rnk = ord;
  for(int i = 0; i < n; i++) rnk[ord[i]] = i;
  vector<int> v(n);
  vector<pair<int,int>> ans;
  ll base = n - 2 * (n - 1);
  for(int i = n - 1; i >= 1; i--) {
    // dump(d[ord[i]], v[i], i);
    ll s = d[ord[i]] + (base + v[i] * 2);
    // dump(s);
    if(s >= d[ord[i]]) NO(1);
    if(!mp.count(s)) NO(2);
    v[rnk[mp[s]]] = v[i] + 1;
    int a = mp[s], b = ord[i];
    // dump(a, b);
    ans.emplace_back(a, b);
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  // dump("here");
  dfs(0, -1, 1);
  for(int i = 0; i < n; i++) if(d[i] != dfs(i, -1, 0)) NO();
  for(int i = 0; i < n - 1; i++) cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void NO(int)':
a.cc:6:3: error: 'dump' was not declared in this scope; did you mean 'dup'?
    6 |   dump(where);
      |   ^~~~
      |   dup
Language: C++

#include<iostream>
#include<stdint>
#include<algorithm>
using namespace std;

const int MAX = 100000;

typedef struct node {
	int id;
	int64_t num;
	int edge;
	int height;
	bool operator<(const node& r) const {
		return num < r.num;
	}
} Node;

int main() {
	int N;
	static Node node[MAX];
	cin >> N;
	for (int i = 0;i < N;++ i) {
		cin >> node[i].num;
		node[i].id = i + 1;
		node[i].height = 1;
	}
	sort(node, node + N);
	
	int64_t sum = 0; // 1からの距離
	for (int i = N - 1;i > 0;-- i) { // 大きい数字から確定させる
		int min = 0, max = i - 1;
		int64_t check = node[i].num - N + (node[i].height << 1);
		for (int mid = i >> 1;max - min > 1;mid = min + (max - min >> 1)) {
			if (node[mid].num > check) max = mid;
			else min = mid;
		}
		if (node[min].num != check) { // 繋げる辺が存在しなかった
			cout << -1;
			return 0;
		}
		node[i].edge = min;
		node[min].height += node[i].height;
		sum += node[i].height;
	}
	
	if (sum != node[0].num) {
		cout << -1;
		return 0;
	}
	for (int i = N - 1;i > 0;-- i) {
		cout << node[i].id << " " << node[node[i].edge].id << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

解説AC
数字の大きい方の頂点から確定させることを考える
この時、この頂点から繋ぐ辺は、自分の数-N+(現時点の自分の属する木の高さ*2)となることが数学的に証明できる(解説放送参照)
ということは二分探索していけばO(NlogN)で判定と構築ができるわけだ
最後に本当に正しいか確認だけして、問題ないなら構築完了
*/

Compiler output:
a.cc:2:9: fatal error: stdint: No such file or directory
    2 | #include<stdint>
      |         ^~~~~~~~
compilation terminated.
Language: C++

#include <stdio.h>
#include <utility>
#include <algorithm>
#include <map>

int t1,t2;

int n;
std::pair<long long,int> d[100005];
std::map<long long,int> m;
bool vis[100005];

std::vector<std::pair<int,int> > out;

long long base=0;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        scanf("%lld",&d[i].first);
        d[i].second=i+1;
        m[d[i].first]=i+1;
    }
    std::sort(d,d+n);
    int centroid=d[0].second;
    vis[0]=1;
    while (1) {
        long long hi=0;
        for (int i=0; i<n; i++) {
            if (vis[d[i].second]) continue;
            if (hi<d[i].first) hi=d[i].first;
        }
        if (hi==0) break;
        int dist=0;
        while (hi>d[0].first) {
            t1=m[hi];
            vis[t1]=1;
            dist++;
            hi-=n-2*dist;
            if (!m.count(hi)) {
                printf("-1\n");
                return 0;
            }
            t2=m[hi];
            vis[t2]=1;
            out.push_back({t1,t2});
        }
        if (hi<d[0].first) {
            printf("-1\n");
            return 0;
        }
        base+=(dist*(long long)(dist+1))/2;
    }
    if (base!=d[0].first) {
        printf("-1\n");
        return 0;
    }
    for (auto &p:out) printf("%d %d\n",p.first,p.second);
}


Compiler output:
a.cc:13:6: error: 'vector' in namespace 'std' does not name a template type
   13 | std::vector<std::pair<int,int> > out;
      |      ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include <map>
  +++ |+#include <vector>
    5 | 
a.cc: In function 'int main()':
a.cc:50:13: error: 'out' was not declared in this scope
   50 |             out.push_back({t1,t2});
      |             ^~~
a.cc:62:18: error: 'out' was not declared in this scope
   62 |     for (auto &p:out) printf("%d %d\n",p.first,p.second);
      |                  ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; (i) < (int) (n); (i) ++)
using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	vector<long long> d(n);
	long long miii = 1e15;
	int cent = -1;
	map<long long, int> mp;
	rep(i, n) {
		scanf("%lld", &d[i]);
		mp[d[i]] = i;
		if (miii > d[i]) {
			miii = d[i];
			cent = i;
		}
	}
	set<long long> st;
	rep(i, n) {
		if (miii != d[i]) {
			st.insert(d[i]);
		}
	}
	vector<pair<int, int>> ans;
	auto no = [](){ cout << -1 << endl; exit(0); };
	while (true) {
		if (ans.size() >= n - 1) braak;
		long long mi;
		for (auto it : st) {
			mi = it;
			break;
		}
		st.erase(mi);
		int id = mp[mi];
		ans.push_back({id, cent});
		long long dist = mi - miii;
		long long k = ((long long) n - dist) / 2;
		k --;
		dist += 2;
		long long cur = mi;
		long long prev;
		while (k --) {
			prev = cur;
			cur += dist;
			if (st.count(cur) == 0) {
				no();
			}
			st.erase(cur);
			int pid = mp[prev];
			int cid = mp[cur];
			ans.push_back({pid, cid});
			dist += 2;
		}
	}
	for (auto it : ans) printf("%d %d\n", it.first + 1, it.second + 1);
        return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:42: error: 'braak' was not declared in this scope; did you mean 'brk'?
   29 |                 if (ans.size() >= n - 1) braak;
      |                                          ^~~~~
      |                                          brk
Language: C++

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline ll read(){
	ll re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n;
struct node{
	ll num,dis;
}a[100010];
int siz[100010],fa[100010],d[100010],dep[100010];
vector<int>son[100010];
bool cmp(node l,node r){
	return l.dis<r.dis;
}
void dfs(int u,int f){
	int i;dep[u]=dep[f]+1;
//	cout<<u<<' '<<dep[u]<<"***\n";
	for(auto v:son[u]){
		if(v!=f) dfs(v,u);
	}
}
int main(){
	n=read();int i;
	for(i=1;i<=n;i++) a[i].dis=read(),a[i].num=i;
	sort(a+1,a+n+1,cmp);
	for(i=1;i<=n;i++) d[i]=a[i].dis;
	for(i=n;i>=2;i--){
		siz[a[i].num]++;
		ll tmp=d[i]-(n-2*siz[a[i].num]);
		int pos=lower_bound(d+1,d+i,tmp)-d;
//		cout<<i<<' '<<d[i]<<' '<<a[i].num<<' '<<siz[a[i].num]<<' '<<tmp<<' '<<pos<<' '<<a[pos].num<<' '<<d[pos]<<'\n';
		if(pos>=i||d[pos]!=tmp){
			puts("-1");return 0;
		}
		siz[a[pos].num]+=siz[a[i].num];fa[a[i].num]=a[pos].num;
	}
	std::ios::sync_with_stdio(false);
	for(i=1;i<=n;i++) if(fa[i]) son[fa[i]].push_back(i);
	dep[0]=-1;dfs(a[1].num,0);
	ll ans=0;
	for(i=1;i<=n;i++) ans+=dep[i];
	if(ans!=d[1]){
		puts("-1");return 0;
	}
	for(i=1;i<=n;i++) if(fa[i]) cout<<i<<' '<<fa[i]<<'\n';
} 

Compiler output:
a.cc:23:1: error: 'vector' does not name a type
   23 | vector<int>son[100010];
      | ^~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:30:20: error: 'son' was not declared in this scope; did you mean 'sin'?
   30 |         for(auto v:son[u]){
      |                    ^~~
      |                    sin
a.cc: In function 'int main()':
a.cc:50:37: error: 'son' was not declared in this scope; did you mean 'sin'?
   50 |         for(i=1;i<=n;i++) if(fa[i]) son[fa[i]].push_back(i);
      |                                     ^~~
      |                                     sin
Language: C++

#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int s_int(string s){
    return atoi(s.c_str());
}

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    cout << max({s_int(a + b) + s_int(c), s_int(a) + s_int(b + c),s_int(a)+s_int(b)+s_int(c)*10) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:96: error: expected '}' before ')' token
   31 |     cout << max({s_int(a + b) + s_int(c), s_int(a) + s_int(b + c),s_int(a)+s_int(b)+s_int(c)*10) << endl;
      |                 ~                                                                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  m = max({a,b,c});
  cout << (a+b+c) - m + (10 * m);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'm' was not declared in this scope
    7 |   m = max({a,b,c});
      |   ^
Language: C++

#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  int ans=max({a,b,c});
  
  cout<<ans*9+a+b+c;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:14: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
    7 |   int ans=max({a,b,c});
      |           ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided