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

#include <bits/stdc++.h>
using namespace std;
string N;int K,n;
int nCr(int n,int r){
    if(r==1)return n;
    if(r==2)return n*(n-1)/2;
    if(r==3)return n*(n-1)*(n-2)/6;
    return 0;
}
int dp(int i,int k,bool s){
    k==0?return 1:(i==n?return 0:0);
    if(s)return nCr(n-i,k)*pow(9,k);
    else {
        if(N[i]=='0')return dp(i+1,k,0);
        else return dp(i+1,k,1)+dp(i+1,k-1,1)*(N[i]-'1')+dp(i+1,k-1,0);
    }
}
int main(){
    cin>>N>>K;
    n=N.size();
    cout<<dp(0,K,0)<<endl;
}


Compiler output:
a.cc: In function 'int dp(int, int, bool)':
a.cc:11:10: error: expected primary-expression before 'return'
   11 |     k==0?return 1:(i==n?return 0:0);
      |          ^~~~~~
a.cc:11:10: error: expected ':' before 'return'
   11 |     k==0?return 1:(i==n?return 0:0);
      |          ^~~~~~
      |          :
a.cc:11:10: error: expected primary-expression before 'return'
   11 |     k==0?return 1:(i==n?return 0:0);
      |          ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
string N;int K,n;
int nCr(int n,int r){
    if(r==1)return n;
    if(r==2)return n*(n-1)/2;
    if(r==3)return n*(n-1)*(n-2)/6;
    return 0;
}
int dp(int i,int k,bool s){
    k==0?return 1:i==n?return 0:0;
    if(s)return nCr(n-i,k)*pow(9,k);
    else {
        if(N[i]=='0')return dp(i+1,k,0);
        else return dp(i+1,k,1)+dp(i+1,k-1,1)*(N[i]-'1')+dp(i+1,k-1,0);
    }
}
int main(){
    cin>>N>>K;
    n=N.size();
    cout<<dp(0,K,0)<<endl;
}

Compiler output:
a.cc: In function 'int dp(int, int, bool)':
a.cc:11:10: error: expected primary-expression before 'return'
   11 |     k==0?return 1:i==n?return 0:0;
      |          ^~~~~~
a.cc:11:10: error: expected ':' before 'return'
   11 |     k==0?return 1:i==n?return 0:0;
      |          ^~~~~~
      |          :
a.cc:11:10: error: expected primary-expression before 'return'
   11 |     k==0?return 1:i==n?return 0:0;
      |          ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

string N;ll K,n;

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;
}

ll dp(ll i,ll k,bool smaller){
    if(k==0)return 1;
    else if(i==n)return 0;

    if(smaller)return nCr(n-i,k)*pow(9,k);
    else {
        ll oxx= dp(i+1,k,1);
        ll xxx= (N[i]=='0') ? 0 : dp(i+1,k-1,1)*(N[i]-'1');
        ll nxx= (N[i]=='0') ? 0 : dp(i+1,k-1,0);
        return oxx+xxx+nxx;
    }
}

