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

#include <iostream>
#include <string>

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:5:5: error: 'string' was not declared in this scope
    5 |     string s;
      |     ^~~~~~
a.cc:5:5: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:6:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |     cin>>s;
      |     ^~~
      |     std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:6:10: error: 's' was not declared in this scope
    6 |     cin>>s;
      |          ^
a.cc:28:16: error: 'n' was not declared in this scope
   28 |     int ans=dp[n][K][0]+dp[n][K][1];
      |                ^
a.cc:29:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |     cout<<ans<<endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:29:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   29 |     cout<<ans<<endl;
      |                ^~~~
      |                std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

n = int(input())
k = int(input())
number = []
while n:
    number.append(n%10)
    n//=10

from math import factorial
def comb(n,k):
    if n>=k:
        return int(factorial(n)/(factorial(k)*factorial(n-k)))
    else:
        return 0


t = len(number)
t1 = len(number) - 1
#if t>k:
   # ans = (9**k)*comb(t1,k) + (9**(k-1))*(number[t1]-1)*comb(t1,k-1)
#else:
 #   ans = (9**(k-1))*(number[t1]-1)*comb(t1,k-1)



ans = 0
def calc(a,k):
    t = len(a)
    t1 = len(a) - 1
    if k<1:
        return 0
    else:
        if a[t1]>0: #and t>1:
            ans = (9**k)*comb(t1,k) + (9**(k-1))*(a[t1]-1)*comb(t1,k-1)
        #elif a[t1]>0 and t==1:
           # ans = a[t1]
        else:
            ans = 0
        ans+=calc(a[:(t-1)],k-1)
        return ans
ans += calc(number,k)
if ans>0:
    if number[-k]>=1:
        print(ans+1)
    else:
        print(ans)
else:
    print(0)

Compiler output:
a.cc:18:8: error:  ':' without preceding '?'
   18 | #if t>k:
      |        ^
a.cc:20:6: warning: extra tokens at end of #else directive [-Wendif-labels]
   20 | #else:
      |      ^
a.cc:21:6: error: invalid preprocessing directive #ans
   21 |  #   ans = (9**(k-1))*(number[t1]-1)*comb(t1,k-1)
      |      ^~~
a.cc:32:21: error: stray '#' in program
   32 |         if a[t1]>0: #and t>1:
      |                     ^
a.cc:34:10: error: #elif after #else
   34 |         #elif a[t1]>0 and t==1:
      |          ^~~~
a.cc:18: error: the conditional began here
   18 | #if t>k:
a.cc:18: error: unterminated #elif
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

import math
import pprint
#N以下の0以外のK種類の数が含まれている数字列
N = int(input())
K = int(input())


N_d = int(math.log10(N))


