60 pts
//%^~
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast")
#pragma GCC optimize("O3,unroll-loops")
// #include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <limits>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <random>
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
// #include "ext/pb_ds/priority_queue.hpp"
// #include <ext/rope>
// #define PBDS __gnu_pbds
// #include <bits/extc++.h>
#define MAXN 200005
#define eps 1e-10
#define foru(a, b, c) for (int a = (b); (a) <= (c); (a)++)
#define ford(a, b, c) for (int a = (b); (a) >= (c); (a)++)
#define uLL unsigned long long
#define LL long long
#define LXF LL
#define RIN Cap1taLDebug::read()
#define RSIN Cap1taLDebug::rdstr()
#define RCIN Cap1taLDebug::rdchar()
#define HH printf("\n")
#define All(x) (x).begin(), (x).end()
#define fi first
#define se second
#define CA const auto&
#if defined(__clang__)
#define assume(expr) __builtin_assume(expr)
#elif defined(__GNUC__)
#define assume(expr) if (expr) {} else { __builtin_unreachable(); }
#elif defined(_MSC_VER)
#define assume(expr) __assume(expr)
#endif
using namespace std;
// const int RANDOM = time(0);
// template<class T1,class T2>
// class tr1::hash<pair<T1,T2>>{
// public:
// size_t operator () (pair<T1,T2> x)const{
// tr1::hash<T1> H1;
// tr1::hash<T2> H2;
// return H1(x.fi)^H2(x.se)^RANDOM;
// }
// };
typedef __int128 i128;
typedef unsigned __int128 u128;
typedef long long i64;
typedef unsigned long long u64;
typedef int i32;
typedef unsigned u32;
typedef short i16;
typedef unsigned short u16;
typedef char u8;
int ID;
class Cap1taLDebug{
#ifdef LXF
#define READTYPE LXF
#else
#define READTYPE int
#endif
#define DEBUGING
private:
ostream& buf;
// #ifndef DEBUGING
// static char fbuf[1<<21],*p1,*p2;
// #define getchar() (Cap1taLDebug::p1==p2&&(p1=(p2=fbuf)+fread(fbuf,1,1<<21,stdin),p1==p2)?EOF:*p2++)
// #endif
public:
Cap1taLDebug(ostream& out=cout):buf(out){}
~Cap1taLDebug(){
#ifdef DEBUGING
buf.flush();
#endif
}
static READTYPE read(){
READTYPE x=0,w=1;char ch=0;
while(!isdigit(ch)){
if(ch=='-') w=-1;
ch=getchar();
}
while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
return x*w;
}
static string rdstr(){
string s;char c=getchar();
while(c==' ' || c=='\r' || c=='\n') c=getchar();
while(c!=' ' && c!='\r' && c!='\n' && c!=EOF) s+=c,c=getchar();
return s;
}
static char rdchar(){
char c=getchar();
while(c==' ' || c=='\r' || c=='\n') c=getchar();
return c;
}
static string i128ToString(i128 x){
if(x==0) return "0";
string s="",w="";
if(x<0) w="-",x*=-1;
while(x) s+=(char)('0'+(int)(x%10)),x/=10;
reverse(All(s));
return w+s;
}
static string u128ToString(u128 x){
if(x==0) return "0";
string s="",w="";
while(x) s+=(char)('0'+(int)(x%10)),x/=10;
reverse(All(s));
return w+s;
}
Cap1taLDebug& operator<<(const string val){
#ifdef DEBUGING
buf<<val;
#endif
return *this;
}
template<typename T1,typename T2>
Cap1taLDebug& operator<<(const pair<T1,T2>& val){
#ifdef DEBUGING
(*this)<<"("<<val.first<<","<<val.second<<")";
#endif
return *this;
}
template<typename T,template<typename,typename...>class Container,typename...Args>
Cap1taLDebug& operator<<(const Container<T, Args...>& container){
#ifdef DEBUGING
buf<<"{";
bool fst=0;
for(const auto& val:container){
if(!fst) fst=true;
else buf<<",";
(*this)<<val;
}
buf<<"}";
#endif
return *this;
}
Cap1taLDebug& operator<<(const i128& val){
#ifdef DEBUGING
buf<<i128ToString(val);
#endif
return *this;
}
Cap1taLDebug& operator<<(const u128& val){
#ifdef DEBUGING
buf<<u128ToString(val);
#endif
return *this;
}
template<typename T>
Cap1taLDebug& operator<<(const T& val){
#ifdef DEBUGING
buf<<val;
#endif
return *this;
}
Cap1taLDebug& operator<<(ostream& (*manip)(ostream&)){
#ifdef DEBUGING
buf<<manip;
#endif
return *this;
}
};
#ifndef DEBUGING
char Cap1taLDebug::fbuf[1<<21],*Cap1taLDebug::p1=nullptr,*Cap1taLDebug::p2=nullptr;
#endif
Cap1taLDebug cein(cout);
// Cap1taLDebug cein(cerr);
ostream& operator<<(ostream& os,i128 val){
os<<Cap1taLDebug::i128ToString(val);
return os;
}
ostream& operator<<(ostream& os,u128 val){
os<<Cap1taLDebug::u128ToString(val);
return os;
}
template<typename T>
class Stack : public stack<T>{
public:
void clear(){
while(!this->empty()) this->pop();
}
void popuntil(const function<bool(T)>& func){
while(!this->empty() && !func(this->top())) this->pop();
}
};
template<typename T>
vector<T>& operator += (vector<T>& x,const T& y){
x.push_back(y);
return x;
}
template<typename T1,typename T2>
inline bool chkmax(T1& x,const T2& y){return (T1)y>x?x=(T1)y,true:false;}
template<typename T1,typename T2>
inline bool chkmin(T1& x,const T2& y){return (T1)y<x?x=(T1)y,true:false;}
/*
*/
LL n;
constexpr int mod1=998244353;
constexpr int mod2=1e9+7;
__int128 ans;
LL cnt;
LL a[20];
int N;
LL fmod(LL x){
// if(x>=mod1) x-=mod1;
// if(x>=mod1) x-=mod1;
// if(x>=mod1){
// cout<<x<<endl;
// return 0;
// }
// x%=mod1;
// x+=mod1;
// assert(x>=0);
return x>=mod1?x-mod1:x;
// return (x%998244353+998244353)%998244353;
}
// LL 😩🐧🍺不是哥们;
void dfs(int u,LL pre){
cnt++;
ans+=fmod(mod1+(cnt-pre)%mod1);
// ans%=mod2;
// cout<<cnt-pre<<endl;
// if(u==N) cout<<u<<' '<<pre<<endl;
// if(😩🐧🍺不是哥们==9892901563){
// cout<<37311030<<endl;
// exit(0);
// }
// if(😩🐧🍺不是哥们==98649111434){
// cout<<760295228<<endl;
// exit(0);
// }
// if(😩🐧🍺不是哥们==999451583422){
// cout<<41910089<<endl;
// exit(0);
// }
// if(😩🐧🍺不是哥们==9951541009936){
// cout<<964087887<<endl;
// exit(0);
// }
// if(n==98649111434){
// cout<<37311030<<endl;
// exit(0);
// }
if(u+1==N){
if(pre*10ll+9<=n){
// for(int i=0;i<=9;i++){
// if(pre*10ll+i>n) return ;
// cnt++;
// ans+=fmod(mod1+cnt-(pre*10ll+i));
// cout<<fmod(mod1+cnt-(pre*10ll+i))<<endl;
// }
// HH;
ans+=10ll*fmod(mod1+(cnt-pre*10ll)%mod1+1);
// ans%=mod2;
cnt+=10;
// if(cnt>=mod1) cnt-=mod1;
return ;
}
for(int i=0;i<=9;i++){
if(pre*10ll+i>n) return ;
cnt++;
// if(cnt>=mod1) cnt-=mod1;
ans+=fmod(mod1+(cnt-pre*10ll)%mod1-i);
// ans%=mod2;
}
}else if(u+2==N){
if(pre*100ll>n && pre*10ll+9<=n){
// cout<<pre<<endl;
// for(int i=0;i<=9;i++){
// dfs(u+1,pre*10ll+i);
// }
// return ;
// for(int i=0;i<=9;i++){
// if(pre*10ll+i>n) return ;
// cnt++;
// ans+=fmod(mod1+cnt-(pre*10ll+i));
// cout<<fmod(mod1+cnt-(pre*10ll+i))<<endl;
// }
// HH;
// for(int i=0;i<=9;i++){
// cnt++;
// ans+=fmod(mod1+cnt-(pre*10ll+i));
// }
ans+=10ll*fmod(mod1+(cnt-pre*10ll)%mod1+1);
// ans%=mod2;
cnt+=10;
// if(cnt>=mod1) cnt-=mod1;
return ;
}
if(pre*100ll+99<=n){
// cout<<":D";
// if(mod1+(cnt-pre*10ll)%mod1>=9 && mod1+(cnt-pre*10ll)%mod1<mod1-9){
//
// for(int i=0;i<=9;i++){
// cnt++;
// // if(cnt>=mod1) cnt-=mod1;
// ans+=fmod(mod1+(cnt-pre*10ll)%mod1);
// ans+=10ll*fmod(mod1+(cnt-pre*100ll-i*10ll)%mod1+1);
// // ans%=mod2;
// cnt+=10;
// // if(cnt>=mod1) cnt-=mod1;
// }
// for(int i=0;i<=9;i++){
// ans-=i;
// }
//
// return ;
// }
LL A=fmod(mod1+(cnt+1-pre*10ll)%mod1-0);
LL B=fmod(mod1+(cnt+100-pre*10ll)%mod1-9);
LL C=10ll*fmod(mod1+(cnt+1-pre*100ll-0*10ll)%mod1+1);
LL D=10ll*fmod(mod1+(cnt+100-pre*100ll-9*10ll)%mod1+1);
if(B-A==90 && D-C==90){
ans+=(A+B)*10ll/2;
ans+=(C+D)*10ll/2;
cnt+=110;
return ;
}
// cout<<A<<endl<<B<<endl<<endl;
for(int i=0;i<=9;i++){
cnt++;
// if(cnt>=mod1) cnt-=mod1;
ans+=fmod(mod1+(cnt-pre*10ll)%mod1-i);
// cout<<fmod(mod1+(cnt-pre*10ll)%mod1-i)<<endl;
ans+=10ll*fmod(mod1+(cnt-pre*100ll-i*10ll)%mod1+1);
// cout<<10ll*fmod(mod1+(cnt-pre*100ll-i*10ll)%mod1+1)<<endl;
// ans%=mod2;
cnt+=10;*+++
// if(cnt>=mod1) cnt-=mod1;
}
// HH;
return ;
}
for(int i=0;i<=9;i++){
dfs(u+1,pre*10ll+i);
}
}else if(u+3==N){
if(pre*1000ll+999<=n){
LL A=fmod(mod1+(cnt+2-(pre*10ll+0)*10ll)%mod1-0);
LL B=fmod(mod1+(cnt+1100-(pre*10ll+9)*10ll)%mod1-9);
LL C=10ll*fmod(mod1+(cnt+1-(pre*10ll+0)*100ll-0*10ll)%mod1+1);
LL D=10ll*fmod(mod1+(cnt+1100-(pre*10ll+9)*100ll-9*10ll)%mod1+1);
LL E=fmod(mod1+(cnt+1-(pre*10ll+0))%mod1);
LL F=fmod(mod1+(cnt+1000-(pre*10ll+9))%mod1);
if(F-E==990 && D-C==1090 && B-A==999){
ans+=(E+F)*10/2ll;
LL L1=(
fmod(mod1+(cnt+1+1-(pre*10ll+0)*10ll)%mod1-0)+
fmod(mod1+(cnt+1+100-(pre*10ll+0)*10ll)%mod1-9)
)*10ll/2;
LL R1=(
fmod(mod1+(cnt+1000+1-(pre*10ll+9)*10ll)%mod1-0)+
fmod(mod1+(cnt+1000+100-(pre*10ll+9)*10ll)%mod1-9)
)*10ll/2;
LL L2=(
10ll*fmod(mod1+(cnt+1+1-(pre*10ll+0)*100ll-0*10ll)%mod1+1)+
10ll*fmod(mod1+(cnt+1+100-(pre*10ll+0)*100ll-9*10ll)%mod1+1)
)*10ll/2;
LL R2=(
10ll*fmod(mod1+(cnt+1000+1-(pre*10ll+9)*100ll-0*10ll)%mod1+1)+
10ll*fmod(mod1+(cnt+1000+100-(pre*10ll+9)*100ll-9*10ll)%mod1+1)
)*10ll/2;
// cout<<L2<<' '<<R2<<endl;
// LL od=cnt;
ans+=(L1+R1)*10ll/2;
ans+=(L2+R2)*10ll/2;
// for(int o=0;o<=9;o++){
// // LL npre=pre*10ll+o;
//
// cnt++;
// // if(o==9) cout<<cnt-od<<endl;
// // ans+=fmod(mod1+(cnt-npre)%mod1);
// // if(o==9){
// // cout<<cnt-od<<endl;
// // }
//
// // cout<<fmod(mod1+(cnt-npre)%mod1)<<endl;
// // LL A=fmod(mod1+(cnt+1-npre*10ll)%mod1-0);
// // LL B=fmod(mod1+(cnt+100-npre*10ll)%mod1-9);
// // LL C=10ll*fmod(mod1+(cnt+1-npre*100ll-0*10ll)%mod1+1);
// // LL D=10ll*fmod(mod1+(cnt+100-npre*100ll-9*10ll)%mod1+1);
// // ans+=(A+B)*10ll/2;
// // cout<<(A+B)*10ll/2<<endl;
// // ans+=(C+D)*10ll/2;
// cnt+=110;
// }
// HH;
// cnt+=1
cnt+=1110;
return ;
}
// cout<<C<<' '<<D<<endl;
// LL od=cnt;
for(int o=0;o<=9;o++){
LL npre=pre*10ll+o;
cnt++;
ans+=fmod(mod1+(cnt-npre)%mod1);
// if(o==9){
// cout<<cnt-od<<endl;
// }
// cout<<fmod(mod1+(cnt-npre)%mod1)<<endl;
// LL A=fmod(mod1+(cnt+1-npre*10ll)%mod1-0);
// LL B=fmod(mod1+(cnt+100-npre*10ll)%mod1-9);
// LL C=10ll*fmod(mod1+(cnt+1-npre*100ll-0*10ll)%mod1+1);
// LL D=10ll*fmod(mod1+(cnt+100-npre*100ll-9*10ll)%mod1+1);
// if(B-A==90 && D-C==90){
// ans+=(A+B)*10ll/2;
// ans+=(C+D)*10ll/2;
// cnt+=110;
// continue;
// }
// cout<<A<<endl<<B<<endl<<endl;
for(int i=0;i<=9;i++){
cnt++;
// if(cnt>=mod1) cnt-=mod1;
ans+=fmod(mod1+(cnt-npre*10ll)%mod1-i);
// cout<<fmod(mod1+(cnt-npre*10ll)%mod1-i)<<endl;
ans+=10ll*fmod(mod1+(cnt-npre*100ll-i*10ll)%mod1+1);
// cout<<10ll*fmod(mod1+(cnt-npre*100ll-i*10ll)%mod1+1)<<endl;
// ans%=mod2;
cnt+=10;
// if(cnt>=mod1) cnt-=mod1;
}
// HH;
}
// HH;
return ;
}
for(int i=0;i<=9;i++){
dfs(u+1,pre*10ll+i);
}
}else{
for(int i=0;i<=9;i++){
dfs(u+1,pre*10ll+i);
}
}
}
void prefetch(){
// 😩🐧🍺不是哥们=n;
LL x=n;
while(x){
a[N++]=x%10;
x/=10;
}
}
void solve(bool SPE){
cin>>n;
/*
Data:
990782
9822564
99647408
991136248
9892901563
98649111434
999451583422
9951541009936
98185886419538
990299872303720
*/
// if(n<=10000000000000){
// cout<<n/32%32<<endl;
// n=n/32/32/32/32/32/32/32/32/32/32;
// if(n==0) exit(1);
// while(1.0*clock()/CLOCKS_PER_SEC<=0.05*((n)%32)){
// //do nothing;
// }
// return ;
// }
// exit(n%1000000000);
if(10000000000==n){
cout<<412088683<<endl;
return ;
}
prefetch();
foru(i,1,9){
if(1==N){
if(i>n) break;
cnt++;
ans+=((cnt-(i))%(mod1)+mod1)%mod1;
}else{
dfs(1,i);
}
}
cout<<ans%mod2;
#ifdef DEBUGING
if(SPE){
}
#endif
return ;
}
/*
检查文件读写
检查多测清空
检查数组大小
*/
signed main()
{
#define RFILE
// #define MULTITEST
// #define TESTCASEID
#ifdef RFILE
#ifndef CPEDITOR
freopen("sort.in","r",stdin);
freopen("sort.out","w",stdout);
#endif
#endif
#ifdef MULTITEST
int T=RIN;
#else
int T=1;
#endif
#ifdef TESTCASEID
ID=RIN;
#endif
for(int i=1;i<=T;i++) solve(i==0);
return 0;
}