ZhenlongDai/ACPR huggingface dataset:
Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())

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

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


Failing test case input:
2158

Expected output:
46642


Actual output:
46620


Fixed submission (verdict: Accepted):
N = int(input())
cnt = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    cnt[int(str(i)[0])][int(str(i)[-1])] += 1

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

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [[0]*10 for i in range(10)]
for i in range(1,N):
    h = int(str(i)[0])
    t = int(str(i)[-1])
    A[h][t] += 1
ans = 0
for i in range(1,10):
    for j in range(0,10):
        ans += A[i][j] * A[j][i]
if N < 10:
    ans += 1
print(ans)

Failing test case input:
2011

Expected output:
40631


Actual output:
40409


Fixed submission (verdict: Accepted):
N = int(input())
A = [[0]*10 for i in range(10)]
for i in range(1,N+1):
    h = int(str(i)[0])
    t = int(str(i)[-1])
    A[h][t] += 1
ans = 0
for i in range(1,10):
    for j in range(0,10):
        ans += A[i][j] * A[j][i]
print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
N_str = list(str(N))
length = len(str(N))


c = [[0]*9 for i in range(9)]


for i in range(1, N):
    s = str(i)
    if s[0] == "0" or s[-1] == "0":continue
    c[int(s[0])-1][int(s[-1])-1] += 1

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

print(ans)


Failing test case input:
2011

Expected output:
40631


Actual output:
40409


Fixed submission (verdict: Accepted):
N = int(input())
N_str = list(str(N))
length = len(str(N))


c = [[0]*9 for i in range(9)]


for i in range(1, N+1):
    s = str(i)
    if s[0] == "0" or s[-1] == "0":continue
    c[int(s[0])-1][int(s[-1])-1] += 1

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

print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

def f(n):
    str_n = str(n)
    return (str_n[0], str_n[-1])

from collections import Counter
c = Counter()

for i in range(1, N):
    p = f(i)
    c[p] += 1




ans = 0
for i in range(1, N):
    p = f(i)
    p_ = (p[1], p[0])
    ans += c[p_]
print(ans)

Failing test case input:
2011

Expected output:
40631


Actual output:
40409


Fixed submission (verdict: Accepted):
N = int(input())

def f(n):
    str_n = str(n)
    return (str_n[0], str_n[-1])

from collections import Counter
c = Counter()

for i in range(1, N+1):
    p = f(i)
    c[p] += 1




ans = 0
for i in range(1, N+1):
    p = f(i)
    p_ = (p[1], p[0])
    ans += c[p_]
print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=[[0]*9 for i in range(9)]
sum=0
for i in range(N):
  s=str(i)
  if(int(s[0])!=0 and int(s[-1])!=0):
    A[int(s[0])-1][int(s[-1])-1]+=1
for i in range(9):
  for j in range(9):
    sum+=A[i][j]*A[j][i]
  

print(sum)

Failing test case input:
1257

Expected output:
15840


Actual output:
15818


Fixed submission (verdict: Accepted):
N=int(input())
A=[[0]*9 for i in range(9)]
sum=0
for i in range(1,N+1):
  s=str(i)
  if(int(s[0])!=0 and int(s[-1])!=0):
    A[int(s[0])-1][int(s[-1])-1]+=1
for i in range(9):
  for j in range(9):
    sum+=A[i][j]*A[j][i]
  

print(sum)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
cnt = [[0] * 10 for i in range(10)]
for i in range(1,n+1):
    cnt[int(str(i)[0])][int(str(i)[-1])] += 1

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

Failing test case input:
2424

Expected output:
58947


Actual output:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [111, 112, 111, 111, 111, 111, 111, 111, 111, 111], [54, 54, 55, 54, 54, 53, 53, 53, 53, 53], [11, 11, 11, 12, 11, 11, 11, 11, 11, 11], [11, 11, 11, 11, 12, 11, 11, 11, 11, 11], [11, 11, 11, 11, 11, 12, 11, 11, 11, 11], [11, 11, 11, 11, 11, 11, 12, 11, 11, 11], [11, 11, 11, 11, 11, 11, 11, 12, 11, 11], [11, 11, 11, 11, 11, 11, 11, 11, 12, 11], [11, 11, 11, 11, 11, 11, 11, 11, 11, 12]]
58947


Fixed submission (verdict: Accepted):
n = int(input())
cnt = [[0] * 10 for i in range(10)]
for i in range(1,n+1):
    cnt[int(str(i)[0])][int(str(i)[-1])] += 1
    
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

def main():
    N = int(input())
    combs = [(S[0], S[-1]) for S in map(str, range(1, N+1))]
    d = defaultdict(int)
    for pre, suf in combs:
        if suf != "0":
            a, b = sorted([pre, suf])
            d[(a, b)] += 1
            
    ans = 0
    for key, val in d.items():
        if key[0] == key[1]:
            ans += val ** 2
        elif val > 1:
            ans += 2
        
    print(ans)
if __name__ == "__main__":
    main()

Failing test case input:
2011

Expected output:
40631


Actual output:
13793


Fixed submission (verdict: Accepted):
from collections import defaultdict

