Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
n = int(readline())
#a = []
C = [0]*n
D = [0]*n

M = 10**9
for i in range(n):
    bi = float(readline())
    ai = int(round(bi*M))
        
    c2=c5=0    
    x = ai
    while x%2==0:
        c2 += 1
        x//=2
    
    x = ai
    while x%5==0:
        c5 += 1
        x//=5
    #print(ai,c2,c5)
    #a.append((c2,c5,v))
    C[i] = c2
    D[i] = c5
    #print(ai)
#print(C)
#print(D)

ans = 0
for i in range(n):
    for j in range(i+1,n):
        if C[i]+C[j] >= 18 and D[i]+D[j] >= 18:
            ans += 1

print(ans)




Fixed submission:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n = int(readline())
#C = [0]*n
#D = [0]*n

"""
dp[i][j] = 2,5で何回割れるか
"""
dp = [[0]*20 for _ in range(50)]

M = 10**9
for i in range(n):
    bi = float(readline())
    ai = int(round(bi*M))
    
    c2=c5=0    
    x = ai
    while x%2==0:
        c2 += 1
        x//=2
    
    x = ai
    while x%5==0:
        c5 += 1
        x//=5
    #C[i] = c2
    #D[i] = c5
    dp[c2][c5] += 1
    #print(c2,c5)

"""
dp[i][j] = 2,5で何回割れるか(50*20)
"""
acc = [dp[i][:] for i in range(50)]
for i in range(49,-1,-1):
    for j in range(19,-1,-1):
        if i != 49:
            acc[i][j] += acc[i+1][j] 
        if j != 19:
            acc[i][j] += acc[i][j+1] 
        if i != 49 and j != 19:
            acc[i][j] -= acc[i+1][j+1] 
            
ans = 0
for i in range(50):
    for j in range(20):
        ans += dp[i][j] * acc[max(0,18-i)][max(0,18-j)]
        if i >= 9 and j >= 9: ans -= dp[i][j]

#print(ans)
print(ans//2)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
n = int(readline())
a = []
for i in range(n):
    ai = readline().strip()
    idx = ai.find(".")
    if idx >= 0:
        v = len(ai)-idx-1
        ai = int(ai.replace(".",""))
    else:
        ai = int(ai)
        v = 0
    c2 = c5 = 0

    x = ai
    while x%2==0:
        c2 += 1
        x//=2
    
    x = ai
    while x%5==0:
        c5 += 1
        x//=5
    #print(ai,c2,c5)
    a.append((c2,c5,v))

ans = 0
for i in range(n):
    c,d,v = a[i]
    for j in range(i+1,n):
        e,f,w = a[j]
        if c+e >= v+w and d+f >= v+w:
            ans += 1

print(ans)




Fixed submission:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n = int(readline())
#C = [0]*n
#D = [0]*n

"""
dp[i][j] = 2,5で何回割れるか
"""
dp = [[0]*20 for _ in range(50)]

M = 10**9
for i in range(n):
    bi = float(readline())
    ai = int(round(bi*M))
    
    c2=c5=0    
    x = ai
    while x%2==0:
        c2 += 1
        x//=2
    
    x = ai
    while x%5==0:
        c5 += 1
        x//=5
    #C[i] = c2
    #D[i] = c5
    dp[c2][c5] += 1
    #print(c2,c5)

"""
dp[i][j] = 2,5で何回割れるか(50*20)
"""
acc = [dp[i][:] for i in range(50)]
for i in range(49,-1,-1):
    for j in range(19,-1,-1):
        if i != 49:
            acc[i][j] += acc[i+1][j] 
        if j != 19:
            acc[i][j] += acc[i][j+1] 
        if i != 49 and j != 19:
            acc[i][j] -= acc[i+1][j+1] 
            
ans = 0
for i in range(50):
    for j in range(20):
        ans += dp[i][j] * acc[max(0,18-i)][max(0,18-j)]
        if i >= 9 and j >= 9: ans -= dp[i][j]

#print(ans)
print(ans//2)