Buggy python submission (verdict: Time Limit Exceeded):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

from decimal import Decimal

def get_primes(n):
	divs = defaultdict(int)
	if n == 0: return divs
	for i in [2,5]:
		c = 0
		while n % i == 0:
			n = n // i
			c += 1
		if c > 0:
			divs[i] = c
	return divs

L = 10**9
N = ri()
A = []
for i in range(N):
	d = Decimal(rs())
	A.append(int(d*L))
#print(A)

R = [0] * N
for i, a in enumerate(A):
	R[i] = A[i] % L
#print(R)

M = 18
K = 0
C = []
D = []
for i in range(N):
	r = R[i]
	a = A[i]
	if r > 0:
		ps = get_primes(a)
		C.append([min(ps[2], M), min(ps[5], M)])
	else:
		ps = get_primes(a)
		D.append([min(ps[2], M), min(ps[5], M)])
#print('C',C)
#print('D',D)

h = defaultdict(int)
ans0 = 0
for c in C:
	d = [M-c[0], M-c[1]]
	i, j = d[0], d[1]
	for i in range(d[0], M+1):
		for j in range(d[1], M+1):
			if (i, j) in h:
				ans0 += h[(i,j)] - (c == (i,j))
	h[tuple(c)] += 1

ans1 = len(D)*(len(D)-1)//2

ans2 = 0
for c in D:
	d = [M-c[0], M-c[1]]
	for i in range(d[0], M+1):
		for j in range(d[1], M+1):
			if (i, j) in h:
				ans2 += h[(i,j)] - (c == (i,j))
#print(ans0, ans1, ans2)
ans = ans0 + ans1 + ans2
print(ans)


Fixed submission:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

from decimal import Decimal

def gcd(a, b):
	return gcd(b, a%b) if b else a

L = 10**9
LL = 10**18
N = ri()
A = []
for i in range(N):
	d = Decimal(rs())
	A.append(int(d*L))

h = defaultdict(int)
for i in range(N):
	g = gcd(A[i], LL)
	h[g] += 1

ans = 0
for g, c in h.items():
	for g2, c2 in h.items():
		if g == g2:
			if g*g % LL == 0:
				ans += c*(c-1)//2
		elif g < g2:
			if g*g2 % LL == 0:
				ans += c * c2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

from decimal import Decimal

def get_primes(n):
	divs = defaultdict(int)
	for i in [2,5]:
		c = 0
		while n % i == 0:
			n = n // i
			c += 1
		if c > 0:
			divs[i] = c
	return divs

L = 10**9
N = ri()
A = []
for i in range(N):
	d = Decimal(rs())
	A.append(int(d*L))
#print(A)

C = [[0, 0] for i in range(N)]
for i, r in enumerate(A):
	ps = get_primes(r)
	C[i] = [min(ps[2], 18), min(ps[5], 18)]
#print(C)

h = defaultdict(int)
ans = 0
for c in C:
	d = [18-c[0], 18-c[1]]
	for i in range(d[0], 19):
		for j in range(d[1], 19):
			if (i, j) in h:
				ans += h[(i,j)] - (c == (i,j))
	h[tuple(c)] += 1

print(ans)


Fixed submission:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

from decimal import Decimal

def gcd(a, b):
	return gcd(b, a%b) if b else a

L = 10**9
LL = 10**18
N = ri()
A = []
for i in range(N):
	d = Decimal(rs())
	A.append(int(d*L))

h = defaultdict(int)
for i in range(N):
	g = gcd(A[i], LL)
	h[g] += 1

ans = 0
for g, c in h.items():
	for g2, c2 in h.items():
		if g == g2:
			if g*g % LL == 0:
				ans += c*(c-1)//2
		elif g < g2:
			if g*g2 % LL == 0:
				ans += c * c2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

from decimal import Decimal

def get_primes(n):
	#divs = []
	divs = defaultdict(int)
	for i in range(2, int(n**0.5)+1):
		c = 0
		while n % i == 0:
			n = n // i
			c += 1
		if c > 0:
			#divs.append((i, c))
			divs[i] = c
	if n > 1:
		#divs.append((n, 1))
		divs[n] = 1
	return divs

L = 10**9
N = ri()
A = []
for i in range(N):
	d = Decimal(rs())
	A.append(int(d*L))
#print(A)

C = [[0, 0] for i in range(N)]
for i, r in enumerate(A):
	ps = get_primes(r)
	#print(r, ps)
	C[i] = [min(ps[2], 18), min(ps[5], 18)]
#print(C)

h = defaultdict(int)
#for c in C:
#print(h)
ans = 0
for c in C:
	#print('c',c)
	d = [18-c[0], 18-c[1]]
	for i in range(d[0], 19):
		for j in range(d[1], 19):
			if (i, j) in h:
				#print('ok', i, j)
				ans += h[(i,j)] - (c == (i,j))
	h[tuple(c)] += 1

print(ans)


Fixed submission:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

from decimal import Decimal

def gcd(a, b):
	return gcd(b, a%b) if b else a

L = 10**9
LL = 10**18
N = ri()
A = []
for i in range(N):
	d = Decimal(rs())
	A.append(int(d*L))

h = defaultdict(int)
for i in range(N):
	g = gcd(A[i], LL)
	h[g] += 1

ans = 0
for g, c in h.items():
	for g2, c2 in h.items():
		if g == g2:
			if g*g % LL == 0:
				ans += c*(c-1)//2
		elif g < g2:
			if g*g2 % LL == 0:
				ans += c * c2
print(ans)