Problem:


Score : 300 points

Problem Statement

You are given N real values A_1, A_2, \ldots, A_N.
Compute the number of pairs of indices (i, j)
    such that i < j and the product A_i \cdot A_j is integer.

Constraints

2 \leq N \leq 200\,000

0 < A_i < 10^4

A_i is given with at most 9 digits after the decimal.

Input

Input is given from Standard Input in the following format.

N
A_1
A_2
\vdots
A_N

Output

Print the number of pairs with integer product A_i \cdot A_j (and i < j).

Sample Input 1

5
7.5
2.4
17.000000001
17
16.000000000

Sample Output 1

3

There are 3 pairs with integer product:

7.5 \cdot 2.4 = 18

7.5 \cdot 16 = 120

17 \cdot 16 = 272

Sample Input 2

11
0.9
1
1
1.25
2.30000
5
70
0.000000001
9999.999999999
0.999999999
1.000000001

Sample Output 2

8



Sample input:
5
7.5
2.4
17.000000001
17
16.000000000


Sample output:
3

Submission status: Runtime Error

Solution code:
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n = ii()
    a = []
    ans = 0
    for i in range(n):
        tmp = input()
        ketaage = 0
        if '.' in tmp:
            cnt = 1
            while tmp[-cnt] != '.':
                cnt += 1
            ketaage = cnt - 1
            tmp = tmp[:-cnt] + tmp[-cnt + 1:]
        tmp = int(tmp)
        while tmp % 10 == 0:
            ketaage -= 1
            tmp //= 10
        tcnt = 0
        fcnt = 0
        while tmp % 2 == 0:
            tcnt += 1
            tmp //= 2
        if tcnt == 0:
            while tmp % 5 == 0:
                fcnt += 1
                tmp //= 5
        a.append([tcnt, fcnt, ketaage])
    tlist = []
    flist = [[0 for i in range(40)] for j in range(30)]
    tlistlist = [0 for i in range(40)]

    seisuucnt = 0
    fseisuucnt = 0

    for i in range(n):
        if a[i][1] == 0:
            tlist.append([a[i][0], a[i][2]])

            if a[i][2] <= 0:
                seisuucnt += 1
                tlistlist[a[i][2] + 10] += 1
        else:
            flist[a[i][2] + 10][a[i][1]] += 1
            if a[i][2] <= 0:
                fseisuucnt += 1
    for i in range(1, 30):
        tlistlist[i] += tlistlist[i - 1]

    for tmp in range(30):
        for i in range(1, 40):
            flist[tmp][39 - i] += flist[tmp][39 - i + 1]
    for tmp in tlist:
        keta = tmp[1]
        tcnt = tmp[0]
        for i in range(-5, 22):
            if keta + i > tcnt:
                break
            ans += flist[i + 10][max(0, keta + i)]


#            print(tmp, keta, i, flist[i + 10][max(0, keta + i)],
#                  tlistlist[10 - keta])
        ans += tlistlist[10 - keta]

    if seisuucnt > 0:
        ans -= (seisuucnt * (seisuucnt - 1)) // 2
        ans -= seisuucnt
    if fseisuucnt > 0:
        ans += (fseisuucnt * (fseisuucnt - 1)) // 2
    print(ans)

main()

Submission status: Runtime Error

Solution code:
from math import *

cnt = [[0] * 25 for i in range(25)]

ans = 0
for _ in range(int(input())):
    t = float(input())
    b = int(t * 1000000000.0)
    x, y = 0, 0
    while b % 2 == 0:
        x += 1
        b //= 2
    while b % 5 == 0:
        y += 1
        b //= 5
    print(x, y)
    for i in range(25):
        for j in range(25):
            if i + x >= 18 and j + y >= 18:
                ans += cnt[i][j]
    cnt[x][y] += 1
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
from collections import defaultdict
n = int(input())
a = [[0 for i in range(20)] for j in range(20)]
data = []
ans = 0
p = pow(10,9)
two_size = 18
five_size = 18
count = 0
for i in range(n):
    k = float(input()) * p
    two = 0
    five = 0
    while k % 2 == 0:
        two += 1
        k //= 2
    while k % 5 == 0:
        five += 1
        k //= 5
    t, f = two_size - two, five_size - five
    for x in range(t, 20):
        for y in range(f, 20):
            count += a[x][y]
    a[two][five] += 1
