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: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

n = int(readline())
data = read().split()
x = 10**9

a = []
for si in data:
    if('.' in si):
        num1,num2 = si.split('.')
        a.append(int(num1)*x + int(num2) * 10**(9- len(num2)))
    else:
        a.append(int(si) * x)

fac_25 = [[0]*19 for _ in range(19)]
for ai in a:
    # print(ai)

    num = 2
    cnt2 = 0
    while(ai%num == 0)&(cnt2<18):
        ai //= num
        cnt2 += 1

    num = 5
    cnt5 = 0
    while(ai%num == 0)&(cnt5<18):
        ai //= num
        cnt5 += 1

    fac_25[cnt2][cnt5] += 1

    # print(cnt2,cnt5)

fac_cs = [[0]*19 for _ in range(19)]
for i in range(18,-1,-1):
    for j in range(18,-1,-1):
        fac_cs[i][j] = fac_25[i][j]
for i in range(18,-1,-1):
    for j in range(17,-1,-1):
        fac_cs[i][j] += fac_cs[i][j+1]

for i in range(17,-1,-1):
    for j in range(18,-1,-1):
        fac_cs[i][j] += fac_cs[i+1][j]

ans = 0
for i in range(18,-1,-1):
    for j in range(18,-1,-1):
        ans += fac_25[i][j] * fac_cs[18-i][18-j]

# print(ans)
ans -= fac_cs[9][9]
# print(ans)
ans //=2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
B = []
X = [[0]*19 for _ in range(19)]

for _ in range(N):
    s = input()
    if '.' not in s: s = s+'.0'
    a1, a2 = s.split('.')
    a2 = a2 + '0'*(9-len(a2))
    A = int(a1)*10**9 + int(a2)

    d2 = d5 = 0
    while A%2==0:
        A//=2
        d2+=1
    d2 = min(18, d2)

    while A%5==0:
        A//=5
        d5+=1
    d5 = min(18, d5)

    B.append((d2,d5))
    X[d2][d5] += 1

C = [[0]*19 for _ in range(19)]
for n2 in range(19):
    s = 0
    for n5 in range(18, -1, -1):
        s += X[n2][n5]
        C[n2][n5] = s

D = [[0]*19 for _ in range(19)]
for n5 in range(19):
    s = 0
    for n2 in range(18, -1, -1):
        s += C[n2][n5]
        D[n2][n5] = s

ans = 0
for n2, n5 in B:
    if n2*2>=18 and n5*2>=18: ans-=1
    ans += D[18-n2][18-n5]
    