def N_n(n):
    return int(N//(10**(n))%(10))

dp = [[[-1]*2 for i in range(K+2)] for i in range(int(math.log10(N))+2)]




def rec(i,j,t):
    if j < 0 :
        return 0

    if dp[i][j][t]!=-1:
        return dp[i][j][t]
    
    nnn = N_n(i)
    #print("start",i,j,t, nnn)
    if i == 0:
        if j == 0:
            dp[i][j][t] = 1
        elif j == 1:
            if t:
                dp[i][j][t] = nnn
            else:
                dp[i][j][t] = 9
        else:
            dp[i][j][t] = 0
    else:
        if t:
            if nnn==0:
                dp[i][j][t] = rec(i-1,j,True)
            else:
                dp[i][j][t] = rec(i-1,j,False) + (rec(i-1,j-1,False) * (nnn-1)) + (rec(i-1,j-1,True))
        else:
            dp[i][j][t] = rec(i-1,j,False) + (rec(i-1,j-1,False) * 9)
    return dp[i][j][t]

print(rec(N_d,K,True))
#pprint.pprint(dp)

Compiler output:
a.cc:3:2: error: invalid preprocessing directive #N\U00004ee5\U00004e0b\U0000306e0\U00004ee5\U00005916\U0000306eK\U00007a2e\U0000985e\U0000306e\U00006570\U0000304c\U0000542b\U0000307e\U0000308c\U00003066\U00003044\U0000308b\U00006570\U00005b57\U00005217
    3 | #N以下の0以外のK種類の数が含まれている数字列
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:27:6: error: invalid preprocessing directive #print
   27 |     #print("start",i,j,t, nnn)
      |      ^~~~~
a.cc:49:2: error: invalid preprocessing directive #pprint
   49 | #pprint.pprint(dp)
      |  ^~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import math
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: Java

import java.util.*;
class Main{
    void main(){
        Scanner in = new Scanner(System.in);
        long n = in.nextLong(), d = in.nextLong();
        int s = 0;
        for(long i = 1 ; i < n ; i++){
            int c=0;String cs = Integer.toString(i);
            for(int j = 0; j < cs.length(); j++)
              if(cs.charAt(j)!='0')
                c++;
            if(c==d)
              s++;
        }
        System.out.println(s);
    }
}

Compiler output:
Main.java:8: error: incompatible types: possible lossy conversion from long to int
            int c=0;String cs = Integer.toString(i);
                                                 ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: C++

#include <iostream>
#include <cmath>

int d(int,int);

int main(void){
  int N,K;
  std::cin >> N;
  std::cin >> K;
  int ans = d(N,K);
  //最初の頭が０
  int n = (int)std::log10(N);
  ans = ans + BC(n-1,K)*std::pow(9,K);
  std::cout << ans << std::endl; 
  return 0;
}

int d(int N,int K){
  if(K!=0){
    // 桁数を求める
    int n = (int)std::log10(N);
    // 最上位の数
    int Xn = (int)(N/std::pow(10,n));
    // あまりの数
    int remain = N - Xn * std::pow(10,n);
    return (Xn-1)*BC(n-1,K-1)*std::pow(9,K-1) + d(remain,K-1);
  }else{
    return 0;
  }
  return 0;
}

int BC(int n, int k) {
   if (k == 0 || k == n){
   	  return 1;
   }
   return BC(n - 1, k - 1) + BC(n - 1, k);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:15: error: 'BC' was not declared in this scope
   13 |   ans = ans + BC(n-1,K)*std::pow(9,K);
      |               ^~
a.cc: In function 'int d(int, int)':
a.cc:26:19: error: 'BC' was not declared in this scope
   26 |     return (Xn-1)*BC(n-1,K-1)*std::pow(9,K-1) + d(remain,K-1);
      |                   ^~
Language: C++

#include <iostream>
#include <cmath>

int d(int,int);

int main(void){
  int N,K;
  std::cin >> N;
  std::cin >> K;
  int ans = d(N,K);
  std::cout << ans << std::endl; 
  return 0;
}

int d(int N,int K){
  if(K!=0){
    // 桁数を求める
    int n = (int)std::log10(N);
    // 最上位の数
    int Xn = (int)(N/std::pow(10,n));
    // あまりの数
    int remain = N - Xn * std::pow(10,n);
    return (Xn-1)*BC(n-1,K-1)*std::pow(9,K-1) + d(remain,K-1);
  }else{
    return 0;
  }
  return 0;
}

int BC(int n, int k) {
   if (k == 0 || k == n){
   	  return 1;
   }
   return BC(n - 1, k - 1) + BC(n - 1, k);
}


Compiler output:
a.cc: In function 'int d(int, int)':
a.cc:23:19: error: 'BC' was not declared in this scope
   23 |     return (Xn-1)*BC(n-1,K-1)*std::pow(9,K-1) + d(remain,K-1);
      |                   ^~
Language: C++

#include <iostream>
#include <cmath>

int d(int,int);

int main(void){
  int N,K;
  std::cin >> N;
  std::cin >> K;
  int ans = d(N,K);
  std::cout << ans << std::endl; 
  return 0;
}

int d(int N,int K){
  if(K!=0){
    // 桁数を求める
    int n = (int)std::log10(N);
    // 最上位の数
    int Xn = (int)(N/std::pow(10,n));
    // あまりの数
    int remain = N - Xn * std::pow(10,n);
    return (Xn-1)*BC(n-1,K-1)*std::pow(9,K-1) + d(remain,K-1);
  }else{
    return 0;
  }
  return 0;
}

int BC(int n, int k) {
   if (k == 0 || k == n)
   	  return 1;
   }
   return BC(n - 1, k - 1) + BC(n - 1, k);
}

Compiler output:
a.cc: In function 'int d(int, int)':
a.cc:23:19: error: 'BC' was not declared in this scope
   23 |     return (Xn-1)*BC(n-1,K-1)*std::pow(9,K-1) + d(remain,K-1);
      |                   ^~
a.cc: At global scope:
a.cc:34:4: error: expected unqualified-id before 'return'
   34 |    return BC(n - 1, k - 1) + BC(n - 1, k);
      |    ^~~~~~
a.cc:35:1: error: expected declaration before '}' token
   35 | }
      | ^
a.cc: In function 'int BC(int, int)':
a.cc:33:4: warning: control reaches end of non-void function [-Wreturn-type]
   33 |    }
      |    ^
Language: C++

