Language: C++

#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
using Pii = pair<int, int>;
using Pil = pair<int, ll>;
using Pll = pair<ll, ll>;
using Pid = pair<int, ld>;
using Pis = pair<int, string>;
#define rep(i,n) for(int i=0; i<n; i++)
#define repm(i,s,n) for(int i=s; i<n; i++)

const int INF = 1 << 30;
const ll INF_L = 1LL << 60;
const int MOD = 1e9+7; // 998244353;

void cout_ynl(bool b) {cout << (b ? "Yes" : "No") << endl;}
void cout_YNU(bool b) {cout << (b ? "YES" : "NO") << endl;}
void cout_setprecision(ld ld, int n) {cout << fixed << setprecision(n) << ld << endl;}


// ----------------------------------------------------------------
// String Functions
// ----------------------------------------------------------------
int ctoi(char c){
    if(isdigit(c)) return c - '0';
    else if(islower(c)) return c - 'a';
    else if(isupper(c)) return c - 'A';
    else return -1;
}
char itocd(int i){char c = i+'0'; if(isdigit(c)) return c; else return 0x00;}
char itocl(int i){char c = i+'a'; if(islower(c)) return c; else return 0x00;}
char itocu(int i){char c = i+'A'; if(isupper(c)) return c; else return 0x00;}
// ----------------------------------------------------------------


// ----------------------------------------------------------------
// Dynamical Programming
// ----------------------------------------------------------------
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ----------------------------------------------------------------


// ----------------------------------------------------------------
// Graph Theory
// ----------------------------------------------------------------
vector<vector<int>> adjMat;
vector<set<Pii>> adjList;

void graphDijkstra(){}
void graphBellmanFord(){}
void graphWarshallFloyd(){}
// ----------------------------------------------------------------


// ----------------------------------------------------------------
// Mathematical Functions
// ----------------------------------------------------------------
ll gcd(ll A, ll B) {if (A%B == 0) {return(B);} else {return(gcd(B, A%B));}}
ll lcm(ll A, ll B) {return A * B / gcd(A, B);}
ll divTimes(ll N, ll D) {ll res = 0; while(N%D == 0) {N/=D; res++;} return res;}

ll powMod(ll B, ll P) {
    if(P == 0) return 1;
    if(P%2 == 0){ll t = powMod(B, P/2); return t*t % MOD;}
    return B * powMod(B, P-1) % MOD;
}

/* ----------------------------------
 Factorial, Permutation, Combination
 ---------------------------------- */
const int FAC_INIT_SIZE = 1e6+9;
vector<ll> fac, finv, inv;

void factModInit() {
    fac.resize(FAC_INIT_SIZE);
    finv.resize(FAC_INIT_SIZE);
    inv.resize(FAC_INIT_SIZE);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_INIT_SIZE; 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;
    }
}
ll factMod(ll N){return fac[N] % MOD;}
ll factInvMod(ll N){return finv[N] % MOD;}
ll permMod(ll N, ll K){
    if (N < 0 || K < 0 || N < K) return 0;
    else return factMod(N) * factInvMod(N-K) % MOD;
}
ll combMod(ll N, ll K){
    if (N < 0 || K < 0 || N < K) return 0;
    else if (N < FAC_INIT_SIZE){ return factMod(N) * (factInvMod(K) * factInvMod(N-K) % MOD) % MOD;}
    else {
        ll ans = 1; ll Ks = K < N-K ? K : N-K;
        for (ll i = N; i > N-Ks; i--) {ans *= i; ans %= MOD;}
        return ans * factInvMod(Ks) % MOD;
    }
}

/* ----------------------------------
 Sieve of Atkin & Bernstein
 ---------------------------------- */