print(ans//2)

Submission status: Accepted

Solution code:
N = int(input())
p2 = [0] * N
p5 = [0] * N

out = 0

for i in range(N):
    s = input()
    
    if '.' in s:
        a, b = s.split('.')
        inp = int(a+b)
        twos = -len(b)
        fives = -len(b)
    else:
        inp = int(s)
        twos = 0
        fives = 0

    while inp % 2 == 0:
        twos += 1
        inp //= 2
    while inp % 5 == 0:
        fives += 1
        inp //= 5

    if twos >= 0 and fives >= 0:
        out -= 1

    p2[i] = twos
    p5[i] = fives

count = [[0] * 105 for i in range(105)]
for i in range(N):
    count[p2[i]][p5[i]] += 1

pref = [[0] * 105 for i in range(105)]
for i in range(50,-51,-1):
    for j in range(50, -51, -1):
        curr = count[i][j]
        curr += pref[i + 1][j]
        curr += pref[i][j + 1]
        curr -= pref[i + 1][j + 1]
        pref[i][j] = curr

for i in range(N):
    out += pref[-p2[i]][-p5[i]]
    #print(pref[-p2[i]][-p5[i]])
print(out//2)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# Dmitry _kun_ Sayutin (2020)

from fractions import *

n = int(input())

mp = dict()
for i in range(n):
    var = Fraction(input().strip())
    nom = var.numerator
    denom = var.denominator

    i, j = 0, 0
    
    while denom % 2 == 0:
        i -= 1
        denom //= 2
    
    while denom % 5 == 0:
        j -= 1
        denom //= 5

    while nom % 2 == 0:
        i += 1
        nom //= 2

    while nom % 5 == 0:
        j += 1
        nom //= 5

    i = min(i, 10)
    j = min(j, 10)

    mp[(i, j)] = mp.get((i, j), 0) + 1

ans = 0
for (a, cnt1) in mp.items():
    for (b, cnt2) in mp.items():
        if a < b and a[0] + b[0] >= 0 and a[1] + b[1] >= 0:
            ans += cnt1 * cnt2

for (a, cnt) in mp.items():
    if a[0] >= 0 and a[1] >= 0:
        ans += cnt * (cnt - 1) // 2
            
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
# 小数以下桁数、2の倍数、5の倍数
num = {}
for i in range(n):
    a = input()
    if "." in a:
        temp = a.index(".")
        a1 = len(a) - temp - 1
        a = int(a[:temp] + a[temp + 1:])
    else:
        a1 = 0
        a = int(a)
    a_ = a
    a2 = 0
    for i in range(18):
        if a % 2 == 0:
            a2 += 1
            a //= 2
        else:
            break
    a3 = 0
    for i in range(18):
        if a_ % 5 == 0:
            a3 += 1
            a_ //= 5
        else:
            break
    num.setdefault((a1, a2, a3), 0)
    num[(a1, a2, a3)] += 1
num2 = []
for i, j in num.items():
    num2.append([i, j])
ans = 0
for i in range(len(num2)):
    for j in range(i, len(num2)):
        if i == j:
            temp = num2[i]
            if temp[0][0] <= min(temp[0][1], temp[0][2]):
                ans += temp[1] * (temp[1] - 1) // 2
        else:
            temp = num2[i]
            temp2 = num2[j]
            if temp[0][0] + temp2[0][0] <= min(temp[0][1] + temp2[0][1], temp[0][2] + temp2[0][2]):
                ans += temp[1] * temp2[1]
print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def calc(s):
    if "." not in s:
        n = int(s) * 10 ** 9
    else:
        s1, s2 = s.split(".")
        n = int(s1) * 10 ** 9 + int(s2) * 10 ** (9 - len(s2))
    
    a = 0
    b = 0
    while n % 2 == 0:
        n //= 2
        a += 1
    while n % 5 == 0:
        n //= 5
        b += 1
    return (min(a, 18), min(b, 18))

ans = 0
N = int(input())
X = [[0] * 19 for _ in range(19)]
for _ in range(N):
    a, b = calc(input())
    if a >= 9 and b >= 9:
        ans -= 1
    X[a][b] += 1

Y = [x[:] for x in X]

for i in range(18)[::-1]:
    for j in range(19):
        Y[i][j] += Y[i+1][j]
for i in range(19):
    for j in range(18)[::-1]:
        Y[i][j] += Y[i][j+1]

for i in range(19):
    for j in range(19):
        ans += X[i][j] * Y[18-i][18-j]
print(ans // 2)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())

cnt25 = [[0]*19 for i in range(19)]

for i in range(n):
    a = input()[:-1]
    cnt2 = 0
    cnt5 = 0
    if "." in a:
        a, b = a.split(".")
        cnt2 += 9 - len(b)
        cnt5 += 9 - len(b)
        a = int(a+b)
    else:
        a = int(a)
        cnt2 += 9
        cnt5 += 9
    b = a
    while a>0 and a%2 == 0:
        a //= 2
        cnt2 += 1
    while b>0 and b%5 == 0:
        b //= 5
        cnt5 += 1

    cnt25[min(18, cnt2)][min(18, cnt5)] += 1

sumcnt = [[cnt25[i][j] for j in range(19)] for i in range(19)]
for i in range(18,-1,-1):
    for j in range(18, 0, -1):
        sumcnt[i][j-1] += sumcnt[i][j]

for i in range(18, -1, -1):
    for j in range(18, 0, -1):
        sumcnt[j-1][i] += sumcnt[j][i]

ans = 0
for i in range(19):
    for j in range(19):
        ans += cnt25[i][j] * sumcnt[18-i][18-j]
        if 18-i <= i and 18-j <= j and cnt25[i][j] > 0:
            ans -= cnt25[i][j]


print(ans//2)

Submission status: Accepted

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

from collections import Counter
ctr = Counter()

for a in A:
    of = 0
    if '.' in a:
        of = a[::-1].index('.')
        a = a.replace('.', '')
    a = int(a)
    ni = go = -of
    while a%2==0:
        a//=2
        ni += 1
    while a%5==0:
        a//=5
        go += 1
    ctr[(ni,go)] += 1

ans = 0
for (ni1,go1),v1 in ctr.items():
    for (ni2,go2),v2 in ctr.items():
        if ni1+ni2 < 0 or go1+go2 < 0: continue
        if ni1==ni2 and go1==go2:
            ans += v1*(v1-1)
        else:
            ans += v1*v2
print(ans//2)

Submission status: Accepted

Solution code:
# problem a
# score 300
from collections import defaultdict
N = int(input())
A = []
for i in range(N):
    x = float(input())
    x = "{:.9f}".format(x)
    x=int(x[:-10]+x[-9:])
    A.append(x)
remove = 0
for i in range(N):
    if (A[i]**2) % (10**18) == 0:
        remove += 1
D = defaultdict(int)
data = []
for x in A:
    order2 = 0
    order5 = 0
    K = x
    while K % 2 == 0:
        order2 += 1
        K = K//2
    while K % 5 == 0:
        order5 += 1
        K = K//5
    data.append((order2, order5))
    for i in range(order2+1):
        for j in range(order5+1):
            D[2**i*5**j] += 1
ans = 0
for ord2, ord5 in data:
    new_ord2 = max(0, 18-ord2)
    new_ord5 = max(0, 18-ord5)
    ans += D[(2**new_ord2)*(5**new_ord5)]
ans-=remove
ans = ans//2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = [[0] * 21 for _ in range(21)]
ans = 0
for _ in range(n):
    a = input()
    if '.' not in a:
        c2 = c5 = 0
    else:
        c2 = c5 = -(len(a) - (a.index('.') + 1))
    a = int(a.replace('.',''))
    while a % 2 == 0:
        a //= 2
        c2 += 1
    while a % 5 == 0:
        a //= 5
        c5 += 1
    c2 = min(10, c2)
    c5 = min(10, c5)
    for i in range(-c2, 11):
        for j in range(-c5, 11):
            ans += d[i+10][j+10]
    d[c2+10][c5+10] += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

two_fives = []
mapping = [[0] * 19 for _ in range(19)]
ans = 0
for _ in range(N):
    s = input()
    if '.' in s:
        m, x = s.split('.')
        A = int(m) * 10 ** 9 + int(x.ljust(9, '0'))
    else:
        A = int(s) * 10 ** 9

    for two in range(19):
        if A % 2 == 0:
            A //= 2
        else:
            break
    for five in range(19):
        if A % 5 == 0:
            A //= 5
        else:
            break
        
    two_fives.append((two, five))
    mapping[18 - two][18 - five] += 1
    if two >= 9 and five >= 9:
        ans -= 1 # excluding ai * ai

for i in range(18):
    for j in range(19):
        mapping[i+1][j] += mapping[i][j]

for i in range(19):
    for j in range(18):
        mapping[i][j+1] += mapping[i][j]


for two, five in two_fives:
    ans += mapping[two][five]

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

Submission status: Accepted

Solution code:
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n = int(input())
da = [[0 for i in range(50)] for j in range(50)]
ans = 0
for i in range(n):
    now = round(float(input())*1000000000)
    # print(now)
    a, b = 0, 0
    while(now%5 == 0):
        now //= 5
        a += 1
    while(now%2 == 0):
        now //= 2
        b += 1
    da[a][b] += 1
    # print(a, b)
    if a >= 9 and b >= 9: ans -= 1


for i in range(50):
    for j in range(50):
        for k in range(50):
            for l in range(50):
                if i+k >= 18 and j+l>= 18:
                    ans += da[i][j]*da[k][l]

print(ans//2)

Submission status: Accepted

Solution code:
from fractions import Fraction
N=int(input())
A=[Fraction(input()) for i in range(N)]
def vp(n,p):
    res=0
    m=n
    while(m>0):
        if m%p==0:
            res+=1
            m//=p
        else:
            return res
def div25(f):
    return (vp(f.numerator,2)-vp(f.denominator,2),vp(f.numerator,5)-vp(f.denominator,5))
B=[div25(f) for f in A]
B.sort()
MAX_N=100
C=[[0 for j in range(MAX_N)] for i in range(MAX_N)]
for seq in B:
    x,y=seq
    C[x+MAX_N//2][y+MAX_N//2]+=1
D=[[0 for j in range(MAX_N)] for i in range(MAX_N+1)]
E=[[0 for j in range(MAX_N+1)] for i in range(MAX_N+1)]
for i in range(MAX_N):
    for j in range(MAX_N):
        D[i+1][j]=D[i][j]+C[i][j]
for i in range(MAX_N+1):
    for j in range(MAX_N):
        E[i][j+1]=E[i][j]+D[i][j]
ans=0
for seq in B:
    x,y=seq
    tmp=E[MAX_N][MAX_N]+E[-x+MAX_N//2][-y+MAX_N//2]-E[MAX_N][-y+MAX_N//2]-E[-x+MAX_N//2][MAX_N]
    if x>=0 and y>=0:
        ans+=tmp-1
    else:
        ans+=tmp
print(ans//2)

Submission status: Accepted

Solution code:
# import sys
# input = sys.stdin.readline
n = int(input())
A = [input() for i in range(n)]
B = []

for i in range(n):
    if "." in A[i]:
        ind = A[i].index(".")
        A[i] += "0" * (10-(len(A[i]) - ind))
        B.append(int(A[i][:ind] + A[i][ind+1:]))
    else:
        B.append(int(A[i] + "0" * 9))

# print(B)

l = 100
D = [[0] * l for i in range(l)]
E = []

for i in range(n):
    a2 = 0
    a5 = 0
    while B[i] % 2 == 0:
        a2 += 1
        B[i] //= 2
    while B[i] % 5 == 0:
        a5 += 1
        B[i] //= 5
    D[a2][a5] += 1
    E.append([a2,a5])

for i in range(l-2,-1,-1):
    D[l-1][i] += D[l-1][i+1]
for i in range(l-2,-1,-1):
    D[i][l-1] += D[i+1][l-1]

for i in range(l-2,-1,-1):
    for j in range(l-2,-1,-1):
        D[i][j] += D[i+1][j] + D[i][j+1] - D[i+1][j+1]

# print(D)

ans = 0
for i in range(n):
    b2 = max(0, 18-E[i][0])
    b5 = max(0, 18-E[i][1])
    ans += D[b2][b5]
    if E[i][0]>=b2 and E[i][1]>=b5:
        ans -= 1

print(ans//2)

Submission status: Accepted

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

class BIT2D:
    def __init__(self, H, W):
        self.H = H
        self.W = W
        self.data = [[0] * (H+1) for _ in range(W+1)]

    def add(self, a, b, x):
        a += 1
        b += 1
        i = a
        while i <= self.H:
            j = b
            while j <= self.W:
                self.data[i][j] += x
                j += j & -j
            i += i & -i

    def sum(self, a, b):
        a += 1
        b += 1
        ret = 0
        i = a
        while i > 0:
            j = b
            while j > 0:
                ret += self.data[i][j]
                j -= j & -j
            i -= i & -i
        return ret

N = int(input())
A = []
for _ in range(N):
    n = input().rstrip()
    if '.' not in n:
        A.append(int(n) * 10**9)
    else:
        a, b = n.split('.')
        b += '0' * (9 - len(b))
        A.append(int(a + b))
ans = 0
bit = BIT2D(100, 100)
for i in range(N):
    cnt2 = cnt5 = 0
    while A[i] % 2 == 0:
        A[i] //= 2
        cnt2 += 1
    while A[i] % 5 == 0:
        A[i] //= 5
        cnt5 += 1
    if cnt2 >= 18 and cnt5 >= 18:
        ans += i
    else:
        ans += i - bit.sum(99, 17 - cnt5) - bit.sum(17 - cnt2, 99) + bit.sum(17 - cnt2, 17 - cnt5)
    bit.add(cnt2, cnt5, 1)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
r = [[0 for _ in range(19)] for _ in range(19)]
ans = 0
for _ in range(n):
  x = int(float(input()) * 10**9+0.1)
  y2 = -9
  y5 = -9
  while x % 2 == 0:
    x //= 2
    y2 += 1
  while x % 5 == 0:
    x //= 5
    y5 += 1
  y2 = min(18,y2+9)
  y5 = min(18,y5+9)
  r[y2][y5] += 1
  #print(y2,y5)
  if y2 >= 9 and y5 >= 9:
    #print('%')
    ans -= 1
for i2 in range(19):
  for i5 in range(19):
    for j2 in range(19):
      for j5 in range(19):
        if i2 + j2 >= 18 and i5 + j5 >= 18:
          ans += r[i2][i5] * r[j2][j5]
          #if r[i2][i5] * r[j2][j5]:
            #print(i2,i5,j2,j5,r[i2][i5] * r[j2][j5])
#for x in r:
  #print(x,sum(x))
print(ans//2)

Submission status: Accepted

Solution code:
N = int(input())
A = {}
# 2, 5 , sum has to be >= 18 for both
for _ in range(N):
  a = round(float(input())*10**9)
  #print(a)
  pow2 = 0
  pow5 = 0
  while a % 2 == 0 and pow2 < 18:
    pow2 += 1
    a //= 2
  while a % 5 ==0 and pow5 < 18:
    pow5 += 1
    a //= 5
  if (pow2, pow5) not in A:
    A[(pow2, pow5)] = 0
  A[(pow2, pow5)] += 1
  #print(a, pow2, pow5)
#print(A)
ans = 0
for p1, c1 in A.items():
  for p2, c2 in A.items():
    if p1[0] + p2[0] < 18 or p1[1] + p2[1] < 18:
      continue
    if p1 == p2:
      ans += c1 * (c1 - 1)
    else:
      ans += c1 * c2
print(ans // 2)

Submission status: Accepted

Solution code:
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], ), cache=True)
def main(A):
    counts = np.zeros((19, 19), np.int64)
    for x in A:
        e = 0
        while x % 2 == 0:
            x, e = x // 2, e + 1
        f = 0
        while x % 5 == 0:
            x, f = x // 5, f + 1
        e = min(e, 18)
        f = min(f, 18)
        counts[e, f] += 1
    # 任意の順序対
    x = 0
    for a in range(361):
        for b in range(361):
            i, j = divmod(a, 19)
            k, l = divmod(b, 19)
            if i + k >= 18 and j + l >= 18:
                x += counts[i, j] * counts[k, l]
    # 自分どうし
    for a in range(361):
        i, j = divmod(a, 19)
        if i + i >= 18 and j + j >= 18:
            x -= counts[i, j]
    return x // 2

N = int(readline())
A = np.array(read().split(), np.float64)

A = np.rint(10**9 * A).astype(np.int64)

print(main(A))

Submission status: Runtime Error

Solution code:
N=int(input())

log=[[0 for i in range(19)] for j in range(19)]

#0が多い　13/5が普通  27/11が少ない
ans=0
for _ in range(N):
    A=float(input())*10**9
    
    t_count=0
    f_count=0
    temp=A
    while temp%2==0:
        temp/=2
        t_count+=1
    temp=A
    while temp%5==0:
        temp/=5
        f_count+=1
    
    for i in range(19):
        for j in range(19):
            if (A*2**i*5**j)%10**18==0:
                ans+=log[i][j]
    
    log[t_count][f_count]+=1
    
print(ans)

Submission status: Runtime Error

Solution code:
import numbers
n=int(input())
l=[]
for i in range(0,n):
    x=eval(input())
      l.append(x)
c=0
for i in range(0,n):
    for j in range(i+1,n):
        x=l[i]*l[j]
        if isinstance(x,numbers.Integral):
            c=c+1
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
l=[]
for i in range(0,n):
    x=eval(input())
      l.append(x)
c=0
for i in range(0,n):
    for j in range(i+1,n):
        x=l[i]*l[j]
        if isinstance(x,int):
            c=c+1
            print(x)
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
for i in range(0,n):
  x=eval(input())
  l.append(x)
c=0
for i in range(0,n):
  for j in range(i+1,n):
    x=l[i]*l[j]
    if isinstance(x,int):
      c=c+1
      print(x)
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
for i in range(0,n):
  x=eval(input())
  l.append(x)
c=0
for i in range(0,n):
  for j in range(i+1,n):
    x=l[i]*l[j]
    if isinstance(x,int):
      c=c+1
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
l=[]
for i in range(0,n):
  x=eval(input())
  l.append(x)
c=0
for i in range(0,n):
  for j in fange(i+1,n):
    f=l[i]*l[j]
    if f==int(f):
      c=c+1
print(c)

Submission status: Runtime Error

Solution code:
def prog(x):
    n = len(x)
    y = [int(i * 10**9) for i in x]
    #y

    def count25(s): # count25(0)
        if s.find('.') == -1:
            s += '.'
        s = s.rstrip('0')
        decimal_point = s.find('.')
        int_part = s[:decimal_point]
        float_part = s[decimal_point+1:]
        float_part += '0' * (9 - len(float_part))
        n = int(int_part + float_part)
        if n == 0:
            return (0, 0)
        two = five = 0
        while n % 2 == 0:
            two += 1
            n //= 2
        while n % 5 == 0:
            five += 1
            n //= 5
        return (two, five)

    two = [0] * n
    five = [0] * n
    for i in range(n):
        two[i], five[i] = count25(y[i])
    count = 0
    for i in range(n - 1):
        two_i = 18 - two[i]
        five_i = 18 - five[i]
        for j in range(i + 1, n):
            #if min(two[i] + two[j], five[i] + five[j]) >= 18:
            if two[j] >= two_i and five[j] >= five_i:
                #print(min(two1,two2) + min(five1, five2), two1, two2, five1, five2)
                #print(y[i] * y[j], (y[i] * y[j]) / 10**18)
                #print(y[i] / 10**9, y[j] / 10**9)
                #print('=================')
                count += 1
    print(count)

n = int(input())
x = [0] * n
x = [input() for i in range(n)]
prog(x)

Submission status: Runtime Error

Solution code:
def prog(x):
    n = len(x)
    y = [int(i * 10**9) for i in x]
    #y

    def count25(n):
        two = five = 0
        while n % 2 == 0:
            two += 1
            n //= 2
        while n % 5 == 0:
            five += 1
            n //= 5
        return two, five

    two = [0] * n
    five = [0] * n
    for i in range(n):
        two[i], five[i] = count25(y[i])
    count = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            #if min(two[i] + two[j], five[i] + five[j]) >= 18:
            if two[i] + two[j] >= 18 and five[i] + five[j] >= 18:
                #print(min(two1,two2) + min(five1, five2), two1, two2, five1, five2)
                #print(y[i] * y[j], (y[i] * y[j]) / 10**18)
                #print(y[i] / 10**9, y[j] / 10**9)
                #print('=================')
                count += 1
    print(count)

n = int(input())
x = list(map(int, input().split()))
prog(x)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import copy

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N = int(input())
    M = 41
    offset = M//2
    cnt = [[0]*M for _ in range(M)]
    p = [None for _ in range(N)]
    for i in range(N):
        A = input()
        n = len(A)
        tmp = [0,0]# 2と5の数を調べる。-は不足
        if '.' in A:
            tmp[0] -= n-1-A.index('.')
            tmp[1] -= n-1-A.index('.')
        A = int(A.replace('.',''))
        while A % 2 == 0:
            A //= 2
            tmp[0] += 1
        while A%5 == 0:
            A //= 5
            tmp[1] += 1
        cnt[offset+tmp[0]][offset+tmp[1]] += 1
        p[i] = (tmp[0]+offset, tmp[1]+offset)
    # print(cnt)
    cnt2 = copy.deepcopy(cnt)

    # 累積和をとる
    for i in range(M-1,-1,-1):
        for j in range(M-1,-1,-1):
            if j < M-1:
                cnt[i][j] += cnt[i][j+1]
    
    for i in range(M-1,-1,-1):
        for j in range(M-1,-1,-1):
            if i < M-1:
                cnt[i][j] += cnt[i+1][j]
    
    # print(cnt)
    ans = 0
    for i in range(M):
        for j in range(M):
            if cnt2[i][j]==0: continue
            ans += cnt2[i][j]*cnt[offset*2-i][offset*2-j]
            # print(p[i])
            # print(cnt[offset*2-p[i][0]][offset*2-p[i][1]])
            # ans += cnt[offset*2-p[i][0]][offset*2-p[i][1]]
            # print(i,j,cnt2[i][j],ans)
    print((ans-cnt[offset][offset])//2)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import copy

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N = int(input())
    M = 21
    offset = M//2
    cnt = [[0]*M for _ in range(M)]
    p = [None for _ in range(N)]
    for i in range(N):
        A = input()
        n = len(A)
        tmp = [0,0]# 2と5の数を調べる。-は不足
        if '.' in A:
            tmp[0] -= n-1-A.index('.')
            tmp[1] -= n-1-A.index('.')
        A = int(A.replace('.',''))
        while A % 2 == 0:
            A //= 2
            tmp[0] += 1
        while A%5 == 0:
            A //= 5
            tmp[1] += 1
        cnt[offset+tmp[0]][offset+tmp[1]] += 1
        p[i] = (tmp[0]+offset, tmp[1]+offset)
    # print(cnt)
    cnt2 = copy.deepcopy(cnt)

    # 累積和をとる
    for i in range(M-1,-1,-1):
        for j in range(M-1,-1,-1):
            if j < M-1:
                cnt[i][j] += cnt[i][j+1]
    
    for i in range(M-1,-1,-1):
        for j in range(M-1,-1,-1):
            if i < M-1:
                cnt[i][j] += cnt[i+1][j]
    
    # print(cnt)
    ans = 0
    for i in range(M):
        for j in range(M):
            if cnt2[i][j]==0: continue
            ans += cnt2[i][j]*cnt[offset*2-i][offset*2-j]
            # print(p[i])
            # print(cnt[offset*2-p[i][0]][offset*2-p[i][1]])
            # ans += cnt[offset*2-p[i][0]][offset*2-p[i][1]]
            # print(i,j,cnt2[i][j],ans)
    print((ans-cnt[offset][offset])//2)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


def div_cnt(n, d):
    res = 0
    while n % d == 0:
        res += 1
        n //= d
    return res


N = int(input())
A = list(int(float(input()) * 1_000_000_000) for _ in range(N))
divs = [(div_cnt(a, 2), div_cnt(a, 5)) for a in A]

table = [[0] * 19 for _ in range(19)]
for t, f in divs:
    table[t][f] += 1

ans = 0
for t, f in divs:
    for i in range(19):
        for j in range(19):
            if t + i >= 18 and f + j >= 18:
                ans += table[i][j]
                if t == i and f == j:
                    ans -= 1

print(ans // 2)

Submission status: Runtime Error

Solution code:
inputs = int(input())
nums = [float(input()) for _ in inputs]

count = 0
for i, num in enumerate(nums):
  j = i + 1
  while j < len(nums):
    if num * nums[j] == int(num * nums[j]):
      count += 1
return count

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 2 ** 31 - 1
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    cnt = collections.Counter()
    ans = 0
    C = []
    for _ in range(N):
        s = SI()
        a = []
        bit = 0
        for x in s:
            x = ord(x) - ord('a')
            bit |= 1 << x
            a.append(bit)
        for i in range(len(s),-1,-1):
            if i == len(s):
                c = 0
            else:
                c = (c * 27 + ord(s[i]) - ord('a') + 1) % MOD
            if i > 0:
                d = c * 27
                for j in range(26):
                    if a[i-1] & (1<<j) and i < 0:
                        cnt[(d+j+1)%MOD] += 1
        C.append(c)
    for c in C:
        ans += cnt[c] - 1

    print(ans)
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 2 ** 31 - 1
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    cnt = collections.Counter()
    ans = 0
    C = []
    for _ in range(N):
        s = SI()
        a = []
        bit = 0
        for x in s:
            x = ord(x) - ord('a')
            bit |= 1 << x
            a.append(bit)
        for i in range(len(s),-1,-1):
            if i == len(s):
                c = 0
            else:
                c = (c * 27 + ord(s[i]) - ord('a') + 1) % MOD
            if i > 0:
                d = c * 27
                for j in range(26):
                    if a[i-1] & (1<<j) & i < 0:
                        cnt[(d+j+1)%MOD] += 1
        C.append(c)
    for c in C:
        ans += cnt[c] - 1

    print(ans)
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
i = input()
nums = []
for rep in range(int(i)):
  nums.append(float(input()))

count = 0
for i in range(len(nums)-1):
  for j in range(i, len(nums)):
    product = nums[i] * num[j]
    if int(product) == product:
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
import sys
import math
import collections
import bisect
import itertools
import decimal

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===
def prime_factorize(n):
    two = 0
    five = 0
    while n % 2 == 0:
        two += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f == 5:
                five += 1
            n //= f
        else:
            f += 2
    if n != 1:
        if n == 2:
            two += 1
        if n == 5:
            five += 1
    return two, five


def main():
    n = ni()
    a = [int(decimal.Decimal(sys.stdin.readlin()) * (10 ** 9)) for _ in range(n)]
    res = {}
    border = 18

    twoflg = False
    fiveflg = False
    for ai in a:
        two, five = prime_factorize(ai)

        if two >= 9:
            twoflg = True
        if five >= 9:
            fiveflg = True

        if (two, five) not in res.keys():
            res[(two, five)] = 1
        else:
            res[(two, five)] += 1

    ans = 0
    if twoflg and fiveflg:
        for k, v in res.items():
            two, five = k
            for tk, tv in res.items():
                t_two, t_five = tk
                if two + t_two >= border and five + t_five >= border:
                    if two == t_two and five == t_five:
                        ans += v * (tv - 1)
                    else:
                        ans += v * tv

    print(ans // 2)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
import math
import collections
import bisect
import itertools
import decimal

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===
def prime_factorize(n):
    two = 0
    five = 0
    while n % 2 == 0:
        two += 1
        n //= 2

    while n % 5 == 0:
        five += 1
        n //= 5

    return two, five


def main():
    n = ni()
    a = [int(decimal.Decimal(sys.stdin.readline().restrip()) * (10 ** 9)) for _ in range(n)]
    res = {}
    border = 18

    twoflg = False
    fiveflg = False
    for ai in a:
        two, five = prime_factorize(ai)

        if two >= 9:
            twoflg = True
        if five >= 9:
            fiveflg = True

        if (two, five) not in res.keys():
            res[(two, five)] = 1
        else:
            res[(two, five)] += 1

    ans = 0
    if twoflg and fiveflg:
        for k, v in res.items():
            two, five = k
            for tk, tv in res.items():
                t_two, t_five = tk
                if two + t_two >= border and five + t_five >= border:
                    if two == t_two and five == t_five:
                        ans += v * (tv - 1)
                    else:
                        ans += v * tv

    print(ans // 2)


if __name__ == '__main__':
    main()