CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))

ab = {}
for i in range(1, n+1):
    t = str(i)
    if (t[0], t[-1]) in ab:
        ab[(t[0], t[-1])] += 1
    else:
        ab[(t[0], t[-1])] = 1
#print(ab)
ans = 0
for i in range(1, n+1):
    t = str(i)
    if (t[-1], t[0]) in ab:
        ans += ab[(t[-1], t[0])]
print(ans)


# Optimized solution
from collections import defaultdict
n = int(eval(input()))
counter = defaultdict(int)

for i in range(1, n+1):
    t = str(i)
    counter[(t[0], t[-1])] += 1

ans = 0
for i in range(1, n+1):
    t = str(i)
    ans += counter[(t[-1], t[0])]
print(ans)
# Original solution
n = int(eval(input()))

c=[[0]*10 for i in range(10)]
for k in range(1,n+1):
  k=str(k)
  i=int(k[0])
  j=int(k[-1])
  c[i][j]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=c[i][j]*c[j][i]
print(ans)

# Optimized solution
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    N = int(eval(input()))
    presuf = [[0] * 10 for _ in range(10)]
    for i in range(1,N + 1):
        pre = int(str(i)[0])
        suf = i%10
        presuf[pre][suf] += 1
    
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += presuf[i][j]*presuf[j][i]
    print(ans)
if __name__ == '__main__':
    main()
# Original solution
from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 7)


@lru_cache(maxsize=None)
def check(l, r, n, k=1):
    t = l + '0' * k + r
    e = l + '9' * k + r

    if int(e) <= n:
        return pow(10, k) + check(l, r, n, k + 1)

    if int(t) <= n < int(e):
        x = int(str(n)[1:-1])
        if int(str(n)[-1]) < int(r):
            x -= 1
        return x + 1

    if n < int(t):
        return 0


def main():
    n = int(eval(input()))

    ret = 0
    for x in range(1, n + 1):
        if x % 10 == 0:
            continue
        s = str(x)
        t = s[-1] + s[0]
        if s[0] == s[-1]:
            ret += 1
        if int(t) <= n:
            ret += 1
        ret += check(s[-1], s[0], n, k=1)

    print(ret)


if __name__ == '__main__':
    main()


# Optimized solution
# 解説放送

def main():
    from collections import defaultdict

    n = int(eval(input()))

    d = defaultdict(int)
    for x in range(1, n + 1):
        if x % 10 == 0:
            continue

        tail = x % 10
        head = 0
        while x:
            head = x
            x //= 10

        d[head, tail] += 1

    ret = 0
    for (head, tail), cnt in tuple(d.items()):
        # RuntimeError: dictionary changed size during iteration
        # defaultdictの未定義(?)のkeyにアクセスするせいで、REになる
        # d.items()をtuple化して回避
        ret += d[head, tail] * d[tail, head]
        # (head,tail)の出現数を辞書で管理する
        # (head,tail)*(tail,head)の組み合わせがある

    print(ret)


if __name__ == '__main__':
    main()
# Original solution
n=int(eval(input()))
ans=0
dic={}
for i in range(1,n+1):
    s=str(i)
    d=(s[0],s[-1])
    if d not in list(dic.keys()):
        dic[d] = 1
    else:
        dic[d] += 1
 
for a in list(dic.keys()):
    b = (a[1],a[0])
    if b in list(dic.keys()):
        ans += dic[a]*dic[(a[1],a[0])]
 
print(ans)

# Optimized solution
n=int(eval(input()))

ans=0
Dic={}
for i in range(1,n+1):
    s=str(i)
    d=(s[0],s[-1])
    if d in list(Dic.keys()):
        Dic[d]+=1
    else:
        Dic[d]=1

for a in list(Dic.keys()):
    b=(a[1],a[0])
    if b in list(Dic.keys()):
        ans+=Dic[a]*Dic[b]
print(ans)
# Original solution
n=int(eval(input()))

D={}
for i in range(1,n+1):
    s=(str(i)[0],str(i)[-1])
    if s not in D:
        D[s]=1
    else:
        D[s]+=1
ans=0
for i in D:
    t=(i[1],i[0])
    if t in D:
        ans+=D[t]*D[i]
print(ans)

