Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<sstream>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
#include<set>
#include<functional>
#define in(x) x=read()
#define qr read()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=' ';
	ll f=1,x=0;
	while(!isdigit(ch)){ch=getchar();if(ch=='-')f*=-1;}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return f*x;
}
struct pizza
{
	ll x;
	ll v;
}e[100010];
bool cmp(pizza d1,pizza d2){return d1.x<d2.x;}
ll a[100010],b[100010],c[100010],d[100010],maxa[100010],maxb[100010],maxc[100010],maxd[100010];
int main()
{
	ll n=qr,C=qr;
	for(int i=1;i<=n;i++)in(e[i].x),in(e[i].v);
	sort(e+1,e+1+n,cmp);
	e[n+1].x=C;
	for(int i=1;i<=n;i++)a[i]=a[i-1]+e[i].v-2*(e[i].x-e[i-1].x),b[i]=b[i-1]+e[i].v-(e[i].x-e[i-1].x);
	for(int i=1;i<=n;i++)c[i]=c[i+1]+e[i].v-2*(e[i+1].x-e[i].x),d[i]=d[i+1]+e[i].v-(e[i+1].x-e[i].x);
	maxa[0]=maxb[0]=maxc[n+1]=maxd[n+1]=-C-1;
	for(int i=1;i<=n;i++)maxa[i]=max(maxa[i-1],a[i]),maxb[i]=max(maxb[i-1],b[i]);
	for(int i=n;i>=1;i--)maxc[i]=max(maxc[i+1],c[i]),maxd[i]=max(maxd[i+1],d[i]);
	ll ans=-C-1;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,maxb[i]),ans=max(ans,maxd[i]);
		ans=max(ans,maxa[i]+maxd[i+1]),ans=max(ans,maxb[i]+maxc[i+1]);
	}
	cout<<max(ans,0);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:18: error: no matching function for call to 'max(ll&, int)'
   55 |         cout<<max(ans,0);
      |               ~~~^~~~~~~
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:   template argument deduction/substitution failed:
a.cc:55:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   55 |         cout<<max(ans,0);
      |               ~~~^~~~~~~
/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,
                 from a.cc:8:
/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:55:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   55 |         cout<<max(ans,0);
      |               ~~~^~~~~~~