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:
import copy
import math
import time
import statistics
import math
from decimal import Decimal
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_DOWN

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''



def main():
    start = time.time()

    n = get_int()
    #youso2 = []
    #youso5 = []
    youso = []
    aite = [[0] * 20 for i in range(20)]

    ans = 0
    for i in range(0,n):
        s = input()
        wk = Decimal(s)
        wk = wk - wk.quantize(Decimal('0'), rounding=ROUND_DOWN)
        seisu = Decimal.is_zero(wk)

        if seisu:
            if '.' in s:
                s_i, s_d = s.split('.')
                s = s_i

            count2 = 0
            wk = int(s)
            for ii in range(0, 19):
                if wk % 2 == 0:
                    count2 += 1
                    wk = wk // 2
                else:
                    break

            count5 = 0
            wk = int(s)
            for ii in range(0, 19):
                if wk % 5 == 0:
                    count5 += 1
                    wk = wk // 5
                else:
                    break

            #youso.append([count2, count5])

        else:
            s_i, s_d = s.split('.')

            while s_d[-1] == '0':
                s_d = s_d[:-1]

            count2 = 0
            wk = int(s_i + s_d)
            for ii in range(0, 19):
                if (wk * 2) % 10 == 0:
                    wk = wk * 2 / 10
                    count2 += 1
                else:
                    break

            count5 = 0
            wk = int(s_i + s_d)
            for ii in range(0,19):
                if (wk * 5) % 10 == 0:
                    wk = wk * 5 / 10
                    count5 += 1
                else:
                    break

            count2_wk = -len(s_d) + count5
            count5 = min(9, -len(s_d) + count2)
            count2 = min(9, count2_wk)
            #youso.append([-len(s_d) + count5, -len(s_d) + count2])

        youso.append([count2, count5])
        aite[10 - count2][10 - count5] += 1
        #for ii in range (10 - count2, 20):
        #    for iii in range(10 - count5, 20):
        #        aite[ii][iii] += 1


    #print(time.time() - start)

    aite2 = [[0] * 20 for i in range(20)]
    for i in range (0,20):
        for ii in range (0, 20):
            for iii in range(i, 20):
                for iiii in range(ii, 20):
                    aite2[iii][iiii] += aite[i][ii]

    #print(time.time() - start)
    #print(youso)

    #for i in range(len(aite2)):
    #    print(i, aite2[i])

    ans = 0
    for i in range(0,n):
        y1 = youso[i]
        if y1[0] >= 0 and y1[1] >= 0:
            ans += aite2[10 + y1[0]][10 + y1[1]] -1
        else:
            ans += aite2[10 + y1[0]][10 + y1[1]]

    ans = ans // 2

    print(ans)
    #print(time.time() - start)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np


def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())
arr = np.array([float(input()) for _ in range(n)], np.float64)
arr = np.rint(arr * 10**9).astype(np.int64)

f = np.vectorize(div)
arr2 = (f(arr, 2) + np.zeros([arr.shape[0],
                              arr.shape[0]], np.int64)).astype(np.int32)
arr5 = (f(arr, 5) + np.zeros([arr.shape[0],
                              arr.shape[0]], np.int64)).astype(np.int32)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
import numpy as np


def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())
arr = np.array([float(input()) for _ in range(n)], np.float64)
arr = np.rint(arr * 10**9).astype(np.int64)

f = np.vectorize(div)
arr2 = (f(arr, 2) + np.zeros([arr.shape[0],　arr.shape[0]], np.int64)).astype(np.int32)
arr5 = (f(arr, 5) + np.zeros([arr.shape[0],　arr.shape[0]], np.int64)).astype(np.int32)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
import numpy as np
from functools import lru_cache


@lru_cache(maxsize=None)
def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())
arr = np.array([float(input()) for _ in range(n)], np.float64)
arr = np.rint(arr * 10**9).astype(np.int64)

f = np.vectorize(div)
arr2 = (f(arr, 2) + np.zeros([arr.shape[0],　arr.shape[0]], np.int64)).astype(np.int32)
arr5 = (f(arr, 5) + np.zeros([arr.shape[0],　arr.shape[0]], np.int64)).astype(np.int32)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
import numpy as np
from functools import lru_cache


@lru_cache(maxsize=None)
def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())

arr2 = []
arr5 = []
for _ in range(n):
    x = round(float(input()) * 10**9)
    arr2.append(div(x, 2))
    arr5.append(div(x, 5))