# Optimized solution
n=int(eval(input()))
D={}
for i in range(1,n+1):
    s=(str(i)[0],str(i)[-1])
    if s in D:
        D[s]+=1
    else:
        D[s]=1
ans=0
for i in D:
    t=(i[1],i[0])
    if t in D:
        ans+=D[t]*D[i]
print(ans)
# Original solution
n=int(eval(input()))
D={}
DD={}
for i in range(1,n+1):
   s=(str(i)[0],str(i)[-1])
   t=(str(i)[-1],str(i)[0])
   if s not in D:
      D[s]=1
   else:
      D[s]+=1
   if t not in DD:
      DD[t]=1
   else:
      DD[t]+=1
ans=0
for i in D:
   if i in DD:
      ans+=D[i]*DD[i]
print(ans)
      

# Optimized solution
n=int(eval(input()))
D={}
for i in range(1,n+1):
   s=(str(i)[0],str(i)[-1])
   if s in D:
      D[s]+=1
   else:
      D[s]=1

ans=0
for aj,bj in D:
   if (bj,aj) in D:
      ans+=D[(aj,bj)]*D[(bj,aj)]
print(ans)
# Original solution
N = int(eval(input()))
mem = [[0]*10 for _ in range(10)]

for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    mem[a][b] += 1

ans = 0
for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    ans += mem[b][a]
print(ans)


# Optimized solution
N = int(eval(input()))
mem=[[0] * 10 for _ in range(10)]

for i in range(1, N+1):
    s = str(i)
    mem[int(s[0])][int(s[-1])] += 1 
    
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += mem[i][j] * mem[j][i]
print(ans)
# Original solution
import sys
from collections import deque
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from bisect import bisect, bisect_left

def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    strN = str(N)
    maxDig = len(strN)
    count = 0
    for i in range(1, N + 1):
        a = str(i)
        low = int(a[-1])
        if low == 0: continue
        high = int(a[0])
        if low == high: count += 1 #一番上位と下位の桁の数字が同じ
        digb = 2
        while digb < maxDig:
            count += 10 ** (digb - 2)
            digb += 1
        if N >= 10:
            if low > int(strN[0]): continue
            elif low < int(strN[0]): count += 10 ** (digb - 2)
            elif N >= 10:
                DP = [[0, 0] for _ in range(maxDig)]
                DP[0][0] = 1
                for j in range(1, maxDig - 1):
                    DP[j][0] = 1
                    DP[j][1] = DP[j-1][1] * 10 + DP[j-1][0] * (int(strN[j]))

                count += DP[maxDig - 2][1] 
                #print(i, DP)
                if int(strN[maxDig - 1]) >= high: count += 1

    print(count)
        
        

    return 0

if __name__ == "__main__":
    solve()

# Optimized solution
import sys

def solve():
    N = int(eval(input()))
    D = dict()
    for i in range(1, N + 1):
        front = i % 10
        back = i
        while back >= 10: back //= 10
        if front > 0:
            if (front, back) in D: D[(front, back)] += 1
            else: D[(front, back)] = 1
    Ans = 0
    for i in range(1, N + 1):
        back = i % 10
        if back > 0:
            front = i
            while front >= 10: front //= 10
            if (front, back) in D: Ans += D[(front, back)]
    print(Ans)

    return 0

if __name__ == "__main__":
    solve()
# Original solution
import sys

def solve():
    N = int(eval(input()))
    D = dict()
    for i in range(1, N + 1):
        front = i % 10
        back = i
        while back >= 10: back //= 10
        if front > 0:
            if (front, back) in D: D[(front, back)] += 1
            else: D[(front, back)] = 1
    Ans = 0
    for i in range(1, N + 1):
        back = i % 10
        if back > 0:
            front = i
            while front >= 10: front //= 10
            if (front, back) in D: Ans += D[(front, back)]
    print(Ans)

    return 0

if __name__ == "__main__":
    solve()

# Optimized solution
import sys

def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    dictType = dict()
    for i in range(1, 10):
        for j in range(1, 10): dictType[(i, j)] = 0
    for i in range(1, N + 1):
        bottom = i % 10
        if bottom == 0: continue
        top = i
        while top >= 10: top //= 10
        dictType[(top, bottom)] += 1

    ans = 0
    for i in range(1, N + 1):
        bottom = i % 10
        if bottom == 0: continue
        top = i
        while top >= 10: top //= 10
        ans += dictType[(bottom, top)]
    print(ans)

    return 0

