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

dic = {}
for i in range(1,10):
  for j in range(1,10):
    dic[(str(i),str(j))] = 0

for i in range(N):
  nstr = str(i)
  pre = nstr[0]
  suf = nstr[-1]
  if suf == '0':
    continue
  dic[(pre, suf)] =dic[(pre, suf)] + 1

cnt = 0 
for i in range(1,10):
  for j in range(1,i):
    cnt += 2*dic[(str(i),str(j))] * dic[(str(j),str(i))]
  cnt += dic[(str(i),str(i))] * dic[(str(i),str(i))]

print(cnt)

Failing test case input:
2158

Expected output:
46642


Actual output:
46620


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

dic = {}
for i in range(1,10):
  for j in range(1,10):
    dic[(str(i),str(j))] = 0

for i in range(N+1):
  nstr = str(i)
  pre = nstr[0]
  suf = nstr[-1]
  if suf == '0':
    continue
  dic[(pre, suf)] =dic[(pre, suf)] + 1

cnt = 0 
for i in range(1,10):
  for j in range(1,10):
    cnt += dic[(str(i),str(j))] * dic[(str(j),str(i))]

print(cnt)

Problem: p02792
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import defaultdict
strN=input()
lenN=len(strN)
N=int(strN)

if N<=9:print(N)
else:
  count = defaultdict(int)
  for i in range(10,N+1):
    a,b=int(str(i)[0]),int(str(i)[1])
    if b==0:continue
    count[(a,b)] += 1

  ans=0
  for i in range(1,10):
    count[(i,i)] += 1
  count = dict(count)
  for key in count.keys():
    if key[0]<key[1] and count.get((key[1],key[0])):
      ans += count[key] * count[(key[1],key[0])] * 2
    if key[0]==key[1]:
      ans += count[key]**2
  print(ans)

Failing test case input:
2424

Expected output:
58947


Actual output:
77358


Fixed submission (verdict: Accepted):
from collections import defaultdict
strN=input()
lenN=len(strN)
N=int(strN)

if N<=9:print(N)
else:
  count = defaultdict(int)
  for i in range(10,N+1):
    a,b=int(str(i)[0]),int(str(i)[-1])
    if b==0:continue
    count[(a,b)] += 1

  ans=0
  for i in range(1,10):
    count[(i,i)] += 1
  count = dict(count)
  for key in count.keys():
    if key[0]<key[1] and count.get((key[1],key[0])):
      ans += count[key] * count[(key[1],key[0])] * 2
    if key[0]==key[1]:
      ans += count[key]**2
  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):
    str_i = str(i)
    c[int(str_i[0])][int(str_i[-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)

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):
    str_i = str(i)
    c[int(str_i[0])][int(str_i[-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)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
L = len(str(N))
B = int(str(N)[0])
c = 0
if L == 1:
    c += N
for i in range(1,N):
    I = str(i)
    l = len(I)
    a,b = int(I[0]),int(I[l-1])
    if a == 0 or b == 0:
        continue
    else:
        if a == b:
            c += 1
        for m in range(max(L-2,0)):
            c += 10**m
        if b > B:
            continue
        elif b < B:
            c += 10**(L-2)
        elif L > 2:
            c += int(str(N)[1:L-1])
        elif L == 2:
            c += 1
print(c)

Failing test case input:
2011

Expected output:
40631


Actual output:
40409


Fixed submission (verdict: Accepted):
N = int(input())
L = len(str(N))
A,B=int(str(N)[L-1]),int(str(N)[0])
c = 0
for i in range(1,N+1):
    I = str(i)
    l = len(I)
    a,b = int(I[0]),int(I[l-1])
    if a == 0 or b == 0:
        continue
    else:
        if a == b:
            c += 1
        for m in range(max(L-2,0)):
            c += 10**m
        if L == 1:
            continue
        if b > B:
            continue
        elif b < B:
            c += 10**(L-2)
        elif L > 2 and a <= A:
            c += int(str(N)[1:L-1])+1
        elif L > 2:
            c += int(str(N)[1:L-1])
        elif L == 2:
            c += 1
print(c)

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 == 1:
    ans = 1
print(ans)

Failing test case input:
1257

Expected output:
15840


Actual output:
15818


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 (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])
    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 (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])-1)*10+int(str(i)[-1])-1] += 1