arr2 = np.array(arr2)
arr5 = np.array(arr5)
shape = arr2.shape[0]

arr2 = (arr2 + np.zeros([shape, shape], np.int64)).astype(np.int32)
arr5 = (arr5 + np.zeros([shape, shape], np.int64)).astype(np.int32)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
import numpy as np


def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())

arr2 = []
arr5 = []
for _ in range(n):
    x = round(float(input()) * 10**9)
    arr2.append(div(x, 2))
    arr5.append(div(x, 5))

arr2 = np.array(arr2)
arr5 = np.array(arr5)
shape = arr2.shape[0]

arr2 = (arr2 + np.zeros([shape, shape], np.int64)).astype(np.int32)
arr5 = (arr5 + np.zeros([shape, shape], np.int64)).astype(np.int32)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
import numpy as np


def div(n, d):
    if d == 2:
        return format(n, "b")[::-1].find("1")
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


n = int(input())

arr2 = []
arr5 = []
for _ in range(n):
    x = round(float(input()) * 10**9)
    arr2.append(div(x, 2))
    arr5.append(div(x, 5))

arr2 = np.array(arr2)
arr5 = np.array(arr5)
shape = arr2.shape[0]

arr2 = (arr2 + np.zeros([shape, shape], np.int64)).astype(np.int32)
arr5 = (arr5 + np.zeros([shape, shape], np.int64)).astype(np.int32)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
import numpy as np


def div(n, d):
    if d == 2:
        return format(n, "b")[::-1].find("1")
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


n = int(input())

arr2 = []
arr5 = []
for _ in range(n):
    x = round(float(input()) * 10**9)
    arr2.append(div(x, 2))
    arr5.append(div(x, 5))

shape = arr2.shape[0]

arr2 = (np.array(arr2) + np.zeros([shape, shape], np.int64)).astype(np.int32)
arr5 = (np.array(arr5) + np.zeros([shape, shape], np.int64)).astype(np.int32)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
import numpy as np


def div(n, d):
    if d == 2:
        return format(n, "b")[::-1].find("1")
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


n = int(input())

arr2 = []
arr5 = []
for _ in range(n):
    x = round(float(input()) * 10**9)
    arr2.append(div(x, 2))
    arr5.append(div(x, 5))

arr2 = (np.array(arr2) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)).astype(np.int32)
arr5 = (np.array(arr5) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)).astype(np.int32)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
import numpy as np


def div(n, d):
    if d == 2:
        return format(n, "b")[::-1].find("1")
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


n = int(input())
arr = np.array([float(input()) for _ in range(n)], np.float64)
arr = np.rint(arr * 10**9).astype(np.int64)

f = np.vectorize(div)
arr2 = (f(arr, 2) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)).astype(np.int32)
arr5 = (f(arr, 5) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)).astype(np.int32)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
import numpy as np


def div(n, d):
    if d == 2:
        return format(n, "b")[::-1].find("1")
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


n = int(input())
arr = np.array([float(input()) for _ in range(n)], np.float64)
arr = np.rint(arr * 10**9).astype(np.int64)

f = np.vectorize(div)
arr2 = f(arr, 2) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)
arr5 = f(arr, 5) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

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


@njit(i8(i8, i4), cache=True)
def div(n, d):
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


n = int(input())
arr = np.array([float(input()) for _ in range(n)], np.float64)
arr = np.rint(arr * 10**9).astype(np.int64)

f = np.vectorize(div)
arr2 = f(arr, 2) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)
arr5 = f(arr, 5) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

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


@njit(i8(i8, i4), cache=True)
def div(n, d):
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


n = int(input())
arr = np.array([float(input()) for _ in range(n)], np.float64)
arr = np.rint(arr * 10**9).astype(np.int64)

f = np.vectorize(div)
arr2 = f(arr, 2) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)
arr5 = f(arr, 5) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)

arr2 = np.tril(arr2 + arr2.T) - np.triu(arr2 + arr2.T)
arr5 = np.tril(arr5 + arr5.T) - np.triu(arr5 + arr5.T)

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

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


@njit(i8(i8, i4), cache=True)
def div(n, d):
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


@njit(i8(i8[:, :], i8), cache=True)
def solve(arr, length):
    ans = 0
    for i in range(length):
        for j in range(i + 1, length):
            a, b, c, d = arr[0][i], arr[1][i], arr[0][j], arr[1][j]
            if a + c >= 18 and b + d >= 18:
                ans += 1
    return ans


