Language: C++

#include <iostream>
#include "bits/stdc++.h"
#define ll long long int 
using namespace std;
int dfs(int pos,int n, bool flag,string s,int count,vector<vector<vector<int>>>& dp,int k){
        if(pos >= n) return(count == k);
        if(dp[pos][count][flag] != -1) return dp[pos][count][flag];
        int limit=9;
        if(flag ) limit = s[pos]-'0';
        int res=0;
        for(int i=0;i<=limit;i++){
            if(!flag || i < limit){
                if(i != 0) res+=dfs(pos+1,n,0,s,count+1,dp,k);
                else res+=dfs(pos+1,n,0,s,count,dp,k);
            }
            else{
               if(i != 0) res+=dfs(pos+1,n,1,s,count+1,dp,k);
                else res+=dfs(pos+1,n,1,s,count,dp,k);
            }
        }
        return dp[pos][count][flag]=res;
    }
int main()
{
        int n,k;
        cin >> n >>k;
        string s= to_string(n);
        vector<vector<vector<int>>> dp(s.size(),vector<vector<int>>(162,vector<int>(2,-1)));
        cout<<dfs(0,s.size(),1,s,0,dp,k)<<endl;
    return 0;
}#include <iostream>
#include "bits/stdc++.h"
#define ll long long int 
using namespace std;
int dfs(int pos,int n, bool flag,string s,int count,vector<vector<vector<int>>>& dp,int k){
        if(pos >= n) return(count == k);
        if(dp[pos][count][flag] != -1) return dp[pos][count][flag];
        int limit=9;
        if(flag ) limit = s[pos]-'0';
        int res=0;
        for(int i=0;i<=limit;i++){
            if(!flag || i < limit){
                if(i != 0) res+=dfs(pos+1,n,0,s,count+1,dp,k);
                else res+=dfs(pos+1,n,0,s,count,dp,k);
            }
            else{
               if(i != 0) res+=dfs(pos+1,n,1,s,count+1,dp,k);
                else res+=dfs(pos+1,n,1,s,count,dp,k);
            }
        }
        return dp[pos][count][flag]=res;
    }
int main()
{
        int n,k;
        cin >> n >>k;
        string s= to_string(n);
        vector<vector<vector<int>>> dp(s.size(),vector<vector<int>>(162,vector<int>(2,-1)));
        cout<<dfs(0,s.size(),1,s,0,dp,k)<<endl;
    return 0;
}#include <iostream>
#include "bits/stdc++.h"
#define ll long long int 
using namespace std;
int dfs(int pos,int n, bool flag,string s,int count,vector<vector<vector<int>>>& dp,int k){
        if(pos >= n) return(count == k);
        if(dp[pos][count][flag] != -1) return dp[pos][count][flag];
        int limit=9;
        if(flag ) limit = s[pos]-'0';
        int res=0;
        for(int i=0;i<=limit;i++){
            if(!flag || i < limit){
                if(i != 0) res+=dfs(pos+1,n,0,s,count+1,dp,k);
                else res+=dfs(pos+1,n,0,s,count,dp,k);
            }
            else{
               if(i != 0) res+=dfs(pos+1,n,1,s,count+1,dp,k);
                else res+=dfs(pos+1,n,1,s,count,dp,k);
            }
        }
        return dp[pos][count][flag]=res;
    }
int main()
{
        int n,k;
        cin >> n >>k;
        string s= to_string(n);
        vector<vector<vector<int>>> dp(s.size(),vector<vector<int>>(162,vector<int>(2,-1)));
        cout<<dfs(0,s.size(),1,s,0,dp,k)<<endl;
    return 0;
}

Compiler output:
a.cc:31:2: error: stray '#' in program
   31 | }#include <iostream>
      |  ^
a.cc:61:2: error: stray '#' in program
   61 | }#include <iostream>
      |  ^
a.cc:31:3: error: 'include' does not name a type
   31 | }#include <iostream>
      |   ^~~~~~~
a.cc:35:5: error: redefinition of 'int dfs(int, int, bool, std::string, int, std::vector<std::vector<std::vector<int> > >&, int)'
   35 | int dfs(int pos,int n, bool flag,string s,int count,vector<vector<vector<int>>>& dp,int k){
      |     ^~~
a.cc:5:5: note: 'int dfs(int, int, bool, std::string, int, std::vector<std::vector<std::vector<int> > >&, int)' previously defined here
    5 | int dfs(int pos,int n, bool flag,string s,int count,vector<vector<vector<int>>>& dp,int k){
      |     ^~~
a.cc:53:5: error: redefinition of 'int main()'
   53 | int main()
      |     ^~~~
a.cc:23:5: note: 'int main()' previously defined here
   23 | int main()
      |     ^~~~
a.cc:61:3: error: 'include' does not name a type
   61 | }#include <iostream>
      |   ^~~~~~~
a.cc:65:5: error: redefinition of 'int dfs(int, int, bool, std::string, int, std::vector<std::vector<std::vector<int> > >&, int)'
   65 | int dfs(int pos,int n, bool flag,string s,int count,vector<vector<vector<int>>>& dp,int k){
      |     ^~~
a.cc:5:5: note: 'int dfs(int, int, bool, std::string, int, std::vector<std::vector<std::vector<int> > >&, int)' previously defined here
    5 | int dfs(int pos,int n, bool flag,string s,int count,vector<vector<vector<int>>>& dp,int k){
      |     ^~~
a.cc:83:5: error: redefinition of 'int main()'
   83 | int main()
      |     ^~~~
a.cc:23:5: note: 'int main()' previously defined here
   23 | int main()
      |     ^~~~