Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int S;

int Digits(int n) {
	int ret = 0;
	while (n > 0) {
		n /= 10;
		++ret;
	}
	return ret;
}

MInt lss(int d) {
	vector<PP> A;
	int a = 9;
	REP(i, 0, d) {
		A.push_back(PP(i + 1, a));
		a *= 10;
	}

	PP l(0, 0);
	PP r(0, 0);
	
	int sum = 0;
	int cnt = 0;
	while (true) {
		while (sum < S) {
			sum += A[r.first].first;

			++r.second;
			if (r.second >= A[r.first].second) r = PP(r.first + 1, 0);
			if (r.first >= A.size()) return cnt + (sum == S);
		}
		if (sum == S) ++cnt;

		sum -= A[l.first].first;
		++l.second;
		if (l.second >= A[l.first].second) l = PP(l.first + 1, 0);
	}
}

MInt grtr(int d) {
	MInt cnt = 0;

	MInt a = 9;
	REP(i, 0, d) {
		a *= 10;
	}
	REP(i, d + 1, S / 2 + 2) {
		int q = (S - 1) / (i - 1);
		int r = (S - 1) % (i - 1) + 1;

		cnt += MInt((q - r + ((int)i - 1)) / (int)i);
		if (S % i == 0) cnt += a - (int)(S / i - 1);
		a *= 10;
	}
	if (S >= 3) cnt += 10_m[S - 1] * 9;
	return cnt;
}


int main() {
	cin >> S;
	
	int d = min(Digits(S), 8);
	MInt ans = lss(d);
	ans += grtr(d);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:97:1: error: 'MInt' does not name a type
   97 | MInt lss(int d) {
      | ^~~~
a.cc:126:1: error: 'MInt' does not name a type
  126 | MInt grtr(int d) {
      | ^~~~
a.cc: In function 'int main()':
a.cc:150:9: error: 'MInt' was not declared in this scope
  150 |         MInt ans = lss(d);
      |         ^~~~
a.cc:151:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
  151 |         ans += grtr(d);
      |         ^~~
      |         abs
a.cc:151:16: error: 'grtr' was not declared in this scope
  151 |         ans += grtr(d);
      |                ^~~~