Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
t = [0 for _ in range(81)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in range(1, N+1):
            s = 0
            a = str(q)[0]
            b = str(q)[-1]
            if int(a) == i and int(b) == l:
                s += 1
            t[9*(i - 1)+l - 1] += s
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[9*(int(a)-1)+int(a)-1]
    else:
        ans += t[9*(int(b)-1)+int(a)-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
t = [0 for _ in range(81)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in range(1, N+1):
            s = 0
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                s += 1
            t[9*(i - 1)+l - 1] += s
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[9*(int(a)-1)+int(a)-1]
    else:
        ans += t[9*(int(b)-1)+int(a)-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
t = [0 for _ in range(81)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in range(1, N+1):
            s = 0
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                s += 1
            t[9*(i - 1)+l - 1] += s
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[9*(int(a)-1)+int(a)-1]
    else:
        ans += t[9*(int(b)-1)+int(a)-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in range(1, N+1):
            s = 0
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                s += 1
            t[i - 1][l - 1] += s
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[int(a)-1][int(a)-1]
    else:
        ans += t[int(b)-1][int(a)-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in range(1, N+1):
            s = 0
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                s += 1
            t[i - 1][l - 1] += s
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[int(a)-1][int(a)-1]
    else:
        ans += t[int(b)-1][int(a)-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
check = tuple(i for i in range(1, N+1))
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in check:
            s = 0
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                s += 1
            t[i - 1][l - 1] += s
for i in range(1, N+1):
    if str(i)[-1] == "0":
        continue
    elif len(str(i)) == 1:
        ans += t[i-1][i-1]
    else:
        ans += t[int(str(i)[-1])-1][int(str(i)[0])-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
check = tuple(i for i in range(1, N+1))
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in check:
            s = 0
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                s += 1
            t[i - 1][l - 1] += s
for i in range(1, N+1):
    if str(i)[-1] == "0":
        continue
    elif len(str(i)) == 1:
        ans += t[i-1][i-1]
    else:
        ans += t[int(str(i)[-1])-1][int(str(i)[0])-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
check = tuple(i for i in range(1, N+1))
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in check:
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                t[i-1][l-1] += 1
for i in range(1, N+1):
    if str(i)[-1] == "0":
        continue
    elif len(str(i)) == 1:
        ans += t[i-1][i-1]
    else:
        ans += t[int(str(i)[-1])-1][int(str(i)[0])-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
check = tuple(i for i in range(1, N+1))
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in check:
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                t[i-1][l-1] += 1
for i in range(1, N+1):
    if str(i)[-1] == "0":
        continue
    elif len(str(i)) == 1:
        ans += t[i-1][i-1]
    else:
        ans += t[int(str(i)[-1])-1][int(str(i)[0])-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
check = [i for i in range(1, N+1)]
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in check:
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                t[i-1][l-1] += 1
for i in range(1, N+1):
    if str(i)[-1] == "0":
        continue
    elif len(str(i)) == 1:
        ans += t[i-1][i-1]
    else:
        ans += t[int(str(i)[-1])-1][int(str(i)[0])-1]
print(ans)


Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque
input = sys.stdin.readline
N = int(input())
check = [i for i in range(1, N+1)]
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in check:
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                t[i-1][l-1] += 1
for i in range(1, N+1):
    if str(i)[-1] == "0":
        continue
    elif len(str(i)) == 1:
        ans += t[i-1][i-1]
    else:
        ans += t[int(str(i)[-1])-1][int(str(i)[0])-1]
print(ans)



Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque
input = sys.stdin.readline
N = int(input())
check = [i for i in range(1, N+1)]
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in check:
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                t[i-1][l-1] += 1
for i in range(1, N+1):
    if str(i)[-1] == "0":
        continue
    elif len(str(i)) == 1:
        ans += t[i-1][i-1]
    else:
        ans += t[int(str(i)[-1])-1][int(str(i)[0])-1]
print(ans)



Fixed submission:
N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)