前缀和统计 预处理
枚举每个非零位的贡献扫一次就好了
#include <bits/stdc++.h>
using namespace std;
#define MOD (int)(1e9+7)
#define ll long long
#define db(a) (cout<<"->"<<a<<endl)
ll ppow(ll a,ll n){
ll ret=1;
while(n){
if(n&1) ret=ret*a%MOD;
a*=a%MOD;
n>>=1;
}
return ret;
}
ll now[102000];
ll pre[102000];
ll fac10[102000];
int main(){
string s;
cin>>s;
ll len=s.size();
fac10[1]=1;
for(ll i=2;i<=101000;i++){
fac10[i]=(fac10[i-1]*10+1)%MOD;
}
s='#'+s;
for(ll i=1;i<=len;++i){
now[i]=s[i]-'0';
}
for(ll i=1;i<=len;++i){
if(now[i]) pre[i]=pre[i-1]+1;
else pre[i]=pre[i-1];
}
ll ans=0;
for(ll i=1;i<=len;++i){
if(now[i]) ans=(ans+now[i]*fac10[len-i+1]%MOD*pre[i]%MOD)%MOD;
}
cout<<ans<<endl;
return 0;
}