n = int(input())
arr = np.array([float(input()) for _ in range(n)], np.float64)
arr = np.rint(arr * 10**9).astype(np.int64)

f = np.vectorize(div)
arr2 = f(arr, 2) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)
arr5 = f(arr, 5) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)

arr2 = np.tril(arr2 + arr2.T) - np.triu(arr2 + arr2.T)
arr5 = np.tril(arr5 + arr5.T) - np.triu(arr5 + arr5.T)

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

Submission status: Runtime Error

Solution code:
debug=False
import random
from collections import Counter
from collections import defaultdict

def fact(n):
    k5 = 0
    while n%5==0:
        n//=5
        k5+=1
    k2=0
    while n%2==0:
        n//=2
        k2+=1
    return (k2, k5)

n=5*10**3 if debug else int(input())
a=[]
aa=[]
inp = [] if not debug else [str(random.random()*10**4) for _ in range(n)]
if not debug:
    for _ in range(n):
        inp.append(input())
    
for i in range(n):
    n=inp[i]
    aa.append(n)
    if "." in n:
        p,q=n.split(".")
        a.append((int(p+q),len(q)))
    else:
        p=int(n)
        q=0
        a.append((p,0))
    
G=[]
for idx,v in enumerate(a):
    r2, r5 = fact(v[0])
    #print(r2,r5,v[1])
    G.append((r2-v[1], r5-v[1]))

H=Counter(G)

L = [(i,j) for i in range(-10,10) for j in range(-10,10)]

c=0
#print(H)
for l,m in combinations(L,2):
    if l[0]+m[0]>=0 and l[1]+m[1]>=0:
        k = H[l]*H[m]
        if k>0:
            #print(l,m,k)
            c+=k
            
for l in L:
    k = H[l]*(H[l]-1)//2
    if l[0]+l[1]>=0 and m[0]+m[1]>=0 and k>0:
        #print(l,l,k)
        c+=k
print(c)

Submission status: Runtime Error

Solution code:
import sys

def a():
    nums=[]
    count=0
    for l in sys.stdin:
        nums.append(int(l))
#    for i in range(0,200001):
#        s=input()
        if s != "":
            nums.append(s)
        else:
            break
    del nums[0]
#
    for i in range(len(nums)):
        nums[i]=float(nums[i])
    print(nums)
#
    for i in range(0,len(nums)-1):
        for t in range(i+1,len(nums)):
            r=nums[i]*nums[t]
            if nums[i]*nums[t]==int(nums[i]*nums[t]):
                print(i)
                print(t)
                print(nums[i]*nums[t])
                count+=1
    return count

a()

Submission status: Runtime Error

Solution code:
import copy
import math
import time
import statistics
import math
from decimal import Decimal
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_DOWN

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''



def main():
    start = time.time()

    n = get_int()
    #youso2 = []
    #youso5 = []
    youso = []
    aite = [[0] * 20 for i in range(20)]

    ans = 0
    for i in range(0,n):
        s = input()
        wk = Decimal(s)
        wk = wk - wk.quantize(Decimal('0'), rounding=ROUND_DOWN)
        seisu = Decimal.is_zero(wk)

        if seisu:
            if '.' in s:
                s_i, s_d = s.split('.')
                s = s_i

            count2 = 0
            wk = int(s)
            for ii in range(0, 10):
                if wk % 2 == 0:
                    count2 += 1
                    wk = wk // 2
                else:
                    break

            count5 = 0
            wk = int(s)
            for ii in range(0, 6):
                if wk % 5 == 0:
                    count5 += 1
                    wk = wk // 5
                else:
                    break

            #youso.append([count2, count5])

        else:
            s_i, s_d = s.split('.')

            count2 = 0
            wk = int(s_i + s_d)
            for ii in range(0, 10):
                if (wk * 2) % 10 == 0:
                    wk = wk * 2 / 10
                    count2 += 1
                else:
                    break

            count5 = 0
            wk = int(s_d)
            for ii in range(0,10):
                if (wk * 5) % 10 == 0:
                    wk = wk * 5 / 10
                    count5 += 1
                else:
                    break

            count2_wk = -len(s_d) + count5
            count5 = -len(s_d) + count2
            count2 = count2_wk
            #youso.append([-len(s_d) + count5, -len(s_d) + count2])

        youso.append([count2, count5])
        aite[10 - count2][10 - count5] += 1
        #for ii in range (10 - count2, 20):
        #    for iii in range(10 - count5, 20):
        #        aite[ii][iii] += 1


    #print(time.time() - start)

    aite2 = [[0] * 20 for i in range(20)]
    for i in range (0,20):
        for ii in range (0, 20):
            for iii in range(i, 20):
                for iiii in range(ii, 20):
                    aite2[iii][iiii] += aite[i][ii]

    #print(time.time() - start)
    #print(youso)

    #for i in range(len(aite2)):
    #    print(i, aite2[i])

    ans = 0
    for i in range(0,n):
        y1 = youso[i]
        if y1[0] >= 0 and y1[1] >= 0:
            ans += aite2[10 + y1[0]][10 + y1[1]] -1
        else:
            ans += aite2[10 + y1[0]][10 + y1[1]]

    ans = ans // 2

    print(ans)
    #print(time.time() - start)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