def main():
    N = int(input())
    combs = [(S[0], S[-1]) for S in map(str, 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 d.items():
        pre, suf = key
        ans += val * d[(suf, pre)]
        
    print(ans)
if __name__ == "__main__":
    main()
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 0
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
        
        tmp = int(str(N)[1:-1])
        
        if L <= int(str(N)[-1]):
            ans += tmp-1
        else:
            ans += tmp
        
        break
print(ans)


Failing test case input:
3437

Expected output:
118300


Actual output:
117656


Fixed submission (verdict: Accepted):
N = int(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)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

ans_list = [[0 for i in range(10)] for i in range(10)]

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

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

print(ans)

Failing test case input:
1292

Expected output:
16754


Actual output:
16732


Fixed submission (verdict: Accepted):
N = int(input()) + 1

ans_list = [[0 for i in range(10)] for j in range(10)]

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

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

print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

c = [[0] * 10] * 10
for x in range(1, N+1):
    check = str(x)
    it = int(check[0])
    jt = int(check[-1])
    c[it][jt] += 1

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

print(ans)



Failing test case input:
141750

Expected output:
200930633


Actual output:
20093062500


Fixed submission (verdict: Accepted):
N = int(input())

c = [[0 for _ in range(10)] for __ in range(10)]
for x in range(1, N+1):
    check = str(x)
    it = int(check[0])
    jt = int(check[-1])
    c[it][jt] += 1

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

print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
import collections

def solve(N: int):
    c = collections.defaultdict(int)
    if N == 1:
        print(1)
        return
    for i in range(1, N):
        target = str(i)
        c[target[0], target[-1]] += 1
    result = 0
    for i in range(0, 10):
        for j in range(0, 10):
            i = str(i)
            j = str(j)
            result += c[i, j] * c[j, i]
    print(result)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()


Failing test case input:
3437

Expected output:
118300


Actual output:
118278


Fixed submission (verdict: Accepted):

import sys
import collections

def solve(N: int):
    c = collections.defaultdict(int)
    if N == 1:
        print(1)
        return
    for i in range(1, N+1):
        target = str(i)
        c[target[0], target[-1]] += 1
    result = 0
    for i in range(0, 10):
        for j in range(0, 10):
            i = str(i)
            j = str(j)
            result += c[i, j] * c[j, i]
    print(result)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
tbl=[[0 for j in range(10)] for i in range(10)]
for i in range(n):
  s=str(i)
  h=int(s[0])
  b=int(s[-1])
  tbl[h][b]+=1
ans=0
for i in range(10):
  for j in range(i,10):
    ans+=tbl[i][j]*tbl[j][i]
print(ans)

Failing test case input:
453

Expected output:
2099


Actual output:
1290


Fixed submission (verdict: Accepted):
n=int(input())
tbl=[[0 for j in range(10)] for i in range(10)]
for i in range(1,n+1):
  s=str(i)
  h=int(s[0])
  b=int(s[-1])
  tbl[h][b]+=1
ans=0
for i in range(10):
  for j in range(10):
    ans+=tbl[i][j]*tbl[j][i]
print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ans = 0
cnt = [[0] * 9 for _ in range(9)]
tmp = 0
for i in range(1, n + 1):
    one = str(i)
    two = list(str(i))
    two.reverse()
    two = ''.join(two)
    if one[-1] == '0':
        continue
    if one == two:
        tmp += 1
    cnt[int(one[0]) - 1][int(one[-1]) - 1] += 1
for i in range(9):
    for j in range(9):
        ans += cnt[j][i]
print(ans - tmp)

Failing test case input:
200000

Expected output:
400000008

Actual output:
178802


Fixed submission (verdict: Accepted):
n = int(input())
ans = 0
cnt = [[0] * 9 for _ in range(9)]
tmp = 0
for i in range(1, n + 1):
    one = str(i)
    if one[-1] == '0':
        continue
    cnt[int(one[0]) - 1][int(one[-1]) - 1] += 1
for i in range(9):
    for j in range(9):
        ans += cnt[i][j] * cnt[j][i]
print(ans)
Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())

def f(p,q):
    res = 0
    if p == q and n >= p:
        res += 1
    

    for k in range(2,7):
        t = p*pow(10,k-1) + q
        if t > n:
            continue
        res += min(n-t+1,pow(10,k-2))
    return res

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += f(i,j)*f(j,i)
print(ans)

Failing test case input:
141750

Expected output:
200930633


Actual output:
400000008


Fixed submission (verdict: Accepted):
n = int(input())

def f(p,q):
    res = 0
    if p == q and n >= p:
        res += 1
    

    for k in range(2,7):
        t = p*pow(10,k-1) + q
        if t > n:
            continue
        for w in range(10**(k-2)):
            if t+w*10 <= n:
                res += 1
            else:
                break
    return res

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += f(i,j)*f(j,i)
print(ans)

Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def N(x,y,n): 
    if n<100:
        r=0
        for i in range(1,n+1):
            if str(i)[0]==str(x) and str(i)[-1]==str(y):
                r+=1
        return r
    
    r=N(x,y,99)
    d=len(str(n))
    for i in range(1,d-2):
        r+=10**i
    top=int(str(n)[0])
    if top<x:
        r+=0
    elif top==x:
        r+=int(str(n)[1:-1])
        if str(n)[-1]==str(y):
            r+=1
    else:
        r+=10**(d-2)

        
    return r


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

Failing test case input:
1478

Expected output:
21890


Actual output:
21639


Fixed submission (verdict: Accepted):
def N(x,y,n): 
    if n<100:
        r=0
        for i in range(1,n+1):
            if str(i)[0]==str(x) and str(i)[-1]==str(y):
                r+=1
        return r
    
    r=N(x,y,99)
    d=len(str(n))
    for i in range(1,d-2):
        r+=10**i
    top=int(str(n)[0])
    if top<x:
        r+=0
    elif top==x:
        r+=int(str(n)[1:-1])
        if str(n)[-1]>=str(y):
            r+=1
    else:
        r+=10**(d-2)

        
    return r


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

Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
ans = 0
A = [0]*100
for i in range(1,N+1):
    A[(int(str(i)[0]))*10+int(str(i)[-1])] += 1
for i in range(0,10):
    for j in range(i,10):
        if i==j:
            ans += A[i*10+j]**2
        else:
            ans += min(A[i*10+j],A[j*10+i])*2
print(ans) 

Failing test case input:
816

Expected output:
6701


Actual output:
1539


Fixed submission (verdict: Accepted):

N = int(input())
A = [[0]*10 for _ in range(10)]
ans = 0
for i in range(1,N+1):
    A[(int(str(i)[0]))][int(str(i)[-1])] += 1

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

print(ans)
Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
m = len(str(n))
ans = 0



for i in range(n + 1):
    A = str(i)
    first = A[0]
    end = A[-1]

    if end == '0':
        continue
    if first == end:
        ans += 1


    if m >= 3:
        for j in range(m - 2):
            ans += 10 ** (j)
    mini = int(end + '0' * (m - 2) + first)
    maxi = int(end + '9' * (m - 2) + first)
    
    if n < mini:
        continue
    elif mini <= n <= maxi:
        
        if int(str(n)[-1]) > int(first):
            ans += int(str(n)[1:-1])
            
        else:
            ans += int(str(n)[1:-1])
            
    else:
        ans += (10 ** (m - 2))

print(ans)


Failing test case input:
1257

Expected output:
15840


Actual output:
15736


Fixed submission (verdict: Accepted):
n = int(input())
m = len(str(n))
ans = 0



for i in range(n + 1):
    A = str(i)
    first = A[0]
    end = A[-1]

    if end == '0':
        continue
    if first == end:
        ans += 1


    if m >= 3:
        for j in range(m - 2):
            ans += 10 ** (j)
    mini = int(end + '0' * (m - 2) + first)
    maxi = int(end + '9' * (m - 2) + first)
    
    if n < mini:
        continue
    elif mini <= n <= maxi:
        
        if int(str(n)[-1]) >= int(first):
            ans += int(str(n)[1:-1]) + 1
            
        else:
            ans += int(str(n)[1:-1])
            
    else:
        ans += (10 ** (m - 2))

print(ans)

Problem: p02792
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
dp = [[0]*10 for _ in range(10)]
for a in range(N):
    A = str(a)
    dp[int(A[0])][int(A[-1])] += 1
ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += dp[i][j]*dp[j][i]
print(ans)

Failing test case input:
897

Expected output:
8083


Actual output:
8061


Fixed submission (verdict: Accepted):
N = int(input())
dp = [[0]*10 for _ in range(10)]
for a in range(N+1):
    A = str(a)
    dp[int(A[0])][int(A[-1])] += 1
ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += dp[i][j]*dp[j][i]
print(ans)

Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
cnts = [[0] * 10 for _ in range(10)]
ans = 0
for i in range(N):
    if i % 10 == 0:
        continue
    s = str(i)
    cnts[int(s[0])][int(s[-1])] += 1

for i in range(N):
    if i % 10 == 0:
        continue
    s = str(i)
    ans += cnts[int(s[-1])][int(s[0])]

print(ans)


Failing test case input:
2158

Expected output:
46642


Actual output:
46620


Fixed submission (verdict: Accepted):
N = int(input())
cnts = [[0] * 10 for _ in range(10)]
ans = 0
for i in range(N + 1):
    if i % 10 == 0:
        continue
    s = str(i)
    cnts[int(s[0])][int(s[-1])] += 1

for i in range(N + 1):
    if i % 10 == 0:
        continue
    s = str(i)
    ans += cnts[int(s[-1])][int(s[0])]

print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main(n):
    c=[[0]*10 for _ in range(10)]
    for k in range(1,n+1):
        n=str(k)
        i = int(n[0])
        j = int(n[-1])
        c[i][j] += 1
    ans =0
    for i in range(10):
        ans+=sum(c[i])
    print(ans)
             
if __name__=='__main__':
    main(int(input()))

Failing test case input:
453

Expected output:
2099


Actual output:
453


Fixed submission (verdict: Accepted):
def main(n):
    c=[[0]*10 for _ in range(10)]
    for k in range(1,n+1):
        n=str(k)
        i = int(n[0])
        j = int(n[-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)
             
if __name__=='__main__':
    main(int(input()))

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

DP = [[0 for _ in range(10)] for _ in range(10)]

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

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

print(ans)

Failing test case input:
897

Expected output:
8083


Actual output:
8061


Fixed submission (verdict: Accepted):
N = int(input())

DP = [[0 for _ in range(10)] for _ in range(10)]

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

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

print(ans)

Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
from collections import defaultdict
d=defaultdict(int)
for i in range(1,N):
    a,b=str(i)[0],str(i)[-1]
    d[(int(a),int(b))]+=1
r = 0
for i in range(1,10):
    for j in range(1,10):
        r += d[(i,j)] * d[(j,i)]
print(r)


Failing test case input:
1292

Expected output:
16754


Actual output:
16732


Fixed submission (verdict: Accepted):
N = int(input())
from collections import defaultdict
d=defaultdict(int)
for i in range(1,N+1):
    a,b=str(i)[0],str(i)[-1]
    d[(int(a),int(b))]+=1
r = 0
for i in range(1,10):
    for j in range(1,10):
        r += d[(i,j)] * d[(j,i)]
print(r)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

c = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, n):
    val = str(i)
    s = val[0]
    e = val[-1]
    c[int(s)][int(e)] += 1

ans = 0
for s in range(1, 10):
    for e in range(1, 10):
        ans += c[s][e] * c[e][s]
    
print(ans)

Failing test case input:
2011

Expected output:
40631


Actual output:
40409


Fixed submission (verdict: Accepted):
n = int(input())

c = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, n+1):
    val = str(i)
    s = val[0]
    e = val[-1]
    
    c[int(s)][int(e)] += 1


