Language: C++

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	map<long long int, int> d_map;
	vector<pair<long long int, int> > d;
	for(int i = 1; i <= n; i++){
		long long int tmp;
		cin >> tmp;
		d.push_back(make_pair(tmp, i));
		d_map[tmp] = i;
	}
	sort(d.begin(), d.end());
	reverse(d.begin(), d.end());
	vector<bool> ischecked(n, false);
	set<pair<int, int> > ans;
	for(int i = 0; i < d.size(); i++){
		int now = d[i].second;
		long long int nowd = d[i].first;
		if(ischecked[now]) continue;
		ischecked[now] = true;
		// nowから1本でつながっている分をつなげていく
		int j = 1;
		for(j = 1; j < n; j++){
			long long int nextd = nowd - (n  - j) + j;
			if(nextd >= nowd || d_map.find(nextd) == d_map.end()){
				break;
			} else {
				long long int next = d_map[nextd];
				ans.insert(make_pair(min(now, next), max(now, next)));
				ischecked[next] = true;
				now = next;
				nowd = nextd;
			}
		}
		if(j == 1){
			cout << -1 << endl;
			return 0;
		}
	}
	for(auto i = ans.begin(); i != ans.end(); i++){
		cout << (*i).first << " " << (*i).second << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:57: error: no matching function for call to 'min(int&, long long int&)'
   54 |                                 ans.insert(make_pair(min(now, next), max(now, next)));
      |                                                      ~~~^~~~~~~~~~~
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:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:54:57: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   54 |                                 ans.insert(make_pair(min(now, next), max(now, next)));
      |                                                      ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:54:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   54 |                                 ans.insert(make_pair(min(now, next), max(now, next)));
      |                                                      ~~~^~~~~~~~~~~
a.cc:54:73: error: no matching function for call to 'max(int&, long long int&)'
   54 |                                 ans.insert(make_pair(min(now, next), max(now, next)));
      |                                                                      ~~~^~~~~~~~~~~
/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:   template argument deduction/substitution failed:
a.cc:54:73: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   54 |                                 ans.insert(make_pair(min(now, next), max(now, next)));
      |                                                                      ~~~^~~~~~~~~~~
/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, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:54:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   54 |                                 ans.insert(make_pair(min(now, next), max(now, next)));
      |                                                                      ~~~^~~~~~~~~~~