if __name__ == "__main__":
    solve()
# Original solution
import sys
input = sys.stdin.readline
N = int(eval(input()))
keta = len(str(N))
if keta == 1:
    print(N)
    sys.exit()
ans = {}
for i in [1,2,3,4,5,6,7,8,9]:
    for j in [1,2,3,4,5,6,7,8,9]:
        ans[(i, j)] = 0
for i in range(1, N+1):
    maxdigit = int(str(i)[0])
    mindigit = int(str(i)[-1])
    if mindigit != 0:
        ans[(maxdigit, mindigit)] += 1
cnt = 0
for i in range(1, 10):
    for j in range(1, 10):
        if i == j:
            cnt += ans[(i, i)] ** 2
        else:
            cnt += ans[(i, j)] * ans[(j, i)] * 2
            ans[(i, j)] = 0
            ans[(j, i)] = 0
print(cnt)

        

    

# Optimized solution
import sys
input = sys.stdin.readline

n = int(eval(input()))

from collections import defaultdict

d = defaultdict(int) # d[(a, b)] : 先頭a, 末尾b

for i in range(1, n + 1):
    i_str = str(i)
    d[(i_str[0], i_str[-1])] += 1

ans = 0

for i in range(1, 10):
    for j in range(10):
        ans += d[(str(i), str(j))] * d[(str(j), str(i))]