ans = 0
for s in range(1, 10):
    for e in range(1, 10):
        ans += c[s][e] * c[e][s]
    
print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
strN = input()
N = int(strN)
p = {i: {j: 0 for j in range(1, 10)} for i in range(1, 10)}
for k in range(1, N):
    strk = str(k)
    i = int(strk[0])
    j = int(strk[-1])
    if i == 0 or j == 0:
        continue
    p[i][j] += 1

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

print(ans)


Failing test case input:
2424

Expected output:
58947


Actual output:
58925


Fixed submission (verdict: Accepted):
strN = input()
N = int(strN)
p = {i: {j: 0 for j in range(1, 10)} for i in range(1, 10)}
for k in range(1, N+1):
    strk = str(k)
    i = int(strk[0])
    j = int(strk[-1])
    if i == 0 or j == 0:
        continue
    p[i][j] += 1

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

print(ans)

Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
ans=0
for i in range(1,n):
    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-3-j,0))
                break
if n==1:
    ans+=1

print(ans)





Failing test case input:
2158

Expected output:
46642


Actual output:
44482


Fixed submission (verdict: Accepted):
n = int(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)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=[[0]*9]*9
for  i in range(1,n):
  if i%10:
    l[int(str(i)[0])-1][int(str(i)[-1])-1]+=1