for i in range(1,10):
    for j in range(i,10):
        if i==j:
            ans += A[i*10+j]**2
        else:
            ans += 2*A[i*10+j]
print(ans) 

Failing test case input:
200000

Expected output:
400000008

Actual output:
133424443


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 (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
t=[[0 for i in range(10)]for j in range(10)]
for i in range(1,n):
  i=str(i)
  t[int(i[0])][int(i[-1])]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=t[i][j]*t[j][i]
    
print(ans)

Failing test case input:
1478

Expected output:
21890


Actual output:
21868


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

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

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

for i in range(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)

Failing test case input:
1478

Expected output:
21890


Actual output:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
21891


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())

ans = 0

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

for number in range(1, n):
    i = int(str(number)[0])
    j = int(str(number)[-1])
    table[i][j] += 1

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



Failing test case input:
2158

Expected output:
46642


Actual output:
46620


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

ans = 0

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

for number in range(1, n+1):
    i = int(str(number)[0])
    j = int(str(number)[-1])
    table[i][j] += 1

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

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

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

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

print(ans)




Failing test case input:
3093

Expected output:
95976


Actual output:
95933


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

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

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

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

print(ans)

Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
L = len(str(N))
B = int(str(N)[0])
c = 0
for i in range(1,N+1):
    I = str(i)
    l = len(I)
    a,b = int(I[0]),int(I[l-1])
    if a == 0 or b == 0:
        continue
    else:
        if a == b:
            c += 1
        for m in range(max(L-2,0)):
            c += 10**m
        if L == 1:
            continue
        if b > B:
            continue
        elif b < B:
            c += 10**(L-2)
        elif L > 2:
            c += int(str(N)[1:L-1])
        elif L == 2:
            c += 1
print(c)

Failing test case input:
3093

Expected output:
95976


Actual output:
95732


Fixed submission (verdict: Accepted):
N = int(input())
L = len(str(N))
A,B=int(str(N)[L-1]),int(str(N)[0])
c = 0
for i in range(1,N+1):
    I = str(i)
    l = len(I)
    a,b = int(I[0]),int(I[l-1])
    if a == 0 or b == 0:
        continue
    else:
        if a == b:
            c += 1
        for m in range(max(L-2,0)):
            c += 10**m
        if L == 1:
            continue
        if b > B:
            continue
        elif b < B:
            c += 10**(L-2)
        elif L > 2 and a <= A:
            c += int(str(N)[1:L-1])+1
        elif L > 2:
            c += int(str(N)[1:L-1])
        elif L == 2:
            c += 1
print(c)

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


Failing test case input:
3093

Expected output:
95976


Actual output:
95933


