Language: C++

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define pb push_back
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
 
const int mod = 1e9 + 7;
 
ll S, mul = 9, cnt, ans;
int pref[15000005];
bool ck[100000005];
 
ll binpw(ll base, ll pw){
	ll ans = 1;
	while(pw){
		if(pw & 1) ans = (ans * base) % mod;
		base = (base * base) % mod;
		pw >>= 1;
	}
	return ans;
}
 
signed main(){
	ios_base::sync_with_stdio(0);
	cin >> S;
	ck[0] = 1;
	for(int i = 1; i <= 7; i++){
		for(int j = 1; j <= mul; j++){
			++cnt;
			pref[cnt] = pref[cnt - 1] + i;
			ans += (pref[cnt] >= S && ck[pref[cnt] - S]);
			if(pref[cnt] <= 100000000) ck[pref[cnt]] = 1;
		}
		mul *= 10;
	}
	//cout << "OK\n";
	int pos = -1;
	for(int i = 1; i <= 5000000; i++){
		++cnt;
		pref[cnt] = pref[cnt - 1] + 8;
		ans += (pref[cnt] >= S && ck[pref[cnt] - S]);
		if(pref[cnt] <= 100000000) ck[pref[cnt]] = 1;
		else{
			pos = cnt;
			break;
		}
	}
	//cout << ans << "\n";
	for(int i = min(S - 1) / 8; i >= 1; i--){
		if(!(S % i)){
			ll tmp = S / i, tmp2 = binpw(10, tmp - 1) * 9;
			//if(tmp2 < i) continue;
			//cout << ans << " " << tmp2 << "\n";
			ans = (ans + tmp2 - i + 1) % mod;
		}
		else{
			ans++;
			if(ans >= mod) ans -= mod;
		}
	}
	for(int i = (S / 7) - 1; i >= (S + 15) / 8; i--){
		int r = S - i * 7;
		if(r <= 5000000) continue;
		ans++;
		if(ans >= mod) ans -= mod;
	}
	if(!(S % 8)){
		if(S / 8 < pos - 10000000) ans += 100000000 - (ll)pos - 1;
		else ans += 100000000 - S / 8 + 1;
		if(ans >= mod) ans -= mod;
	}
	cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:24: error: no matching function for call to 'min(long long int)'
   55 |         for(int i = min(S - 1) / 8; i >= 1; i--){
      |                     ~~~^~~~~~~
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: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
In file included from /usr/include/c++/14/algorithm:61:
/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:55:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   55 |         for(int i = min(S - 1) / 8; i >= 1; i--){
      |                     ~~~^~~~~~~
/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