This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define db long double
#define vll vector<pll>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define int long long
int dp[20][11][11][2], a, b;
int solve(string &s, int pos, int d1, int d2, int f){
    // cout << pos << " " << d1 << " " << d2 << " " << f << endl;
    if(pos == s.size()) return 1;
    if(dp[pos][d1][d2][f] != -1)    return dp[pos][d1][d2][f];
    int res = 0;
    if(d2 == 10)    res += solve(s, pos + 1, d1, d2, 0);
    for(int i = (d2 == 10 ? 1 : 0); i <= (f ? s[pos] - '0' : 9); i++){
        if(i == d1 or i == d2)  continue;
        res += solve(s, pos + 1, d2, i, (f & ((s[pos] - '0') == i)));
    }
    return dp[pos][d1][d2][f] = res;
}
void fmain(){
    cin >> a >> b;
    a--;
    string sa = to_string(a), sb = to_string(b);
    for(int i = 0; i < 20; i++){
        for(int j = 0; j < 11; j++){
            for(int z = 0; z < 11; z++){
                dp[i][j][z][0] = dp[i][j][z][1] = -1;
            }
        }
    }
    int resa = (a == -1 ? 0 : solve(sa, 0, 10, 10, 1));
    for(int i = 0; i < 20; i++){
        for(int j = 0; j < 11; j++){
            for(int z = 0; z < 11; z++){
                dp[i][j][z][0] = dp[i][j][z][1] = -1;
            }
        }
    }
    int resb = solve(sb, 0, 10, 10, 1);
    cout << resb - resa;
}
 
signed main(){
    fastio;
    int tmr = 1;
    // cin >> tmr;
    while(tmr--){
        fmain();
    }
    
}
Compilation message (stderr)
numbers.cpp: In function 'long long int solve(std::string&, long long int, long long int, long long int, long long int)':
numbers.cpp:25:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     if(pos == s.size()) return 1;
      |        ~~~~^~~~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |