Language: C++

#include <bits/stdc++.h>
using namespace std;

using ll = __int128;

template<typename T>
std::vector<T> table(int n, T v) { return std::vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
	auto val = table(args...);
	return std::vector<decltype(val)>(n, std::move(val));
}


ll solve(ll n) {
	const auto s = to_string(n);
	const int m = s.size();
	// [pos][i - 3][i - 2][i - 1][already ok][strictly less]
	auto dp = table<ll>(m + 1, 10, 10, 10, 2, 2, 0);
	dp[0][0][0][0][0][0] = 1;
	for (int i = 0; i < m; ++i) {
		for (int i3 = 0; i3 <= 9; ++i3) for (int i2 = 0; i2 <= 9; ++i2) for (int i1 = 0; i1 <= 9; ++i1) {
			for (int aok = 0; aok <= 1; ++aok) {
				for (int le = 0; le <= 1; ++le) {
					const int lim = le ? 9 : s[i] - '0';
					for (int add = 0; add <= lim; ++add) {
						int nok = aok || (i3 == 5 && i2 == 1 && add == 3);
						int nle = le || s[i] - '0' > add;
						dp[i + 1][i2][i1][add][nok][nle] += dp[i][i3][i2][i1][aok][le];
					}
				}
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i <= 9; ++i) {
		for (int j = 0; j <= 9; ++j) {
			for (int k = 0; k <= 9; ++k) {
				ans += dp[m][i][j][k][1][0] + dp[m][i][j][k][1][1];
			}
		}
	}
	return ans;
}

int main() {
	long long N;
	cin >> N;
	cout << (long long)solve(N) << endl;
}



Compiler output:
a.cc: In function 'll solve(ll)':
a.cc:17:33: error: call of overloaded 'to_string(ll&)' is ambiguous
   17 |         const auto s = to_string(n);
      |                        ~~~~~~~~~^~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4240:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
 4240 |   to_string(int __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4259:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
 4259 |   to_string(unsigned __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4275:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
 4275 |   to_string(long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4294:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
 4294 |   to_string(unsigned long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4310:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
 4310 |   to_string(long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4327:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
 4327 |   to_string(unsigned long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4401:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
 4401 |   to_string(float __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4411:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
 4411 |   to_string(double __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4421:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
 4421 |   to_string(long double __val)
      |   ^~~~~~~~~