void solve() 
{
    cin>>N>>K;
    n=N.size();
    cout<<dp(0,K,0)<<endl;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'll dp(ll, ll, bool)':
a.cc:36:23: error: 'nCr' was not declared in this scope
   36 |     if(smaller)return nCr(n-i,k)*pow(9,k);
      |                       ^~~
Language: C++

#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;

int main() {
  string n;
  ll k;
  cin>>n>>k;
  if(n.size()<k){
    cout<<0<<endl;
    return 0;
  }
  ll ans=0;
  for(ll i=1;i<n.size();i++){
    if(i<k) continue;
    else {
      if(k==1) ans+=9;
      else if(k==2) ans+=81*(i-1);
      else ans+=729*(i-1)*(i-2)/2;
    }
  }
  cout<<ans<<endl;
  if(k==1) ans+=(n.at(0)-'0');
  if(k==2) {
    ans+=(n.at(0)-'0'-1)*9*(n.size()-1);
    for(int i=1; i<n.size();i++){
      if(n.at(i)=='0') continue;
      else{
        ans+=(n.at(i)-'0');
        ans+=9*(n.size()-1-i);
        break;
      }
    }
  }
  if(k==3){
    ans+=(n.at(0)-'0'-1)*81*(n.size()-1)*(n.size()-2)/2;
    for(int i=1; i<n.size()-1;i++){
      if(n.at(i)=='0') continue;
      else{
        ans+=(n.at(i)-'0'-1)*9*(n.size()-i-1)+81*(n.size()-i-1)*(n.size()i-2)/2;
        for(int j=i+1;j<n.size();j++){
          if(n.at(j)=='0') continue;
          else {
            ans+=(n.at(j)-'0');
            ans+=9*(n.size()-1-j);
            break;
          }
        }
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:74: error: expected ')' before 'i'
   41 |         ans+=(n.at(i)-'0'-1)*9*(n.size()-i-1)+81*(n.size()-i-1)*(n.size()i-2)/2;
      |                                                                 ~        ^
      |                                                                          )
Language: C++

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	int ans = 0;
	string n;
	
	cin>>n>>K;
	
	if(K == 1) {
		int con = ((int)n.size() - 1) * 9 + n[0] - '0';
		cout<<con<<endl;
	} else if(K == 2) {
		int con =  9 * 9 * (n.size()-0) * (n.size()-1) / 2 - (9 - (n[0] - '0')) * (n.size()-1) * 9;
		for(int i = 1, cc = 0, hoge = 0; i < n.size() && c < 1; i++, hoge += 9){
			if(n[i] != '0' || n.size() == i + 1) {
				cc++;
				con -=  (9 - (n[i] - '0')) + hoge;
			}
		}
		
		cout<<con<<endl;
	} else if(K == 3) {
		int con =  9 * 9 * 9 *  (n.size()-1) * (n.size()-2) * (n.size() - 3)/ 6;
		
		for(int i = 0, cc = 0; i < n.size() && cc < 3; i++){
			if(n[i] != '0') {
				if(cc == 0) con += ((int)n.size() - i - 1) * ((int)n.size() - i - 2) / 2 * (n[i] - '1') * 9 * 9;
				else if(cc == 1) con += ((int)n.size() - i - 1)  / 1 * (n[i] - '1') * 9 + ((int)n.size() - i - 1) * ((int)n.size() - i - 2) / 2 * 9 * 9;
				else if(cc == 2) con += (n[i] - '0') + ((int)n.size() - i - 1) * 9;
				cc++;
			}
		}
		
		cout<<con<<endl;
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:66: error: 'c' was not declared in this scope; did you mean 'cc'?
   37 |                 for(int i = 1, cc = 0, hoge = 0; i < n.size() && c < 1; i++, hoge += 9){
      |                                                                  ^
      |                                                                  cc
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  int K;
  cin >> K;
  int D = N.size();
  int total = 0;
  if (K == 1) {
    total = 9 * (D - 1);
    total += N.at(0);
    cout << total << endl;
  } else if (K == 2) {
    total = 9 * 9 * (D - 1) * (D - 2);
    total += (N.at(0) - 1) * 9 * (D - 1);
    for (int i = 1; i < D; i++) {
      if (N.at(i) == '0') {
        continue;
      } else {
        total += stoi(N.at(i)) + 9 * (D - 1 -i);
        break;
      }
    }
    cout << total << endl;
  } else {
    total = 9 * 9 * 9 * (D - 1) * (D - 2) * (D - 3) / 6;
    total += (N.at(0) - 1) * 9 * 9 * (D - 1) * (D - 2) / 2;
    for (int i = 1; i < D; i++) {
      if (N.at(i) == '0') {
        continue;
      } else {
        total += (N.at(i) - 1) * 9 * (D - 1 - i);
        for (int j = 1; j < D - i; j++) {
          if (N.at(i + j) == '0') {
            continue;
          }
          else {
            total += N.at(i + j) + 9 * (D - 1 - i - j);
            break;
          }
        }
      }
    }
    cout << total << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:22: error: no matching function for call to 'stoi(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
   22 |         total += stoi(N.at(i)) + 9 * (D - 1 -i);
      |                  ~~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:22: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'}
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidate: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:23: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
long long comb(int n, int r) {
	std::vector<std::vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v[n][r];
}
int main(){
    string s;
    std::cin >> s;
    ll k;
    std::cin >> k;
    ll ans=0ll;
    while(k>0ll{
        rrep(i,1,s.size()){
            ans+=9ll*comb(i-1,k-1)*pow(9,k-1);
        }
       // std::cout << ans << std::endl;
        ans+=(s[0]-'0'-1)*comb(s.size()-1,k-1)*pow(9,k-1);
        k--;
     //   std::cout << ans << std::endl;
        if(s.size()==1)break;
        s=s.substr(1,s.size()-1);
    }
    ans++;
    std::cout << ans << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:16: error: expected ')' before '{' token
   49 |     while(k>0ll{
      |          ~     ^
      |                )
Language: C

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
//int atoi(const char *str)

int ruijo(int i,int j){
  int mat=1;
  for(int k=0;k<j;k++){
    mat*=i;}
  return mat;
}

int c(int l,int k){
  int mat=1;
  int tmp=l;
  for(int i=0;i<k;i++){
    mat*=tmp;
    tmp--;}
  for(int i=0;i<k;i++){
    mat/=i+1;}
  return mat;
}

int myatoi(char n){
  if(n=='0') return 0;
  if(n=='1') return 1;
  if(n=='2') return 2;
  if(n=='3') return 3;
  if(n=='4') return 4;
  if(n=='5') return 5;
  if(n=='6') return 6;
  if(n=='7') return 7;
  if(n=='8') return 8;
  if(n=='9') return 9;
  return 0;
}

long int sum(char n[],int k){
  if(k<=0) return 1;
  if(myatoi(n[0])==0){
    res+=sum(n+1,k);
    return res;}
  int len=strlen(n);
  long int res=0;
  if(len>k) res+=c(len-1,k)*ruijo(9,k);
  res+=(myatoi(n[0])-1)*c(len-1,k-1)*ruijo(9,k-1);
  res+=sum(n+1,k-1);
  return res;
}

int main(){
  char n[102];
  int k;
  scanf("%s",n);
  scanf("%d",&k);


  long int res=sum(n,k);

  printf("%ld\n",res);
  
  return 0;
}


Compiler output:
main.c: In function 'sum':
main.c:41:5: error: 'res' undeclared (first use in this function)
   41 |     res+=sum(n+1,k);
      |     ^~~
main.c:41:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
//int atoi(const char *str)

int ruijo(int i,int j){
  int mat=1;
  for(int k=0;k<j;k++){
    mat*=i;}
  return mat;
}

int c(int l,int k){
  int mat=1;
  int tmp=l;
  for(int i=0;i<k;i++){
    mat*=tmp;
    tmp--;}
  for(int i=0;i<k;i++){
    mat/=i+1;}
  return mat;
}

int myatoi(char n){
  if(n=='0') return 0;
  if(n=='1') return 1;
  if(n=='2') return 2;
  if(n=='3') return 3;
  if(n=='4') return 4;
  if(n=='5') return 5;
  if(n=='6') return 6;
  if(n=='7') return 7;
  if(n=='8') return 8;
  if(n=='9') return 9;
  return 0;
}

long int sum(char n[],int k){
  if(k<=0) return 1;
  if(myatoi(n[0])==0){
    res+=sum(n+1,k);}
  int len=strlen(n);
  long int res=0;
  if(len>k) res+=c(len-1,k)*ruijo(9,k);
  res+=(myatoi(n[0])-1)*c(len-1,k-1)*ruijo(9,k-1);
  res+=sum(n+1,k-1);
  return res;
}

int main(){
  char n[102];
  int k;
  scanf("%s",n);
  scanf("%d",&k);


  long int res=sum(n,k);

  printf("%ld\n",res);
  
  return 0;
}


Compiler output:
main.c: In function 'sum':
main.c:41:5: error: 'res' undeclared (first use in this function)
   41 |     res+=sum(n+1,k);}
      |     ^~~
main.c:41:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

//static const MAXIN=101;

int main(){

  string s;
  cin >> s;
  
  //cout << s.length() << endl;
  
  int k;
  cin >> k;
  int c[101][4] = {0};

  int maxn = s.length();
  for (int i=1; i<=maxn;i++){
    c[i][1]=9*(i-1)+s[maxn-i];
    c[i][2]=9*9*(i-1)*(i-2)/2 + s[maxn-i]*c[i-1][1];
    c[i][3]=9*9*9*(i-1)*(i-2)*(i-3)/6 +s[maxn-i]*s[i-1][2];
  }

  cout << c[maxn][k] << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:56: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   26 |     c[i][3]=9*9*9*(i-1)*(i-2)*(i-3)/6 +s[maxn-i]*s[i-1][2];
      |                                                        ^
Language: C++

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

int main(){
  string N;
  cin>>N;
  int K;
  cin>>K;

  if(K==1){
    if(N.size()==1) cout<<N[0]<<endl;
    if(N.size()>1){
      int n=N[0]-'0';
      int64_t ans;
      ans += (int64_t)pow(9,N.size()-1);
      ans += n;
      cout<<ans<<endl;
    }
  }
  else if(K==2){
    if(N.size()==1) cout<<0<<endl;
    else if(N.size()>=2){
      int n=N.size();
      int64_t sum=0;
      vector<int> a(n,0);
      for(int i=0;i<N.size();++i){
        a[i]=N[i]-'0';
      }
      for(int i=1;i<=9;++i){
        for(int j=1;j<=9;++j){
          for(int k=0;k<n;++k){
            for(int l=k+1;l<n;++l){
              vector<int> b(n,0);
              b[k]=i;
              b[l]=j;
              if(a>=b){
                ++sum;
              }
            }
          }
        }
      }
      cout<<sum<<endl;
  }
}

   else if(K==3){
     if(N.size()<=2) cout<<0<<endl;
     else{
     int n=N.size();
     int64_t sum=0;
     vector<int> v(n,0);
     for(int i=0;i<N.size();++i){
       v[i]=N[i]-'0';
     }

     if(N.size()>3){
       sum += 9*9*9*(n-1)*(n-2)*(n-3)/6;
     }


     for(int i=1;i<=9;++i){
       for(int j=1;j<=9;++j){
         for(int k=1;k<=9;++k){
           for(int b=1;b<n;++b){
           for(int c=b+1;c<n;++c){
             vector<int> w(n,0);
             w[0]=i;
             w[b]=j;
             w[c]=k;
             if(v>=w){
               ++sum;
             }
           }
         }
       }
     }
    }
   }
  cout<<sum<<endl;
  }
}

}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:9: error: 'sum' was not declared in this scope
   80 |   cout<<sum<<endl;
      |         ^~~
a.cc: At global scope:
a.cc:84:1: error: expected declaration before '}' token
   84 | }
      | ^
Language: C++

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

//     d     4
int dp[101][2][4];
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, K;
    cin >> N >> K;
    // 桁数１−１０0 => d 
    // dC_K の和?
    string s = to_string(N);
    int len = s.length();
    dp[0][0][0] = 1;
    for (int d = 0; d < len; d++) {
        for (int smaller = 0; smaller < 2; smaller++) {
            for (int k = 0; k <= K; k++) {
                for (int x = 0; x <= (smaller ? 9 : (s[d] - '0')); x++) {
                    dp[d + 1][smaller || x < (s[d] - '0')][(x != 0 ? k + 1 : k)] += dp[i][smaller][k];
                }
            }
        }
    }
    cout << dp[len][0][3] + dp[len][1][3] << endl;


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:88: error: 'i' was not declared in this scope
   20 |                     dp[d + 1][smaller || x < (s[d] - '0')][(x != 0 ? k + 1 : k)] += dp[i][smaller][k];
      |                                                                                        ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
using namespace std;
typedef long long ll;

ll c(ll n, ll r) {
	ll p1=1, p2=1;
	rep(i, r) {
		p1 *= n - i;
		p2 *= i + 1;
	}
	return p1 / p2;
}

int main(void) {
	string n;
	cin >> n;
	int k; cin >> k;
	int cnt = 1;
	ll sum=0;
	for (int i = 0; i < n.size(); i++) {
		for (int j = 1; j <= n[i] - 48; j++) {
			if (i == n.size() || j == n[i] - 48) {
				continue;
			}
			sum += int(c(n.size()-i - 1, k-1)*pow(9, k-1);
		}
	}

	for (int i =0; i < n.size(); i++) {
		for (int j = 0; j < n[i] - 48; j++) {
			if (j == 0) {
				sum += c(n.size()-i - cnt, k - cnt);
			}
			else {
				sum += c(n.size()-i - cnt - 1, k - cnt - 1);
			}
		}
		if (n[i] - 48 != 0)cnt++;

		if (cnt == k) {
			break;
		}
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:32: error: expected primary-expression before 'int'
   42 |                         sum += int(c(n.size()-i - 1, k-1)*pow(9, k-1);
      |                                ^~~
Language: C++

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

int main()
{
	string N;
	long K;
	long long  result=0;

	

	cin >> N >> K;


	while (true) {

		int NLen = N.length();

		//0ホニャララ
		long i = 1;
		for (int a = 0; a < K; a++) {
			i *= (NLen - 1 - a);
		}
		result += i * 9;

		//Xホニャララ(X<一番上の桁)
		string firstString = N.substr(0, 1);
		int top = atoi(firstString.c_str());
		i = 1;
		for (int a = 0; a < K - 1; a++) {
			i *= (NLen - 1 - a);
		}
		i *= (top - 1);
		result += pow( 9,i);

		//Xホニャララ(Xが一番上の桁)
		if (K == 1) {
			result += 1;


			break;
		}
		else {
			K-=1;
			N = N.substr(1);
		}

	}

	
	
	cout << result<< endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:37:27: error: 'pow' was not declared in this scope
   37 |                 result += pow( 9,i);
      |                           ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
int  pow1(int  x, int  y){
int  ans = 1;
  while(y>0){
    if (y&1)
    {
      ans*=x;
    }
    x *= x;
    y>>=1;
  }
return ans;
} 
signed main(){
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    string s;
    cin>>s;
    int k;
    cin >> k;
    if(k==1){
        int q= s.size()-1, ans = 0;    
        ans+=9*q;
        ans+=(int)(s[0]-'0')-1;
        ans+=1ll;
        return cout << ans,0;
    }
    int n =s.size();
    string t(n-1,'0');
    for(int i=0 ;i <k-1;i++) t[n-2-i]='1';
    int cnt=0;
    vector<int>C;
    for(int i=pow1(10ll,k-1)+1;i<pow1(10ll,k);i++){
        int ii=i;
        int flag=1;
        while(ii){
            if((ii%10)==0) flag=0;
            ii/=10;
        }
        if(flag) cnt++;
        if(flag) C.pb(i);
    }
    int mul=1,den=1;
    for(int i=0 ;i < k;i++){
        mul*=(n-1-i);
        den*=(i+1);
    }
   int ans=1ll*(mul/den)*cnt;
    do{
        vector<int>p;
        p.pb(0);
       for(int i= 0;i<n-1;i++) if(t[i]=='1') p.pb(i+1);
        string t1="1";
        t1+=t;
        vector<int>d(k);
        for(int i:C){
            int ii=i;
            for(int j =0 ;ii>0 && j < k;j++){
                d[k-1-j]=ii%10;
                ii/=10;
            }
            for(int j =0 ;j < k;j++) {
              if(p[j]<t1.size())t1[p[j]]='0'+d[j];
            if(t1<=s) ans++;
        }
    }while(next_permutation(all(t)));
    cout << ans;
  
  
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:107:10: error: expected 'while' before numeric constant
  107 |   return 0;
      |          ^
a.cc:107:10: error: expected '(' before numeric constant
  107 |   return 0;
      |          ^
      |          (
a.cc:107:11: error: expected ')' before ';' token
  107 |   return 0;
      |          ~^
      |           )
a.cc:108:2: error: expected '}' at end of input
  108 | }
      |  ^
a.cc:44:14: note: to match this '{'
   44 | signed main(){
      |              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
string s;
int len; 
int n;
int comb(int m, int n){
	//cout << "M:" << m<< " ";
	if(m <= 0 || m < n) return 0;
	int result = 1, d = 1;
	for(int i = 0; i < n; i ++){
		result *= (m - i);
		d *= i+1;
	}
	//cout << result << " " << d << endl;
	if(n == 1)
		return (result/d)*9;
	if(n == 2)
		return result/d*72;
	return result/d*9*8*7;
} 
int main(){
	getline(cin,s);
	cin >> n;
	
	len = s.size();
	if(n == 1)
		cout << s[0]-48 + comb(len-1, 1);
	if(n == 2)
		cout << (s[0]-48-1) * comb(len-1, 1) + (s[1]-48) + comb(len-1, 2);
	if(n == 3)
		cout << (s[0]-48-1) * comb(len-1, 2) + (s[1]-48-1)*comb(len-2,1) + (s[2]-48) + comb(len-3, 1) + comb(len-1,3));
	
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:31:126: error: expected ';' before ')' token
   31 |                 cout << (s[0]-48-1) * comb(len-1, 2) + (s[1]-48-1)*comb(len-2,1) + (s[2]-48) + comb(len-3, 1) + comb(len-1,3));
      |                                                                                                                              ^
      |                                                                                                                              ;
Language: C++

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

int main(){
    char N[102];
    int K;
    int l;
    int nonZeroN[3] = {1000, 1000, 1000};
    int nonZeroRank[3] = {1000, 1000, 1000};
    int nonZeroCount = 0;
    int rank = 0;
    ll ans = 0;

    //input
    cin >> N;
    l = strlen(N);
    for(int i = 0; i < l; i++){
        if(N[i] != '0'){
            nonZeroN[nonZeroCount] = i;
            nonZeroRank[nonZeroCount] = l - i;
            nonZeroCount++;
        }
        if(nonZeroCount > 3){
            break;
        }
    }

    cin >> K;

    if(K == 1){
        ans += 9 * (nonZeroRank[0] - 1);
        ans += (int)N[nonZeroN[0]] - 48;
    }else if(K == 2){
        ans += 9 * 9 * (nonZeroRank[0] - 1) * (nonZeroRank[0] - 2) / 2;
        for(int i = 1; i < (int)N[nonZeroN[0]] - 48; i++){
            ans += 9 * (nonZeroRank[0] - 1);
        }
        if(nonZeroRank[1] != 1000){
            ans += 9 * (nonZeroRank[1] - 1);
            ans += (int)N[nonZeroN[1]] - 48;
        }
    }else{
        ans += 9 * 9 * 9 * (nonZeroRank[0] - 1) * (nonZeroRank[0] - 2) * (nonZeroRank[0] - 3) / 6;
        for(int i = 1; i < (int)N[nonZeroN[0]] - 48; i++){
            ans += 9 * 9 * (nonZeroRank[0] - 1) * (nonZeroRank[0] - 2) / 2;
        }
        if(nonZeroRank[1] != 1000){
            ans += 9 * 9 * (nonZeroRank[1] - 1) * (nonZeroRank[1] - 2) / 2;
            for(int i = 1; i < (int)N[nonZeroN[1]] - 48; i++){
                ans += 9 * (nonZeroRank[1] - 1);
            }
        if(nonZeroRank[2] != 1000){
            ans += 9 * (nonZeroRank[2] - 1);
            ans += (int)N[nonZeroN[2]] - 48;
        }
    }

    cout << ans << endl;

    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:2: error: expected '}' at end of input
   66 | }
      |  ^
a.cc:8:11: note: to match this '{'
    8 | int main(){
      |           ^
Language: Java

import java.util.*;
public class Main {
    public static Long com (Long x,Long y){
        if(y==1) return x;
        return com(x-1,y-1)+com(x-1,y);
    }
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
        Long b = a-a; 
        int c = sc.nextInt();
        for(int i=0;i<100;i++){if(Math.pow(10,i)<=a && Math.pow(10,i+1)>a){b=a/Math.pow(10,i)*com(i-1,c-1)*Math.pow(9,c-1)+com(i-1,c)*Math.pow(9,c);}
                              }       
		System.out.println(b);
	}
}


Compiler output:
Main.java:12: error: incompatible types: int cannot be converted to Long
        for(int i=0;i<100;i++){if(Math.pow(10,i)<=a && Math.pow(10,i+1)>a){b=a/Math.pow(10,i)*com(i-1,c-1)*Math.pow(9,c-1)+com(i-1,c)*Math.pow(9,c);}
                                                                                                   ^
Main.java:12: error: incompatible types: int cannot be converted to Long
        for(int i=0;i<100;i++){if(Math.pow(10,i)<=a && Math.pow(10,i+1)>a){b=a/Math.pow(10,i)*com(i-1,c-1)*Math.pow(9,c-1)+com(i-1,c)*Math.pow(9,c);}
                                                                                                                                ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

lli triangle[105][105];
void go(){
    triangle[0][0] = 1;
    for(int i = 0; i<105; i++){
        triangle[i][0] = 1;
        for(int j = 0; j<105; j++){
            triangle[i][j] = triangle[i-1][j] + triangle[i-1][j-1];
        }
    }
    return;
}
void solve(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    int f1 = (int)s[0] - (int)'0';
    int l = s.length();
    int ans = 0;
    if(k==1){
        ans = (9*(l-1)) + f1;
    }
    if(k==2){
        if(l>=2){
            int f2 = (int)s[1] - (int)'0';
            ans=(triangle[l-1][2]*81) +((f1-1)*(l-1)*9) +f2 + ((l-2)*9);
        }
    }
    if(k==3){
        if(l>=3){
            int f2 = (int)s[1] - (int)'0';
            int f3 = (int)s[2] - (int)'0';
            ans = (729*triangle[l-1][3]) + (81*(f1-1)*triangle[l-1][2]) + (81*triangle[l-2][2]) + (9*(f2-1)*(l-2)) + (9*(l-3)) + f3;
        }
    }
}
signed main(){
    speedX;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    go();
    while(t--){
        solve();
    }
    end_time();
    return 0;
}

Compiler output:
a.cc:43:1: error: 'lli' does not name a type; did you mean 'll'?
   43 | lli triangle[105][105];
      | ^~~
      | ll
a.cc: In function 'void go()':
a.cc:45:5: error: 'triangle' was not declared in this scope
   45 |     triangle[0][0] = 1;
      |     ^~~~~~~~
a.cc: In function 'void solve()':
a.cc:68:18: error: 'triangle' was not declared in this scope
   68 |             ans=(triangle[l-1][2]*81) +((f1-1)*(l-1)*9) +f2 + ((l-2)*9);
      |                  ^~~~~~~~
a.cc:75:24: error: 'triangle' was not declared in this scope
   75 |             ans = (729*triangle[l-1][3]) + (81*(f1-1)*triangle[l-1][2]) + (81*triangle[l-2][2]) + (9*(f2-1)*(l-2)) + (9*(l-3)) + f3;
      |                        ^~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;


long long combi(int n, int k) {
    
    long long answer = 1;

    for (long long i = n; i > n - k; i--) {
        answer *= i;
    }

    for (long long i = 2; i <= k; i++) {
        answer /= i;
    }

    return answer;
}




int main()
{
    string n;
    int k;

    long long answer = 0;

    cin >> n >> k;

    int keta = n.length() - 1;


    if(keta + 1 < k){
        cout << 0 << endl;
        return 0;
    }
    else if (k < keta + 1) {
        answer += combi(keta, k) * pow(9, k);
    }




    k--;
    if (k <= 0) {
        cout << answer + atoi(n.substr(0, 1).c_str()) << endl;
        return 0;
    }
    
    for (int i = 1; i < atoi(n.substr(0,1).c_str()); i++) {
        answer += combi(keta, k) * pow(9, k);
    }

    n = n.substr(1, n.length() - 1);

    k--; keta--;
    if (k <= 0) {
        if (keta >= 2) { answer += combi(keta - 2, 1) * pow(9, k); }
        cout << answer + atoi(n.substr(0, 1).c_str()) << endl;
        return 0;
    }




    for (int i = 1; i < atoi(n.substr(0, 1).c_str()); i++) {
        answer += combi(keta, k) * pow(9, k);
    }

    n = n.substr(1, n.length() - 1);



    if(keta >= 2) { answer += combi(keta - 2, 1) * pow(9, k); }
 
    cout << answer + atoi(n.substr(0, 1).c_str()) << endl;

    return 0;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:36: error: 'pow' was not declared in this scope
   43 |         answer += combi(keta, k) * pow(9, k);
      |                                    ^~~
a.cc:56:36: error: 'pow' was not declared in this scope
   56 |         answer += combi(keta, k) * pow(9, k);
      |                                    ^~~
a.cc:63:57: error: 'pow' was not declared in this scope
   63 |         if (keta >= 2) { answer += combi(keta - 2, 1) * pow(9, k); }
      |                                                         ^~~
a.cc:72:36: error: 'pow' was not declared in this scope
   72 |         answer += combi(keta, k) * pow(9, k);
      |                                    ^~~
a.cc:79:52: error: 'pow' was not declared in this scope
   79 |     if(keta >= 2) { answer += combi(keta - 2, 1) * pow(9, k); }
      |                                                    ^~~
Language: Java

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

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        long K = sc.nextInt();
        long res=0;
        for(long i=1;i<N.length();i++){
            StringBuilder bld = new StringBuilder();
            for(long k=0;k<i;k++){
                bld.append("9");
            }
            res += calc(bld.toString(), K);
        }
        res += calc(N, K);
        System.out.prlongln(res);
    }

    public static long calc(String N, long K){
        long top = N.charAt(0)-'0';
        long L = N.length();
        if(L == 1){
            if(K==1){
                return top;
            }else{
                return 0;
            }
        }
        long nxt = N.charAt(1) - '0';
        long res = 0;
        if(K == 1){
            res = top + 9 * (L-1);
        }else if(K==2){
            if(L==1){return 0;}
            res = (top-1) * (L-1) * 9 + (L-2)*9+nxt;
        }else if(K==3){
            if(L <= 2){return 0;}
            res += com2(L-1) * 81 * (top-1);
            res += com2(L-2) * 81;
            res += (L - 2) * 9 * (nxt-1);
            res += (L - 3) * 9;
            res += (N.charAt(2) - '0');
        }
        return res;
    }

    public static long com2(long n){
        return n*(n-1)/2;
    }
}

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

#include<bits/stdc++.h>

using namespace std;

#define il inline
#define re register int
#define Rep(i, s, e) for (re i = s; i <= e; ++i)
#define Dep(i, s, e) for (re i - s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout);

il int read() {
	int x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}

char s[110];
int len, k;
long long f[110][4], arr[110][4], ans;

il ll Query(int pos, int res) {
	if (arr[pos][res]) return arr[pos][res];
	if (!res) return arr[pos][res] = 1;
	if (s[i] == '0') return arr[pos][res] = Query(pos + 1, res);
	return arr[pos][res] = (s[i] - '1') * Query(pos + 1, res - 1) + Qurey()
}

int main() {
	scanf("%s", s + 1);
	k = read(), len = strlen(s + 1);
	f[0][0] = 1;
	Rep(i, 1, len) {
		Rep(j, 1, k) {
			f[i][j] = f[i - 1][j] + f[i - 1][j - 1] * 9;
		}
	}
	return printf("%lld", f[len][k]) & 0;
}

Compiler output:
a.cc:22:4: error: 'll' does not name a type; did you mean 'il'?
   22 | il ll Query(int pos, int res) {
      |    ^~
      |    il
a.cc: In function 'int main()':
a.cc:33:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |         Rep(i, 1, len) {
      |             ^
a.cc:7:30: note: in definition of macro 'Rep'
    7 | #define Rep(i, s, e) for (re i = s; i <= e; ++i)
      |                              ^
a.cc:34:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   34 |                 Rep(j, 1, k) {
      |                     ^
a.cc:7:30: note: in definition of macro 'Rep'
    7 | #define Rep(i, s, e) for (re i = s; i <= e; ++i)
      |                              ^
Language: C++

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

//     d     4
int dp[101][2][4];
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, K;
    cin >> N >> K;
    // 桁数１−１０0 => d 
    // dC_K の和?
    string s = to_string(N);
    int len = s.length();
    dp[0][0][0] = 1;
    for (int d = 0; d < len; d++) {
        for (int smaller = 0; smaller < 2; smaller++) {
            for (int k = 0; k <= K; k++) {
                for (int x = 0; x <= (smaller ? 9 : (s[i] - '0')); x++) {
                    dp[d + 1][smaller || x < (s[i] - '0')][(x != 0 ? k + 1 : k)] += dp[i][smaller][k];
                }
            }
        }
    }
    cout << dp[len][0][3] + dp[len][1][3] << endl;


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:56: error: 'i' was not declared in this scope
   19 |                 for (int x = 0; x <= (smaller ? 9 : (s[i] - '0')); x++) {
      |                                                        ^
Language: C++

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

int M2(int k, int m, int p) {
  return (k - 1) * 9 * (m - 1) + p + (k - 2) *9;
}

int main() {
  string S;
  cin >> S;
  int s = S.size();
  int p = 0;
  vector<int> n(s);
  for (int i = 0; i < s; i++) {
    n.at(i) = S.at(i) - '0';
    p += n.at(i);
  }
  p -= n.at(0);
  int K;
  cin >> K;
  if (K = 1) {
    cout << (s - 1) * 9 + n.at(0);
  }
  else if (K = 2) {
    if (s == 1) {
      cout << 0 <<endl;
    }
    else if (s == 2) {
      cout << (n.at(0) - 1) * 9 + n.at(1) <<endl;;
    }
    else {
      cout << M2(s, n.at(0), p) <<endl;
    }
  else {
    if (s == 0 || s == 1) {
      cout << 0 <<endl;
    }
    else if (s == 2) {
      cout << 81 * (n.at(0) - 1) + 9 + (n.at(1) - 1) + n.at(2) <<endl;
    }
    else {
      cout << 729 * (s-3) * (s-2) / 2 + 81 * (m -1) * (s - 2) * (s -1) / 2 + M2(s, n.at(0) , p) <<endl;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:3: error: expected '}' before 'else'
   34 |   else {
      |   ^~~~
a.cc:24:19: note: to match this '{'
   24 |   else if (K = 2) {
      |                   ^
a.cc:42:47: error: 'm' was not declared in this scope
   42 |       cout << 729 * (s-3) * (s-2) / 2 + 81 * (m -1) * (s - 2) * (s -1) / 2 + M2(s, n.at(0) , p) <<endl;
      |                                               ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstdint>

using namespace std;

long long combination(long long n, int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for (int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int len(long long n){//桁数
  for(int i=1; i<101; i++){
    if(n<pow(10,i)) return i;
  }
}

int top(long long n, int i){//先頭の大きさ
  for(int j=2; j<11; j++){
    if(j*pow(10,i)>n) return j-1;
  }
}

long long p(long long n, int k){
  int len = len(n);
  int top = top(n, len);
  return (top-1)*combination(len-1,k)*pow(9,k)+p(n-top*pow(10,len));
}

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

  cout << p << endl;
  return 0;
}


Compiler output:
a.cc: In function 'long long int p(long long int, int)':
a.cc:36:16: error: 'len' cannot be used as a function
   36 |   int len = len(n);
      |             ~~~^~~
a.cc:37:16: error: 'top' cannot be used as a function
   37 |   int top = top(n, len);
      |             ~~~^~~~~~~~
a.cc:38:49: error: too few arguments to function 'long long int p(long long int, int)'
   38 |   return (top-1)*combination(len-1,k)*pow(9,k)+p(n-top*pow(10,len));
      |                                                ~^~~~~~~~~~~~~~~~~~~
a.cc:35:11: note: declared here
   35 | long long p(long long n, int k){
      |           ^
a.cc: In function 'int len(long long int)':
a.cc:27:1: warning: control reaches end of non-void function [-Wreturn-type]
   27 | }
      | ^
a.cc: In function 'int top(long long int, int)':
a.cc:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^
Language: C++

0の数と誤読してた、時間あるときにとき直す

Compiler output:
a.cc:1:1: error: extended character 、 is not valid in an identifier
    1 | 0の数と誤読してた、時間あるときにとき直す
      | ^
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 0の数と誤読してた、時間あるときにとき直す
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

long long choose(int l, int k) {
	if (k > l) {
		return 0;
	}

	if (k == 0) {
		return 1;
	}
	else if (k == 1) {
		return l;
	}
	else if(k == 2) {
		return (l * (l - 1)) / 2;
	}
	else {
		return (l * (l - 1) * (l - 2)) / 6;
	}
}
int main() {
	string n;
	cin >> n;
	int k;
	cin >> k;

	if (k > (int) n.size()) {
		cout << 0 << endl;
		return;
	}

	int l = (int) n.size() - 1;

	long long ans1 = choose(l,k) * pow(9,k), ans2 = (n[0] - '0' - 1) * choose(l, k - 1) * pow(9, k - 1);
	k--;

	if (k == 0) {
		ans2++;	
	}
	else if (k == 1) {
		int ind = -1;
		for (int i = 1; i < (int) n.size(); ++i) {
			if (n[i] != '0') {
				ind = i;
				break;
			}
		}

		if (ind != -1) {
			ans2 += (n[ind] - '0') + ((int) n.size() - 1 - ind) * 9;
		}
	}
	else {
		int ind = -1;
		for (int i = 1; i < (int) n.size(); ++i) {
			if (n[i] != '0') {
				ind = i;
				break;
			}
		}

		if (ind < (int) n.size() - 1) {
			ans2 += choose((int) n.size() - 1 - ind, 2) * 9 * 9;
			ans2 += (n[ind] - '0' - 1) * choose((int) n.size() - 1 - ind, 1) * 9;

			int kk = ind;
			for (int i = kk + 1; i < (int) n.size(); ++i) {
				if (n[i] != '0') {
					ind = i;
					break;
				}
			}

			if (ind != -1) {
				ans2 += (n[ind] - '0') + ((int) n.size() - 1 - ind) * 9;
			}		
		}

	}

	cout << ans1 + ans2 << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
   54 |                 return;
      |                 ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef double dou;
bool isk(dou a,dou k)
{
	int sum = 0;
	while(a>0)
	{
		if(a%10>0)
		{
			sum++;
		}
		a = a/10;
	}
	if(sum == k)
	{
		return true;
	}
	return false;
}
int main()
{
	dou n,k;
	cin>>n>>k;
	dou cnt = 0;
	for(dou i=1;i<=n;i++)
	{
		if(isk(i,k))
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'bool isk(dou, dou)':
a.cc:9:21: error: invalid operands of types 'dou' {aka 'double'} and 'int' to binary 'operator%'
    9 |                 if(a%10>0)
      |                    ~^~~
      |                    | |
      |                    | int
      |                    dou {aka double}
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
const int MAX = 1000;

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;
}

int main(){
    COMinit();
    string n;
    int k;
    cin >> n;
    cin >> k;
    int count = 0, i = 0, result = 0;
    int mul = 1;
    for(int i=0; i<k; i++) mul *= 9;
    while(count < k || i < n.length()){
        if(n[i] != '0'){
            result += (int)(n[i] - '1') * mul * COM(n.length - i, k-count-1);
            mul /= 9;
            result += mul * COM(n.length() - i, k-count-1);

        }
        i++;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:55: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   38 |             result += (int)(n[i] - '1') * mul * COM(n.length - i, k-count-1);
      |                                                     ~~^~~~~~
      |                                                             ()
Language: Java

import java.util.*;
public class Main {
    public static Long com (Long x,Long y){
        if(x<=1) return 1;
        if(y==0 || y==x) return 1;
        if(y<0 || y>x) return 0;
        return com(x-1,y-1)+com(x-1,y);
    }
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
        Long b = a-a; 
        int c = sc.nextInt();
        for(int i=0;i<100;i++){if(Math.pow(10,i)<=a && Math.pow(10,i+1)>a){b=a/Math.pow(10,i)*com(i-1,c-1)*Math.pow(9,c-1)+com(i-1,c)*Math.pow(9,c);}
                              }       
		System.out.println(b);
	}
}

Compiler output:
Main.java:4: error: incompatible types: int cannot be converted to Long
        if(x<=1) return 1;
                        ^
Main.java:5: error: incompatible types: int cannot be converted to Long
        if(y==0 || y==x) return 1;
                                ^
Main.java:6: error: incompatible types: int cannot be converted to Long
        if(y<0 || y>x) return 0;
                              ^
Main.java:14: error: incompatible types: int cannot be converted to Long
        for(int i=0;i<100;i++){if(Math.pow(10,i)<=a && Math.pow(10,i+1)>a){b=a/Math.pow(10,i)*com(i-1,c-1)*Math.pow(9,c-1)+com(i-1,c)*Math.pow(9,c);}
                                                                                                   ^
Main.java:14: error: incompatible types: int cannot be converted to Long
        for(int i=0;i<100;i++){if(Math.pow(10,i)<=a && Math.pow(10,i+1)>a){b=a/Math.pow(10,i)*com(i-1,c-1)*Math.pow(9,c-1)+com(i-1,c)*Math.pow(9,c);}
                                                                                                                                ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
5 errors