Language: C++

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

int count(int a, int x, int y, int n) {
  int keta = log10(a) + 1;
  int nketa = log10(n) + 1;
  // if (keta == 1) {
  if(nketa == 1){
    return 1;
  }
  if(nketa == 2){
    if(keta == 1 || x==y) {
    }
    if((10*y+x) > n) {
      ret =  0;
    }
    else {
      ret =  1;
    }
  }
  if(nketa == 3) {
    if(100*y+x > n){
      ret = 2;
    }
    else {
      ret =  2 + ((n - (100*y + x)) / 10);
    }
  }
  if(nketa == 4) {
    if(1000*y+x > n){
      ret 2 + 9;
    }
    else {
      ret 2 + 9 + ((n - (1000*y + x)) / 10);
    }
  }
  if(nketa == 5) {
    if(1-000*y+y > n){
      ret 2 + 9 + 99;
    }
    else {
      ret 2 + 99 + ((n - (10000*y + x)) / 10);
    }
  }
  if(x == y)
    return ret +1;
  else
    return ret;
}
//   if(keta >= 2) {
//     if(x == y){
//       if(nketa <= 2)
//       return 2;
//     }
//     int kouho = y*10 + x;
//     if(kouho <= n){
//       return 1;
//     }
//     else{
//       return 0;
//     }
//   }
//   return 0;
// }

int main() {
  int n;
  cin >> n;
  int keta = log10(n) + 1;
  int chigau = 36;
  int onaji = 9;
  int ans = 0;
  rep(i,n+1) {
    if(i%10 == 0) {
      cout << "i: " << i << " pass" << endl;
      cout << endl;
      continue;
    }
    else{
      int x = i / pow(10, log(1) +1);
      int y = i % 10;
      // cout << "i :" << i << endl;
      // cout << "x :" << x << endl;
      // cout << "y :" << y << endl;
      // cout << "count(i, x, y, n) :" << count(i, x, y, n) << endl;
      // cout << endl;
      ans += count(i, x, y, n);
    }
  }
  cout << ans<< endl;
  return 0;
}


Compiler output:
a.cc: In function 'int count(int, int, int, int)':
a.cc:17:7: error: 'ret' was not declared in this scope; did you mean 'rep'?
   17 |       ret =  0;
      |       ^~~
      |       rep
a.cc:20:7: error: 'ret' was not declared in this scope; did you mean 'rep'?
   20 |       ret =  1;
      |       ^~~
      |       rep
a.cc:25:7: error: 'ret' was not declared in this scope; did you mean 'rep'?
   25 |       ret = 2;
      |       ^~~
      |       rep
a.cc:28:7: error: 'ret' was not declared in this scope; did you mean 'rep'?
   28 |       ret =  2 + ((n - (100*y + x)) / 10);
      |       ^~~
      |       rep
a.cc:33:7: error: 'ret' was not declared in this scope; did you mean 'rep'?
   33 |       ret 2 + 9;
      |       ^~~
      |       rep
a.cc:36:7: error: 'ret' was not declared in this scope; did you mean 'rep'?
   36 |       ret 2 + 9 + ((n - (1000*y + x)) / 10);
      |       ^~~
      |       rep
a.cc:41:7: error: 'ret' was not declared in this scope; did you mean 'rep'?
   41 |       ret 2 + 9 + 99;
      |       ^~~
      |       rep
a.cc:44:7: error: 'ret' was not declared in this scope; did you mean 'rep'?
   44 |       ret 2 + 99 + ((n - (10000*y + x)) / 10);
      |       ^~~
      |       rep
a.cc:48:12: error: 'ret' was not declared in this scope; did you mean 'rep'?
   48 |     return ret +1;
      |            ^~~
      |            rep
a.cc:50:12: error: 'ret' was not declared in this scope; did you mean 'rep'?
   50 |     return ret;
      |            ^~~
      |            rep