Language: C++

#include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int offset=30;
int xl[60];
int xr[60];

int main(void){
	int r,n;
	while(cin >> r >> n){
		if(n==0)
			break;
		rep(i,60) xl[i]=xr[i]=0;
		rep(i,n){
			int l,r,h;
			cin >> l >> r >> h;
			l+=offset,r+=offset;
			for(int j=l;j<=r;++j){
				if(j!=l)
					xl[j]=max(xl[j],h);
				if(j!=r)
					xr[j]=max(xr[j],h);
			}
		}
		double cmin=inf;
		for(int x=-r;x<=r;++x){
			int h=inf;
			if(x!=-r)h=min(h,xl[x+offset]);
			if(x!=r)h=min(h,xr[x+offset]);

			int diff=r*r-x*x;
			if(diff<0){

			}
			double y=sqrt(diff);
			double t=h-y+r;
			cmin=min(cmin,t);
		}
		cout.precision(9);
		cout << fixed << max(cmin,0) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:37: error: no matching function for call to 'max(double&, int)'
   68 |                 cout << fixed << max(cmin,0) << endl;
      |                                  ~~~^~~~~~~~
In file included 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_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:68:37: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
   68 |                 cout << fixed << max(cmin,0) << endl;
      |                                  ~~~^~~~~~~~
/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
In file included from /usr/include/c++/14/algorithm:61:
/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:68:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   68 |                 cout << fixed << max(cmin,0) << endl;
      |                                  ~~~^~~~~~~~