print(ans)
# Original solution
n = int(eval(input()))
t = [[0 for j in range(10)] for i in range(10)]
for i in range(1,n+1):
    s = str(i)
    t[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += t[i][j]*t[j][i]
print(ans)

# Optimized solution
n = int(eval(input()))
c = [[0 for j in range(10)] for i in range(10)]

for i in range(1,n+1):
    t = str(i)
    c[int(t[0])][int(t[-1])] += 1
    
ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += c[i][j]*c[j][i]
print(ans)
# Original solution
n=int(eval(input()))
a=[[0]*10 for i in range(10)]
for i in range(1,n+1):
    a[int(str(i)[0])][i%10]+=1
def N(x,y): # no of x...y < n
    return a[x][y]

ans=0
for x in range(1,10):
    ans+=N(x,x)*N(x,x)
    for y in range(x+1,10):
        ans+=N(x,y)*N(y,x)*2
print(ans)

# Optimized solution
n=int(eval(input()))
a=[[0]*10 for i in range(10)]
for i in range(1,n+1):
    a[int(str(i)[0])][i%10]+=1
ans=0
for x in range(1,10):
    ans+=a[x][x]**2
    for y in range(x+1,10):
        ans+=a[y][x]*a[x][y]*2
print(ans)
# Original solution
mod = 1e9+7
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    m = {}
    N = int(input())
    
    for i in range(1, N+1):
        s = str(i)
        first = s[0]
        last = s[-1]
        key = first + last
        m[key] = m.get(key, 0) + 1
    
    ans = 0
    
    #print(m)
    
    for key1 in m:
        for key2 in m:
            #if key1 == key2:
            #    continue
            if key1[0] == key2[1] and key1[1] == key2[0]:
                ans += m[key1] * m[key2]
    
    print(ans)
    
    
    

main()

# Optimized solution
mod = 1e9+7
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    m = {}
    N = int(input())
    
    for i in range(1, N+1):
        s = str(i)
        first = s[0]
        last = s[-1]
        key = first + last
        m[key] = m.get(key, 0) + 1
    
    ans = 0
    
    #print(m)
    for k in m:
        if k[0] == k[1]:
            ans += m[k] * m[k]
        else:
            swap = k[1] + k[0]
            ans += m[k] * m.get(swap, 0)
    """
    for key1 in m:
        for key2 in m:
            #if key1 == key2:
            #    continue
            if key1[0] == key2[1] and key1[1] == key2[0]:
                ans += m[key1] * m[key2]
    """
    
    print(ans)
    
    
    

main()
# Original solution
from collections import defaultdict

def main():
    N = int(eval(input()))
    combs = [(S[0], S[-1]) for S in map(str, list(range(1, N+1)))]
    d = defaultdict(int)
    for pre, suf in combs:
        if suf != "0":
            d[(pre, suf)] += 1
            d[(suf, pre)]

    ans = 0
    for key, val in list(d.items()):
        pre, suf = key
        ans += val * d[(suf, pre)]
        
    print(ans)
if __name__ == "__main__":
    main()

# Optimized solution
from collections import defaultdict

def main():
    N = int(eval(input()))
    combs = [(S[0], S[-1]) for S in map(str, list(range(1, N+1)))]
    d = defaultdict(int)
    for pre, suf in combs:
        d[(pre, suf)] += 1
        d[(suf, pre)]

    ans = 0
    for key, val in list(d.items()):
        pre, suf = key
        ans += val * d[(suf, pre)]
        
    print(ans)
if __name__ == "__main__":
    main()
# Original solution
d=[0]*100
for i in range(int(eval(input()))):
  s=str(i+1)
  d[int(s[0])*10+int(s[-1])]+=1
print((sum(d[i]*d[i%10*10+i//10]for i in range(100))))

# Optimized solution
d=[0]*100
for i in range(int(eval(input()))):s=str(i+1);d[int(s[0]+s[-1])]+=1
print((sum(d[i]*d[i%10*10+i//10]for i in range(100))))
# Original solution
N = int(eval(input()))

li = [[0 for j in range(9)] for i in range(9)]


for i in range(1,N+1):
    start = str(i)[0]
    end = str(i)[-1]
    if start != '0' and end != '0':
        li[int(start)-1][int(end)-1] += 1
ans = 0
for i in range(1,N+1):
    start = str(i)[0]
    end = str(i)[-1]
    if start != '0' and end != '0':
        ans += li[int(end)-1][int(start)-1]
print(ans)

# Optimized solution
n = int(eval(input()))

a = [[0 for i in range(10)] for j in range(10)]
for i in range(1,n+1):
    s = str(i)
    a[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += a[i][j]*a[j][i]
print(ans)
# Original solution
N = int(eval(input()))
mem = [[0]*10 for i in range(10)]

for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    mem[a][b] += 1

ans = 0
for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    ans += mem[b][a]
print(ans)

# Optimized solution
N = int(eval(input()))

d = [[0]*10 for i in range(10)]
for n in range(1,N+1):
    s = str(n)
    d[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += d[i][j] * d[j][i]
print(ans)
# Original solution
N = int(eval(input()))

c = [[0]*10 for _ in range(10)]
for n in range(1,N+1):
    s = str(n)
    c[int(s[0])][int(s[-1])] += 1

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

# Optimized solution
N = int(eval(input()))

dp = [[0]*10 for _ in range(10)]

for n in range(1,N+1):
    s = str(n)
    dp[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += dp[i][j] * dp[j][i]
print(ans)
# Original solution
#python3
from collections import defaultdict
from collections import namedtuple

P = namedtuple('P', ['front', 'end'])

def f(x):
    return P(str(x)[0], str(x)[-1]) 

def main():

    n = int(eval(input()))
    freq = defaultdict(int)

    for i in range(1, n+1):
        p = f(i)
        freq[p]+=1


    ans = 0
    for i in range(1, n + 1):
        p = f(i)
        q = (p.end, p.front)
        ans += freq[q]

    print(ans)

main()

# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import defaultdict

def f(x):
    return (int(str(x)[0]), int(str(x)[-1])) 
def main():
    N = int(readline())
    df = defaultdict(int)
    for i in range(1, N+1):
        df[f(i)] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans +=  df[(i, j)]*df[(j, i)]
    print(ans)
if __name__ == '__main__':
    main()
# Original solution
n=int(eval(input()))
lists=[[ [] for j in range(10)]for i in range(10)]
for i in range(1,n+1):
    a=str(i)
    lists[int(str(a[0]))][int(str(a[-1]))].append(i)
c=0
for i in range(1,10):
    for j in range(1,10):
        c+=len(lists[i][j])*len(lists[j][i])
print(c)        


# Optimized solution
n=int(eval(input()))
lists=[[ 0 for j in range(10)]for i in range(10)]
for i in range(1,n+1):
    a=str(i)
    lists[int(a[0])][int(a[-1])]+=1
c=0
for i in range(1,10):
    for j in range(1,10):
        c+=lists[i][j]*lists[j][i]
print(c)
# Original solution
N=int(eval(input()))

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(i)
  f=int(S[0])
  b=int(S[-1])
  M[f][b]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)


# Optimized solution
N=int(eval(input()))

M=[[0]*10 for _ in range(10)]

for i in range(1,N+1):
  S=str(i)
  M[int(S[0])][int(S[-1])]+=1
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)
# Original solution
n = int(eval(input()))
ans=0
for i in range(1,n+1):
    a=str(i)[0]
    b=str(i)[-1]
    for digit in range(1,7):
        if digit == 1:
            if a==b:
                ans+=1
        elif b!='0':
            mn = int(b+'0'*(digit-2)+a)
            mx = int(b+'9'*(digit-2)+a)
            if mn>n:
                break
            if mx<=n:
                ans+=10**(digit-2)
            else:
                ns=str(n)
                for j in range(1,len(ns)-1):
                    ans+=int(ns[j])*10**(max(digit-2-j,0))
                if ns[-1]>=a:
                    ans+=1
                break


print(ans)





# Optimized solution
n = int(eval(input()))
ans=0
mp=[[0]*10 for _ in range(10)]
for i in range(1,n+1):
    a=int(str(i)[0])
    b=int(str(i)[-1])
    mp[a][b]+=1

for i in range(10):
    for j in range(10):
        ans+=mp[i][j]*mp[j][i]
    


print(ans)
# Original solution
n = int(eval(input()))
c = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
  p = int(str(i)[0])
  q = int(str(i)[-1])
  c[p][q] += 1

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

print(ans)

# Optimized solution
n = int(eval(input()))
C = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
  C[int(str(i)[0])][i % 10] += 1
  
ans = 0
for i in range(10):
  for j in range(10):
    ans += C[i][j] * C[j][i]
print(ans)
# Original solution
from collections import defaultdict
N = int(eval(input()))
ans = 0
c = defaultdict(int)

for i in range(1, N+1):
  s = int(str(i)[0])
  t = int(str(i)[-1])
  if s != 0 and t != 0:
    c[(s, t)] += 1

for i in range(1, 10):
  for j in range(1, 10):
    ans += c[(i, j)] * c[(j, i)]
print(ans)


# Optimized solution
from collections import defaultdict
N = int(eval(input()))
d = defaultdict(int)

for i in range(1, N+1):
  s, t = str(i)[0], str(i)[-1]

  if s != 0 and t != 0:
    if s > t:
      s, t = s, t
    d[(s, t)] += 1

ans = 0
for i in range(1, 11):
  for j in range(1, 11):
    i = str(i)
    j = str(j)
    ans += d[(i, j)]*d[(j, i)]

print(ans)
# Original solution
# !/usr/bin/python3

"""
https://atcoder.jp/contests/abc152/tasks/abc152_d
Low Elements.
"""

def solve(n):
    res = 0

    for num in range(n+1):
        start = int(str(num)[0])
        end = int(str(num)[-1])

        for i in range(10):
            for j in range(10):
                if i == start and j == end: dp[i][j] += 1

    for i in range(1, 10):
        for j in range(1, 10):
            res += dp[i][j]*dp[j][i]
    # for each in dp: print(each)

    return res


if __name__ == "__main__":
    n = int(eval(input()))
    dp = [[0 for _ in range(10)] for _ in range(10)]

    print((solve(n)))


# Optimized solution
# !/usr/bin/python3

"""
https://atcoder.jp/contests/abc152/tasks/abc152_d
Low Elements.
"""

def solve(n):
    res = 0

    for num in range(n+1):
        start = int(str(num)[0])
        end = int(str(num)[-1])

        for i in range(1, 10):
            for j in range(1, 10):
                if i == start and j == end: dp[i][j] += 1

    for i in range(1, 10):
        for j in range(1, 10):
            res += dp[i][j]*dp[j][i]
    # for each in dp: print(each)

    return res


if __name__ == "__main__":
    n = int(eval(input()))
    dp = [[0 for _ in range(10)] for _ in range(10)]

    print((solve(n)))
# Original solution
n = int(eval(input()))
letters_mapping = {num: {num2:[] for num2 in range(10)} for num in range(10)}

for num in range(1, n + 1):
    first_letter = str(num)[0]
    last_letter = str(num)[-1]
    letters_mapping[int(first_letter)][int(last_letter)].append(num)

count = 0
for i, v in list(letters_mapping.items()):
    for j, x in list(letters_mapping[i].items()):
        for num in letters_mapping[i][j]:
            count += len(letters_mapping[j][i])
            
print(count) 

# Optimized solution
n = int(eval(input()))
a = [[0 for i in range(10)] for j in range(10)]
for i in range(1, n+1):
    s = str(i)
    if s[-1] != '0':
        a[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += a[i][j] * a[j][i]
print(ans)
# Original solution
N = int(eval(input()))
ans = 0
tmp = int("0"+str(N)[1:-1])
NR = int(str(N)[-1])
for i in range(1,N+1):
    L = int(str(i)[0])
    R = int(str(i)[-1])
    if R == 0:
        continue
    if L == R:
        ans += 1
    for j in range(1,6):
        mini = (R*10**j) +L
        maxi = ((R+1)*10**j) +L-10
        if N < mini:
            break
        if maxi <= N:
            ans += 10**(j-1)
            continue
        
        if L <= NR:
            ans += tmp+1
        else:
            ans += tmp
        break
print(ans)


# Optimized solution
#https://atcoder.jp/contests/abc152/submissions/9607915

N = int(eval(input()))
lis = [[0]*10 for _ in range(10)]

for i in range(1,N+1):
    s = str(i)
    lis[int(s[0])][int(s[-1])] += 1

ans = 0
#A,Bになりうる数字の数をカウントして掛け算
for i in range(10):
    for j in range(10):
        ans += lis[i][j]*lis[j][i]
print(ans)
# Original solution
n=int(eval(input()))
A=[[0 for i in range(9)] for j in range(9)]

for i in range(1,n+1):
    if i%10!=0:
        num=str(i)
        A[int(num[0])-1][int(num[-1])-1] +=1

cnt=0
for i in range(9):
    for j in range(9):
        cnt +=A[i][j]*A[j][i]

print(cnt)

# Optimized solution
n=int(eval(input()))
A=[[0 for i in range(10)] for j in range(10)]

for i in range(1,n+1):
    num=str(i)
    A[int(num[0])][int(num[-1])] +=1

ans=0
for i in range(1,10):
    for j in range(1,10):
        ans +=A[i][j]*A[j][i]
        
print(ans)
# Original solution
def n0():return int(eval(input()))
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(eval(input())) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
length=len(str(n))

ans=0
for i in range(1,10):
    if n<i:
        break
    s=0
    for j in range(1,length+1):
        if j<=1:
            s+=1
        elif j<length:
            s+=(10**(j-2))
        else:
            for m in range(n,10**(length-1),-1):
                if str(m)[0]==str(m)[-1]==str(i):
                    s+=1
    ans+=s*s
for i1 in range(1,10):
    for i2 in range(1,10):
        if i1==i2:
            break;
        s1=0
        s2=0
        for j in range(2,length+1):
            if j<length:
                s1+=10**(j-2)
                s2+=10**(j-2)
            else:
                for m in range(n,10**(length-1),-1):
                    if str(m)[0]==str(i1) and str(m)[-1]==str(i2):
                        s1+=1
                    elif str(m)[0]==str(i2) and str(m)[-1]==str(i1):
                        s2+=1
        ans+=s1*s2*2
print(ans)

# Optimized solution
def n0():return int(eval(input()))
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(eval(input())) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
length=len(str(n))

ans=0
for i in range(1,10):
    if n<i:
        break
    s=0
    for j in range(1,length+1):
        if j<=1:
            s+=1
        elif j<length:
            s+=(10**(j-2))
        else:
            if not(length==6 and i>=2):
                for m in range(n,10**(length-1),-1):
                    if str(m)[0]==str(m)[-1]==str(i):
                        s+=1
    ans+=s*s
for i1 in range(1,10):
    for i2 in range(1,10):
        if i1==i2:
            break;
        s1=0
        s2=0
        for j in range(2,length+1):
            if j<length:
                s1+=10**(j-2)
                s2+=10**(j-2)
            else:
                if not(length==6 and i1>=2 and i2>=2):
                    for m in range(n,10**(length-1),-1):
                        if str(m)[0]==str(i1) and str(m)[-1]==str(i2):
                            s1+=1
                        elif str(m)[0]==str(i2) and str(m)[-1]==str(i1):
                            s2+=1
        ans+=s1*s2*2
print(ans)