Problem p02588 (python)

Fixed submission:
n = int(input())

lst = [[0 for _ in range(25)] for _ in range(25)]
int_cnt = 0
for _ in range(n):
    a = input()
    if "." in a:
        pos = a.index(".")
        a1, a2 = a[:pos], a[pos + 1:]
        l = len(a2)
        a = a1 + a2
        a = int(a)
        a *= 10 ** (9 - l)
    else:
        a = int(a)
        int_cnt += 1
        a *= 10 ** 9
    t = 0
    while a % 2 == 0:
        t += 1
        a //= 2
    f = 0
    while a % 5 == 0:
        f += 1
        a //= 5
    t = min(t, 24)
    f = min(f, 24)
    lst[t][f] += 1


 
ans = 0
for i in range(25):
    for j in range(25):
        for k in range(25):
            for l in range(25):
                if i + j >= 18 and k + l >= 18:
                    if i == j and k == l:
                        tmp = lst[i][k]
                        ans += tmp * (tmp - 1)
                    else:
                        ans += lst[i][k] * lst[j][l]
print(ans // 2)

Buggy submission (verdict: Runtime Error):
n = int(input())

int_cnt = 0
int_25 = [[0 for _ in range(10)] for _ in range(10)]
int_10 = [0 for _ in range(10)]
float_25 = [[0 for _ in range(11)] for _ in range(11)]
float_10 = [0 for _ in range(10)]
float22 = [0 for _ in range(10)]
float55 = [0 for _ in range(10)]

for _ in range(n):
    a = float(input())
    if a % 1 == 0:
        int_cnt += 1
        num = a
        cnt = 0
        while num % 10 == 0:
            cnt += 1
            num //= 10
        int_10[cnt] += 1
        num = a
        cnt2 = 0
        while num % 2 == 0:
            cnt2 += 1
            num //= 2
        num = a
        cnt5= 0
        while num % 5 == 0:
            cnt5 += 1
            num //= 5
        int_25[cnt2][cnt5] += 1
    else:
        a *= 10 ** 9
        a = int(a)
        num = a
        cnt = 9
        while num % 10 == 0:
            cnt -= 1
            num //= 10
        float_10[cnt] += 1
        num = a
        cnt = 9
        while num % 2 == 0:
            cnt -= 1
            num //= 2
        if cnt >= 0:
            cnt2 = cnt
        else:
            cnt2 = 0
            cnt = abs(cnt)
            cnt = min(cnt, 9)
            float22[cnt] += 1
        num = a
        cnt = 9
        while num % 5 == 0:
            cnt -= 1
            num //= 5
        if cnt >= 0:
            cnt5 = cnt
        else:
            cnt5 = 0
            cnt = abs(cnt)
            cnt = min(cnt, 9)
            float55[cnt] += 1
        float_25[cnt2][cnt5] += 1

ans = int_cnt * (int_cnt - 1) // 2

for i in range(10):
    for j in range(10):
        for k in range(i + 1):
            for l in range(j + 1):
                ans += int_25[i][j] * float_25[k][l]

for i in range(1, 10):
    for j in range(1, 10):
        ans += float22[i] * float55[j]


print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
alst = [float(input()) for _ in range(n)]

int_cnt = 0
lst = [[0 for _ in range(10)] for _ in range(10)]
lst2 = [[0 for _ in range(20)] for _ in range(30)]
for num in alst:
    if num % 1 == 0:
        int_cnt += 1
        b = 0
        f = 0
        while num % 2 == 0:
            b += 1
            num //= 2
        while num % 5 == 0:
            f += 1
            num //= 5
        b = min(9, b)
        lst[b][f] += 1
    else:
        num *= 10 ** 9
        b = 1
        f = 1
        while num % 2 == 0:
            f += 1
            num //= 2
        while num % 5 == 0:
            b += 1
            num //= 5
        lst2[b][f] += 1

ans = int_cnt * (int_cnt - 1) // 2

for i in range(10):
    for j in range(10):
        cnt = 0
        for k in range(max(10 - i, 0), 30):
            for l in range(10 - j, 20):
                cnt += lst2[k][l]
        ans += lst[i][j] * cnt

cnt = 0
for i in range(11, 20):
    for j in range(20):
        cnt += lst2[i][j]

cnt2 = 0
for i in range(11, 20):
    for j in range(30):
        cnt2 += lst2[j][i]

ans += cnt * cnt2
print(ans)