ans=0
for i in range(9):
  for j in range(9):
    ans+=l[i][j]*l[j][i]
print(ans)

Failing test case input:
897

Expected output:
8083


Actual output:
651249


Fixed submission (verdict: Accepted):
n=int(input())
l=[[0 for i in range(10)]for s in range(10)]
for  i in range(n+1):
  if i%10:
    l[int(str(i)[0])-1][int(str(i)[-1])-1]+=1
ans=0
for i in range(9):
  for j in range(9):
    ans+=l[i][j]*l[j][i]
print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [0] * 100
for i in range(n):
  msb = str(i)[0]
  lsb = str(i)[-1]
  if msb == '0' or lsb == '0':
    continue
  a[int(msb) * 10 + int(lsb)] += 1

tmp = 0
for i, ai in enumerate(a):
  if '0' not in str(i):
    if i % 11 == 0:
      tmp += ai * ai
    else:
      tmp += ai * a[int(str(i)[::-1])]
  else:
    continue
    
print(tmp)

Failing test case input:
1292

Expected output:
16754


Actual output:
16732


Fixed submission (verdict: Accepted):
n = int(input())
a = [0] * 100
for i in range(1,n+1):
  msb = str(i)[0]
  lsb = str(i)[-1]
  if msb == '0' or lsb == '0':
    continue
  a[int(msb) * 10 + int(lsb)] += 1

tmp = 0
for i, ai in enumerate(a):
  if '0' not in str(i):
    if i % 11 == 0:
      tmp += ai * ai
    else:
      tmp += ai * a[int(str(i)[::-1])]
  else:
    continue
    
print(tmp)

Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
ans = 0

def solve(x):
    df = str(x)[0]
    dl = str(x)[-1]
    return df, dl
    

numMap = {}

for i in range(1, n):
    
    
    pair = solve(i)
    if pair in numMap:
        numMap[pair] += 1
    else:
        numMap[pair] = 1

for i in range(n):
    key = solve(i)
    rev = key[::-1]
    
    
    if rev in numMap:
        ans += numMap[rev]


print(ans)

Failing test case input:
2424

Expected output:
58947


Actual output:
58925


Fixed submission (verdict: Accepted):
n = int(input())
ans = 0

def solve(x):
    df = str(x)[0]
    dl = str(x)[-1]
    return df, dl

numMap = {}

for i in range(1, n+1):
    
    
    pair = solve(i)
    if pair in numMap:
        numMap[pair] += 1
    else:
        numMap[pair] = 1

for i in range(1, n+1):
    key = solve(i)
    rev = key[::-1]
    
    
    if rev in numMap:
        ans += numMap[rev]


print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

c = [[0 for i in range(10)] for j in range(10)]

for i in range(n):
    if i % 10 == 0:
        continue
    s = str(i)
    a = int(s[0])
    b = int(s[-1])

    c[a][b] += 1

ans = 0

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

print(ans)



Failing test case input:
453

Expected output:
2099


Actual output:
2077


Fixed submission (verdict: Accepted):
n = int(input())

c = [[0 for i in range(10)] for j in range(10)]

for i in range(n+1):
    if i % 10 == 0:
        continue
    s = str(i)
    a = int(s[0])
    b = int(s[-1])

    c[a][b] += 1

