criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

string s;
int k;
ll dp[110][2][5];

int main() {
    cin >> s >> k;
    int slen = s.length();

    dp[0][0][0] = 1;
    for(int i = 0; i < slen; ++i) {
        for(int j = 0; j <= k; ++j) {
            // i桁目まででsより小さいならi+1桁目は全部
            dp[i+1][1][k+1] += dp[i][1][k] * 9;
            // 追加しなかったとき
            dp[i+1][1][k] += dp[i][1][k];

            int check = slen.at(i) - '0';
            // i桁目までは一緒だったが、i+1桁目を入れたら小さくなった
            if(check > 0) {
                dp[i+1][1][k+1] += dp[i][0][k] * (check-1);
                dp[i+1][1][k] += dp[i][0][k];
            }

            // i+1桁目もピンチケ
            if(check > 0) {
                dp[i+1][0][k+1] = dp[i][0][k];
            }else {
                dp[i+1][0][k] = dp[i][0][k];
            }
        }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:25:30: error: request for member 'at' in 'slen', which is of non-class type 'int'
   25 |             int check = slen.at(i) - '0';
      |                              ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
long long n,a;
cin>>n;
a=n;
int k;
cin>>k;
int counter1,counter2,counter=0,;
while(n>0){
n/=10;
counter++;}
while(n>0){
n/=10;
counter++;}
if(k=1){
counter2=counter;
while(counter>1){
a/=10;
counter--;}
cout<<(counter2-1)*9+a<<endl;}
else if(k=2)
if(counter==n){
cout<<"APPROVED"<<endl;}
else{
cout<<"DENIED"<<endl;}}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:33: error: expected unqualified-id before ';' token
   10 | int counter1,counter2,counter=0,;
      |                                 ^
Language: Java

import java.util.*;
 
import java.io.*;
 
public class Main{

    public static long Combination(long n, long r){
        long A = 1;
        long B = 1;
        for(long i = 0; i < r; i++){
            A = A*(n-i);
            B = B*(r-i);
        }
        if(A == 0) return 1;
        return A/B;
    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        String N = s.next();
        int K = s.nextInt();
        
        long max = 0;
        if(K > N.length()){
            System.out.println(0);
        }else if(K < N.length){
            for(int i = 0; i < K; i++){
                for(int j = 0; j < Character.getNumericValue(N.charAt(i)); j++){
                    if(j == 0){
                        max = max + (long)(Math.pow(9, (double)(K-i)))*Combination((long)(N.length()-i-1), K-i);
                    }else{
                        max = max + (long)(Math.pow(9, (double)(K-i-1)))*Combination((long)(N.length()-i-1), K-i-1);
                    }
                    
                }
            }
            max++;

            System.out.println(max);
        }else{
            for(int i = 0; i < K; i++){
                for(int j = 0; j < Character.getNumericValue(N.charAt(i)); j++){
                    if(j == 0){
                        
                    }else{
                        max = max + (long)(Math.pow(9, (double)(K-i-1)));
                    }
                    
                }
            }
            max++;

            System.out.println(max);
        }
        
	}
} 

Compiler output:
Main.java:26: error: cannot find symbol
        }else if(K < N.length){
                      ^
  symbol:   variable length
  location: variable N of type String
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;

int n, K, dp[5][105][3];
char str[105];

int dfs(int m, int use, int limit) {
    if(use > K) return 0;
    if(m > n) return use == K;
    if(dp[use][m][limit] != -1) return dp[use][m][limit];
    int up = limit == 1? str[m]-'0':9; ans = 0;
    for(int i = 0; i <= up; ++i)
        ans += dfs(m+1, use+(i!=0), limit&&i==up); 
    return dp[use][m][limit] = ans;
}

void run_case() {
    cin >> (str+1) >> K;
    n = strlen(str+1);
    memset(dp, -1, sizeof(dp));
    cout << dfs(1, 0, 1);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    //cout.setf(ios_base::showpoint);cout.precision(8);
    run_case();
    cout.flush();
    return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:13:40: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |     int up = limit == 1? str[m]-'0':9; ans = 0;
      |                                        ^~~
      |                                        abs
Language: C++

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string S,T,U;
ll K;
string n;
ll N[101];
ll ans;
ll M;
ll dp[105][101];
ll cnt;



int main(){
    cin >> n>>K;
    ll a = n.size();
    for (int i=0;i<a;i++){
        N[i] = n[i] -'0';
    }
    cnt = 0;
    for(int i=0;i<a;i++){
        dp[i][0] = 1;
        for(int j=0;j<=cnt;j++){
            if(cnt<=j){
               dp[i+1][j+1] = dp[i][j+1] +N[i]+(dp[i][j]-1)*9;
            } else {
                dp[i+1][j+1] = dp[i][j+1] + dp[i][j]*9;
            }
        }
        if(N[i]!=0){
            cnt++;
        }
        
    }
    cout << dp[a][K] << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:43:30: error: expected '}' at end of input
   43 |     cout << dp[a][K] << endl;
      |                              ^
a.cc:22:11: note: to match this '{'
   22 | int main(){
      |           ^
Language: C++

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}
int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

#define MAX_ 500000
int inv_list[MAX_]; //inv_list[i-1] = inverse of i
int fac[MAX_];
int finv[MAX_];
void nCk_init() {
  inv_list[0] = fac[0] = finv[0] = 1;
  for (int i = 0; i < MAX_ - 1; i++) {
    inv_list[i + 1] = MOD - ((inv_list[(MOD % (i + 2)) - 1] * (MOD / (i + 2))) % MOD);
    fac[i + 1]      = (fac[i] * (i + 2)) % MOD;
    finv[i + 1]     = (finv[i] * inv_list[i + 1]) % MOD;
  }
}
int nCk(int n, int k) {
  if (n <= k || k <= 0) {
    return 1;
  }
  return (fac[n - 1] * ((finv[k - 1] * finv[n - k - 1]) % MOD)) % MOD;
}

class EAlmostEverywhereZero {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    nCk_init();
    string S;
    int K;
    cin >> S >> K;
    int ans = 0;
    FOR(i, 1, S.size()) {
      if (i >= K)
        ans += nCk(i - 1, K - 1) * bpm(9, K);
    }
    vector<int> product(S.size());
    vector<int> cum_sum(S.size(), 0);
    rep(i, S.size()) {
      product[i] = stoi(string(1, S[i]));
    }
    rep(i, S.size() - 1) {
      cum_sum[i + 1] = product[i + 1];
      cum_sum[i + 1] += cum_sum[i];
    }
    if (K == 1) {
      ans += product[0];
    } else if (K == 2) {
      int i = 0;
      FOR(j, i + 1, S.size()) {
        if (cum_sum[i] != 0 || j == i + 1) {
          ans += 9 * (product[i] - 1) + product[j];
        } else {
          ans += 9 * product[i];
        }
      }
    } else {
      int i = 0;
      FOR(j, i + 1, S.size() - 1) {
        FOR(k, j + 1, S.size()) {
          if (cum_sum[j] != 0 && j != i + 1 && k != j + 1) {
            ans += 81* product[i];
          } else if (cum_sum[j] == 0 && cum_sum[k] != 0 && j != i + 1) {
            ans += (product[i] - 1) * 81 + product[j] * 9;
          } else {
            ans += (product[i] - 1) * 81 + (product[j] - 1) * 9 + product[k];
          }
        }
      }
    }
    cout << ans << endl;
  }
};


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const int MOD = 1e9 + 7;
 
int K;
string N;
ll dp[10005][2][5];
 
int main() {
    cin >> N >> K;
    int n = N.size();
 
    dp[0][0][0] = 1;
 
    REP(i, n) {
        REP(k, K + 1) {
            // i桁目まででNより小さいならi+1桁目は何でも良い
            dp[i + 1][1][k + 1] += dp[i][1][k] * 9;  // i+1桁目が0以外
            dp[i + 1][1][k] += dp[i][1][k];          // i+1桁目が0
 
            int ni = (N[i] - '0');
 
            // i桁目までNと同じで、i+1桁目はNより小さい数の時
            if (ni > 0) {
                dp[i + 1][1][k + 1] += dp[i][0][k] * (ni - 1);  // i+1桁目が0以外
                dp[i + 1][1][k] += dp[i][0][k];                 // i+1桁目が0
            }
 
            //  i桁目までNと同じで、i+1桁目もNと同じ数の時
            if (ni > 0) {
                dp[i + 1][0][k + 1] = dp[i][0][k];  // i+1桁目が0以外
            } else {
                dp[i + 1][0][k] = dp[i][0][k];  // i+1桁目が0
            }
        }
    }
 
    cout << dp[n][0][K] + dp[n][1][K] << endl;
 
    return 0;
}

Compiler output:
a.cc:13:1: error: 'string' does not name a type
   13 | string N;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:17:5: error: 'cin' was not declared in this scope
   17 |     cin >> N >> K;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define LOOP(n) for (int _i = 0; _i < (n); _i++)
a.cc:17:12: error: 'N' was not declared in this scope
   17 |     cin >> N >> K;
      |            ^
a.cc:45:5: error: 'cout' was not declared in this scope
   45 |     cout << dp[n][0][K] + dp[n][1][K] << endl;
      |     ^~~~
a.cc:45:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:45:42: error: 'endl' was not declared in this scope
   45 |     cout << dp[n][0][K] + dp[n][1][K] << endl;
      |                                          ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define LOOP(n) for (int _i = 0; _i < (n); _i++)
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= x;
	if (n % 2 == 1)t *= a;
	return t % x;
}

const int INF = 1001001001;

ll k_1(string s) {
	ll ans = (s.size() - 1) * 9;
	int p = s[0] - '0';
	ans += p;
	return ans;
}

ll k_2(string s) {
	ll n = s.size();
	ll ans = 81 * (n - 1)*(n - 2) / 2;
	int p = s[0] - '0';
	ans += (p - 1)*(n - 1) * 9;
	ans += k_1(s.substr(1));
	return ans;
}

ll k_3(string s) {
	ll n = s.size();
	ll ans = 729 * (n - 1)*(n - 2)*(n - 3) / 6;
	ll p = s[0] - '0';
	ans += (p - 1) * 81 * (n - 1)*(n - 2) / 2;
	ans += k_2(s.substr(1));
	return ans;
}

int main() {
	string s;
	cin >> s;
	ll n = s.size();
	int k;
	cin >> k;
	ll ans;
	if (k == 1) {
		ans = k_1(s);
	}
	else if (k == 2) {
		ans = k_2(s);
	}
	else {
		ans = k_3(s);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'll n_pow(ll, ll)':
a.cc:22:14: error: 'x' was not declared in this scope
   22 |         t %= x;
      |              ^
Language: Java

import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int k = sc.nextInt();
		int digit = n.length();
		int[][][] dp = new int[digit+1][k+1][2];
		dp[0][0][0] = 1;
		for(int i = 1; i <= digit; i++) {
			int x = Character.getNumericValue(n.charAt(i-1));
				for(int j = 0; j <= K; j++) {
					dp[i][j][1] = dp[i-1][j][1];
					if(j > 0)
						dp[i][j][1] += dp[i-1][j-1][1] * 9;
					if(x == 0)
						dp[i][j][0] = dp[i-1][j][0];
					else {
						dp[i][j][1] += dp[i-1][j][0];
						if(j > 0) {
							dp[i][j][0] = dp[i-1][j-1][0];
							dp[i][j][1] += dp[i-1][j-1][0] * (x-1);
						}
					}
				}
		}
		System.out.println(dp[digit][K][0] + dp[digit][K][1]);
 
	}
 
}

Compiler output:
Main.java:15: error: cannot find symbol
				for(int j = 0; j <= K; j++) {
				                    ^
  symbol:   variable K
  location: class Main
Main.java:30: error: cannot find symbol
		System.out.println(dp[digit][K][0] + dp[digit][K][1]);
		                             ^
  symbol:   variable K
  location: class Main
Main.java:30: error: cannot find symbol
		System.out.println(dp[digit][K][0] + dp[digit][K][1]);
		                                               ^
  symbol:   variable K
  location: class Main
3 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
string s;
int K;

  long long com(long long N, long long R) {
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    else if (R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}

long long pow(long long N, long long k) {
    long long res = 1;
    for (int i = 0; i < k; ++i) res *= N;
    return res;
}

long long dfs(int i, int k, int flag){
  if(i == n){
    if(k==0) return 1;
    else return 0;
  }
  if(k==0) return 1;
  
  if(flag)  return com(n-1,k)*pow(9,k);
          
  
  else{
    if(s[i] == '0') return dfs(i+1,k,0);
    
    else{
      long long int ans1 = dfs(i+1,k,1);
      long long int ans2 = dfs(i+1,k-1,1)*((s[i]-'0')-1);
      long long int ans3 = dfs(i+1,k-1,0);
    
      return ans1 + ans2 + ans3;
    }
  }

  
int main(){
  cin >> s;
  int K;cin >> K;
  int n=s.size();
  
  
  cout << dfs(0,K,0) << endl;
}


Compiler output:
a.cc: In function 'long long int dfs(int, int, int)':
a.cc:44:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   44 | int main(){
      |         ^~
a.cc:44:9: note: remove parentheses to default-initialize a variable
   44 | int main(){
      |         ^~
      |         --
a.cc:44:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:44:11: error: a function-definition is not allowed here before '{' token
   44 | int main(){
      |           ^
a.cc:51:2: error: expected '}' at end of input
   51 | }
      |  ^
a.cc:21:38: note: to match this '{'
   21 | long long dfs(int i, int k, int flag){
      |                                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
string s;
int K;


long long dfs(int i, int k, int flag){
  if(i == n){
    if(k==0) return 1;
    else return 0;
  }
  if(k==0) return 1;
  
  if(flag)  return com(n-1,k)*pow(9,k);
          
  
  else{
    if(s[i] == '0') return dfs(i+1,k,0);
    
    else{
      long long int ans1 = dfs(i+1,k,1);
      long long int ans2 = dfs(i+1,k-1,1)*((s[i]-'0')-1);
      long long int ans3 = dfs(i+1,k-1,0);
    
      return ans1 + ans2 + ans3;
    }
  }
  long long com(long long N, long long R) {
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    else if (R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}

long long pow(long long N, long long k) {
    long long res = 1;
    for (int i = 0; i < k; ++i) res *= N;
    return res;
}
  
int main(){
  cin >> s;
  int K;cin >> K;
  int n=s.size();
  
  }
  cout << dfs(0,K,0) << endl;
}


Compiler output:
a.cc: In function 'long long int dfs(int, int, int)':
a.cc:16:20: error: 'com' was not declared in this scope; did you mean 'cos'?
   16 |   if(flag)  return com(n-1,k)*pow(9,k);
      |                    ^~~
      |                    cos
a.cc:30:43: error: a function-definition is not allowed here before '{' token
   30 |   long long com(long long N, long long R) {
      |                                           ^
a.cc:37:41: error: a function-definition is not allowed here before '{' token
   37 | long long pow(long long N, long long k) {
      |                                         ^
a.cc:43:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   43 | int main(){
      |         ^~
a.cc:43:9: note: remove parentheses to default-initialize a variable
   43 | int main(){
      |         ^~
      |         --
a.cc:43:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:43:11: error: a function-definition is not allowed here before '{' token
   43 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[2][][];  /* dp[id][i+1][j] : 先頭からi桁目まででがj個現れるs以下の数の個数。
                                   ただし、id = 0 のとき現時点でsと等しい。
                                   id = 1 のとき現時点でsより小さいことが確定。 */

int main() {
    string s;
    cin >> s;
    ll m = s.size();  // sはm桁とする
    
    dp[0][0][0] = ;
    rep(id, 2) {
        rep(i, m) {
            rep(j, m) {
                ll lim = s[i] - '0';  //  先頭からi桁目にはlim以下の数を置ける
                if(id) {
                    lim = 9;
                }
                exrep(x, 0, lim) {  // 先頭からi桁目にxを置くとする
                    dp[id || x < lim][i+1][j + (x == )] += dp[id][i][j];
                }
            }
        }
    }
    
    

    re0;
}

Compiler output:
a.cc:31:4: error: declaration of 'dp' as multidimensional array must have bounds for all dimensions except the first
   31 | ll dp[2][][];  /* dp[id][i+1][j] : 先頭からi桁目まででがj個現れるs以下の数の個数。
      |    ^~
a.cc: In function 'int main()':
a.cc:40:5: error: 'dp' was not declared in this scope
   40 |     dp[0][0][0] = ;
      |     ^~
a.cc:40:19: error: expected primary-expression before ';' token
   40 |     dp[0][0][0] = ;
      |                   ^
a.cc:49:54: error: expected primary-expression before ')' token
   49 |                     dp[id || x < lim][i+1][j + (x == )] += dp[id][i][j];
      |                                                      ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int dp[105][4][2];

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int K;
	cin >> K;
	dp[0][0][0] = 1;
	rep(i, n)rep(j, 4)rep(k, 2) {
		int tmp = s[i] - '0';
		rep(d, 10) {
			int ni = i + 1, nj = j, nk = k;
			if (d != 0) nj++;
			if (nj > K) continue;
			if (k == 0) {
				if (tmp > d) nk = 1;
				if (tmp < d) continue;
			}
			dp[ni][nj][nk] += dp[i][j][k];
		}
	}
	cout << dp[n][K][0] + dp[n][K][1] << endl;
	return 0;
}

int main() {

	return 0;
}


Compiler output:
a.cc:38:5: error: redefinition of 'int main()'
   38 | int main() {
      |     ^~~~
a.cc:14:5: note: 'int main()' previously defined here
   14 | int main() {
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp


int dp[110][100][2];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
	
    string s; int k;
    cin >> s >> k;
    dp[0][0][0] = 1;
    f(i, s.length()) {
        int tmp = s[i] - '0';
        f(j, 5) {
            f(l, 2) {
                for (int d = 0; d <= (l ? 9 : tmp); ++d) {
                    dp[i + 1][j + (d != 0)][l || (d < tmp)] += dp[i][j][l];
                }
            }
        }
    }
    cout << dp[s.size()][k][0] + dp[s.size()][k][1] << endl;
    

}   








Compiler output:
a.cc:27:20: error: macro "f" requires 3 arguments, but only 2 given
   27 |     f(i, s.length()) {
      |                    ^
a.cc:8:9: note: macro "f" defined here
    8 | #define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
      |         ^
a.cc:29:15: error: macro "f" requires 3 arguments, but only 2 given
   29 |         f(j, 5) {
      |               ^
a.cc:8:9: note: macro "f" defined here
    8 | #define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
      |         ^
a.cc:30:19: error: macro "f" requires 3 arguments, but only 2 given
   30 |             f(l, 2) {
      |                   ^
a.cc:8:9: note: macro "f" defined here
    8 | #define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
      |         ^
a.cc: In function 'int main()':
a.cc:27:5: error: 'f' was not declared in this scope
   27 |     f(i, s.length()) {
      |     ^
Language: C++

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// functions and classes
using Edge = pair<ll, ll>;

ll calc_seq9(ll n, ll k) {
	if (n < k) {
		return 0LL;
	}

	ll res = 1LL;
	for (ll i = 0; i < k; ++i)
	{
		res *= 9LL;
		res *= n - i;
	}
	for (ll i = 0; i < k; ++i)
	{
		res /= i + 1LL;
	}

	return res;
}

ll calc(string& n, ll k, vector<vector<ll>>& dp) {
	if (dp[n.size()][k] != -1) {
		return dp[n.size()][k];
	}
	if (k == 0) {
		return 1LL;
	}
	if (n.size() == 0) {
		return 0LL;
	}
	
	ll top_digit = (ll)(n[0] - '0');
	ll res = 0LL;
	res += calc_seq9(n.size() - 1, k);
	res += calc_seq9(n.size() - 1, k - 1) * (top_digit - 1);
	res += calc(n.substr(1), k - 1, dp);

	dp[n.size()][k] = res;

	return res;
}

//main function
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string N;
	ll K;
	cin >> N >> K;

	vector<vector<ll>> dp(N.size() + 1);
	for (ll i = 0; i < dp.size(); ++i)
	{
		dp[i] = vector<ll>(K + 1, -1LL);
		dp[i][0] = 1LL;
	}

	ll res = 0LL;
	res = calc(N, K, dp);

	cout << res << endl;

	return 0;
}


Compiler output:
a.cc: In function 'll calc(std::string&, ll, std::vector<std::vector<long long int> >&)':
a.cc:86:29: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
   86 |         res += calc(n.substr(1), k - 1, dp);
      |                     ~~~~~~~~^~~
a.cc:71:17: note:   initializing argument 1 of 'll calc(std::string&, ll, std::vector<std::vector<long long int> >&)'
   71 | ll calc(string& n, ll k, vector<vector<ll>>& dp) {
      |         ~~~~~~~~^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define s(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  ll k;
  cin>>s>>k;
  ll n=sz(s);
  vector<vvll> dp(105,vvll(4,vll(2)));
  dp[0][0][0]=1;
  rep(i,n)rep(j,4)rep(u,2){
    ll nd=s[i]-'0';
    rep(d,10){
      ll ni=i+1,nj=j,nu=u;
      if(u==0){
        if(d>nd) continue;
        if(d<nd) nu=1;
      }
      if(d!=0) nj++;
      if(nj>k) continue;
      dp[ni][nj][nu]+=dp[i][j][u];
    }
  }
  COUT(dp[n][k][1]+dp[n][k][0]);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:8: error: 'sz' was not declared in this scope; did you mean 's'?
   53 |   ll n=sz(s);
      |        ^~
      |        s
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define s(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  ll k;
  cin>>s>>k;
  ll n=sz(s));
  vector<vvll> dp(105,vvll(4,vll(2)));
  dp[0][0][0]=1;
  rep(i,n)rep(j,4)rep(u,2){
    ll nd=s[i]-'0';
    rep(d,10){
      ll ni=i+1,nj=j,nu=u;
      if(u==0){
        if(d>nd) continue;
        if(d<nd) nu=1;
      }
      if(d!=0) nj++;
      if(nj>k) continue;
      dp[ni][nj][nu]+=dp[i][j][u];
    }
  }
  COUT(dp[n][k][1]+dp[n][k][0]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:8: error: 'sz' was not declared in this scope; did you mean 's'?
   53 |   ll n=sz(s));
      |        ^~
      |        s
Language: C++

#include<bits/stdc++.h>
using namespace std;

using i32 = int_fast32_t;
using i64 = int_fast64_t;

string n;
i32 k;

i64 com(i64 m, i64 r) {
    if (r < 0 || r > m) return 0;
    if (r == 0) return 1;
    return m * com(m-1, r-1) / r;
}

i64 solve(i32 i, i32 j, bool less) {
    if (j == 0) return 1;
    if (i == n.size()) return 0;

    if (less) return com(l-i, j) * pow(9, j);
    if (n[i] == '0') return solve(i+1, j, false);
    return solve(i+1, j, true) + solve(i+1, j-1, true) * (n[i] - '1') + solve(i+1, j-1, false);
}

int main() {
    cin >> n;
    cin >> k;

    cout << solve(0, k, false) << endl;
}


Compiler output:
a.cc: In function 'i64 solve(i32, i32, bool)':
a.cc:20:26: error: 'l' was not declared in this scope
   20 |     if (less) return com(l-i, j) * pow(9, j);
      |                          ^
Language: Java

#include <bits/stdc++.h>
using namespace std;

string n;
int k;

int comb(int n, int k) {
	int rv = 1;
	for (int i = 0; i < k; i++)
		rv *= n--;
	while (k)
		rv /= k--;
	return rv;
}

int g(int free, int k) {
	return comb(free, k) * pow(9, k);
}

int f(string n, int k) {
	if (k == 0)
		return 1;
	if (n.size() < k)
		return 0;
	int init = n[0] - '0';
	if (init) {
		return f(n.substr(1), k - 1) + (init - 1) * g(n.size() - 1, k - 1)
				+ g(n.size() - 1, k);
	}
	return f(n.substr(1), k);
}

int main() {
	cin >> n >> k;
	cout << f(n, k) << endl;

}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:4: error: unnamed classes are a preview feature and are disabled by default.
string n;
^
  (use --enable-preview to enable unnamed classes)
Main.java:34: error: not a statement
	cin >> n >> k;
	         ^
Main.java:35: error: not a statement
	cout << f(n, k) << endl;
	                ^
5 errors
Language: C++

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

typedef long long LL;

const int N = 200010;

int k;

int C(int a, int b)
{
    int up = 1, down = 1;
    for(int i = a, j = b; j; i --, j --)
        up *= i, down *= j;
    return up / down;
}

int main()
{
    string s;
    cin >> s >> k;
    
    vector<int> nums;
    for(int i = s.size() - 1; i >= 0; i --)  nums.push_back(s[i] - '0');
    
    LL res = 0, last = 0;
    for(int i = nums.size() - 1; i >= 0; i --)
    {
        //printf("%d\n", nums[i]);
        if(nums[i] > 0)
        {
            LL x = C(i, k - last);      //  当前位置0
            for(int j = 0; j < k - last; j ++)  x *= 9;
            res += x;
            
            x = C(i, k - last - 1);     //  当前位置[1, nums[i] - 1]
            for(int j = 0; j < k - last - 1; j ++)  x *= 9;
            x *= nums[i] - 1;
            res += x;
            
            last ++;
            if(last >= k)
            {
                res ++;
                break;
            }
        }
    }
    printf("%lld", res);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:5: error: 'vector' was not declared in this scope
   27 |     vector<int> nums;
      |     ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include<cstdio>
  +++ |+#include <vector>
    5 | 
a.cc:27:12: error: expected primary-expression before 'int'
   27 |     vector<int> nums;
      |            ^~~
a.cc:28:46: error: 'nums' was not declared in this scope
   28 |     for(int i = s.size() - 1; i >= 0; i --)  nums.push_back(s[i] - '0');
      |                                              ^~~~
a.cc:31:17: error: 'nums' was not declared in this scope
   31 |     for(int i = nums.size() - 1; i >= 0; i --)
      |                 ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 桁DP

int dp[105][4][2];
/*
    dp[i][j][k] := iけためまで決めて、j個の非0を使って、
    k==0: そこまでの桁はnと一緒
    k==1: そこまでの桁はすでにn以下であることが確定
*/

int main(){
    string s;
     cin >> s;
     int n = s.size();
     int K;
     cin >> K;
     dp[0][0][0] = 1;
     rep(i, n)rep(j, 4)rep(k, 2){
         int nd = s[i] - '0';
         rep(d, 10){
             int ni = i+1, nj = j, nk = k;
             if (d!=0) nj++;
             if (nj>K) continue;
             if (k==0) {
                 if (d > nd) continue;
                 if (d < nd) nk = 1;
             }
             dp[ni][nj][nk] += dp[i][j][k]
         }
     }
     int ans = dp[n][K][0] + dp[n][K][1];
     cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:43: error: expected ';' before '}' token
   41 |              dp[ni][nj][nk] += dp[i][j][k]
      |                                           ^
      |                                           ;
   42 |          }
      |          ~
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	string n;
	cin >> n;
	int k;
	cin >> k;

	vector<vector<unsigned long long>> dp(2, vector<unsigned long long>(3, 0));
	{
		int i = n[0] - '0';
		dp[0][0] = 1;
		dp[1][0] = i - 1;
	}

	for (size_t i = 1; i < n.size(); ++i)
	{
		vector<vector<long long>> dpcpy = dp;
		int j = n[i] - '0';
		if (0 < j) {
			dp[0][0] -= dpcpy[0][0];
			dp[0][1] -= dpcpy[0][1];
			dp[0][1] += dpcpy[0][0];
			dp[0][2] -= dpcpy[0][2];
			dp[0][2] += dpcpy[0][1];

			dp[1][0] = 9 + dpcpy[0][0] + dpcpy[1][0];
			dp[1][1] = dpcpy[0][0] * (j - 1) + dpcpy[1][0] * 9 + dpcpy[0][1] + dpcpy[1][1];
			dp[1][2] = dpcpy[0][2] + dpcpy[0][1] * (j - 1) + dpcpy[1][1] * 9 + dpcpy[1][2];
		}
		else {
			dp[0][0] = dpcpy[0][0];
			dp[0][1] = dpcpy[0][1];
			dp[0][2] = dpcpy[0][2];

			dp[1][0] = 9 + dpcpy[1][0];
			dp[1][1] = dpcpy[1][1];
			dp[1][2] = dpcpy[1][2];
		}
	}

	cout << dp[0][k - 1] + dp[1][k - 1] << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:51: error: conversion from 'vector<vector<long long unsigned int>>' to non-scalar type 'vector<vector<long long int>>' requested
   22 |                 vector<vector<long long>> dpcpy = dp;
      |                                                   ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

const int MAX_DIGIT = 100;
long long dp[200][2][5];

int main() {
  string n;
  int k;
  cin >> n >> k;

  dp[0][0][0] = 1;

  rep(i, n.length()) {
    rep(j, 2) {
      rep(t, k + 1) {
        int c = n[i] - '0';  // i桁目
        rep(now, 10) {
          if (c < now && j == 0) continue;  // n以下でない場合は除く
          int jj = j;
          int tt = t;
          if (now != 0) tt++;
          if (now < c) jj = 1;  //これ以降は絶対に小さくなる
          dp[i + 1][jj][tt] += dp[i][j][t];　
        }
      }
    }
  }
  ll ans = dp[n.length()][0][k] + dp[n.length()][1][k];
  cout << ans << endl;
}

Compiler output:
a.cc:31:44: error: extended character 　 is not valid in an identifier
   31 |           dp[i + 1][jj][tt] += dp[i][j][t];　
      |                                            ^
a.cc: In function 'int main()':
a.cc:31:44: error: '\U00003000' was not declared in this scope
   31 |           dp[i + 1][jj][tt] += dp[i][j][t];　
      |                                            ^~
Language: Java

import java.util.*;
import java.math.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int k = sc.nextInt();
    int n = s.length();
    int[][] f = new int[n][k];
    f[0][0] = 9;
    for(int i = 0; i < k; ++i) {
      for(int j = i; j < n; ++j) {
        int a = 1;
        int b = 1;
        for(int m = 0; m < k; ++m) {
          a *= i - m;
          b *= m + 1;
        }
        f[i][j] = a / b * 9 * (i + 1);
      }
    }
    int res = a[n - 1] - '0';
    char[] a = s.toCharArray();
    for(int i = n - 2; i > -1; ++i) {
      if(a[i] - '0' == 0) continue;
      res += (a[i] - '1') * f[n - i][k] + (a[i] - '1');
    }
    System.out.println(res);
  }
}

Compiler output:
Main.java:23: error: cannot find symbol
    int res = a[n - 1] - '0';
              ^
  symbol:   variable a
  location: class Main
1 error
Language: C++

#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
    string s;
    int K;
    cin >> s >> K;
    int N = s.size();
    int dp[N + 1][2][K + 5];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    for (int i = 0; i < N;i++){
        for (int j = 0; j < 2;j++){
            for (int k = 0; k < K + 1;k++){
                int t = j ? 9 : s[i] - '0';
                for (int l = 0; l < t + 1;l++){
                    dp[i + 1][j || l < t][k + (d != 0)] += dp[i][j][k];
                }
            }
        }
    }
    cout << dp[N][0][K] + dp[N][1][K] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'memset' was not declared in this scope
   13 |     memset(dp, 0, sizeof(dp));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | #include <string>
a.cc:21:48: error: 'd' was not declared in this scope
   21 |                     dp[i + 1][j || l < t][k + (d != 0)] += dp[i][j][k];
      |                                                ^
Language: C++

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s;
    int k;
    cin>>s>>k;
    int dp[200][4];
    rep(i,200){
        rep(j,4){
            dp[i][j]=0;
        }
    }
    int n=s.size();
    dp[0][0]=9;
    dp[0][1]=1;
    dp[0][2]=0;
    dp[0][3]=0;
    rep(i,200){
        rep(j,4){
            if(j<=2){
                dp[i+1][j]=dp[i][j]
            }
            if(j==3){
                
            }
        }
    }

    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:36: error: expected ';' before '}' token
   58 |                 dp[i+1][j]=dp[i][j]
      |                                    ^
      |                                    ;
   59 |             }
      |             ~
Language: C++

#include <iostream>
#include <string>
using namespace std;


#define REP(var, init, num) for(int var = init ; var < num; var ++)

int main(){
    string n;
    int k;

    cin >> n;
    cin >> k;

    int dig = n.size();
    int dp0[dig+1][k+2];
    int dp1[dig+1][k+2];
    
    memset(dp0, 0, sizeof(int)*(dig+1)*(k+2));
    memset(dp1, 0, sizeof(int)*(dig+1)*(k+2));
    dp1[0][0] = 1;

    for(int i=1; i<=dig; i++){
        int hi = stoi(n.substr(i-1,1));

        for(int j=0; j<=9; j++){
                if(j < hi){
                    if(j == 0){
                        REP(jj, 0, k+2) {
                            dp0[i][jj] += dp0[i-1][jj];
                            dp0[i][jj] += dp1[i-1][jj];
                        }
                    }else{
                        REP(jj, 0, k){
                            dp0[i][jj+1] += dp0[i-1][jj];
                            dp0[i][jj+1] += dp1[i-1][jj];
                        }
                        dp0[i][k+1] += dp0[i-1][k+1];
                        dp0[i][k+1] += dp1[i-1][k+1];
                    }
                }else if(j == hi){
                    if(j == 0){
                        REP(jj, 0, k+2) {
                            dp0[i][jj] += dp0[i-1][jj];
                            dp1[i][jj] += dp1[i-1][jj];
                        }
                    }else{
                        REP(jj, 0, k){
                            dp0[i][jj+1] += dp0[i-1][jj];
                            dp1[i][jj+1] += dp1[i-1][jj];
                        }
                        dp0[i][k+1] += dp0[i-1][k+1];
                        dp1[i][k+1] += dp1[i-1][k+1];
                    }
                }else{
                    REP(jj, 0, k) {
                        dp0[i][jj+1] += dp0[i-1][jj];
                    }
                    dp0[i][k+1] += dp0[i-1][k+1];
                }
            
        }
    }

    cout << (dp0[dig][k] + dp1[dig][k]) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'memset' was not declared in this scope
   19 |     memset(dp0, 0, sizeof(int)*(dig+1)*(k+2));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
ll dp1[101][4];
ll dp2[101][4];
int main() {
    int K;
    strign N;
    cin >> N >> K;
    // cout << "wo" << endl;
    int keta = N.length();
    // cout << keta << endl;
    // vector<vector<ll>> dp1(keta, vector<ll>(K + 1, 0LL));
    // vector<vector<ll>> dp2(keta, vector<ll>(K + 1, 0LL));
    // cout << "memory allocated" << endl;
    // dp1 inactive
    // dp2 active
    dp1[0][0] = 1LL;
    // cout << "e" << endl;
    dp1[0][1] = N[0] - '0' - 1;
    // cout << dp1[0][1] << endl;
    dp2[0][1] = 1;
    dp2[0][0] = 0;
    for(int i = 1; i < keta; i++) {
        for(int j = 0; j <= K; j++) {
            // jは0出ない数
            if(j == 0) {
                dp1[i][j] = dp1[i - 1][j];
            } else {
                dp1[i][j] = 9 * dp1[i - 1][j - 1] + dp1[i - 1][j];
                if(N[i] != '0') {
                    dp1[i][j] +=
                        (N[i] - '0' - 1) * dp2[i - 1][j - 1] + dp2[i - 1][j];
                }
                if(j != 0) {
                    if(N[i] == '0') {
                        dp2[i][j] = dp2[i - 1][j];
                    } else {
                        dp2[i][j] = dp2[i - 1][j - 1];
                    }
                }
            }
        }
    }
    // cout << dp2[keta - 1][K] << " : " << dp1[keta - 1][K] << endl;
    cout << dp2[keta - 1][K] + dp1[keta - 1][K] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:5: error: 'strign' was not declared in this scope; did you mean 'strspn'?
   34 |     strign N;
      |     ^~~~~~
      |     strspn
a.cc:35:12: error: 'N' was not declared in this scope
   35 |     cin >> N >> K;
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	//DP
	string N;
	int K;
	cin >> N >> K;
	vector<vector<long long>> dp(N.size(),vector<long long>(K+2));//((0-indexedで)N桁目,ゼロ以外の数(0~KのK+1通り))
	dp.at(0).at(1) = (N.at(0) - '0');//
	dp.at(0).at(0) = 1;//仮処分
	for (size_t i = 1; i < N.size(); i++)
	{
		for (size_t j = 0; j <= K; j++)
		{
			dp.at(i).at(j) += dp.at(i - 1).at(j);//0を足す
			dp.at(i).at(j + 1) += dp.at(i - 1).at(j) * 9;//1~9を足す
			if (i==j) {
				//(0以外)==(桁数)の場合はNを超えるのが怖い
				//cout << dp.at(i).at(j + 1);
				dp.at(i).at(j+1)-= (9LL - long long(N.at(i) - '0'));
				//cout << dp.at(i).at(j + 1);
				//cout << i;
			}

		}
	}
	cout << dp.at(N.size()-1).at(K);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:59: error: expected primary-expression before 'long'
   20 |                                 dp.at(i).at(j+1)-= (9LL - long long(N.at(i) - '0'));
      |                                                           ^~~~
a.cc:20:58: error: expected ')' before 'long'
   20 |                                 dp.at(i).at(j+1)-= (9LL - long long(N.at(i) - '0'));
      |                                                    ~     ^~~~~
      |                                                          )
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin>>s;
    int K;
    cin>>K;
    int dp[105][11][2];
    for(int i=0;i<s.size();++i){
        int D=s[i]-'0';
        for(int j=0;j<4;++j){
            for(int k=0;k<2;++k){
                for(int d=0;d<10;++d){
                    int ni=i+1,nj=j,nk=k;
                    if(d!=0)nj++;
                    if(nj>K)continue;
                    if(k==0){
                        if(d>D)continue;
                        if(d<D)nk=1;
                    }
                    dp[ni][nj][nk]+=dp[i][j][k];    
                }

            }
        }
    }
    int ans=dp[n][K][0]+dp[n][K][1];
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: 'n' was not declared in this scope
   30 |     int ans=dp[n][K][0]+dp[n][K][1];
      |                ^