Fixed submission (verdict: Accepted):
N = int(input())
c = {(str(i), str(j)):0 for i in range(10) for j in range(10)}
for i in range(1, N+1):
    s = str(i)
    c[(s[0], s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        i, j = str(i), str(j)
        ans += c[(i, j)] * c[(j, i)]
print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 0
l=[[0]*10 for _ in range(10)]
for i in range(1,2021):
  s = str(i)
  l[int(s[0])][int(s[-1])]+=1
  
for i in range(10):
  for j in range(10):
    ans+=l[i][j]*l[j][i]
    
print(ans)

Failing test case input:
897

Expected output:
8083


Actual output:
40812


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

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

for i in range(1,N+1):
  if int(str(i)[-1])==0:
    pass
  else:
    h=int(str(i)[0])
    t=int(str(i)[-1])
    K[h-1][t-1] += 1
  
ans=0
for i in range(9):
  for j in range(i+1):
    if i!=j:
      ans += 2*K[i][j]* K[j][i]
      print(i+1,j+1)
    else:
      ans += K[i][j]**2
    
      
print(ans)

Failing test case input:
2011

Expected output:
40631


Actual output:
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
40631


Fixed submission (verdict: Accepted):
N=int(input())
K=[[0 for i in range(9)] for j in range(9)]

for i in range(1,N+1):
  if int(str(i)[-1])==0:
    pass
  else:
    h=int(str(i)[0])
    t=int(str(i)[-1])
    K[h-1][t-1] += 1


ans=0
for i in range(9):
  for j in range(i+1):
    if i==j:
      ans += K[i][j]* K[j][i]
    else:
      ans += 2*K[i][j]* K[j][i]
      
      
print(ans)
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(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
    print(m)
    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:
200000

Expected output:
400000008

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


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):
N = int(input())


c = []
for i in range(10):
    c.append([0] * 10)

for i in range(1,N):
    s = str(i)
    i1 = int(s[0])
    i2 = int(s[-1])
    c[i1][i2] += 1
    
total = 0
for i in range(10):
    for j in range(10):
        total += c[i][j] * c[j][i]
        
print(total)

Failing test case input:
3437

Expected output:
118300


Actual output:
118278


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

c = []
for i in range(10):
    c.append([0] * 10)

for i in range(N):
    s = str(i+1)
    i1 = int(s[0])
    i2 = int(s[-1])
    c[i1][i2] += 1
    
total = 0
for i in range(10):
    for j in range(10):
        total += c[i][j] * c[j][i]
        
print(total)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N= int(input())
lead_N = int(str(N)[0]) 
end_N = int(str(N)[len(str(N)) - 1])
ans = 0

for i in range(1, N + 1):
  lead = int(str(i)[0])
  end = int(str(i)[len(str(i)) - 1])
  
  if lead == end:
    ans += 1
  
  for j in range((len(str(N)) - 2) + 1):
    if end == 0:
      
      continue
    elif end > lead_N and j == (len(str(N)) - 2) :
      
      continue
    elif end == lead_N and j == (len(str(N)) - 2):
      
      
      if len(str(N)) >= 4:
        ans += int(str(N)[1:len(str(N)) - 2])
      if lead <= end_N:
        ans += 1
      
      pass
    else:
      
      ans += 10 ** j

print(ans)

Failing test case input:
1478

Expected output:
21890


Actual output:
15526


Fixed submission (verdict: Accepted):
N= int(input())
lead_N = int(str(N)[0]) 
end_N = int(str(N)[len(str(N)) - 1])
ans = 0

for i in range(1, N + 1):
  lead = int(str(i)[0])
  end = int(str(i)[len(str(i)) - 1])
  
  if lead == end:
    ans += 1
  
  for j in range((len(str(N)) - 2) + 1):
    if end == 0:
      
      continue
    elif end > lead_N and j == (len(str(N)) - 2) :
      
      continue
    elif end == lead_N and j == (len(str(N)) - 2):
      
      
      if len(str(N)) >= 3:
        ans += int(str(N)[1:len(str(N)) - 1])

      if lead <= end_N:
        ans += 1
      
      pass
    else:
      
      ans += 10 ** j

print(ans)

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


if N <= 10:
    print(N)
    exit()

dic = {}
for i in range(11,100):
    if i % 10 == 0:
        continue
    if i % 11 == 0:
        dic[i] = 1
    else:
        dic[i] = 0

for i in range(11, N):
    if i % 10 == 0:
        continue
    tmp = str(i)[0] + str(i)[-1]
    dic[int(tmp)] += 1

res = 0
for current, num in dic.items():
    if current % 11 == 0:
        res += num * num
    else:
        tmp = int(str(current)[::-1])
        res += num * dic[tmp]

print(res)


Failing test case input:
816

Expected output:
6701


Actual output:
6679


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


if N <= 10:
    print(N)
    exit()

dic = {}
for i in range(11,100):
    if i % 10 == 0:
        continue
    if i % 11 == 0:
        dic[i] = 1
    else:
        dic[i] = 0

for i in range(11, N+1):
    if i % 10 == 0:
        continue
    tmp = str(i)[0] + str(i)[-1]
    dic[int(tmp)] += 1

res = 0
for current, num in dic.items():
    if current % 11 == 0:
        res += num * num
    else:
        tmp = int(str(current)[::-1])
        res += num * dic[tmp]

print(res)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
N = int(input())

res = 0
freq = defaultdict(int)

for i in range(1, N):
    si = str(i)
    freq['{}{}'.format(si[0], si[-1])] += 1
    
for i in range(1, N):
    si = str(i)
    res += freq['{}{}'.format(si[-1], si[0])]
        
print(res)

Failing test case input:
2011

Expected output:
40631


Actual output:
40409


Fixed submission (verdict: Accepted):
from collections import defaultdict
N = int(input())

res = 0
freq = defaultdict(int)

for i in range(1, N+1):
    si = str(i)
    freq['{}{}'.format(si[0], si[-1])] += 1
    
for i in range(1, N+1):
    si = str(i)
    res += freq['{}{}'.format(si[-1], si[0])]
        
print(res)

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

for x in range(1,n+1):
    if x%10!=0:
        str_x = str(x)
        l,r = int(str_x[0]), int(str_x[-1])
        table[l][r] += 1

ans = 0
for x in range(1, n+1):
    if x%10 != 0:
        str_x = str(x)
        l,r = int(str_x[0]), int(str_x[-1])
        if l==r:
            ans += table[l][r]
        else:
            ans += (table[l][r] * table[r][l])
print(ans)

Failing test case input:
200000

Expected output:
400000008

Actual output:
1283906214328


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

for x in range(1,n+1):
    if x%10!=0:
        str_x = str(x)
        l,r = int(str_x[0]), int(str_x[-1])
        table[l][r] += 1

ans = 0
for x in range(1, n+1):
    if x%10 != 0:
        str_x = str(x)
        l,r = int(str_x[0]), int(str_x[-1])
        if l==r:
            ans += table[l][r]
        else:
            ans += table[r][l]
print(ans)

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

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

for i in range(N):
    Top = str(i)[0]
    Btm = str(i)[-1]

    if Btm == '0':
        continue
    
    IJ[int(Top)][int(Btm)] += 1

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

Failing test case input:
816

Expected output:
6701


Actual output:
6679


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

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

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

    if Btm == '0':
        continue
    
    IJ[int(Top)][int(Btm)] += 1

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

num = [[0 for j in range(10)]for i in range(10)]
for i in range(N):
    NN = i
    kouho = []
    while NN>=1:
        kouho.append(int(NN%10))
        NN = NN/10
    if len(kouho) == 0:
        continue
    
    low_bit = int(kouho[0])
    high_bit = int(kouho[-1])
    
    if (not low_bit or not high_bit):
        continue
    num[low_bit][high_bit] += 1
ans = 0


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


Failing test case input:
3093

Expected output:
95976


Actual output:
95933


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

num = [[0 for j in range(10)]for i in range(10)]
for i in range(1,N+1):
    NN = i
    kouho = []
    while NN>=1:
        kouho.append(int(NN%10))
        NN = NN/10
    if len(kouho) == 0:
        continue
    
    low_bit = int(kouho[0])
    high_bit = int(kouho[-1])
    
    if (not low_bit or not high_bit):
        continue
    num[low_bit][high_bit] += 1
ans = 0


for i in range(1,10):
    for j in range(1,10):
        ans += num[i][j] * num[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):
    a = str(i)
    s = int(a[0])
    e = int(a[-1])
    table[s][e] += 1



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

print(ans)

Failing test case input:
2158

Expected output:
46642


Actual output:
46620


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

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



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



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

print(ans)

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

cnt=[[0,0,0,0,0,0,0,0,0,0] for _ in range(10)]
ans = 0


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

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

print(ans)

Failing test case input:
1478

Expected output:
21890


Actual output:
21868


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

cnt=[[0,0,0,0,0,0,0,0,0,0] for _ in range(10)]
ans = 0


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

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

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

    table = [0] * 100
    for i in range(n):
        i_str = str(i)
        table[int(i_str[0]) * 10 + int(i_str[-1])] += 1

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

    print(num)


if __name__ == '__main__':
    main()


Failing test case input:
453

Expected output:
2099


Actual output:
2077


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

    table = [0] * 100
    for i in range(n+1):
        i_str = str(i)
        table[int(i_str[0]) * 10 + int(i_str[-1])] += 1

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

    print(num)


if __name__ == '__main__':
    main()

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(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:
3437

Expected output:
118300


Actual output:
118279


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())
l = [[0] * 10 for _ in range(10)]
ans = 0

for i in range(N):
    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)

Failing test case input:
2158

Expected output:
46642


Actual output:
46620


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):
def main3(N):
    lst = list()
    for i in range(1, 10):
        lst.append([0]*9)

    for n in range(1, N+1):
        head = int(str(n)[0])
        tail = int(str(n)[-1])
        lst[head-1][tail-1] += 1
    
    count = 0
    for i in range(0, len(lst)):
        for j in range(0, len(lst[i])):
            count += lst[i][j] * lst[j][i]

    print(count)