M = 10
L = 2*M
A = [[0 for _ in range(L+1)] for _ in range(L+1)]

for _ in range(N):
  y = float(input())
  x = y
  x *= 10.**M
  x = int(x)
  k_2 = 0
  while x % 2 == 0 and k_2 <= 2*M:
    x = x // 2
    k_2 += 1
  k_5 = 0 
  while x % 5 == 0 and k_5 <= 2*M:
    x = x // 5
    k_5 += 1
  A[k_2][k_5] += 1

ans = 0
for k_2 in range(L+1):
  for k_5 in range(L+1):
    for l_2 in range(k_2, L+1):
      for l_5 in range(L+1):
        if k_2+l_2 >= 2*M and k_5+l_5 >= 2*M:
          if k_2 == l_2 and k_5 == l_5:
            ans += A[k_2][k_5]*(A[k_2][k_5]-1)//2
            
          elif l_2 > k_2 or (k_2 == l_2 and k_5 < l_5):
            ans += A[k_2][k_5]*A[l_2][l_5]
          
#print(A)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
M = 9
L = 2*M
A = [[0 for _ in range(L+1)] for _ in range(L+1)]

for _ in range(N):
  y = float(input())
  x = y
  x *= 10.**M
  x = int(x)
  k_2 = 0
  while x % 2 == 0 and k_2 <= 2*M:
    x = x // 2
    k_2 += 1
  k_5 = 0 
  while x % 5 == 0 and k_5 <= 2*M:
    x = x // 5
    k_5 += 1
  A[k_2][k_5] += 1

ans = 0
for k_2 in range(L+1):
  for k_5 in range(L+1):
    for l_2 in range(k_2, L+1):
      for l_5 in range(L+1):
        if k_2+l_2 >= 2*M and k_5+l_5 >= 2*M:
          if k_2 == l_2 and k_5 == l_5:
            ans += A[k_2][k_5]*(A[k_2][k_5]-1)//2
            
          elif l_2 > k_2 or (k_2 == l_2 and k_5 < l_5):
            ans += A[k_2][k_5]*A[l_2][l_5]
          
#print(A)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
M = 9
L = 2*M
A = [[0 for _ in range(L+1)] for _ in range(L+1)]

for _ in range(N):
  y = float(input())
  x = y
  x *= 10.**M
  x = int(x+0.01)
  k_2 = 0
  while x % 2 == 0 and k_2 <= 2*M:
    x = x // 2
    k_2 += 1
  k_5 = 0 
  while x % 5 == 0 and k_5 <= 2*M:
    x = x // 5
    k_5 += 1
  A[k_2][k_5] += 1

ans = 0
for k_2 in range(L+1):
  for k_5 in range(L+1):
    for l_2 in range(k_2, L+1):
      for l_5 in range(L+1):
        if k_2+l_2 >= 2*M and k_5+l_5 >= 2*M:
          if k_2 == l_2 and k_5 == l_5:
            ans += A[k_2][k_5]*(A[k_2][k_5]-1)//2
            
          elif l_2 > k_2 or (k_2 == l_2 and k_5 < l_5):
            ans += A[k_2][k_5]*A[l_2][l_5]
          
#print(A)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
from decimal import Decimal
input = sys.stdin.readline


def divide(n):
    c1, c2 = 0, 0
    while (n%2 == 0):
        c1 += 1
        n //= 2
    while (n%5 == 0):
        c2 += 1
        n //= 5
    c1, c2 = min(18, c1), min(18, c2)
    return (c1, c2)
    

