Language: C++

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
using ll = long long;
 
const int nax = 10123;
char k[nax];
const int mod = 1e9 + 7;
 
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
 
int modder(int x, int moddi)
{
	if (x >= moddi)
        return x - moddi;
    return x;
}
 
int main() {
    scanf("%s", k);
    int D;
    scanf("%d", &D);
    int len = strlen(k);
    vector<array<int,2>> dp(D, array<int,2>{});
    vector<array<int,2>> new_dp(D, array<int,2>{});
    // dp[sum][smaller_already] - the number of ways to choose digits so far
    // such that the sum of digits modulo D is 'sum' and 'smaller_already'
    // says whether we already chosen some digit smaller than in K
    dp[0][0] = 1;
    for(int where = 0; where < len; ++where) {
        fill(new_dp.begin(), new_dp.end(), array<int,2>{});
        for(int sum = 0; sum < D; ++sum) {
            int sum2 = sum % D;
            for(bool sm_already : {false, true}) {
                for(int digit = 0; digit < 10; ++digit) {
                    if(digit > k[where] - '0' && !sm_already) {
                        break;
                    }
                    add_self(new_dp[modder(sum2+digit,D)][sm_already || (digit < k[where]-'0')],
                        dp[sum][sm_already]);
                }
            }
        }
        swap(dp, new_dp);
    }
    int answer = (dp[0][false] + dp[0][true]) % mod;
    --answer;
    if(answer == -1) {
        answer = mod - 1;
    }
    printf("%d\n", answer);
}

Compiler output:
a.cc:8:34: error: 'cerr' was not declared in this scope
    8 | sim > auto dud(c* x) -> decltype(cerr << *x, 0);
      |                                  ^~~~
a.cc:8:34: error: 'cerr' was not declared in this scope
a.cc: In function 'int main()':
a.cc:51:5: error: 'scanf' was not declared in this scope
   51 |     scanf("%s", k);
      |     ^~~~~
a.cc:54:15: error: 'strlen' was not declared in this scope
   54 |     int len = strlen(k);
      |               ^~~~~~
a.cc:1:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | #define sim template < class c
a.cc:55:5: error: 'vector' was not declared in this scope
   55 |     vector<array<int,2>> dp(D, array<int,2>{});
      |     ^~~~~~
a.cc:55:12: error: 'array' was not declared in this scope
   55 |     vector<array<int,2>> dp(D, array<int,2>{});
      |            ^~~~~
a.cc:55:18: error: expected primary-expression before 'int'
   55 |     vector<array<int,2>> dp(D, array<int,2>{});
      |                  ^~~
a.cc:55:46: error: expected primary-expression before ')' token
   55 |     vector<array<int,2>> dp(D, array<int,2>{});
      |                                              ^
a.cc:56:18: error: expected primary-expression before 'int'
   56 |     vector<array<int,2>> new_dp(D, array<int,2>{});
      |                  ^~~
a.cc:56:50: error: expected primary-expression before ')' token
   56 |     vector<array<int,2>> new_dp(D, array<int,2>{});
      |                                                  ^
a.cc:60:5: error: 'dp' was not declared in this scope
   60 |     dp[0][0] = 1;
      |     ^~
a.cc:62:14: error: 'new_dp' was not declared in this scope
   62 |         fill(new_dp.begin(), new_dp.end(), array<int,2>{});
      |              ^~~~~~
a.cc:62:50: error: expected primary-expression before 'int'
   62 |         fill(new_dp.begin(), new_dp.end(), array<int,2>{});
      |                                                  ^~~
a.cc:62:56: error: expected primary-expression before '{' token
   62 |         fill(new_dp.begin(), new_dp.end(), array<int,2>{});
      |                                                        ^
a.cc:62:9: error: 'fill' was not declared in this scope; did you mean 'll'?
   62 |         fill(new_dp.begin(), new_dp.end(), array<int,2>{});
      |         ^~~~
      |         ll
a.cc:65:47: error: deducing from brace-enclosed initializer list requires '#include <initializer_list>'
  +++ |+#include <initializer_list>
    1 | #define sim template < class c
......
   65 |             for(bool sm_already : {false, true}) {
      |                                               ^
a.cc:75:9: error: 'swap' was not declared in this scope
   75 |         swap(dp, new_dp);
      |         ^~~~
a.cc:82:5: error: 'printf' was not declared in this scope
   82 |     printf("%d\n", answer);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #define sim template < class c