vector<bool> sieve;
void sieveInit(ll size){
    sieve.clear();
    if(size < 0 || size > INF) return;
    
    int ss = (int)size+9;
    int ssq = sqrt(ss+0.1);
    sieve.resize(ss);
    sieve[2] = sieve[3] = true;
    
    int n = 0;
    for (int z = 1; z <= 5; z += 4) {
      for (int y = z; y <= ssq; y += 6) {
        for (int x = 1; x <= ssq && (n = 4*x*x+y*y) < ss; x++) sieve[n] = !sieve[n];
        for (int x = y+1; x <= ssq && (n = 3*x*x-y*y) < ss; x += 2) sieve[n] = !sieve[n];
      }
    }
    for (int z = 2; z <= 4; z += 2) {
      for (int y = z; y <= ssq; y += 6) {
        for (int x = 1; x <= ssq && (n = 3*x*x+y*y) < ss; x += 2) sieve[n] = !sieve[n];
        for (int x = y+1; x <= ssq && (n = 3*x*x-y*y) < ss; x += 2) sieve[n] = !sieve[n];
      }
    }
    for (int z = 1; z <= 2; z++) {
        for (int y = 3; y <= ssq; y += 6) {
            for (int x = z; x <= ssq && (n = 4*x*x+y*y) < ss; x += 3) sieve[n] = !sieve[n];
        }
    }
    for (int k = 5; k <= ssq; k++)
      if (sieve[k])
        for (int n = k*k; n < ss; n += k*k) sieve[n] = false;
}

/* ----------------------------------
 Prime Factorization
---------------------------------- */
map<ll, set<ll>> primeFactorSet;
map<ll, map<ll, ll>> primeFactorMap;
void primeFactorInit(){primeFactorMap.clear(); primeFactorSet.clear();}
void primeFactor(ll N){
    if (N < 0 || N > INF_L) return;
    
    ll Nc = N;
    ll Nsq = sqrt(N+0.1);
    set<ll> Nset = {1, N};
    map<ll, ll> Nmap;
    
    for (int k = 2; k <= Nsq; k++) {
        ll dt = 0;
        ll d = 1;
        while(Nc%k == 0){
            dt++; d *= k;
            Nset.insert(d);
            Nc /= k;
        }
        if(dt > 0) Nmap[k] = dt;
        if(Nc == 1) break;
    }
    if (Nc != 1) {
        Nmap[Nc] = 1;
        Nset.insert(Nc);
    }
    
    primeFactorSet[N] = Nset;
    primeFactorMap[N] = Nmap;
}
// ----------------------------------------------------------------


int main() {
    
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string N; cin >> N;
    int Ns = (int)(N.size());
    int K; cin >> K;
    
    ll res = 0;
    switch(K){
        case 1:
            res += 9 * (Ns-1);
            res += ctoi(N[0]);
            break;
        case 2:
            res += 9 * 9 * (Ns-1)*(Ns-2)/2;
            res += ctoi(N[0]) * 9 * (Ns-2);
            res += 9 * ctoi(N[0]) + ctoi(N[1]) - 9;
            break;
        case 3:
            res += 9 * 9 * 9 * (Ns-1)*(Ns-2)*(Ns-3)/6;
            
            int num = ctoi(N[0]) * 100 + ctoi(N[1]) * 10 + ctoi(N[2]);
            vector<int> zcnt(3, 0);
            repm(i, 100, num+1){
                int cnt = 0;
                if(i%10 == 0) cnt++;
                if((i/10)%10 == 0) cnt++;
                zcnt[cnt]++;
            }
            res += zcnt[0];
            res += zcnt[1] * 9 * (Ns-3);
            res += zcnt[2] * 9 * 9 * (Ns-3)*(Ns-4)/2;
            break;
    }
    cout << max(res, 0) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:243:16: error: no matching function for call to 'max(ll&, int)'
  243 |     cout << max(res, 0) << endl;
      |             ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:243:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  243 |     cout << max(res, 0) << endl;
      |             ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:243:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  243 |     cout << max(res, 0) << endl;
      |             ~~~^~~~~~~~