def main():
    n = int(input())
    a = [divide(int(Decimal(float(input()))*1e9)) for _ in range(n)]

    dp = [[0]*20 for _ in range(20)]
    for i in range(n):
        c1, c2 = a[i]
        dp[c1][c2] += 1
    
    for i in range(18, -1, -1):
        for j in range(18, -1, -1):
            dp[i][j] += dp[i+1][j]+dp[i][j+1]-dp[i+1][j+1]

    ans = 0
    for i in range(n):
        c1, c2 = a[i]
        if (c1 >= 9 and c2 >= 9):
            ans -= 1
        ans += dp[18-c1][18-c2]
        
    print(ans//2)
    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import copy
import math
import time
import statistics
import math
from decimal import Decimal
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_DOWN

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''



def main():
    start = time.time()

    n = get_int()
    #youso2 = []
    #youso5 = []
    youso = []
    aite = [[0] * 20 for i in range(20)]

    ans = 0
    for i in range(0,n):
        s = input()
        wk = Decimal(s)
        wk = wk - wk.quantize(Decimal('0'), rounding=ROUND_DOWN)
        seisu = Decimal.is_zero(wk)

        if seisu:
            if '.' in s:
                s_i, s_d = s.split('.')
                s = s_i

            count2 = 0
            wk = int(s)
            for ii in range(0, 15):
                if wk % 2 == 0:
                    count2 += 1
                    wk = wk // 2
                else:
                    break

            count5 = 0
            wk = int(s)
            for ii in range(0, 6):
                if wk % 5 == 0:
                    count5 += 1
                    wk = wk // 5
                else:
                    break

            #youso.append([count2, count5])

        else:
            s_i, s_d = s.split('.')

            count2 = 0
            wk = int(s_i + s_d)
            for ii in range(0, 50):
                if (wk * 2) % 10 == 0:
                    wk = wk * 2 / 10
                    count2 += 1
                else:
                    break

            count5 = 0
            wk = int(s_d)
            for ii in range(0,50):
                if (wk * 5) % 10 == 0:
                    wk = wk * 5 / 10
                    count5 += 1
                else:
                    break

            count2_wk = -len(s_d) + count5
            count5 = -len(s_d) + count2
            count2 = count2_wk
            #youso.append([-len(s_d) + count5, -len(s_d) + count2])

        youso.append([count2, count5])
        aite[10 - count2][10 - count5] += 1
        #for ii in range (10 - count2, 20):
        #    for iii in range(10 - count5, 20):
        #        aite[ii][iii] += 1


    #print(time.time() - start)

    aite2 = [[0] * 20 for i in range(20)]
    for i in range (0,20):
        for ii in range (0, 20):
            for iii in range(i, 20):
                for iiii in range(ii, 20):
                    aite2[iii][iiii] += aite[i][ii]

    #print(time.time() - start)
    #print(youso)

    #for i in range(len(aite2)):
    #    print(i, aite2[i])

    ans = 0
    for i in range(0,n):
        y1 = youso[i]
        if y1[0] >= 0 and y1[1] >= 0:
            ans += aite2[10 + y1[0]][10 + y1[1]] -1
        else:
            ans += aite2[10 + y1[0]][10 + y1[1]]

    ans = ans // 2

    print(ans)
    #print(time.time() - start)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from decimal import Decimal
import math
n=int(input())
A=[]
for i in range(n):
    a=float(input())
    if (a*10**5-math.floor(a)*10**5)<0:
        A.append(a)
    else:
        continue
multiple=[]
for i in range(1,n):
    for j in range(n-i):
        ans=Decimal(A[i-1])*Decimal(A[i+j])
        if float(ans).is_integer():
            multiple.append(ans)
print(len(multiple))

Submission status: Runtime Error

Solution code:
N = int(input())
A = [0]*N
B = [[0]*19 for x in range(19)]
C = [0]*N
D = [0]*N
a,b,c,d,e,ans = 0,['0']*9,0,0,0,0
for i in range(N):
    c = (input()+'.0').split('.')
    b = ['0']*9
    for k,v in enumerate(c[1]):
        b[k] = v
    A[i] = int(c[0]+''.join(b))

# print(*A)

for i in range(N):
    d,e = 0,0
    while (A[i] % 2 == 0) and (d <= 18):
        A[i] //= 2
        d += 1
    while (A[i] % 5 == 0) and (e <= 18):
        A[i] //= 5
        e += 1
    C[i] = d
    D[i] = e
    B[d][e] += 1

for i in range(N):
    c = C[i]
    d = D[i]
    B[c][d] -= 1
    for j in range(18-c,19):
        for k in range(18-d,19):
            ans += B[j][k]

print(ans)

Submission status: Runtime Error

Solution code:
from decimal import Decimal

n = int(input())
A = [float(input()) for _ in range(n)]

cnt = 0
for i in range(1, n):
    for j in range(n - i):
        ans = A[i - 1] * A[i + j]
        if ans == ans.to_integral_value():
            cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
from decimal import Decimal

n = int(11)
A = list(map(Decimal, inputs.split()))

cnt = 0
for i in range(1, n):
    for j in range(n - i):
        ans = A[i - 1] * A[i + j]
        if ans == ans.to_integral_value():
            cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
from decimal import Decimal as D
# A=[]
excel=[[0]*20 for i in range(50)]
query=[]
for i in range(n):
    q=input()
    q=D(q)
    q=int(q*10**9)
    num2=0 ;num5=0
    k=q
    for i in range(50):
        if k%2==0:
            k//=2
            num2+=1
        else:break
    k=q
    for i in range(20):
        if k%5==0:
            k//=5
            num5+=1
        else:break
    excel[num2][num5]+=1
    query.append([max(0,18-num2),max(0,18-num5)])

A=[[0] * 20 for i in range(50)] #累積和
for i in range(49,-1,-1):
    for j in range(19,-1,-1):
        if i==49 and j==19:
            A[i][j]=excel[i][j]
        elif i==49:
            A[i][j]=A[i][j+1]+excel[i][j]
        elif j==19:
            A[i][j]=A[i+1][j] + excel[i][j]
        else:
            A[i][j]=excel[i][j]+ A[i+1][j]+A[i][j+1]-A[i+1][j+1]

ans=0
for l in query:
    num2,num5=l
    if num2<=9 and num5<=9:
        ans+=A[num2][num5]-1
    else:a
        ans+=A[num2][num5]

#for i in range(50):
 #   print(excel[:][i] , A[:][i])
print(ans//2)

Submission status: Runtime Error

Solution code:
import copy
import math
import time
import statistics
import math
from decimal import Decimal
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_DOWN

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''



def main():
    start = time.time()

    n = get_int()
    #youso2 = []
    #youso5 = []
    youso = []
    aite = [[0] * 20 for i in range(20)]

    ans = 0
    for i in range(0,n):
        s = input()
        wk = Decimal(s)
        wk = wk - wk.quantize(Decimal('0'), rounding=ROUND_DOWN)
        seisu = Decimal.is_zero(wk)

        if seisu:
            if '.' in s:
                s_i, s_d = s.split('.')
                s = s_i

            count2 = 0
            wk = int(s)
            for ii in range(0, 15):
                if wk % 2 == 0:
                    count2 += 1
                    wk = wk // 2
                else:
                    break

            count5 = 0
            wk = int(s)
            for ii in range(0, 6):
                if wk % 5 == 0:
                    count5 += 1
                    wk = wk // 5
                else:
                    break

            #youso.append([count2, count5])

        else:
            s_i, s_d = s.split('.')

            count2 = 0
            wk = int(s_i + s_d)
            for ii in range(0, 50):
                if (wk * 2) % 10 == 0:
                    wk = wk * 2 / 10
                    count2 += 1
                else:
                    break

            count5 = 0
            wk = int(s_d)
            for ii in range(0,50):
                if (wk * 5) % 10 == 0:
                    wk = wk * 5 / 10
                    count5 += 1
                else:
                    break

            count2_wk = -len(s_d) + count5
            count5 = -len(s_d) + count2
            count2 = count2_wk
            #youso.append([-len(s_d) + count5, -len(s_d) + count2])

        youso.append([count2, count5])
        for ii in range (10 - count2, 20):
            for iii in range(10 - count5, 20):
                aite[ii][iii] += 1


    #print(time.time() - start)
    #print(youso)

    #for i in range(len(aite)):
        #print(i, aite[i])

    ans = 0
    for i in range(0,n):
        y1 = youso[i]
        if y1[0] >= 0 and y1[1] >= 0:
            ans += aite[10 + y1[0]][10 + y1[1]] -1
        else:
            ans += aite[10 + y1[0]][10 + y1[1]]

    ans = ans /2

    print(ans)
    #print(time.time() - start)

if __name__ == '__main__':
    main()