N = int(input())
main3(N)


Failing test case input:
141750

Expected output:
200930633


Actual output:
233664026


Fixed submission (verdict: Accepted):
def main3(N):
    lst = list()
    for i in range(1, 10):
        lst.append([0]*9)

    for n in range(1, N+1):
        head = int(str(n)[0])
        tail = int(str(n)[-1])
        
        if tail != 0:
            lst[head-1][tail-1] += 1
        
    
    
    
    count = 0
    for i in range(0, len(lst)):
        for j in range(0, len(lst[i])):
            count += lst[i][j] * lst[j][i]

    print(count)

N = int(input())
main3(N)

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












n = int(input())
count = 0
a = [[0] * 10 for i in range(10)]


for i in range(n):
    head = int(str(i)[0])
    tail = int(str(i)[-1])
    
    
    a[head][tail] += 1


for i in range(n):
    if i % 10 == 0:
        continue

    head = int(str(i)[0])
    tail = int(str(i)[-1])
    count += a[tail][head]

print(count)


Failing test case input:
1478

Expected output:
21890


Actual output:
21868


Fixed submission (verdict: Accepted):












n = int(input())
count = 0
a = [[0] * 10 for i in range(10)]


for i in range(n +1):
    head = int(str(i)[0])
    tail = int(str(i)[-1])
    
    
    a[head][tail] += 1