ans = 0

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

print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
c = [[0]*10 for _ in range(10)]
for k in range(N):
    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]

if N==1:
    print(ans)
else:
    print(ans-1)


Failing test case input:
1478

Expected output:
21890


Actual output:
21868


Fixed submission (verdict: Accepted):
N = int(input())
c = [[0]*10 for _ 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)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
lst = [[0 for i in range(10)]for j in range(10)]
ans = 0
for i in range(N):
    tmp = list(str(i))
    lst[int(tmp[0])][int(tmp[-1])]+=1
for i in range(10):
    for j in range(10):
        if i == 0 or j == 0:
            continue
        if i == j:
            ans+=lst[i][j]**2
        else:
            ans+=lst[i][j]*lst[j][i]
print(ans)

Failing test case input:
2158

Expected output:
46642


Actual output:
46620


Fixed submission (verdict: Accepted):
N = int(input())
lst = [[0 for i in range(10)]for j in range(10)]
ans = 0
for i in range(1,N+1):
    tmp = list(str(i))
    lst[int(tmp[0])][int(tmp[-1])]+=1
for i in range(10):
    for j in range(10):
        if i == 0 or j == 0:
            continue
        if i == j:
            ans+=lst[i][j]**2
        else:
            ans+=lst[i][j]*lst[j][i]
print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

d = [[0]*10 for i in range(10)]

for i in range(1, n+1):
  i_ = str(i)
  x = int(i_[0])
  y = int(i_[-1])
  d[x][y] += 1
  
print(d)
ans = 0
for i in range(10):
  for j in range(10):
    ans += d[i][j]*d[j][i]
    
print(ans)

Failing test case input:
1257

Expected output:
15840


Actual output:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [37, 38, 37, 37, 37, 37, 37, 37, 36, 36], [11, 11, 12, 11, 11, 11, 11, 11, 11, 11], [11, 11, 11, 12, 11, 11, 11, 11, 11, 11], [11, 11, 11, 11, 12, 11, 11, 11, 11, 11], [11, 11, 11, 11, 11, 12, 11, 11, 11, 11], [11, 11, 11, 11, 11, 11, 12, 11, 11, 11], [11, 11, 11, 11, 11, 11, 11, 12, 11, 11], [11, 11, 11, 11, 11, 11, 11, 11, 12, 11], [11, 11, 11, 11, 11, 11, 11, 11, 11, 12]]
15840


Fixed submission (verdict: Accepted):
n = int(input())

d = [[0]*10 for i in range(10)]

for i in range(1, n+1):
  i_ = str(i)
  x = int(i_[0])
  y = int(i_[-1])
  d[x][y] += 1

ans = 0
for i in range(10):
  for j in range(10):
    ans += d[i][j]*d[j][i]
    
print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

counter = [[0 for _ in range(10)] for _ in range(10)]

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

cnt = 0
for i in range(1, 10):
	for j in range(1, 10):
		if i == j:
			if counter[i][j] >= 1:
				cnt += counter[i][j] ** 2
		else:
			cnt += counter[i][j] * counter[j][i]

print(cnt)

Failing test case input:
1478

Expected output:
21890


Actual output:
21868


Fixed submission (verdict: Accepted):
n = int(input())

def calc(n):
	counter = [[0 for _ in range(10)] for _ in range(10)]

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

	cnt = 0
	for i in range(1, 10):
		for j in range(1, 10):
			if i == j:
				if counter[i][j] >= 1:
					cnt += counter[i][j] ** 2
			else:
				cnt += counter[i][j] * counter[j][i]
	return cnt

print(calc(n))

Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    strn = input()
    n = int(strn)
    if n < 10:
        print(n)
        return
    m = [0] * 81

    for i in range(n):
        a = int(str(i)[0])
        b = int(str(i)[-1])
        
        if b == 0:
            continue
        else:
            key = 9 * (a - 1) + b - 1
            
            m[key] += 1
    ans = 0
    
    for i in range(1, 10):
        for j in range(1, 10):
            key = 9 * (i - 1) + j - 1
            oppose = 9 * (j - 1) + i - 1
            ans += m[key] * m[oppose]
    print(ans)
if __name__ == "__main__":
    main()

Failing test case input:
2011

Expected output:
40631


Actual output:
40409


Fixed submission (verdict: Accepted):
def main():
    strn = input()
    n = int(strn)
    if n < 10:
        print(n)
        return
    m = [0] * 81

    for i in range(1, n + 1):
        a = int(str(i)[0])
        b = int(str(i)[-1])
        
        if b == 0:
            continue
        else:
            key = 9 * (a - 1) + b - 1
            
            m[key] += 1
    ans = 0
    
    for i in range(1, 10):
        for j in range(1, 10):
            key = 9 * (i - 1) + j - 1
            oppose = 9 * (j - 1) + i - 1
            ans += m[key] * m[oppose]
    print(ans)
if __name__ == "__main__":
    main()
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def get_lmb(N):
    while (N >= 10):
        N = int(N/10)
    return N

def get_rmb(N):
    return N%10

def find_all():
    from collections import defaultdict
    dic = defaultdict(int)
    N = int(input())
    for i in range(1, N+1):
        lmb, rmb = get_lmb(i), get_rmb(i)
        dic[(lmb, rmb)] += 1
    print(dic)
    count = 0
    for i in range(1, 10):
        for j in range(1, 10):
            count += dic[(i, j)] * dic[(j, i)]
    
    
    return count