#include<bits/stdc++.h>
int chin(char a) {
  int ic[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  for (int i = 0; i < 10; i ++) {
    if (ic[i] == a) return i;
  }
  return 10;
}
using namespace std;
int main () {
  long long key[4][103];
  key[1][0] = key[2][0] = key[3][0] = 0;
  key[1][1] = 9LL;
  key[2][1] = key[3][1] = 0LL;
  for (int i = 1; i < 100; i ++) {
    key[1][i + 1] = key[1][i] + 9;
    key[2][i + 1] = key[2][i] + key[1][i] * 9;
    key[3][i + 1] = key[3][i] + key[2][i] * 9;
  }
  string N;
  cin >> N;
  int k;
  cin >> k;
  long long ans = key[k][N.size() - 1];
  if (N.size < k) {
    cout << 0 << endl;
    return 0;
  }
  if (k == 1) {
    ans += (long long)ic[N[0]];
    cout << ans << endl;
  }
  if (k == 2) {
    ans += (long long) (ic[N[0]] - 1) * (N.size() - 1) * 9;
    int k = 1;
    while(N[k] == '0' && k < N.size()) k ++;
    if (N.size() < k) cout << ans << endl;
    else {
      ans += (long long)ic(N[k]);
      ans += (long long) 9 * (N.size() - k - 1);
      cout << ans << endl;
    }
  }
  if (k == 3) {
    long long ol = (long long) (ic[N[0]] - 1) * (N.size() - 1) * 
      (N.size() - 2) * 81;
    ol /= 2;
    ans += ol;
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   25 |   if (N.size < k) {
      |       ~~^~~~
      |             ()
a.cc:30:23: error: 'ic' was not declared in this scope
   30 |     ans += (long long)ic[N[0]];
      |                       ^~
a.cc:34:25: error: 'ic' was not declared in this scope
   34 |     ans += (long long) (ic[N[0]] - 1) * (N.size() - 1) * 9;
      |                         ^~
a.cc:45:33: error: 'ic' was not declared in this scope
   45 |     long long ol = (long long) (ic[N[0]] - 1) * (N.size() - 1) *
      |                                 ^~
a.cc:48:15: error: expected '}' at end of input
   48 |     ans += ol;
      |               ^
a.cc:44:15: note: to match this '{'
   44 |   if (k == 3) {
      |               ^
a.cc:48:15: error: expected '}' at end of input
   48 |     ans += ol;
      |               ^
a.cc:10:13: note: to match this '{'
   10 | int main () {
      |             ^
Language: C++

#include <stdio.h>
#include <map>
#pragma warning(disable : 4996)
#pragma warning(disable : 4996)

#define N_MAX 100
#define K_MAX 3

// [k桁目][N以下確定?]
int DP[N_MAX][2][K_MAX+1];

int min(int a, int b) {
	if (a < b) return a;
	return b;
}

int main(void) {
	char N[N_MAX + 1];
	scanf("%s", &N[0]);
	int K;
	scanf("%d", &K);
	int len = strlen(N);
	{
		int d = N[0] - '0';
		for (int j = 0; j <= d; ++j) {
			bool lt = j < d;
			if (j != 0) {
				DP[0][lt ? 1 : 0][1] += 1;
			}
			else {
				DP[0][lt ? 1 : 0][0] += 1;
			}
		}
	}
	for (int i = 1; i < len; ++i) {
		int d = N[i] - '0';
		for (int lt = 0; lt < 2; ++lt) {
			for (int j = 0; j <= ((lt == 1) ? 9 : d); ++j) {
				bool nlt = (lt == 1) || (j < d);
				if (j != 0) {
					for (int c = 0; c < 3; ++c) {
						DP[i][nlt ? 1 : 0][c+1] += DP[i - 1][lt][c];
					}
				}
				else {
					for (int c = 0; c < 4; ++c) {
						DP[i][nlt ? 1 : 0][c] += DP[i - 1][lt][c];
					}
				}
			}
		}
	}
	printf("%d\n", DP[len-1][0][K]+ DP[len - 1][1][K]);
	return 0;
}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: 'strlen' was not declared in this scope
   22 |         int len = strlen(N);
      |                   ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <map>
  +++ |+#include <cstring>
    3 | #pragma warning(disable : 4996)
Language: Java

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        static int N = 101;
        static int K;
        static int dp = new int[N][N][2];

        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String number = in.next(); // n
            K = in.nextInt(); // number of non-0 digits in a number
            init_dp();
            int digits[] = getDigitsFrom(number);
            out.print(digitOcc(0, 0, true, digits));
        }

        static int digitOcc(int index, int count, boolean tight, int digits[])
        {
            if (count > K) return 0; // fails condition
            if (index == digits.length) return count == K ? 1 : 0; // out of boundary
            int answer = dp[index][count][boolToInt(tight)];
            if (answer >= 0) return answer;

            answer = 0;
            for (int i = 0; i < 10; ++i)
            {
                if (tight && (i > digits[index])) break; // forming too big number
                boolean nextTight = tight && (i == digits[index]);
                int nextCount = count + (i > 0 ? 1 : 0);
                answer += digitOcc(index + 1, nextCount, nextTight, digits);
            }
            dp[index][count][boolToInt(tight)] = answer;
            return answer;
        }

        private int[] getDigitsFrom(String number)
        {
            int[] digits = new int[number.length()];
            int i = 0;
            for (char digit : number.toCharArray())
            {
                digits[i] = digit - '0';
                i++;
            }
            return digits;
        }

        static int boolToInt(boolean b)
        {
            return b ? 1 : 0;
        }

        static void init_dp()
        {
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        dp[i][j][k] = -1;
                    }
                }
            }
        }

    }
}



Compiler output:
Main.java:28: error: incompatible types: int[][][] cannot be converted to int
        static int dp = new int[N][N][2];
                        ^
Main.java:43: error: array required, but int found
            int answer = dp[index][count][boolToInt(tight)];
                           ^
Main.java:54: error: array required, but int found
            dp[index][count][boolToInt(tight)] = answer;
              ^
Main.java:83: error: array required, but int found
                        dp[i][j][k] = -1;
                          ^
4 errors
Language: Java

package com.kesarling.atCoder;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N = Long.parseLong(scanner.nextLine());
        long K = Long.parseLong(scanner.nextLine());
        System.out.prlongln(numbersWithKNonZeroDigits(K,N));
    }

    private static long numbersWithKNonZeroDigits(long K, long N) {
        long count = 0;
        for (long i = 0; i <= N; i++) {
            long num = i;
            long nonZeroDigits = 0;
            while (num != 0) {
                if (num % 10 != 0) {
                    nonZeroDigits++;
                }
                num = num / 10;
            }
            if (nonZeroDigits == K) {
                count++;
            }
        }
        return count;
    }

}


Compiler output:
Main.java:11: error: cannot find symbol
        System.out.prlongln(numbersWithKNonZeroDigits(K,N));
                  ^
  symbol:   method prlongln(long)
  location: variable out of type PrintStream
1 error
Language: C++

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define MOD 1000000007

int gcd(int a, int b){
    if( a < b){
        swap(a,b);
    }
    return (a % b == 0)? b:gcd(a, a%b);
}

int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}

ll combination(int parent, int choice){
    if( choice == 0 ){
        return 1;
    }

    ll ans = 1;

    repn(i,1,choice+1){
        ans *= parent + 1 - i;
        ans /= i;
    }

    return ans;
} 

