Language: C++

#include <iostream>
#include <cstdio>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
short maps[5001][5001];
int main() {
	short N,M,x,y,size;
	cin >> N >> M;
	REP(i,M){
		scanf("%d%d%d",&x,&y,&size);
		maps[x][y]=max(size+1,maps[x][y]);
	}
	short sum=0;
	REP(i,N+1)
		REP(j,i+1){
			maps[i+1][j+1]=max(maps[i+1][j+1],maps[i][j]-1);
			maps[i+1][j]=max(maps[i+1][j],maps[i][j]-1);
			if(maps[i][j])
				sum++;
		}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:31: error: no matching function for call to 'max(int, short int&)'
   12 |                 maps[x][y]=max(size+1,maps[x][y]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~
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:12:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
   12 |                 maps[x][y]=max(size+1,maps[x][y]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~
/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
a.cc:17:43: error: no matching function for call to 'max(short int&, int)'
   17 |                         maps[i+1][j+1]=max(maps[i+1][j+1],maps[i][j]-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:17:43: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   17 |                         maps[i+1][j+1]=max(maps[i+1][j+1],maps[i][j]-1);
      |                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
a.cc:18:41: error: no matching function for call to 'max(short int&, int)'
   18 |                         maps[i+1][j]=max(maps[i+1][j],maps[i][j]-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:18:41: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   18 |                         maps[i+1][j]=max(maps[i+1][j],maps[i][j]-1);
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/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