print(find_all())

Failing test case input:
3437

Expected output:
118300


Actual output:
defaultdict(<class 'int'>, {(1, 1): 112, (2, 2): 112, (3, 3): 56, (4, 4): 12, (5, 5): 12, (6, 6): 12, (7, 7): 12, (8, 8): 12, (9, 9): 12, (1, 0): 111, (1, 2): 111, (1, 3): 111, (1, 4): 111, (1, 5): 111, (1, 6): 111, (1, 7): 111, (1, 8): 111, (1, 9): 111, (2, 0): 111, (2, 1): 111, (2, 3): 111, (2, 4): 111, (2, 5): 111, (2, 6): 111, (2, 7): 111, (2, 8): 111, (2, 9): 111, (3, 0): 55, (3, 1): 55, (3, 2): 55, (3, 4): 55, (3, 5): 55, (3, 6): 55, (3, 7): 55, (3, 8): 54, (3, 9): 54, (4, 0): 11, (4, 1): 11, (4, 2): 11, (4, 3): 11, (4, 5): 11, (4, 6): 11, (4, 7): 11, (4, 8): 11, (4, 9): 11, (5, 0): 11, (5, 1): 11, (5, 2): 11, (5, 3): 11, (5, 4): 11, (5, 6): 11, (5, 7): 11, (5, 8): 11, (5, 9): 11, (6, 0): 11, (6, 1): 11, (6, 2): 11, (6, 3): 11, (6, 4): 11, (6, 5): 11, (6, 7): 11, (6, 8): 11, (6, 9): 11, (7, 0): 11, (7, 1): 11, (7, 2): 11, (7, 3): 11, (7, 4): 11, (7, 5): 11, (7, 6): 11, (7, 8): 11, (7, 9): 11, (8, 0): 11, (8, 1): 11, (8, 2): 11, (8, 3): 11, (8, 4): 11, (8, 5): 11, (8, 6): 11, (8, 7): 11, (8, 9): 11, (9, 0): 11, (9, 1): 11, (9, 2): 11, (9, 3): 11, (9, 4): 11, (9, 5): 11, (9, 6): 11, (9, 7): 11, (9, 8): 11})
118300


Fixed submission (verdict: Accepted):
def get_lmb(N):
    while (N >= 10):
        N = int(N/10)
    return N

def get_rmb(N):
    return N%10

def find_all():
    from collections import defaultdict
    dic = defaultdict(int)
    N = int(input())
    for i in range(1, N+1):
        lmb, rmb = get_lmb(i), get_rmb(i)
        dic[(lmb, rmb)] += 1
    
    count = 0
    for i in range(1, 10):
        for j in range(1, 10):
            count += dic[(i, j)] * dic[(j, i)]
    
    
    return count

print(find_all())

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())

def pair(x):
    a=x%10
    b=int(str(x)[0])
    return (a,b)
dic={}
for i in range(1,n):
    p=pair(i)
    if(dic.get(p)==None):dic[p]=1
    else:dic[p]+=1
ans=0
for i in range(1,n):
    a,b=pair(i)
    p=(b,a)
    if(not dic.get(p)==None):ans+=dic[p]
print(ans)

Failing test case input:
816

Expected output:
6701


Actual output:
6679


Fixed submission (verdict: Accepted):
n=int(input())

def pair(x):
    a=x%10
    b=int(str(x)[0])
    return (a,b)
dic={}
for i in range(1,n+1):
    p=pair(i)
    if(dic.get(p)==None):dic[p]=1
    else:dic[p]+=1
ans=0
for i in range(1,n+1):
    a,b=pair(i)
    p=(b,a)
    if(not dic.get(p)==None):ans+=dic[p]