for i in range(n+1):
    if i % 10 == 0:
        continue

    head = int(str(i)[0])
    tail = int(str(i)[-1])
    count += a[tail][head]

print(count)

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

ans = 0
C = [ [0 for i in range(10)] for i in range(10)]

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

for first_num in range(1,10):
  for last_num in range(1,10):
    ans += C[first_num][last_num] * C[last_num][first_num]

print(ans)


Failing test case input:
1292

Expected output:
16754


Actual output:
16732


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

ans = 0
C = [ [0 for i in range(10)] for i in range(10)]

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

for first_num in range(1,10):
  for last_num in range(1,10):
    ans += C[first_num][last_num] * C[last_num][first_num]

print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
ans=0
dic={}
for i in range(1,n):
    s=str(i)
    d=(s[0],s[-1])
    if d not in dic.keys():
        dic[d] = 1
    else:
        dic[d] += 1

for a in dic.keys():
    b = (a[1],a[0])
    if b in dic.keys():
        ans += dic[a]*dic[(a[1],a[0])]

print(ans)

Failing test case input:
897

Expected output:
8083


Actual output:
8061


Fixed submission (verdict: Accepted):
n=int(input())
ans=0
dic={}
for i in range(1,n+1):
    s=str(i)
    d=(s[0],s[-1])
    if d not in dic.keys():
        dic[d] = 1
    else:
        dic[d] += 1

for a in dic.keys():
    b = (a[1],a[0])
    if b in dic.keys():
        ans += dic[a]*dic[(a[1],a[0])]

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]) + 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:
15829


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 (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
C = [0]*100
for i in range(N):
  s = str(i)
  C[10*int(s[0])+int(s[-1])] += 1
print(sum([C[10*i+j]*C[10*j+i] for i in range(10) for j in range(10)]))

Failing test case input:
1257

Expected output:
15840


Actual output:
15819


Fixed submission (verdict: Accepted):
N = int(input())
C = [0]*100
for i in range(1,N+1):
  s = str(i)
  C[10*int(s[0])+int(s[-1])] += 1
print(sum([C[10*i+j]*C[10*j+i] for i in range(10) for j in range(10)]))
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

dic = {}
for i in range(1,10):
  for j in range(1,10):
    dic[(str(i),str(j))] = 0

for i in range(N):
  nstr = str(i)
  pre = nstr[0]
  suf = nstr[-1]
  if suf == '0':
    continue
  dic[(pre, suf)] =dic[(pre, suf)] + 1

cnt = 0 
for i in range(1,10):
  for j in range(1,i+1):
    cnt += dic[(str(i),str(j))] * dic[(str(j),str(i))]
  
  
print(dic.values())

Failing test case input:
1478

Expected output:
21890


Actual output:
dict_values([60, 59, 59, 59, 59, 59, 59, 58, 58, 11, 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, 11, 11, 11, 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, 11, 11, 11, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12])


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

dic = {}
for i in range(1,10):
  for j in range(1,10):
    dic[(str(i),str(j))] = 0

for i in range(N+1):
  nstr = str(i)
  pre = nstr[0]
  suf = nstr[-1]
  if suf == '0':
    continue
  dic[(pre, suf)] =dic[(pre, suf)] + 1

cnt = 0 
for i in range(1,10):
  for j in range(1,10):
    cnt += dic[(str(i),str(j))] * dic[(str(j),str(i))]

print(cnt)

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+1):
    A[int(str(i)[0])][int(str(i)[-1])] += 1
    
