Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

c = [[0 for _ in range(9)] for _ in range(9)]
for i in range(1, 10):
  for j in range(1, 10):
    cnt = 0
    for n in range(1, N + 1):
      if n // (10 ** (len(str(n)) - 1)) == i and n % 10 == j:
        cnt += 1
    c[i - 1][j - 1] = cnt

ans = 0
for i in range(9):
  for j in range(9):
    ans += c[i][j] * c[j][i]
print(ans)

Fixed submission:
N = int(input())

c = [[0 for _ in range(9)] for _ in range(9)]
for i in range(1, 10):
  for j in range(1, 10):
    cnt = 0
    for n in range(1, N + 1):
      if n // (10 ** (len(str(n)) - 1)) == i and n % 10 == j:
        cnt += 1
    c[i - 1][j - 1] = cnt

ans = 0
for i in range(9):
  for j in range(9):
    ans += c[i][j] * c[j][i]
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

def check(a, b, i):
  if (a + 1) * 10 ** i + b - 10 <= N:
    return 10 ** (i - 1)
  else:
    ret = 0
    for j in range(10 ** (i - 1)):
      if a * 10 ** i + j * 10 + a <= N:
        ret += 1
      else:
        return ret
ans = 0
for a in range(1, 10):
  for b in range(a, 10):
    if a == b:
      n = 0
      if a * 10 + b <= N:
        n += 2
      elif a <= N:
        n += 1
      for i in range(2, 6):
        n += check(a, b, i)
      ans += n ** 2
    else:
      n, m = 0, 0
      if a * 10 + b <= N:
        n += 1
      if b * 10 + a <= N:
        m += 1
      for i in range(2, 6):
        n += check(a, b, i)
        m += check(b, a, i)
      ans += n * m * 2
print(ans)

Fixed submission:
N = int(input())

c = [[0 for _ in range(9)] for _ in range(9)]
for i in range(1, 10):
  for j in range(1, 10):
    cnt = 0
    for n in range(1, N + 1):
      if n // (10 ** (len(str(n)) - 1)) == i and n % 10 == j:
        cnt += 1
    c[i - 1][j - 1] = cnt

ans = 0
for i in range(9):
  for j in range(9):
    ans += c[i][j] * c[j][i]
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

def check(a, b, i):
  if (a + 1) * 10 ** i + b - 10 <= N:
    return 10 ** (i - 1)
  else:
    ret = 0
    for j in range(10 ** (i - 1)):
      if a * 10 ** i + j * 10 + a <= N:
        ret += 1
      else:
        return ret
ans = 0
for a in range(1, 10):
  for b in range(1, 10):
    if a == b:
      n = 0
      if a * 10 + b <= N:
        n += 2
      elif a <= N:
        ans += 1
      for i in range(2, 6):
        n += check(a, b, i)
      ans += n ** 2
    else:
      n, m = 0, 0
      if a * 10 + b <= N:
        n += 1
      if b * 10 + a <= N:
        m += 1
      for i in range(2, 6):
        n += check(a, b, i)
        m += check(b, a, i)
      ans += n * m
print(ans)

Fixed submission:
N = int(input())

c = [[0 for _ in range(9)] for _ in range(9)]
for i in range(1, 10):
  for j in range(1, 10):
    cnt = 0
    for n in range(1, N + 1):
      if n // (10 ** (len(str(n)) - 1)) == i and n % 10 == j:
        cnt += 1
    c[i - 1][j - 1] = cnt

ans = 0
for i in range(9):
  for j in range(9):
    ans += c[i][j] * c[j][i]
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

def check(a, b, i):
  if (a + 1) * 10 ** i + b - 10 <= N:
    return 10 ** (i - 1)
  else:
    ret = 0
    for j in range(10 ** (i - 1)):
      if a * 10 ** i + j * 10 + a <= N:
        ret += 1
      else:
        return ret
ans = 0
for a in range(1, 10):
  for b in range(a, 10):
    if a == b:
      n = 0
      if a * 10 + b <= N:
        n += 2
      elif a <= N:
        ans += 1
      for i in range(2, 6):
        n += check(a, b, i)
      ans += n ** 2
    else:
      n, m = 0, 0
      if a * 10 + b <= N:
        n += 1
      if b * 10 + a <= N:
        m += 1
      for i in range(2, 6):
        n += check(a, b, i)
        m += check(b, a, i)
      ans += n * m * 2
print(ans)

Fixed submission:
N = int(input())

c = [[0 for _ in range(9)] for _ in range(9)]
for i in range(1, 10):
  for j in range(1, 10):
    cnt = 0
    for n in range(1, N + 1):
      if n // (10 ** (len(str(n)) - 1)) == i and n % 10 == j:
        cnt += 1
    c[i - 1][j - 1] = cnt

ans = 0
for i in range(9):
  for j in range(9):
    ans += c[i][j] * c[j][i]
print(ans)