Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define F first
#define S second
typedef pair<double, double> P;
int N, wh;
double kh;
P prev, next, next2, xr[100000];
double nx, ny;
P cross(int le, int ri)
{
	double xx = (xr[le].S + xr[ri].S) / 2 + (xr[ri].F * xr[ri].F - xr[le].F * xr[le].F) / (2 * (xr[le].S - xr[ri].S));
	double yy = sqrt(xr[le].F * xr[le].F - (xx - xr[le].S) * (xx - xr[le].S));
	return MP(xx, yy);
}
int main()
{
	cin >> N;
	for(int i = 0; i < N; i++)
	{
		cin >> xr[i].S >> xr[i].F;
	}
	sort(xr, xr + N);
	prev = MP(xr[0].S, xr[0].F); // (x, r)
	for(int i = 1; i < N; i++)
	{
		next = next2 = MP(INT_MAX, INT_MAX);
		if(prev.F < xr[i].S)
			next = cross(i, left);
		if(prev.F > xr[i].S)
			next2 = cross(i, right);
		if(next.S < prev.S && next.F > prev.F)
		{
			prev = next;
		}
		if(next2.S < prev.S &&  next2.F < prev.F)
		{
			prev = next;
		}
	}
	printf("%.10f\n", prev.S);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: reference to 'prev' is ambiguous
   25 |         prev = MP(xr[0].S, xr[0].F); // (x, r)
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~
a.cc:28:17: error: reference to 'next' is ambiguous
   28 |                 next = next2 = MP(INT_MAX, INT_MAX);
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:9: note:                 'P next'
    9 | P prev, next, next2, xr[100000];
      |         ^~~~
a.cc:29:20: error: reference to 'prev' is ambiguous
   29 |                 if(prev.F < xr[i].S)
      |                    ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~
a.cc:30:25: error: reference to 'next' is ambiguous
   30 |                         next = cross(i, left);
      |                         ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:9: note:                 'P next'
    9 | P prev, next, next2, xr[100000];
      |         ^~~~
a.cc:30:41: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   30 |                         next = cross(i, left);
      |                                         ^~~~
      |                                         |
      |                                         std::ios_base& (*)(std::ios_base&)
a.cc:11:21: note:   initializing argument 2 of 'P cross(int, int)'
   11 | P cross(int le, int ri)
      |                 ~~~~^~
a.cc:31:20: error: reference to 'prev' is ambiguous
   31 |                 if(prev.F > xr[i].S)
      |                    ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~
a.cc:32:42: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   32 |                         next2 = cross(i, right);
      |                                          ^~~~~
      |                                          |
      |                                          std::ios_base& (*)(std::ios_base&)
a.cc:11:21: note:   initializing argument 2 of 'P cross(int, int)'
   11 | P cross(int le, int ri)
      |                 ~~~~^~
a.cc:33:20: error: reference to 'next' is ambiguous
   33 |                 if(next.S < prev.S && next.F > prev.F)
      |                    ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:9: note:                 'P next'
    9 | P prev, next, next2, xr[100000];
      |         ^~~~
a.cc:33:29: error: reference to 'prev' is ambiguous
   33 |                 if(next.S < prev.S && next.F > prev.F)
      |                             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~
a.cc:33:39: error: reference to 'next' is ambiguous
   33 |                 if(next.S < prev.S && next.F > prev.F)
      |                                       ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:9: note:                 'P next'
    9 | P prev, next, next2, xr[100000];
      |         ^~~~
a.cc:33:48: error: reference to 'prev' is ambiguous
   33 |                 if(next.S < prev.S && next.F > prev.F)
      |                                                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~
a.cc:35:25: error: reference to 'prev' is ambiguous
   35 |                         prev = next;
      |                         ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~
a.cc:35:32: error: reference to 'next' is ambiguous
   35 |                         prev = next;
      |                                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:9: note:                 'P next'
    9 | P prev, next, next2, xr[100000];
      |         ^~~~
a.cc:37:30: error: reference to 'prev' is ambiguous
   37 |                 if(next2.S < prev.S &&  next2.F < prev.F)
      |                              ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~
a.cc:37:51: error: reference to 'prev' is ambiguous
   37 |                 if(next2.S < prev.S &&  next2.F < prev.F)
      |                                                   ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~
a.cc:39:25: error: reference to 'prev' is ambiguous
   39 |                         prev = next;
      |                         ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~
a.cc:39:32: error: reference to 'next' is ambiguous
   39 |                         prev = next;
      |                                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:9: note:                 'P next'
    9 | P prev, next, next2, xr[100000];
      |         ^~~~
a.cc:42:27: error: reference to 'prev' is ambiguous
   42 |         printf("%.10f\n", prev.S);
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:9:3: note:                 'P prev'
    9 | P prev, next, next2, xr[100000];
      |   ^~~~