print(A)

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

print(ans)


Failing test case input:
2158

Expected output:
46642


Actual output:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [111, 112, 111, 111, 111, 111, 111, 111, 111, 111], [27, 27, 28, 27, 27, 27, 27, 27, 27, 26], [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]]
46642


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

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

for i in range(1, N+1):
    A[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] * A[j][i] 

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):
    x = str(n + 1)
    c[int(x[0])][int(x[-1])] += 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:
3437

Expected output:
118300


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
c = [[0 for i in range(10)] for j in range(10)]

for i in range(n):
    x = str(i + 1)
    c[int(x[0])][int(x[-1])] += 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())

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(0,10):
    for j in range(0,10):
        ans += ans_list[i][j]*ans_list[j][i]

print(ans)

Failing test case input:
2011

Expected output:
40631


Actual output:
40410


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())
d = [[0] * 10 for _ in range(10)]

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

result = 0
for i in range(1, 10):
  for j in range(1, 10):
    result = d[i][j] * d[j][i]
print(result)


Failing test case input:
897

Expected output:
8083


Actual output:
4


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

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

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

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<=10:
    print(N)
else:
    print(ans-1)


Failing test case input:
2424

Expected output:
58947


Actual output:
58925


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 (PyPy3 (2.4.0), verdict: Wrong Answer):


s=input()
n=int(s)

d={}

for i in range(1,n):
	ts=str(i)
	hs=ts[0]+" "+ts[len(ts)-1]

	if(hs in d):
		d[hs]+=1
	else:
		d[hs]=1



ans=0

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

print(ans)




Failing test case input:
1257

Expected output:
15840


Actual output:
15818


Fixed submission (verdict: Accepted):


s=input()
n=int(s)

d={}

for i in range(1,n+1):
	ts=str(i)
	hs=ts[0]+" "+ts[len(ts)-1]

	if(hs in d):
		d[hs]+=1
	else:
		d[hs]=1



ans=0

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

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

Failing test case input:
1292

Expected output:
16754


Actual output:
16732


Fixed submission (verdict: Accepted):
N = int(input())
arr = [0]*100
for num in range(1,N+1):
  arr[int(str(num)[0]+str(num)[-1])] += 1
print(sum([arr[i*10+j]*arr[j*10+i]  for i in range(10) for j in range(10)]))

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

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

for i in range(1, n):
    str_i = str(i)
    c[int(str_i[0])][int(str_i[len(str_i)-1])] += 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:
2424

Expected output:
58947


Actual output:
58925


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

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

for i in range(n):
    str_i = str(i+1)
    c[int(str_i[0])][int(str_i[len(str_i)-1])] += 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):
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<=9:
    print(N)
else:
    print(ans)


Failing test case input:
3437

Expected output:
118300


Actual output:
118278


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 (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())

c=[[0]*10 for _ in range(10)]
ans=0
for i in range(1,n):
    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)

Failing test case input:
2424

Expected output:
58947


Actual output:
58925


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

c=[[0]*10 for _ in range(10)]
ans=0
for i in range(1,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())
c = [[0 for i in range(10)] for i in range(10)]
ans = 0

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

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

print(ans)


Failing test case input:
897

Expected output:
8083


Actual output:
8061


Fixed submission (verdict: Accepted):
n = int(input())
c = [[0 for i in range(10)] for i in range(10)]
ans = 0

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

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

print(ans)

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
        
        ans += int(str(N)[1:-1])
        
        break
print(ans)


Failing test case input:
816

Expected output:
6701