print(count)

Submission status: Runtime Error

Solution code:
from math import gcd
n = int(input())
li = []
for i in range(n):
    s = input()
    if '.' in s:
        a, b = s.split('.')
        t = 10 ** len(b)
        li.append((int(a) * t + int(b), t))
    else:
        li.append((int(s), 1))
p = [[0] * 20 for _ in range(24)]
cnt = 0
for i in range(n):
    x, y = li[i]
    g = gcd(x, y)
    x //= g
    y //= g
    if y == 1:
        cnt += 1
    li[i] = x
    a1, b1 = 0, 0
    while x % 2 == 0:
        a1 += 1
        x //= 2
    while x % 5 == 0:
        b1 += 1
        x //= 5
    a2, b2 = 0, 0
    while y % 2 == 0:
        a2 += 1
        y //= 2
    while y % 5 == 0:
        b2 += 1
        y //= 5
    p[a1 - a2 + 9][b1 - b2 + 9] += 1
ans = 0
for i in range(0, 24):
    for j in range(0, 20):
        for a in range(18 - i, 24):
            for b in range(18 - j, 20):
                if p[i][j] * p[a][b]:
                    a
                ans += p[i][j] * p[a][b]
print((ans - cnt) // 2)

Submission status: Runtime Error

Solution code:
import math
x = int(input())

A = []
for i in range(0, int(x)):
  val = int(input(""))
  if val:
    A.append(val)


A.sort(reverse=True)

p = 0
for i in range(int(x)):
    for t in range(int(x)):
        if (i - t > 0) and float(A[i])*float(A[t]) == math.floor(float(A[i])*float(A[t])):
             p += 1
            
print(p)

Submission status: Runtime Error

Solution code:
N = int(input())
A = []
for _ in range(N):
    A.append(float(input())) 

B = [0]*N*N
count=0
for i in range(N):
    for n in range(N):
        if n>=i:
            count =count
        else:
            B[count] = A[i]*A[n]
            count=count+1

kazu=0
l_len=len(B)
for i in range(l_len):
    if B[i]%1==0 and B[i]>0:
        kazu=kazu+1

print(kazu)

Submission status: Runtime Error

Solution code:
import sys
import decimal
import numpy as np
input = sys.stdin.readline

N = int(input())
kizyun = 1e-9
A = []
C2 = np.array([[0 for j in range(14)] for i in range(14)])  # 10countは9タス
C5 = np.array([[0 for j in range(14)] for i in range(14)])
for _ in range(N):
    i = decimal.Decimal(input())
    c10, c2, c5 = 0, 0, 0
    while i%1!=0:
        c10 -= 1
        i *= 10
    while i % 10 == 0:
        c10 += 1
        i /= 10
    while i % 2 == 0:
        c2 += 1
        i /= 2
    while i % 5 == 0:
        c5 += 1
        i /= 5
    c2 = min(c2, 13)
    c5 = min(c5, 13)
    A.append((c10, c2, c5))
    C2[c10+9][c2] += 1
    C5[c10+9][c5] += 1

ans = 0
for c10, c2, c5 in A:
    if c10 >= 0:
        ans -= 1
    ans += np.sum(C2[-c10 + 9:])
    if c5 == 0:
        for i in range(-c10 + 9):
            shouldhave = (-c10+9) - i
            if shouldhave <= c2:
                ans += np.sum(C5[i][shouldhave:])
    elif c2 == 0:
        for i in range(-c10 + 9):
            shouldhave = (-c10 + 9) - i
            if shouldhave <= c5:
                ans += np.sum(C2[i][shouldhave:])
print(ans//2)

Submission status: Runtime Error

Solution code:
t=int(input())
l=[]
for i in range(0,t):
  m=int(input())
  l.append(m)
ct=0
for i in range(0,t-1):
  for j in range(i+1,t):
    n=l[i]*l[j]
    n1=int(l[i]*l[j])
    if(n==n1):
      ct+=1
print(ct)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve0(N, AS):
    ret = 0
    for i in range(N):
        for j in range(i + 1, N):
            if AS[i] * AS[j] % 1000000000_000000000 == 0:
                # debug(": AS[i], AS[j]", AS[i], AS[j])
                ret += 1
    return ret


def solve1(N, AS):
    ret = 0
    P2 = []
    P5 = []
    for i in range(N):
        p2 = 0
        p5 = 0
        x = AS[i]
        while x % 2 == 0:
            p2 += 1
            x //= 2
        while x % 5 == 0:
            p5 += 1
            x //= 5
        P2.append(p2)
        P5.append(p5)
    # debug(": P2, P5", P2, P5)
    for i in range(N):
        for j in range(i + 1, N):
            if P2[i] + P2[j] > 17 and P5[i] + P5[j] > 17:
                # debug(": AS[i], AS[j]", AS[i], AS[j])
                ret += 1
    return ret


def solve(N, AS):
    import numpy as np
    ret = 0
    # P = [[0] * 14 for i in range(14)]
    P2 = []
    P5 = []
    P = np.zeros((20, 20), dtype=np.int)

    for i in range(N):
        p2 = 0
        p5 = 0
        x = AS[i]
        while x % 2 == 0:
            p2 += 1
            x //= 2
        while x % 5 == 0:
            p5 += 1
            x //= 5
        P2.append(p2)
        P5.append(p5)
        P[p2, p5] += 1

    for i in range(19, 0, -1):
        P[i - 1] += P[i]
    for i in range(19, 0, -1):
        P[:, i - 1] += P[:, i]

    for i in range(N):
        ret += P[18 - P2[i], 18 - P5[i]]
    ret -= P[9, 9]
    ret //= 2
    return ret


def main():
    # parse input
    N = int(input())
    AS = []
    for i in range(N):
        s = input().strip()
        try:
            v = int(s) * 1000000000
        except:
            s1, s2 = s.split(b".")
            s2 = s2 + b"0" * (9 - len(s2))
            v = int(s1) * 1000000000 + int(s2)
        # print(v)
        AS.append(v)
    print(solve(N, AS))


# tests
T1 = """
5
7.5
2.4
17.000000001
17
16.000000000
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
3
"""

T2 = """
11
0.9
1
1
1.25
2.30000
5
70
0.000000001
9999.999999999
0.999999999
1.000000001
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
8
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()

Submission status: Runtime Error

Solution code:
N = int(input())

Afact = [[0 for _ in range(19)] for _ in range(19)]

ans = 0

for _ in range(N):
    afloat = float(input())
    aint = int(afloat * (10 ** 9) + 0.9)

    fact_count_two = 0
    while aint & 1 == 0:
        fact_count_two += 1
        aint >>= 1
    fact_count_five = 0
    while aint % 5 == 0:
        fact_count_five += 1
        aint //= 5

    ans += Afact[max(0, 18 - fact_count_two)][max(0, 18 - fact_count_five)]
    for i in range(fact_count_two + 1):
        for j in range(fact_count_five + 1):
            Afact[i][j] += 1

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())

Afact = [[0 for _ in range(19)] for _ in range(19)]

ans = 0

for _ in range(N):
    afloat = float(input())
    aint = int(afloat * (10 ** 9) + 0.9)

    fact_count_two = 0
    while aint & 1 == 0:
        fact_count_two += 1
        aint >>= 1
    fact_count_five = 0
    while aint % 5 == 0:
        fact_count_five += 1
        aint //= 5

    ans += Afact[min(0, 18 - fact_count_two)][min(0, 18 - fact_count_five)]
    for i in range(fact_count_two + 1):
        for j in range(fact_count_five + 1):
            Afact[i][j] += 1

print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = defaultdict(int)
    temp = n
#     M = int(-(-n**0.5//1))+1
#     if m is not None:
#         M = min(m+1, M)
    M = 6
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    return arr

n = int(input())
a = [None]*n
m = [[0]*19 for _ in range(19)]
ab = [None]*n
for i in range(n):
    s = input()
    if "." in s:
        ind = s.index(".")
        vv = len(s) - s.index(".") - 1
        v = int(s[:ind])*10**(vv) + int(s[(ind+1):])
        v *= 10**(9-vv)
    else:
        v = int(s)*10**9
    d = factor(v, 5)
    d.setdefault(2,0)
    d.setdefault(5,0)
    a,b = max(0, 18-d[2]), max(0, 18-d[5])
    m[a][b] += 1
    ab[i] = (d[2],d[5])
def cumsum2(v):
    # v: h*wの2次元リスト
    h,w = len(v), len(v[0])
    v.insert(0, [0]*w)
    for l in v:
        l.insert(0, 0)
    for i in range(1,h+1):
        for j in range(1,w+1):
            v[i][j] = v[i-1][j] + v[i][j-1] - v[i-1][j-1] + v[i][j]
    return v
m = cumsum2(m)
ans = 0
for a,b in ab:
    # print(a,b)
    ans += m[a+1][b+1]
    if a>=9 and b>=9:
        ans -= 1
print(ans//2)

Submission status: Runtime Error

Solution code:
n=int(input())
import itertools
a=tanaka=tottori=[]
for i in range(n):
    aha=float(input())

    a.append(aha)

i=kazu=0


for j in itertools.combinations(a,2):
    
    kari=j[0]*j[1]
    if kari.is_integer():
        kazu+=1
        
        tanaka.append([j])
        
    
    
;print (tanaka)
print(kazu)

Submission status: Runtime Error

Solution code:
n=int(input())
data=[[0]*30 for i in range(30)]

for i in range(n):
    s=input()
    l=len(s)
    num=0
    sho=0
    keta=1
    for i in range(l):
        if(s[l-i-1]!='.'):
            num+=keta*int(s[l-i-1])
            keta*=10
        else:
            sho=i
    #print(num,sho)
    two=-sho
    five=-sho
    for i in range(100):
        if(num%2==0):
            two+=1
            num//=2
        else:
            break
    for i in range(100):
        if(num%5==0):
            five+=1
            num//=5
        else:
            break
    #print(two,five)
    data[two+9][five+9]+=1


ans=0
for i in range(30):
    for j in range(30):
        jibun=data[i][j]
        if(jibun==0):
            continue
        aite=0
        for p in range(max(0,18-i),30):
            for q in range(max(0,18-j),30):
                aite+=data[p][q]
                if(p==i and j==q):
                    aite-=1
        ans+=jibun*aite
        #print(i-9,j-9,jibun,aite)

print(ans//2)

Submission status: Runtime Error

Solution code:
N = int(input())

Afact = [[0 for _ in range(19)] for _ in range(19)]

ans = 0

for _ in range(N):
    afloat = float(input())
    aint = int(afloat * (10 ** 9) + 0.9)

    fact_count_two = 0
    while aint & 1 == 0:
        fact_count_two += 1
        aint >>= 1
    fact_count_five = 0
    while aint % 5 == 0:
        fact_count_five += 1
        aint //= 5

    ans += Afact[18 - fact_count_two][18 - fact_count_five]
    for i in range(fact_count_two + 1):
        for j in range(fact_count_five + 1):
            Afact[i][j] += 1

print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

N=int(input())
A=[input().strip() for i in range(N)]

X=[]

for a in A:
    TWO=0
    FIVE=0

    if "." in a:
        x=a.split(".")
        L=len(x[1])
        #print(x,L)
        TWO-=L
        FIVE-=L

        x=int("".join(x))

        #print(x)

        while x%2==0:
            x//=2
            TWO+=1

        while x%5==0:
            x//=5
            FIVE+=1

        #print(TWO,FIVE)

    else:
        x=int(a)
        while x%2==0:
            x//=2
            TWO+=1

        while x%5==0:
            x//=5
            FIVE+=1

    X.append((TWO,FIVE))

LIST=[[0]*30 for i in range(30)]

for x,y in X:
    LIST[x+15][y+15]+=1

#for l in LIST:
#    print(*l)

#print()

for i in range(30):
    for j in range(28,-1,-1):
        LIST[i][j]+=LIST[i][j+1]

for j in range(30):
    for i in range(28,-1,-1):
        LIST[i][j]+=LIST[i+1][j]

#for l in LIST:
#    print(*l)

ANS=0

for x,y in X:
    x2=-x
    y2=-y

    if x>=x2 and y>=y2:
        ANS-=1

    ANS+=LIST[x2+15][y2+15]

    #print(x,y,ANS)

print(ANS//2)

Submission status: Runtime Error

Solution code:
n = input()
n= int(n)
arr= []
c=0
for i in range(n):
  s = float(input())
  arr.append(s)
 
for i in range(n):
  for j in range(n):
    mul = arr[i]*arr[j
    if mul==int(mul):
      c++

Submission status: Runtime Error

Solution code:
import sys
from fractions import Fraction

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def a(s):
	r = Fraction(s)
	return r.numerator, r.denominator



def main():
	n = int(input())
	#b , c = tin()
	al = [a(input()) for _ in range(n)]
	ret = 0
	for i, (vin, vid) in enumerate(al):
		for (vjn, vjd) in al[i+1:]:
			if (vin*vjn) % (vid, vjd)==0:
				ret += 1
	return ret
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Runtime Error

Solution code:
N = int(input())
S = []
for _ in range(N):
    S.append(input())
ans = 0
    
while len(S) != 0:
    tmp = S[0]
    S.pop(0)
    for i in list(map(lambda x: x * tmp,S)):
        if i.is_integer():
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = defaultdict(int)
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr

n = int(input())
a = [None]*n
m = [[0]*19 for _ in range(19)]
ab = [None]*n
for i in range(n):
    s = input()
    if "." in s:
        ind = s.index(".")
        vv = len(s) - s.index(".") - 1
        v = int(s[:ind])*10**(vv) + int(s[(ind+1):])
        v *= 10**(9-vv)
    else:
        v = int(s)*10**9
    d = factor(v, 5)
    a,b = max(0, 18-d[2]), max(0, 18-d[5])
    m[a][b] += 1
    ab[i] = (d[2],d[5])
def cumsum2(v):
    # v: h*wの2次元リスト
    h,w = len(v), len(v[0])
    v.insert(0, [0]*w)
    for l in v:
        l.insert(0, 0)
    for i in range(1,h+1):
        for j in range(1,w+1):
            v[i][j] = v[i-1][j] + v[i][j-1] - v[i-1][j-1] + v[i][j]
    return v
m = cumsum2(m)
ans = 0
for a,b in ab:
    ans += m[a+1][b+1]
    if a>=9 and b>=9:
        ans -= 1
print(ans//2)

Submission status: Runtime Error

Solution code:

N = int(input())
A = []
count = 0

for _ in range(N):
	A.append(int(input()))

for i in range(N):
	for j in range(N):
		if i < j:
			num1 = A[i] * A[j]
			num2 = int(A[i] * A[j])

			if num1 == num2:
				count += 1

print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
S = []
for _ in range(N):
    S.append(input())
ans = 0
    
while len(S) != 0:
    tmp = S[0]
    S.pop(0)
    for i in list(map(lambda x: x * tmp,S)):
        if i.is_integer():
            ans += 1

Submission status: Runtime Error

Solution code:
import itertools
n = int(input())
a = [input() for i in range(n)]
count = 0
comb = list(itertools.product(a,2))
for i in range(len(comb)):
  aa = float(comb[i][0]) * float(comb[i][1])
  if aa.is_integer():
    count = count + 1
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
arr= []
c=0
for i in range(n):
  s = float(input())
  arr.append(s)
 
for k in range(n):
  for j in range(n):
    mul = arr[k]*arr[j]
    if mul==int(mul):
      c++

Submission status: Runtime Error

Solution code:
N = int(input())
S = []
for _ in range(N):
    list.append(input())
ans = 0
    
while len(S) != 0:
    tmp = S[0]
    S.pop(0)
    for i in list(map(lambda x: x * tmp,S)):
        if i.is_integer():
            ans += 1

Submission status: Runtime Error

Solution code:
l=[]
c=0
for i in range(int(input()):
               l.append(int(input))
for i in range(len(l)-1):
               for j in range(i+1,len(l)):
               if type(l[i]*l[j])==int:
               c+=1
print(c)

Submission status: Runtime Error

Solution code:
n = int(input())

lst = list(map(float,input().split()))
count = 0
for i in range(n-1):
	for j in range(i+1,n):
	    ans = int(lst[i]*lst[j])
	    if ((lst[i]*lst[j]) == ans):
	        count+=1
print(count)

Submission status: Runtime Error

Solution code:
data = []
count = 0
n=input()

for i in range(n):
    data[i] = input()

for i in range(len(data)):
    if i!=0:
        for j in range(len(data)):
            if(i<j):
                if(isinstance(data[i]*data[j],int)):
                    count +=1
print(count)

Submission status: Runtime Error

Solution code:
data = []
count = 0
n=input()

for i in range(n):
    data[i] = input()
    
for i in range(len(data)):
    if i!=0:
        for j in range(len(data)):
            if(i<j):
                if(isinstance(data[i]*data[j],int)):
                    count +=1
#print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
arr= []
c=0
for i in range(n):
  s = float(input())
  arr.append(s)
 
for i in range(n):
  for j in range(n):
    mul = arr[i]*arr[j
    if mul==int(mul):
      c++

Submission status: Runtime Error

Solution code:
#pragma region kyopro_template
#define Nyaan_template
#include <immintrin.h>
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define each(x, v) for (auto &x : v)
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define mem(a, val) memset(a, val, sizeof(a))
#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)
#define inl(...)         \
  long long __VA_ARGS__; \
  in(__VA_ARGS__)
#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__)
#define inc(...)    \
  char __VA_ARGS__; \
  in(__VA_ARGS__)
#define in2(s, t)                           \
  for (int i = 0; i < (int)s.size(); i++) { \
    in(s[i], t[i]);                         \
  }
#define in3(s, t, u)                        \
  for (int i = 0; i < (int)s.size(); i++) { \
    in(s[i], t[i], u[i]);                   \
  }
#define in4(s, t, u, v)                     \
  for (int i = 0; i < (int)s.size(); i++) { \
    in(s[i], t[i], u[i], v[i]);             \
  }
#define rep(i, N) for (long long i = 0; i < (long long)(N); i++)
#define repr(i, N) for (long long i = (long long)(N)-1; i >= 0; i--)
#define rep1(i, N) for (long long i = 1; i <= (long long)(N); i++)
#define repr1(i, N) for (long long i = (N); (long long)(i) > 0; i--)
#define reg(i, a, b) for (long long i = (a); i < (b); i++)
#define die(...)      \
  do {                \
    out(__VA_ARGS__); \
    return;           \
  } while (0)
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vd = V<double>;
using vs = V<string>;
using vvl = vector<vector<long long>>;
using P = pair<long long, long long>;
using vp = vector<P>;
using pii = pair<int, int>;
using vpi = vector<pair<int, int>>;
constexpr int inf = 1001001001;
constexpr long long infLL = (1LL << 61) - 1;
template <typename T, typename U>
inline bool amin(T &x, U y) {
  return (y < x) ? (x = y, true) : false;
}
template <typename T, typename U>
inline bool amax(T &x, U y) {
  return (x < y) ? (x = y, true) : false;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  int s = (int)v.size();
  for (int i = 0; i < s; i++) os << (i ? " " : "") << v[i];
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}
void in() {}
template <typename T, class... U>
void in(T &t, U &... u) {
  cin >> t;
  in(u...);
}
void out() { cout << "\n"; }
template <typename T, class... U>
void out(const T &t, const U &... u) {
  cout << t;
  if (sizeof...(u)) cout << " ";
  out(u...);
}

#ifdef NyaanDebug
#define trc(...)                   \
  do {                             \
    cerr << #__VA_ARGS__ << " = "; \
    dbg_out(__VA_ARGS__);          \
  } while (0)
#define trca(v, N)       \
  do {                   \
    cerr << #v << " = "; \
    array_out(v, N);     \
  } while (0)
#define trcc(v)                             \
  do {                                      \
    cerr << #v << " = {";                   \
    each(x, v) { cerr << " " << x << ","; } \
    cerr << "}" << endl;                    \
  } while (0)
template <typename T>
void _cout(const T &c) {
  cerr << c;
}
void _cout(const int &c) {
  if (c == 1001001001)
    cerr << "inf";
  else if (c == -1001001001)
    cerr << "-inf";
  else
    cerr << c;
}
void _cout(const unsigned int &c) {
  if (c == 1001001001)
    cerr << "inf";
  else
    cerr << c;
}
void _cout(const long long &c) {
  if (c == 1001001001 || c == (1LL << 61) - 1)
    cerr << "inf";
  else if (c == -1001001001 || c == -((1LL << 61) - 1))
    cerr << "-inf";
  else
    cerr << c;
}
void _cout(const unsigned long long &c) {
  if (c == 1001001001 || c == (1LL << 61) - 1)
    cerr << "inf";
  else
    cerr << c;
}
template <typename T, typename U>
void _cout(const pair<T, U> &p) {
  cerr << "{ ";
  _cout(p.fi);
  cerr << ", ";
  _cout(p.se);
  cerr << " } ";
}
template <typename T>
void _cout(const vector<T> &v) {
  int s = v.size();
  cerr << "{ ";
  for (int i = 0; i < s; i++) {
    cerr << (i ? ", " : "");
    _cout(v[i]);
  }
  cerr << " } ";
}
template <typename T>
void _cout(const vector<vector<T>> &v) {
  cerr << "[ ";
  for (const auto &x : v) {
    cerr << endl;
    _cout(x);
    cerr << ", ";
  }
  cerr << endl << " ] ";
}
void dbg_out() { cerr << endl; }
template <typename T, class... U>
void dbg_out(const T &t, const U &... u) {
  _cout(t);
  if (sizeof...(u)) cerr << ", ";
  dbg_out(u...);
}
template <typename T>
void array_out(const T &v, int s) {
  cerr << "{ ";
  for (int i = 0; i < s; i++) {
    cerr << (i ? ", " : "");
    _cout(v[i]);
  }
  cerr << " } " << endl;
}
template <typename T>
void array_out(const T &v, int H, int W) {
  cerr << "[ ";
  for (int i = 0; i < H; i++) {
    cerr << (i ? ", " : "");
    array_out(v[i], W);
  }
  cerr << " ] " << endl;
}
#else
#define trc(...)
#define trca(...)
#define trcc(...)
#endif

inline int popcnt(unsigned long long a) { return __builtin_popcountll(a); }
inline int lsb(unsigned long long a) { return __builtin_ctzll(a); }
inline int msb(unsigned long long a) { return 63 - __builtin_clzll(a); }
template <typename T>
inline int getbit(T a, int i) {
  return (a >> i) & 1;
}
template <typename T>
inline void setbit(T &a, int i) {
  a |= (1LL << i);
}
template <typename T>
inline void delbit(T &a, int i) {
  a &= ~(1LL << i);
}
template <typename T>
int lb(const vector<T> &v, const T &a) {
  return lower_bound(begin(v), end(v), a) - begin(v);
}
template <typename T>
int ub(const vector<T> &v, const T &a) {
  return upper_bound(begin(v), end(v), a) - begin(v);
}
template <typename T>
int btw(T a, T x, T b) {
  return a <= x && x < b;
}
template <typename T, typename U>
T ceil(T a, U b) {
  return (a + b - 1) / b;
}
constexpr long long TEN(int n) {
  long long ret = 1, x = 10;
  while (n) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
}
template <typename T>
vector<T> mkrui(const vector<T> &v) {
  vector<T> ret(v.size() + 1);
  for (int i = 0; i < int(v.size()); i++) ret[i + 1] = ret[i] + v[i];
  return ret;
};
template <typename T>
vector<T> mkuni(const vector<T> &v) {
  vector<T> ret(v);
  sort(ret.begin(), ret.end());
  ret.erase(unique(ret.begin(), ret.end()), ret.end());
  return ret;
}
template <typename F>
vector<int> mkord(int N, F f) {
  vector<int> ord(N);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord), end(ord), f);
  return ord;
}
template <typename T = int>
vector<T> mkiota(int N) {
  vector<T> ret(N);
  iota(begin(ret), end(ret), 0);
  return ret;
}
template <typename T>
vector<int> mkinv(vector<T> &v) {
  vector<int> inv(v.size());
  for (int i = 0; i < (int)v.size(); i++) inv[v[i]] = i;
  return inv;
}

struct IoSetupNya {
  IoSetupNya() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(7);
  }
} iosetupnya;

void solve();
int main() { solve(); }

#pragma endregion
using namespace std;

template <typename T>
struct BinaryIndexedTree2D {
  int H, W;
  vector<vector<T>> bit;
  BinaryIndexedTree2D(int H, int W) : H(H + 1), W(W + 1) {
    bit.resize(H + 3, vector<T>(W + 3, 0));
  }
  // 関数の入力のindexは0-originを想定

  // (x,y)にwを足す
  // 範囲外の時は足さない
  void add(int x, int y, T w) {
    if (x < 0 || x >= H || y < 0 || y >= W) return;
    for (int a = (++y, ++x); a <= H; a += a & -a) {
      for (int b = y; b <= W; b += b & -b) {
        bit[a][b] += w;
      }
    }
  }

  // imos法で[(x1,y1) , (x2,y2)]にwを足す
  void imos(int x1, int y1, int x2, int y2, T w) {
    add(x1, y1, w);
    add(x1, y2 + 1, -w);
    add(x2 + 1, y1, -w);
    add(x2 + 1, y2 + 1, w);
  }

  //  [(0,0) , (x,y)]の和　閉区間に注意！
  // x,y<0の時は0 x>=H y>=Wのときはx=H-1,y=W-1とみなす
  // ( imos法の時は (x,y)の値を返す )
  T sum(int x, int y) {
    if (x < 0 || y < 0) return 0;
    if (x >= H) x = H - 1;
    if (y >= W) y = W - 1;
    T ret = 0;
    for (int a = (++y, ++x); a > 0; a -= a & -a) {
      for (int b = y; b > 0; b -= b & -b) {
        ret += bit[a][b];
      }
    }
    return ret;
  }

  // [(x1,y1) , (x2,y2)] の和
  // x1 > x2, y1 > y2の時はswap
  T sum(int x1, int y1, int x2, int y2) {
    if (x1 > x2 || y1 > y2) return T(0);
    return sum(x2, y2) - sum(x2, y1 - 1) - sum(x1 - 1, y2) +
           sum(x1 - 1, y1 - 1);
  }
};

void solve() {
  ini(N);
  vl a;
  rep(_, N) {
    ins(s);
    auto it = s.find('.');
    if (it == string::npos) {
      a.push_back(stoll(s) * TEN(9));
    } else {
      string t = s.substr(0, it);
      s = s.substr(it + 1, s.size());
      trc(t,s);
      while (s.size() < 9) s += '0';
      a.push_back(stoll(t) * TEN(9) + stoll(s));
    }
  }
  trc(a);
  vp v(sz(a),P(0,0));
  rep(i,N){
    while(v[i].first < 20 and a[i] % 2 == 0) a[i] /= 2, v[i].first++;
    while(v[i].second < 20 and a[i] % 5 == 0) a[i] /= 5, v[i].second++;
  }

  constexpr int m = 22;
  ll memo[m][m]={};
  each(p,v) memo[p.first][p.second]++;


  ll ans = 0;
  rep(i,m)rep(j,m) rep(k,m)rep(l,m){
    if(i + k < 18 || j + l < 18) continue;
    if(i == k and j == l) ans += memo[i][j] * (memo[k][l] - 1);
    else ans += memo[i][j] * (memo[k][l]);
  }
  out(ans / 2);



}

Submission status: Runtime Error

Solution code:
from itertools import combinations
import math


def solve(a, b):
    x = a * b
    return int(x) == math.ceil(x)


n = int(input())
arr = [Decimal(input()) for _ in range(n)]


ans = []
for x, y in combinations(arr, 2):
    ans.append(solve(x, y))

print(sum(ans))