Language: C++

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#define Maxn 1000008 
using namespace std;
typedef long long ll;

int n;
ll d;
int son[Maxn];
map <ll,int> M;

struct node{
	int num;
	ll val;
}N[Maxn];

bool cmp(node a,node b){	return a.val > b.val;}

int main()
{
	memset(son,0,sizeof(son));
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++)
	{
		scanf("%lld",&d);
		M[d] = i;
		N[i].num = i,N[i].val = d;
	}
	sort(N+1,N+1+n,cmp);
	map<ll,int>::iterator iter;;
	for(int i = 1;i < n;i ++)
	{
		int u = N[i].num;
		if(N[i].val - n + 2 + (son[u] << 1) <= 0) continue;
		iter = M.find(N[i].val - n + 2 + (son[u] << 1));
		if(iter >= M.end()) continue;
		int v = iter->second;
		son[v] += son[u]+1;
		printf("%d %d\n",u,v);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:25: error: no match for 'operator>=' (operand types are 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} and 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'})
   38 |                 if(iter >= M.end()) continue;
      |                    ~~~~ ^~ ~~~~~~~
      |                    |            |
      |                    |            _Rb_tree_iterator<[...]>
      |                    _Rb_tree_iterator<[...]>
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:1070:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1070 |     operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1070:5: note:   template argument deduction/substitution failed:
a.cc:38:34: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::pair<_T1, _T2>'
   38 |                 if(iter >= M.end()) continue;
      |                                  ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:476:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  476 |     operator>=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:476:5: note:   template argument deduction/substitution failed:
a.cc:38:34: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
   38 |                 if(iter >= M.end()) continue;
      |                                  ^
/usr/include/c++/14/bits/stl_iterator.h:520:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  520 |     operator>=(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:520:5: note:   template argument deduction/substitution failed:
a.cc:38:34: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
   38 |                 if(iter >= M.end()) continue;
      |                                  ^
/usr/include/c++/14/bits/stl_iterator.h:1724:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1724 |     operator>=(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1724:5: note:   template argument deduction/substitution failed:
a.cc:38:34: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
   38 |                 if(iter >= M.end()) continue;
      |                                  ^
/usr/include/c++/14/bits/stl_iterator.h:1781:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1781 |     operator>=(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1781:5: note:   template argument deduction/substitution failed:
a.cc:38:34: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
   38 |                 if(iter >= M.end()) continue;
      |                                  ^
In file included from /usr/include/c++/14/bits/stl_map.h:63,
                 from /usr/include/c++/14/map:63,
                 from a.cc:4:
/usr/include/c++/14/tuple:2631:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>=(const tuple<_Args1 ...>&, const tuple<_Elements ...>&)'
 2631 |     operator>=(const tuple<_TElements...>& __t,
      |     ^~~~~~~~
/usr/include/c++/14/tuple:2631:5: note:   template argument deduction/substitution failed:
a.cc:38:34: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::tuple<_Args1 ...>'
   38 |                 if(iter >= M.end()) continue;
      |                                  ^
/usr/include/c++/14/bits/stl_map.h:1578:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator>=(const map<_Key, _Tp, _Compare, _Allocator>&, const map<_Key, _Tp, _Compare, _Allocator>&)'
 1578 |     operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1578:5: note:   template argument deduction/substitution failed:
a.cc:38:34: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::map<_Key, _Tp, _Compare, _Allocator>'
   38 |                 if(iter >= M.end()) continue;
      |                                  ^
In file included from /usr/include/c++/14/map:64:
/usr/include/c++/14/bits/stl_multimap.h:1200:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>&, const multimap<_Key, _Tp, _Compare, _Allocator>&)'
 1200 |     operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_multimap.h:1200:5: note:   template argument deduction/substitution failed:
a.cc:38:34: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::multimap<_Key, _Tp, _Compare, _Allocator>'
   38 |                 if(iter >= M.end()) continue;
      |                                  ^