Language: C++

#include <bits/stdc++.h>

using namespace std;
const int MOD=1000000007;
int k,n,num[10000009];
long long b,dp[200000][109][2];
string s;
int get_digit()
{
    fill(num,num+1000009,-1);
    int n=s.size();
    s=" "+s;
    for (int i=1; i<=n; i++)
        num[i]=(int)(s[i]-48);
    return n;
}
long long digit_dp(int idx, int sum, int tight)
{
    if (idx==n+1)
        if (sum%k==0)
            return 1;
        else
            return 0;
    if (dp[idx][sum][tight]!=-1)
        return dp[idx][sum][tight];
    int res=0,limit;
    if (tight==0)
        limit=num[idx];
    else
        limit=9;
    for (int i=0; i<=limit; i++)
    {
        int new_tight=1;
        if (i==limit&&tight==0)
            new_tight=0;
        res=(res+digit_dp(idx+1,(sum+i)%k,new_tight))%MOD;
    }
    dp[idx][sum][tight]=res%MOD;
    return res;
}
int main()
{
    cin>>s>>k;
    n=get_digit();
    memset(dp,-1,sizeof(dp));
    b=digit_dp(1,0,0);
    cout << (b-1)%MOD;
    return 0;
}
#include <bits/stdc++.h>

using namespace std;
const int MOD=1000000007;
int k,n,num[10000009];
long long b,dp[200000][109][2];
string s;
int get_digit()
{
    fill(num,num+1000009,-1);
    int n=s.size();
    s=" "+s;
    for (int i=1; i<=n; i++)
        num[i]=(int)(s[i]-48);
    return n;
}
long long digit_dp(int idx, int sum, int tight)
{
    if (idx==n+1)
        if (sum%k==0)
            return 1;
        else
            return 0;
    if (dp[idx][sum][tight]!=-1)
        return dp[idx][sum][tight];
    int res=0,limit;
    if (tight==0)
        limit=num[idx];
    else
        limit=9;
    for (int i=0; i<=limit; i++)
    {
        int new_tight=1;
        if (i==limit&&tight==0)
            new_tight=0;
        res=(res+digit_dp(idx+1,(sum+i)%k,new_tight))%MOD;
    }
    dp[idx][sum][tight]=res%MOD;
    return res;
}
int main()
{
    cin>>s>>k;
    n=get_digit();
    memset(dp,-1,sizeof(dp));
    b=digit_dp(1,0,0);
    cout << (b-1)%MOD;
    return 0;
}



Compiler output:
a.cc:53:11: error: redefinition of 'const int MOD'
   53 | const int MOD=1000000007;
      |           ^~~
a.cc:4:11: note: 'const int MOD' previously defined here
    4 | const int MOD=1000000007;
      |           ^~~
a.cc:54:5: error: redefinition of 'int k'
   54 | int k,n,num[10000009];
      |     ^
a.cc:5:5: note: 'int k' previously declared here
    5 | int k,n,num[10000009];
      |     ^
a.cc:54:7: error: redefinition of 'int n'
   54 | int k,n,num[10000009];
      |       ^
a.cc:5:7: note: 'int n' previously declared here
    5 | int k,n,num[10000009];
      |       ^
a.cc:54:9: error: redefinition of 'int num [10000009]'
   54 | int k,n,num[10000009];
      |         ^~~
a.cc:5:9: note: 'int num [10000009]' previously declared here
    5 | int k,n,num[10000009];
      |         ^~~
a.cc:55:11: error: redefinition of 'long long int b'
   55 | long long b,dp[200000][109][2];
      |           ^
a.cc:6:11: note: 'long long int b' previously declared here
    6 | long long b,dp[200000][109][2];
      |           ^
a.cc:55:13: error: redefinition of 'long long int dp [200000][109][2]'
   55 | long long b,dp[200000][109][2];
      |             ^~
a.cc:6:13: note: 'long long int dp [200000][109][2]' previously declared here
    6 | long long b,dp[200000][109][2];
      |             ^~
a.cc:56:8: error: redefinition of 'std::string s'
   56 | string s;
      |        ^
a.cc:7:8: note: 'std::string s' previously declared here
    7 | string s;
      |        ^
a.cc:57:5: error: redefinition of 'int get_digit()'
   57 | int get_digit()
      |     ^~~~~~~~~
a.cc:8:5: note: 'int get_digit()' previously defined here
    8 | int get_digit()
      |     ^~~~~~~~~
a.cc:66:11: error: redefinition of 'long long int digit_dp(int, int, int)'
   66 | long long digit_dp(int idx, int sum, int tight)
      |           ^~~~~~~~
a.cc:17:11: note: 'long long int digit_dp(int, int, int)' previously defined here
   17 | long long digit_dp(int idx, int sum, int tight)
      |           ^~~~~~~~
a.cc:90:5: error: redefinition of 'int main()'
   90 | int main()
      |     ^~~~
a.cc:41:5: note: 'int main()' previously defined here
   41 | int main()
      |     ^~~~