Language: C++

#include <iostream>
#include <string>
#include <vector>

int main() {
  std::string n;
  int k;
  std::cin >> n >> k;
  int len = n.size();

  std::vector<int[5][2]> dp(len + 1, {}); // dp[何桁目][非 0 何個][n より小か]
  dp[len][0][0] = 1;
  for (int i = len; i >= 0; i += 1) { // 何桁目
    int d = n[i] - '0';               // i 桁目の数字

    // 配るDP
    for (int j = 0; j <= k; j += 1) {     // 非 0 何個
      for (int s = 0; s <= 1; s += 1) {   // n より小か
        for (int c = 0; c <= 9; c += 1) { // 遷移に使う数字
          if (!s && c > d) // n を超過する場合遷移しない
            continue;
          dp[i][j + (c != 0)][s | c < d] += dp[i + 1][j][s];
        }
      }
    }
  }

  std::cout << dp[0][k][0] + dp[0][k][1] << std::endl;
}


Compiler output:
In file included from /usr/include/c++/14/vector:65,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_uninitialized.h: In instantiation of 'constexpr bool std::__check_constructible() [with _ValueType = int [5][2]; _Tp = const int (&)[5][2]]':
/usr/include/c++/14/bits/stl_uninitialized.h:320:4:   required from '_ForwardIterator std::uninitialized_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = int (*)[5][2]; _Size = long unsigned int; _Tp = int [5][2]]'
  320 |         = _GLIBCXX_USE_ASSIGN_FOR_INIT(_ValueType, const _Tp&)
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:472:39:   required from '_ForwardIterator std::__uninitialized_fill_n_a(_ForwardIterator, _Size, const _Tp&, allocator<_Tp2>&) [with _ForwardIterator = int (*)[5][2]; _Size = long unsigned int; _Tp = int [5][2]; _Tp2 = int [5][2]]'
  472 |       return std::uninitialized_fill_n(__first, __n, __x);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1709:33:   required from 'void std::vector<_Tp, _Alloc>::_M_fill_initialize(size_type, const value_type&) [with _Tp = int [5][2]; _Alloc = std::allocator<int [5][2]>; size_type = long unsigned int; value_type = int [5][2]]'
 1709 |           std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1710 |                                         _M_get_Tp_allocator());
      |                                         ~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:572:9:   required from 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = int [5][2]; _Alloc = std::allocator<int [5][2]>; size_type = long unsigned int; value_type = int [5][2]; allocator_type = std::allocator<int [5][2]>]'
  572 |       { _M_fill_initialize(__n, __value); }
      |         ^~~~~~~~~~~~~~~~~~
a.cc:11:40:   required from here
   11 |   std::vector<int[5][2]> dp(len + 1, {}); // dp[何桁目][非 0 何個][n より小か]
      |                                        ^
/usr/include/c++/14/bits/stl_uninitialized.h:90:56: error: static assertion failed: result type must be constructible from input type
   90 |       static_assert(is_constructible<_ValueType, _Tp>::value,
      |                                                        ^~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:90:56: note: 'std::integral_constant<bool, false>::value' evaluates to false