Buggy python submission (verdict: Runtime Error):
N = int(input())
# N = random.randint(1,2*10**5)

N_ =str(N)
n_o=len(N_)

# ans:条件を満たす組みの個数
ans=0

def get_ans(A):
    ans=0
    A_=str(A)
    a_s=A_[0]
    a_e=A_[-1]
#     print(a_s,a_e)
    
    if int(a_e) == 0:
        return 0

    if a_s == a_e:
        ans+=1

    for b_o in range(2,n_o+1):
        B_temp = []
        if b_o < n_o:
            ans += 10**(b_o-2)

        elif b_o == n_o:
            if int(a_e) > int(N_[0]):
                break
            elif int(a_e) < int(N_[0]):
                ans += 10 ** (b_o-2)
            else:
                ans+=int(N_[1:-1])

        else:
            break
        
    return ans

for a in range(1,N+1):
    ans_=get_ans(a)
    ans+=ans_
print(ans)

Fixed submission:
N = int(input())

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

for n in range(1,N+1):
    n=str(n)
    n_s=int(n[0])
    n_e=int(n[-1])
    
    C[n_s][n_e]+=1
    
ans=0
for c_1 in range(10):
    for c_2 in range(10):
        ans += C[c_1][c_2]*C[c_2][c_1]
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N = int(input())

N_ =str(N)
n_o=len(N_)

# ans:条件を満たす組みの個数
ans=0

def get_ans(A):
    ans=0
    A_=str(A)
    a_s=A_[0]
    a_e=A_[-1]
#     print(a_s,a_e)
    
    if int(a_e) == 0:
        return 0

    if a_s == a_e:
        ans+=1

    for b_o in range(2,n_o+1):
        B_temp = []
        if b_o < n_o:
            ans += 10**(b_o-2)

        elif b_o == n_o:
            if int(a_e) > int(N_[0]):
                break
            elif int(a_e) < int(N_[0]):
                ans += 10**(b_o-2)
            else:      
                for p in product(range(10),repeat=n_o-2):
                    ans_temp=int(a_e+''.join(map(str,p))+a_s)
                    if ans_temp > N:
                        break
                    ans+=1 
                    B_temp.append(ans_temp)
    #                 print(B_temp)

        else:
            break
        
    return ans

for a in range(1,N+1):
#     print('====',a)
    ans_=get_ans(a)
    ans+=ans_
print(ans)

Fixed submission:
N = int(input())

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

for n in range(1,N+1):
    n=str(n)
    n_s=int(n[0])
    n_e=int(n[-1])
    
    C[n_s][n_e]+=1
    
ans=0
for c_1 in range(10):
    for c_2 in range(10):
        ans += C[c_1][c_2]*C[c_2][c_1]
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N = int(input())

N_ =str(N)
n_o=len(N_)

# ans:条件を満たす組みの個数
ans=0

def get_ans(A):
    ans=0
    A_=str(A)
    a_s=A_[0]
    a_e=A_[-1]
#     print(a_s,a_e)
    
    if int(a_e) == 0:
        return 0

    if a_s == a_e:
        ans+=1

    for b_o in range(2,n_o+1):
        B_temp = []
        if b_o < n_o:
            ans += 10**(b_o-2)

        elif b_o == n_o:
            if int(a_e) > int(N_[0]):
                break
            elif int(a_e) < int(N_[0]):
                ans += 10**(b_o-2)
            else:      
                for p in product(range(10),repeat=n_o-2):
                    ans_temp=int(a_e+''.join(map(str,p))+a_s)
                    if ans_temp > N:
                        break
                    ans+=1 
                    B_temp.append(ans_temp)
    #                 print(B_temp)

        else:
            break
        
    return ans

for a in range(1,N+1):
#     print('====',a)
    ans_=get_ans(a)
    ans+=ans_
print(ans)

Fixed submission:
N = int(input())

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

for n in range(1,N+1):
    n=str(n)
    n_s=int(n[0])
    n_e=int(n[-1])
    
    C[n_s][n_e]+=1
    
ans=0
for c_1 in range(10):
    for c_2 in range(10):
        ans += C[c_1][c_2]*C[c_2][c_1]
        
print(ans)

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

N_ =str(N)
n_o=len(N_)

# ans:条件を満たす組みの個数
ans=0

def get_ans(A):
    ans=0
    A_=str(A)
    a_s=A_[0]
    a_e=A_[-1]
#     print(a_s,a_e)
    
    if int(a_e) == 0:
        return 0

    if a_s == a_e:
        ans+=1

    for b_o in range(2,n_o+1):
        B_temp = []
        if b_o < n_o:
            ans += 10**(b_o-2)

        elif b_o == n_o:
            if int(a_e) > int(N_[0]):
                break
            elif int(a_e) < int(N_[0]):
                ans += 10**(b_o-2)
            else:      
                for p in product(range(10),repeat=n_o-2):
                    ans_temp=int(a_e+''.join(map(str,p))+a_s)
                    if ans_temp > N:
                        break
                    ans+=1 
                    B_temp.append(ans_temp)
    #                 print(B_temp)

        else:
            break
        
    return ans

for a in range(1,N+1):
#     print('====',a)
    ans_=get_ans(a)
    ans+=ans_
print(ans)

Fixed submission:
N = int(input())

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

for n in range(1,N+1):
    n=str(n)
    n_s=int(n[0])
    n_e=int(n[-1])
    
    C[n_s][n_e]+=1
    
ans=0
for c_1 in range(10):
    for c_2 in range(10):
        ans += C[c_1][c_2]*C[c_2][c_1]
        
print(ans)