long long solve(string target, int depth){
    ll ans = 1;
    int length = target.length();
    rep(i,length){
        if( depth < 0 ) break;
        int target_decimal = target.at(i) - '0';
        if( target_decimal > 0 ){
            target_decimal--;
            ans += target_decimal * combination(length - i - 1, depth) * pow(9, depth);
            repn(j,i+1,length){
                ans += 9 * combination(length - j - 1, depth) * pow(9, depth);
            }
            depth--;
        }
    }

    return ans;
}

int main(){
    string s;
    int k;
    cin >> s >> k;
    cout << solve(s, k-1) << endl;

}

Compiler output:
a.cc: In function 'long long int solve(std::string, int)':
a.cc:51:74: error: 'pow' was not declared in this scope
   51 |             ans += target_decimal * combination(length - i - 1, depth) * pow(9, depth);
      |                                                                          ^~~
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
const int MX=4e5+7;
const int mod=9901;
using namespace std;
int p[MX],k[MX];
ll qpow(ll a,ll b,ll MOD=mod){for(ll ans=1;;a=a*a%MOD,b>>=1){if(b&1)ans=ans*a%MOD;if(!b)return ans;}}
ll inv(ll a,ll MOD=mod){return qpow(a,MOD-2,MOD);}
ll __gcm(ll a,ll b){return a*b/__gcd(a,b);}
map<string,int>mp;
int a[MX];
ll __C(ll n,ll m)
{
    if(n<m)return 0;
    if(m==1)return 9*n;
    else {
        return 9*9*n*(n-1)/2;
    }
}
int __get(int n,int m,int k)
{
    if(k==0)return m;
    return m*__C(n,k);
}
int main()
{
  ios::sync_with_stdio(0),cin.tie(0);
  string s;
  int k;
  cin>>s>>k;
  int g=k;
  ll sum=0,res=0;
  int n=s.length();
  if(res==k)sum++;
  for(int i=0;i<n-1;i++）sum+=__get(i,9,k-1);
  for(int i=0;i<n;i++)
  {
      if(k){
       if(s[i]-'0'>0)
        sum+=__get(n-i-1,s[i]-'0'-1,k-1);
        if(i>0&&s[i]-'0'>0)
        {
            sum+=__get(n-i-1,1,k);
            if(s[i]-'0'>0)k--;
      }
  }
  int ant=0;
  for(int i=0;i<n;i++)if(s[i]-'0'>0)ant++;
  if(ant>=g)sum++;
  cout<<sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:24: error: expected ')' before '\U0000ff09sum'
   38 |   for(int i=0;i<n-1;i++）sum+=__get(i,9,k-1);
      |      ~                 ^~~~~
      |                        )
a.cc:38:24: error: '\U0000ff09sum' was not declared in this scope
   38 |   for(int i=0;i<n-1;i++）sum+=__get(i,9,k-1);
      |                        ^~~~~
a.cc:54:2: error: expected '}' at end of input
   54 | }
      |  ^
a.cc:29:1: note: to match this '{'
   29 | {
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
typedef map<int,int> ma;
typedef set<int> se;
typedef vector<int> ve;
const int maxn=1e2+7;
char a[107];
int k;
void solve1(){
    for(int i=0;i<N.size();i++)
	{
		for(int j=0;j<2;j++)
		{
			int lim=j?9:N[i]-'0';
			for(int k=0;k<=K;k++)
			{
				for(int l=0;l<=lim;l++)
				{
					int nk=k+!!l;
					if(nk<=K)
					{
						dp[i+1][j||l<lim][nk]+=dp[i][j][k];
					}
				}
			}
		}
	}
}
int main() {
    int sum=0;
    scanf("%s%d",a,&k);
    int s=strlen(a);
    if(k==1){
        for(int i=0;i<s;i++){
            int x=a[i]-'0';
            if(i!=0)
                x=9;
            sum+=x;
        }
    }
    else if(k==2){
        int f=0;
        for(int i=0;i<s;i++){
            for(int j=i+1;j<s;j++){
                int x=a[i]-'0',y=a[j]-'0';
                if(f){
                    y=9;
                    if(i!=0)
                        x=9;
                }
                if(a[j]-'0') f=1;
                sum+=max(0,(x-1)*9+y);
            }
            f=1;
        }
    }
    else {
        int f1=0,f2=0;
        for(int i=0;i<s;i++){
            for(int j=i+1;j<s;j++){
                for(int p=j+1;p<s;p++){
                    int x=a[i]-'0',y=a[j]-'0',z=a[p]-'0';
                    if(f1){
                        z=9;
                        if(i!=0)
                            x=9;
                        if(f2) y=9;
                    }

                    if(a[p]-'0') f1=1;
                    sum+=max(0,(x-1)*81+(y-1)*9+z);
                }
                f1=1;
                if(a[j]-'0') f2=1;
            }
            f1=f2=1;
        }
    }
    printf("%lld\n",sum);
    assert(sum>=0);
	return 0;
}



/**********************


*********************/


Compiler output:
a.cc: In function 'void solve1()':
a.cc:12:19: error: 'N' was not declared in this scope
   12 |     for(int i=0;i<N.size();i++)
      |                   ^
a.cc:17:40: error: 'K' was not declared in this scope
   17 |                         for(int k=0;k<=K;k++)
      |                                        ^
a.cc:24:49: error: 'dp' was not declared in this scope; did you mean 'dup'?
   24 |                                                 dp[i+1][j||l<lim][nk]+=dp[i][j][k];
      |                                                 ^~
      |                                                 dup
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring> 
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
#define ll long long 
const ll MOD=1e9+7LL;
const int INF=2e9;
string S;
int K;
ll combi(ll N, int count)
{
	if (count==1) return N*9ll;
	if (count==2) return 81ll*N*(N-1)/2;
	if (count==3) return 729ll*N*(N-1)*(N-2)/6;
	else return 0ll;
}
ll dfs(int idx, int k, bool smaller)
{
	if (k==0) return 1ll; 
	if (smaller) return combi((ll)S.size()-idx, k);
	if (idx==S.size())
	{
		if (k==0) return 1ll;
		else return 0ll;
	}
	if (S[idx]=='0') return dfs(idx+1, k, false);
	ll zero_count = dfs(idx+1, k, true);
	ll between_count = ll(S[idx] - '1') * dfs(idx+1, k-1, true);
	ll icchi_count = dfs(idx+1, k-1, false);
	return zero_count+between_count+icchi_count
}
int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	cin>>S>>K;
	cout<<dfs(0,K,false)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'long long int dfs(int, int, bool)':
a.cc:8:12: error: expected primary-expression before 'long'
    8 | #define ll long long
      |            ^~~~
a.cc:31:28: note: in expansion of macro 'll'
   31 |         ll between_count = ll(S[idx] - '1') * dfs(idx+1, k-1, true);
      |                            ^~
a.cc:33:52: error: expected ';' before '}' token
   33 |         return zero_count+between_count+icchi_count
      |                                                    ^
      |                                                    ;
   34 | }
      | ~
Language: C++


#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
    arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
    for (auto& i : arr) {
        fill_all(i, v);
    }
}

std::string S;
int64_t dp[200][10][2];
int func(int i, int k, int can_over = false) {
    if (k < 0) { return 0; }
    if (i == S.size()) {
        return k == 0 ? 1 : 0;
    }
    auto& memo = dp[i][k][over?1:0];
    if (memo != -1) {
        return memo;
    }
    int si = can_over?10:(S[i] - '0');

    memo = func(i+1,k,0 < si);//v=0
    for (int v = 1; v <= si; v++)
    {
        memo += func(i + 1, k-1, v < si);
    }
    return memo;
}

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    int K;
    in >> S >> K;
    fill_all(dp, -1);
    out << func(0, K) << endl;

    return 0;
}
#endif

Compiler output:
a.cc: In function 'int func(int, int, int)':
a.cc:50:27: error: 'over' was not declared in this scope
   50 |     auto& memo = dp[i][k][over?1:0];
      |                           ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

int main() {
    // 前処理
    COMinit();

    // 計算例
    int ans = 0;
    ans += COM(10,4)*COM(5,3) + COM(10,5)*COM(5,4) + COM(10,6)*COM(5,5);
    cout << ans << endl;
    return 0;
}

int main() {
    string s;
    cin >> s;
    int k; cin >> k;
    int d = s.size();
    int a[d];
    rep(i,d)a[d - 1 - i] = s[i] - '0';
    if(k > d){
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    if(k == 1){
        ans = 9 * (d - 1) + a[d-1];
    }

    if(k == 2){
        ans = a[d-1] * 9 * (d - 1) + 9 * (d - 1) * 9 * (d - 1) * COM(d- 1, 2);
    }

    if(k == 3){
        ans = a[d-1] * 9 * (d - 1) * 9 * (d - 1) * COM(d- 1, 2) + 9 * (d - 1) * 9 * (d - 1) * 9 * (d - 1) * COM(d-1, 3);
    }

    cout << ans << endl;
    return 0;
}
 


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

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll solve(string s, int k) {
    ll n = s.size();
    if (n < k) return 0;
    if (s[0] == '0') return solve(s.substr(1, n - 1));

    ll ans = 0;
    if (k == 1) {
        ans += s[0] - '0';
        ans += (n - 1) * 9;
    } else if (k == 2) {
        ans += (s[0] - '0' - 1) * 9 * (n - 1);
        ans += 81 * (n - 1) * (n - 2) / 2;
        string t = s.substr(1, n - 1);
        ans += solve(t, 1);
    } else if (k == 3) {
        ans += (s[0] - '0' - 1) * 81 * (n - 1) * (n - 2) / 2;
        ans += 729 * (n - 1) * (n - 2) * (n - 3) / 6;
        string t = s.substr(1, n - 1);
        ans += solve(t, 2);
    }

    return ans;
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string n;
    int k;
    cin >> n >> k;
    
    cout << solve(n, k) << "\n";
    return 0;
}

Compiler output:
a.cc: In function 'll solve(std::string, int)':
a.cc:22:34: error: too few arguments to function 'll solve(std::string, int)'
   22 |     if (s[0] == '0') return solve(s.substr(1, n - 1));
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:19:4: note: declared here
   19 | ll solve(string s, int k) {
      |    ^~~~~
Language: Java

import java.util.*;

class Main{

    public static void main(String args[]) throws Exception{
        Main main = new Main();
    }

    public Main(){
        Scanner scanner = new Scanner(System.in);
        String N = scanner.next();
        long K = scanner.nextLong();

        int L = N.length();

        if(K > N){
            System.out.println("0");
            return;
        }

        long[] D = new long[L];
        for(int i=0;i<L;i++) D[i] = (long)Character.getNumericValue(N.charAt(i));

        long R = 0;
        for(int i=0;i<K;i++){
            if(K-(long)i == 1L){
                R += D[i];
                R += 9L * (L-(long)i-1L);
            } else if(K-(long)i == 2L){
                R += (D[i]-1L) * 9L * (L-(long)i-1L);
                R += 81L * (L-(long)i-1L) * (L-(long)i-2L) /2L;
            } else {
                R += (D[0]-1L) * 81L * (L-1L) * (L-2L) / 2L;
                R += 729L * (L-1L) * (L-2L) * (L-3L) / 6L;
            }
        }

        System.out.println(R);
    }
}


Compiler output:
Main.java:16: error: bad operand types for binary operator '>'
        if(K > N){
             ^
  first type:  long
  second type: String
1 error
Language: C++

#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
using namespace std;

#define COUNTMAX 100


void numberPlusOne(char *p) {	
	char ch1 = NULL;
	char* ptr = &ch1;
		
	int plus = 1;
	for (int i = COUNTMAX -1; i >= 0; i--) {
		ch1 = p[i];
		int num = atoi(ptr);

		if (num + plus > 9) {
			plus = 1; 			
			p[i] = '0';
		} else {
			plus = 0;						
			itoa(++num, &p[i], 10);
			p[i + 1] = '0';
			break;
		}
	}
}

bool checkNonZero(char* p, int K) {		
	int count = 0;

	for (int i = 0; i <COUNTMAX; i++) {
		char ch = p[i];
		int digits = atoi(&ch);
		if (digits != 0) {						
			count++;
		}
	}
	if (count == K)
		return true;
	else
		return false;	
}

bool checkNumber(char* p1, char* p2) {			
	int count = 0;
	for (int i = 0; i < COUNTMAX; i++) {
		if (p1[i] == p2[i])
			count++;		
	}
	if (COUNTMAX == count)
		return false; // exit
	else
		return true;
}

void copytoLast(char* p)
{
	int len = strlen(p);
	int j = 0;
	for (int i = len; i > 0; i--)
	{
		p[COUNTMAX - i] = p[j];
		p[j] = '\0';
		j++;
	}
}

void main()  {		
	char N[100] = { 0, };
	char N_temp[100] = { 0, };
	int K;
	int intMax = INT_MAX;

	scanf("%s", N);
	scanf("%d", &K);	
	// step : need to check the range of N,K

	copytoLast(N);		

	N_temp[99] = '0';
	int sum = 0;
	bool check = true;
	do {				
		numberPlusOne(N_temp);
		if (checkNonZero(N_temp, K) == true) {
			sum++;
		}
		check = checkNumber(N, N_temp);
	} while (check);

	printf("sum = %d\n", sum);
}

Compiler output:
a.cc: In function 'void numberPlusOne(char*)':
a.cc:11:20: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
   11 |         char ch1 = NULL;
      |                    ^~~~
a.cc:24:25: error: 'itoa' was not declared in this scope
   24 |                         itoa(++num, &p[i], 10);
      |                         ^~~~
a.cc: In function 'void copytoLast(char*)':
a.cc:61:19: error: 'strlen' was not declared in this scope
   61 |         int len = strlen(p);
      |                   ^~~~~~
a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <iostream>
  +++ |+#include <cstring>
    5 | using namespace std;
a.cc: At global scope:
a.cc:71:1: error: '::main' must return 'int'
   71 | void main()  {
      | ^~~~
a.cc: In function 'int main()':
a.cc:75:22: error: 'INT_MAX' was not declared in this scope
   75 |         int intMax = INT_MAX;
      |                      ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <iostream>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

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

#define COUNTMAX 100


void numberPlusOne(char *p) {	
	char ch1 = NULL;
	char* ptr = &ch1;
		
	int plus = 1;
	for (int i = COUNTMAX -1; i >= 0; i--) {
		ch1 = p[i];
		int num = atoi(ptr);

		if (num + plus > 9) {
			plus = 1; 			
			p[i] = '0';
		} else {
			plus = 0;						
			itoa(++num, &p[i], 10);
			p[i + 1] = '0';
			break;
		}
	}
}

bool checkNonZero(char* p, int K) {		
	int count = 0;

	for (int i = 0; i <COUNTMAX; i++) {
		char ch = p[i];
		int digits = atoi(&ch);
		if (digits != 0) {						
			count++;
		}
	}
	if (count == K)
		return true;
	else
		return false;	
}

bool checkNumber(char* p1, char* p2) {			
	int count = 0;
	for (int i = 0; i < COUNTMAX; i++) {
		if (p1[i] == p2[i])
			count++;		
	}
	if (COUNTMAX == count)
		return false; // exit
	else
		return true;
}

void copytoLast(char* p)
{
	int len = strlen(p);
	int j = 0;
	for (int i = len; i > 0; i--)
	{
		p[COUNTMAX - i] = p[j];
		p[j] = '\0';
		j++;
	}
}

void main()  {		
	char N[100] = { 0, };
	char N_temp[100] = { 0, };
	int K;
	int intMax = INT_MAX;

	scanf("%s", N);
	scanf("%d", &K);	
	// step : need to check the range of N,K

	copytoLast(N);		

	N_temp[99] = '0';
	int sum = 0;
	bool check = true;
	do {				
		numberPlusOne(N_temp);
		if (checkNonZero(N_temp, K) == true) {
			sum++;
		}
		check = checkNumber(N, N_temp);
	} while (check);

	printf("sum = %d\n", sum);
}

Compiler output:
a.cc: In function 'void numberPlusOne(char*)':
a.cc:9:20: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
    9 |         char ch1 = NULL;
      |                    ^~~~
a.cc:22:25: error: 'itoa' was not declared in this scope
   22 |                         itoa(++num, &p[i], 10);
      |                         ^~~~
a.cc: In function 'void copytoLast(char*)':
a.cc:59:19: error: 'strlen' was not declared in this scope
   59 |         int len = strlen(p);
      |                   ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <iostream>
  +++ |+#include <cstring>
    3 | using namespace std;
a.cc: At global scope:
a.cc:69:1: error: '::main' must return 'int'
   69 | void main()  {
      | ^~~~
a.cc: In function 'int main()':
a.cc:73:22: error: 'INT_MAX' was not declared in this scope
   73 |         int intMax = INT_MAX;
      |                      ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <iostream>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

#define COUNTMAX 100


void numberPlusOne(char *p) {	
	char ch1 = NULL;
	char* ptr = &ch1;
		
	int plus = 1;
	for (int i = COUNTMAX -1; i >= 0; i--) {
		ch1 = p[i];
		int num = atoi(ptr);

		if (num + plus > 9) {
			plus = 1; 			
			p[i] = '0';
		} else {
			plus = 0;						
			itoa(++num, &p[i], 10);
			p[i + 1] = '0';
			break;
		}
	}
}

bool checkNonZero(char* p, int K) {		
	int count = 0;

	for (int i = 0; i <COUNTMAX; i++) {
		char ch = p[i];
		int digits = atoi(&ch);
		if (digits != 0) {						
			count++;
		}
	}
	if (count == K)
		return true;
	else
		return false;	
}

bool checkNumber(char* p1, char* p2) {			
	int count = 0;
	for (int i = 0; i < COUNTMAX; i++) {
		if (p1[i] == p2[i])
			count++;		
	}
	if (COUNTMAX == count)
		return false; // exit
	else
		return true;
}

void copytoLast(char* p)
{
	int len = strlen(p);
	int j = 0;
	for (int i = len; i > 0; i--)
	{
		p[COUNTMAX - i] = p[j];
		p[j] = '\0';
		j++;
	}
}

void main()  {		
	char N[100] = { 0, };
	char N_temp[100] = { 0, };
	int K;
	int intMax = INT_MAX;

	scanf("%s", N);
	scanf("%d", &K);	
	// step : need to check the range of N,K

	copytoLast(N);		

	N_temp[99] = '0';
	int sum = 0;
	bool check = true;
	do {				
		numberPlusOne(N_temp);
		if (checkNonZero(N_temp, K) == true) {
			sum++;
		}
		check = checkNumber(N, N_temp);
	} while (check);

	printf("sum = %d\n", sum);
}

Compiler output:
a.cc: In function 'void numberPlusOne(char*)':
a.cc:9:20: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
    9 |         char ch1 = NULL;
      |                    ^~~~
a.cc:22:25: error: 'itoa' was not declared in this scope
   22 |                         itoa(++num, &p[i], 10);
      |                         ^~~~
a.cc: In function 'void copytoLast(char*)':
a.cc:59:19: error: 'strlen' was not declared in this scope
   59 |         int len = strlen(p);
      |                   ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <iostream>
  +++ |+#include <cstring>
    3 | using namespace std;
a.cc: At global scope:
a.cc:69:1: error: '::main' must return 'int'
   69 | void main()  {
      | ^~~~
a.cc: In function 'int main()':
a.cc:73:22: error: 'INT_MAX' was not declared in this scope
   73 |         int intMax = INT_MAX;
      |                      ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <iostream>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

import itertools as it
import math

N=input()
K=int(input())

keta = len(N)

ans = 0
num = "9" *K
def perm(n,k):
    return math.factorial(n)//math.factorial(n-k)
                                        
ans=0
if keta > K:
    ans += (9**K) * perm(keta-1, K)//math.factorial(K)
print(ans)

if K>keta:
    ans = 0
elif K==1:
    ans += int(N[0])
elif K==2:
    ans += (int(N[0])-1) * 9 * (keta-1)#あたまが1小さい
    ans += int(N[1])#頭が同じ
    if keta >= 3 and int(N[1])>0:
        ans += 9 * (keta-2)
else:
    ##頭が1小さい
    ans += (int(N[0]) - 1)*(9**2)*perm(keta-1, 2)//2 
    ##頭が同じ
    if keta-2 >= 2 and int(N[1])>0:
        ans += 9**2 * perm(keta-2, 2)//2
    if int(N[1])>0:#上2桁目-1
        ans += (int(N[1])-1)*9*(keta-2)
        #上2桁目まで同じ
    if keta-3>0:
        ans += 9*(keta-3)
        #上3桁目まで同じ
    ans += int(N[2])
                    
print(ans)


Compiler output:
a.cc:24:40: error: stray '#' in program
   24 |     ans += (int(N[0])-1) * 9 * (keta-1)#あたまが1小さい
      |                                        ^
a.cc:25:21: error: stray '#' in program
   25 |     ans += int(N[1])#頭が同じ
      |                     ^
a.cc:29:5: error: stray '##' in program
   29 |     ##頭が1小さい
      |     ^~
a.cc:31:5: error: stray '##' in program
   31 |     ##頭が同じ
      |     ^~
a.cc:34:20: error: stray '#' in program
   34 |     if int(N[1])>0:#上2桁目-1
      |                    ^
a.cc:36:10: error: invalid preprocessing directive #\U00004e0a2\U00006841\U000076ee\U0000307e\U00003067\U0000540c\U00003058
   36 |         #上2桁目まで同じ
      |          ^~~~~~~~~~~~~~~
a.cc:39:10: error: invalid preprocessing directive #\U00004e0a3\U00006841\U000076ee\U0000307e\U00003067\U0000540c\U00003058
   39 |         #上3桁目まで同じ
      |          ^~~~~~~~~~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import itertools as it
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

ll com(ll N, ll K) {
  ll ret=1;
  if(N>=K&&K!=0) {
    rep(i,K) ret*=(N-i);
    for(ll i=K;i>0;--i) ret/=i;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll k,ans=0;cin>>k;
  ll len=s.length(), head=s[0]-'0';
  if(k==1) ans=9*(len-1)+head;
  else if(k==2&&len>1) {
    ll a=0;
    for(ll i=2;i<len;++i) a+=9*9*(i-1);
    ll b=0,head1=s[1]-'0',len1=len-1;
    if(head1==0) 
    for(ll i=2;i<len;++i) {
      ll tmp=s[i]-'0';
      if(tmp!=0) {len1=len-i;head1=tmp;break;}
    } 
    if(head1!=0) {
      b+=(head-1)*9*(len-1);
      b+=9*(len1-1);
      b+=head1;
    }
    ans+=a+b;
  }
  else if(k==3&&len>2) {
    ll a=0;
    for(ll i=3;i<len;++i) a+=9*9*9*com(i-1,2);
    ll b=0,head1=s[1]-'0',len1=len-1;
    if(head1==0) 
    for(ll i=2;i<len;++i) {
      ll tmp=s[i]-'0';
      if(tmp!=0) {len1=len-i;head1=tmp;break;}
    }
    head2=s[len1+1]-'0',len2=len1-1;
    if(head2==0) 
    for(ll i=len-len1+1;i<len;++i) {
      ll tmp=s[i]-'0';
      if(tmp!=0) {len2=len-i;head2=tmp;break;}
    }
    if(head1*head2!=0) {
      b+=(head-1)*9*9*com(len-1,2);
      b+=head2*9*(len2-1);
      b+=head2*9*(len1-len2-1);
      b+=head1*9*(len2-1);
      b+=head1*9*(len1-len2-1);
      b+=9*9*com(len1-2,2);
      b+=head1*head2;
    }
    if(head1!=0&&head2==0&&len1>1) {
      b+=(head-1)*9*9*com(len-1,2);
      if(len1>2) b+=9*9*com(len1-1,2);
      b+=head1*9*(len1-1);
    }
    ans+=a+b;
  }
  print(ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:5: error: 'head2' was not declared in this scope; did you mean 'head1'?
   50 |     head2=s[len1+1]-'0',len2=len1-1;
      |     ^~~~~
      |     head1
a.cc:50:25: error: 'len2' was not declared in this scope; did you mean 'len1'?
   50 |     head2=s[len1+1]-'0',len2=len1-1;
      |                         ^~~~
      |                         len1
Language: C++

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

ll C(int n, int r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    int k;
    cin >> n >> k;
    int d =  n.size();
    if (d < k) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ans += (ll)pow(9, k)*C(d-1, k);
    int m = stoi(string(1,n[0]));

    if(d >= 3){
        ans += (ll) m * pow(9, k-1) * C(d-2, k-1);
    }

    if(k>=2){
        if(d>=1){
            int mm = stoi(string(1,n[1]));
            ll s = (ll) 9*(m-1) + mm;
            if (k==2) ans += s;
        else if (k>=3){
            int mmm = stoi(string(1,n[2]));
            ans += (ll) s*(9*(d-3) + mmm);
            }        
        }
    }
    cout << ans << endl;



Compiler output:
a.cc: In function 'int main()':
a.cc:66:25: error: expected '}' at end of input
   66 |     cout << ans << endl;
      |                         ^
a.cc:36:11: note: to match this '{'
   36 | int main(){
      |           ^
Language: C++

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

ll C(int n, int r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    int k;
    cin >> n >> k;
    int d =  n.size();
    if (d < k) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ans += (ll)pow(9, k)*C(d-1, k);
    int m = stoi(string(1,n[0]));

    if(d >= 3){
        ans += (ll) m * pow(9, k-1) * C(d-2, k-1);
    }

    if(k>=2){
        if(d>=1){
            int mm = stoi(string(1,n[1]));
            ll s = (ll) 9*(m-1) + mm;
            if (k==2) ans += s;
        else if (k>=3){
            int mmm = stoi(string(1,n[2]))
            ans += (ll) s*(9*(d-3) + mmm);
            }        
        }
    }
    cout << ans << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:13: error: expected ',' or ';' before 'ans'
   62 |             ans += (ll) s*(9*(d-3) + mmm);
      |             ^~~
Language: C++

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

int main(){

    string n;
    int k; 
     
    cin >> n >> k;

    int c = n.length();

    int m1 = n[0] - '0';
    if (c>1)  int m2 = n[1] - '0';
    if (c>2) int m3 = n[2] - '0';


    if (k==1) {
        cout << m1 + (c - 1) * 9 << endl;
    } else if (k == 2){
        long  ans =0;
        if(c>1){
            if(c > 2){
                ans += 81*(c-2)*(c-1)/2;
            }
            ans += (m1-1)*9*(c-1);
            ans += 9*(c-2);    
            ans += m2;
        }
        cout << ans << endl;
    } else {
        long ans =0;
        if(c>2){
            if(c>3){
                ans += 729*(c-1)*(c-2)*(c-3)/6;
                ans += 81*(c-2)*(c-3)/2;
            }
            // ans += (m.at(0)-1)*81*(c-2)*(c-1)/2;
            // ans += (m.at(1)-1)*9*(c-2);
            ans += (m1-1)*81*(c-2)*(c-1)/2;
            ans += (m2-1)*9*(c-2);
            ans += 9*(c-3);
            ans += m3;
        }
        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:20: error: 'm2' was not declared in this scope; did you mean 'm1'?
   28 |             ans += m2;
      |                    ^~
      |                    m1
a.cc:41:21: error: 'm2' was not declared in this scope; did you mean 'm1'?
   41 |             ans += (m2-1)*9*(c-2);
      |                     ^~
      |                     m1
a.cc:43:20: error: 'm3' was not declared in this scope; did you mean 'm1'?
   43 |             ans += m3;
      |                    ^~
      |                    m1