print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=[[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9]

for n in range(N):
    temp=str(n)
    r=int(temp[-1])
    l=int(temp[0])
    if r!=0 and l!=0:
        A[r-1][l-1]+=1

ans=0
for i in range(9):
    for j in range(9):
        ans+=A[i][j]*A[j][i]
if N==1:
    print(1)
else:
    print(ans)


Failing test case input:
897

Expected output:
8083


Actual output:
8061


Fixed submission (verdict: Accepted):
N=int(input())
A=[[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9]

for n in range(N+1):
    temp=str(n)
    r=int(temp[-1])
    l=int(temp[0])
    A[r-1][l-1]+=1

ans=0
for i in range(9):
    for j in range(9):
        ans+=A[i][j]*A[j][i]
if N<=9:
    print(N)
else:
    print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

N_se = int(str(N)[0] + str(N)[-1])
if len(str(N)) > 2:
    N_mid = int(str(N)[1:-1])
else:
    N_mid = 0

def search(s, e):
    ans = 0
    se = int(str(s) + str(e))
    for i in range(1, len(str(N))+1):
        if i == 1:
            if s == e and s <= N:
                ans += 1
                continue
        else:
            if i != len(str(N)):
                ans += 10**(i-2)
            else:
                if N_se > se:
                    ans += 10**(i-2)
                elif N_se == se:
                    ans += N_mid

    return ans

ret = 0
for i in range(1, 10):
    for j in range(1, 10):
        
        ret += search(i, j) *  search(j, i)
print(ret)

Failing test case input:
2011

Expected output:
40631


Actual output:
40230


Fixed submission (verdict: Accepted):
N = int(input())

N_s = int(str(N)[0])
N_e = int(str(N)[-1])
if len(str(N)) > 2:
    N_mid = int(str(N)[1:-1])
else:
    N_mid = 0

def search(s, e):
    ans = 0
    for i in range(1, len(str(N))+1):
        if i == 1:
            if s == e and s <= N:
                ans += 1
                continue
        else:
            if i != len(str(N)):
                ans += 10**(i-2)
            else:
                if N_s > s:
                    ans += 10**(i-2)
                elif N_s == s:
                    if N_e >= e:
                        ans += N_mid + 1
                    else:
                        ans += N_mid

    return ans

ret = 0
for i in range(1, 10):
    for j in range(1, 10):
        ret += search(i, j) *  search(j, i)
print(ret)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math,sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili=lambda:list(map(int,sys.stdin.readlines()))
li = lambda:list(map(int,input().split()))

I=lambda:int(input())
S=lambda:input().strip()
mod = 1000000007

a=[]
n=I()
for i in range(1,10):
    k=[]
    for j in range(1,10):
        k.append(0)
    a.append(k)
        

for i in range(1,n+1):
    if(i%10==0):
        continue
    k=str(i)
    p=int(k[0])-1
    q=int(k[-1])-1
    a[p][q]+=1
ans=0
for i in a:
    print(*i)
for i in range(0,9):
    for j in range(0,9):
        ans+=a[i][j]*a[j][i]
print(ans)


Failing test case input:
453

Expected output:
2099


Actual output:
12 11 11 11 11 11 11 11 11
11 12 11 11 11 11 11 11 11
11 11 12 11 11 11 11 11 11
7 7 7 7 6 6 6 6 6
1 1 1 1 2 1 1 1 1
1 1 1 1 1 2 1 1 1
1 1 1 1 1 1 2 1 1
1 1 1 1 1 1 1 2 1
1 1 1 1 1 1 1 1 2
2099


Fixed submission (verdict: Accepted):
import math,sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili=lambda:list(map(int,sys.stdin.readlines()))
li = lambda:list(map(int,input().split()))

I=lambda:int(input())
S=lambda:input().strip()
mod = 1000000007

a=[]
n=I()
for i in range(1,10):
    k=[]
    for j in range(1,10):
        k.append(0)
    a.append(k)
        

for i in range(1,n+1):
    if(i%10==0):
        continue
    k=str(i)
    p=int(k[0])-1
    q=int(k[-1])-1
    a[p][q]+=1
ans=0

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

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
ans=-1
c=[[0]*10for i in range(10)]
for i in range(n):c[int(str(i)[0])-1][int(str(i)[-1])-1]+=1
for i in range(10):
 for j in range(10):ans+=c[i][j]*c[j][i]
print(ans)

Failing test case input:
453

Expected output:
2099


Actual output:
2077


Fixed submission (verdict: Accepted):
n=int(input())
ans=-1
c=[[0]*10for i in range(11)]
for i in range(n+1):c[int(str(i)[0])][int(str(i)[-1])]+=1
for i in range(10):
 for j in range(10):ans+=c[i][j]*c[j][i]
print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=[[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9]

for n in range(N):
    temp=str(n)
    r=int(temp[-1])
    l=int(temp[0])
    A[r-1][l-1]+=1

ans=0
for i in range(9):
    for j in range(9):
        ans+=A[i][j]*A[j][i]
if N==1:
    print(1)
else:
    print(ans)


Failing test case input:
1478

Expected output:
21890


Actual output:
21868


Fixed submission (verdict: Accepted):
N=int(input())
A=[[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9]

for n in range(N+1):
    temp=str(n)
    r=int(temp[-1])
    l=int(temp[0])
    A[r-1][l-1]+=1

ans=0
for i in range(9):
    for j in range(9):
        ans+=A[i][j]*A[j][i]
if N<=9:
    print(N)
else:
    print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [[0 for i in range(11)] for j in range(11)]
for i in range(1, N):
  A[int(str(i)[0])][int(str(i)[-1])] +=1

B = [[0 for i in range(11)] for j in range(11)]
for i in range(1, N):
  B[int(str(i)[0])][int(str(i)[-1])] +=1
  
ans = 0
for i in range(10):
  for j in range(10):
    ans += A[i][j] * B[j][i]
  
print(ans)

Failing test case input:
897

Expected output:
8083


Actual output:
8061


Fixed submission (verdict: Accepted):
N = int(input())
A = [[0 for i in range(11)] for j in range(11)]
for i in range(1, N+1):
  A[int(str(i)[0])][int(str(i)[-1])] +=1

B = [[0 for i in range(11)] for j in range(11)]
for i in range(1, N+1):
  B[int(str(i)[0])][int(str(i)[-1])] +=1

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

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
table = [[0] * 10 for _ in range(10)]
for i in range(1, N):
    s = str(i)
    if s[-1] == '0': continue
    table[int(s[0])][int(s[-1])] += 1

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

Failing test case input:
1257

Expected output:
15840


Actual output:
15818


Fixed submission (verdict: Accepted):
N = int(input())
table = [[0] * 10 for _ in range(10)]

for i in range(1, N+1):
    s = str(i)
    if s[-1] == '0': continue
    table[int(s[0])][int(s[-1])] += 1

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

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ans = 0
a = [[[] for i in range(10)] for j in range(10)]
for i in range(n):
    a[int(str(i)[0])][int(str(i)[-1])].append(i)

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

print(ans)

Failing test case input:
453

Expected output:
2099


Actual output:
2077


Fixed submission (verdict: Accepted):
n = int(input())
ans = 0
a = [[[] for i in range(10)] for j in range(10)]
for i in range(1, n + 1):
    a[int(str(i)[0])][int(str(i)[-1])].append(i)

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

print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

N = int(input())
d = defaultdict(int)

for n in range(N):
    n = str(n)

    a = n[0]
    b = n[-1]

    d[(a, b)] += 1


s = 0
for i in range(1, 10):
    for j in range(10):

        s += d[(str(j), str(i))] * d[(str(i), str(j))]

print(s)



Failing test case input:
1257

Expected output:
15840


Actual output:
15818


Fixed submission (verdict: Accepted):
from collections import defaultdict

d = defaultdict(int)
N = int(input())

for n in range(1, N + 1):
    n = str(n)

    a = n[0]
    b = n[-1]

    d[(a, b)] += 1


s = 0
for i in range(10):
    for j in range(10):

        s += d[(str(j), str(i))] * d[(str(i), str(j))]

print(s)
Problem: p02792
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A=[str(i)for i in range(1,10)]
ans=0
for a in A:
    for b in A:
        countA=0
        if a==b and int(a)<=N:
            countA+=1
        for i in range(5):
            m=int(a+'0'*i+b)
            M=int(a+'9'*i+b)
            if m<=N:
                if M<=N:
                    countA+=10**i
                else:
                    countA+=N-m+1

        countB=0
        if b==a and int(b)<=N:
            countB+=1
        for i in range(5):
            m=int(b+'0'*i+a)
            M=int(b+'9'*i+a)
            if m<=N:
                if M<=N:
                    countB+=10**i
                else:
                    countB+=N-m+1

        ans+=countA*countB
print(ans)

Failing test case input:
1292

Expected output:
16754


Actual output:
152880


Fixed submission (verdict: Accepted):
N=int(input())
A=[str(i)for i in range(1,10)]
ans=0
for a in A:
    for b in A:
        countA=0
        if a==b and int(a)<=N:
            countA+=1
        for i in range(5):
            m=int(a+'0'*i+b)
            M=int(a+'9'*i+b)
            if m<=N:
                if M<=N:
                    countA+=10**i
                else:
                    while m<=N:
                        countA+=1
                        m+=10

        countB=0
        if b==a and int(b)<=N:
            countB+=1
        for i in range(5):
            m=int(b+'0'*i+a)
            M=int(b+'9'*i+a)
            if m<=N:
                if M<=N:
                    countB+=10**i
                else:
                    while m<=N:
                        countB+=1
                        m+=10

        ans+=countA*countB
print(ans)

Problem: p02792
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):




n = int(input())

if n <= 9:
    print(n)
    exit()




cij = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, n):
    k0 = int(str(k)[0])
    kn = int(str(k)[-1])
    if k0 != 0 and kn != 0:
        cij[k0][kn] += 1

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

print(ans)

Failing test case input:
2011

Expected output:
40631


Actual output:
40409


Fixed submission (verdict: Accepted):




n = int(input())

if n <= 9:
    print(n)
    exit()




cij = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, n + 1):
    k0 = int(str(k)[0])
    kn = int(str(k)[-1])
    if k0 != 0 and kn != 0:
        cij[k0][kn] += 1

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

print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
max_N = 2 * 10 ** 5
 
d = [[0] * 10 for _ in range(10)]
for i in range(1,int(N)):
  k = str(i)
  d[int(k[0])][int(k[-1])] += 1

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

Failing test case input:
1292

Expected output:
16754


Actual output:
16732


Fixed submission (verdict: Accepted):
n = input()
 
d = [ [0] * 10 for _ in range(10) ]
for i in range( 1, int( n ) + 1 ):
  k = str(i)
  d[ int( k[ 0 ])][ int( k[ -1 ])] += 1

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

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
l = [[0] * 10 for _ in range(10)]
ans = 0

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

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

Failing test case input:
200000

Expected output:
400000008

Actual output:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [11111, 11112, 11111, 11111, 11111, 11111, 11111, 11111, 11111, 11111], [1112, 1111, 1112, 1111, 1111, 1111, 1111, 1111, 1111, 1111], [1111, 1111, 1111, 1112, 1111, 1111, 1111, 1111, 1111, 1111], [1111, 1111, 1111, 1111, 1112, 1111, 1111, 1111, 1111, 1111], [1111, 1111, 1111, 1111, 1111, 1112, 1111, 1111, 1111, 1111], [1111, 1111, 1111, 1111, 1111, 1111, 1112, 1111, 1111, 1111], [1111, 1111, 1111, 1111, 1111, 1111, 1111, 1112, 1111, 1111], [1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1112, 1111], [1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1112]]
400000008


Fixed submission (verdict: Accepted):
N = int(input())
l = [[0] * 10 for _ in range(10)]
ans = 0

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

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

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
d=[[0]*10 for i in range(10)]



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


r=0
for i in range(9):
  for j in range(9):
    r+=d[i+1][j+1]*d[j+1][i+1]
print(r)

Failing test case input:
2011

Expected output:
40631


Actual output:
40409


Fixed submission (verdict: Accepted):
N=int(input())
d=[[0]*10 for i in range(10)]



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


r=0
for i in range(9):
  for j in range(9):
    r+=d[i+1][j+1]*d[j+1][i+1]
print(r)