Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>

using namespace std;
int dp[105][105][105] = { 0 };
const int INF = 2000000005;
int main()
{
	int n, c;
	cin >> n >> c;
	int ls[105][2] = { 0 };
	for (int i = 1; i <= n; i++) {
		cin >> ls[i][0] >> ls[i][1];
	}
	
	for (int i = 1; i <= n; i++) {
		if (dp[0][i][0] < ls[i][1] - min(ls[i][0], c-ls[i][0])) {
			dp[0][i][0] = ls[i][1] - min(ls[i][0],c-ls[i][0]);

		}
		else dp[0][i][0] =0- min(ls[i][0], c-ls[i][0]);
		dp[0][i][i] = 1;
		/*for (int k = 0; k <= n; k++) cout << dp[0][i][k] << " ";
		cout << endl;*/
	}

	for (int i = 1; i <= n; i++) {
		for (int k = 1; k <= n; k++) {
				dp[i][k][0] = dp[i-1][k][0];
				for (int l = 1; l <= n; l++) {
					if(dp[i][k][l]<dp[i-1][k][l]) dp[i][k][l] = dp[i - 1][k][l];
				}
			}
		for (int j = 1; j <= n; j++) {
			
			for (int k = 1; k <= n; k++) {

				if (dp[i-1][j][k] == 0) {
					//cout << "Turn;"<<i<<" Now:" << j << " Turget:" << k << " "<<dp[i][k][0]<<" " << dp[i - 1][j][0] + ls[k][1] - (min(ls[k][0], ls[j][0]) - max(ls[k][0] - ls[j][0])+c, max(ls[k][0],ls[j][0])-min(ls[k][0]-ls[j][0]))) << endl;
					if (dp[i][k][0] < dp[i - 1][j][0] + ls[k][1] - (min(ls[k][0], ls[j][0]) - max(ls[k][0] - ls[j][0]) + c, max(ls[k][0], ls[j][0]) - min(ls[k][0] - ls[j][0])))) {
						//cout << "i:" << i << " k:" << k << endl;
						dp[i][k][0] = dp[i - 1][j][0] + ls[k][1] - (min(ls[k][0], ls[j][0]) - max(ls[k][0] - ls[j][0]) + c, max(ls[k][0], ls[j][0]) - min(ls[k][0] - ls[j][0])));
						for (int l = 1; l <= n; l++) {
							dp[i][k][l] = dp[i-1][j][l];
						}
						dp[i][k][k] = 1;
					}
					//cout << "Final:" << dp[i][k][0] << endl;
				}
				/*for (int p = 1; p <= n; p++) {
					for (int q = 0; q <= n; q++) {
						cout << dp[i][p][q] << endl;
					}
					cout << endl;
				}*/
			}
			
		}
		/*for (int j = 1; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				cout << dp[i][j][k] << " ";
			}
			cout << endl;
		}*/
	}
	/*for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << dp[i][j][0] << " ";

		}
		cout << endl;
	}*/
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, dp[n][i][0]);
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:118: error: no matching function for call to 'max(int)'
   43 |                                         if (dp[i][k][0] < dp[i - 1][j][0] + ls[k][1] - (min(ls[k][0], ls[j][0]) - max(ls[k][0] - ls[j][0]) + c, max(ls[k][0], ls[j][0]) - min(ls[k][0] - ls[j][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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/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:   template argument deduction/substitution failed:
a.cc:43:118: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   43 |                                         if (dp[i][k][0] < dp[i - 1][j][0] + ls[k][1] - (min(ls[k][0], ls[j][0]) - max(ls[k][0] - ls[j][0]) + c, max(ls[k][0], ls[j][0]) - min(ls[k][0] - ls[j][0])))) {
      |                                                                                                                   ~~~^~~~~~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
a.cc:43:174: error: no matching function for call to 'min(int)'
   43 |                                         if (dp[i][k][0] < dp[i - 1][j][0] + ls[k][1] - (min(ls[k][0], ls[j][0]) - max(ls[k][0] - ls[j][0]) + c, max(ls[k][0], ls[j][0]) - min(ls[k][0] - ls[j][0])))) {
      |                                                                                                                                                                           ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:43:174: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   43 |                                         if (dp[i][k][0] < dp[i - 1][j][0] + ls[k][1] - (min(ls[k][0], ls[j][0]) - max(ls[k][0] - ls[j][0]) + c, max(ls[k][0], ls[j][0]) - min(ls[k][0] - ls[j][0])))) {
      |                                                                                                                                                                           ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
a.cc:43:197: error: expected primary-expression before ')' token
   43 |                                         if (dp[i][k][0] < dp[i - 1][j][0] + ls[k][1] - (min(ls[k][0], ls[j][0]) - max(ls[k][0] - ls[j][0]) + c, max(ls[k][0], ls[j][0]) - min(ls[k][0] - ls[j][0])))) {
      |                                                                                                                                                                                                     ^