Actual output:
6635


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 (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
a=int(input())
ans=0
c=[[0 for i in range(10)] for j in range(10)]
for i in range(1,a):
  aa=str(i)
  c[int(aa[0])][int(aa[-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:
3093

Expected output:
95976


Actual output:
95933


Fixed submission (verdict: Accepted):
import math
a=int(input())
ans=0
c=[[0 for i in range(10)] for j in range(10)]
for i in range(1,a+1):
  aa=str(i)
  c[int(aa[0])][int(aa[-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())
count=[[0]*9 for _ in range(9)]
for i in range(1,n+1):
  if i%10>0:
    i=str(i)
    if int(i[::-1])<=n:  
      x,y=int(i[0])-1,int(i[-1])-1
      count[x][y]+=1
ans=0
for i in count:
  for j in i:
    ans+=j**2
print(ans)

Failing test case input:
2011

Expected output:
40631


Actual output:
22529


Fixed submission (verdict: Accepted):
n=int(input())
count=[[0]*9 for _ in range(9)]
for i in range(1,n+1):
  if i%10>0:  
    i=str(i)
    x,y=int(i[0])-1,int(i[-1])-1
    count[x][y]+=1
    
ans=0
for i in range(9):
  for j in range(9):
      ans+=count[i][j]*count[j][i]
print(ans)
Problem: p02792
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=[[0 for n in range(9)] for n in range(9)]

for n in range(N):
    head=int(str(n)[0])
    tail=n%10
    if head!=0 and tail!=0:
        A[head-1][tail-1]+=1

count=0

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

print(count)

Failing test case input:
2424

Expected output:
58947


Actual output:
58925


Fixed submission (verdict: Accepted):
N=int(input())
A=[[0 for n in range(9)] for n in range(9)]

for n in range(N+1):
    head=int(str(n)[0])
    tail=n%10
    if head!=0 and tail!=0:
        A[head-1][tail-1]+=1

count=0

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

print(count)

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

n = int(input())

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

ans = 0
for i in range(n):
    s = str(i)
    t = len(s)
    u = int(s[0])
    v = int(s[len(s)-1])

    if u == 0:
        continue
    if v == 0:
        continue

    if u == v:
        ans += 1

    z = 2 * l[v][u]
    ans += z

    l[u][v] += 1

print(ans)

    
    


Failing test case input:
2158

Expected output:
46642


Actual output:
46620


Fixed submission (verdict: Accepted):

n = int(input())

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

ans = 0
for i in range(n):
    s = str(i+1)
    t = len(s)
    u = int(s[0])
    v = int(s[len(s)-1])

    if u == 0:
        continue
    if v == 0:
        continue

    if u == v:
        ans += 1

    z = 2 * l[v][u]
    ans += z

    l[u][v] += 1

print(ans)

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

ans_list = [[0 for i in range(10)] for j 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(0,10):
    for j in range(0,10):
        ans += ans_list[i][j]*ans_list[j][i]

print(ans)

Failing test case input:
3093

Expected output:
95976


Actual output:
95977


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())
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
        else:
            ans += tmp-1
        break
print(ans)


Failing test case input:
453

Expected output:
2099


Actual output:
2054


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())
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)
print(a)

Failing test case input:
3437

Expected output:
118300


Actual output:
118300
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 111, 111, 111, 111, 111, 111, 111, 111, 0, 111, 112, 111, 111, 111, 111, 111, 111, 111, 0, 55, 55, 56, 55, 55, 55, 55, 54, 54, 0, 11, 11, 11, 12, 11, 11, 11, 11, 11, 0, 11, 11, 11, 11, 12, 11, 11, 11, 11, 0, 11, 11, 11, 11, 11, 12, 11, 11, 11, 0, 11, 11, 11, 11, 11, 11, 12, 11, 11, 0, 11, 11, 11, 11, 11, 11, 11, 12, 11, 0, 11, 11, 11, 11, 11, 11, 11, 11, 12]


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 (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
res=0
M=[[0 for _ in range(10)] for _ in range(10)]
for i in range(n):
  a=i%10
  b=int(str(i)[0])
  M[a][b]+=1
for i in range(1,10):
  for j in range(1,10):
    res+=M[i][j]*M[j][i]
    
print(res)

Failing test case input:
2158

Expected output:
46642


Actual output:
46620


Fixed submission (verdict: Accepted):
n=int(input())
res=0
M=[[0 for _ in range(10)] for _ in range(10)]
for i in range(n+1):
  a=i%10
  b=int(str(i)[0])
  M[a][b]+=1
for i in range(1,10):
  for j in range(1,10):
    res+=M[i][j]*M[j][i]
    
print(res)