Problem p02588 (python)

Fixed submission:
import copy
n = int(input())
def point_shift(s,i):
    p = s.index(".")
    tale = len(s[p+1:])
    if tale <= i:
        return int(s[:p]+s[p+1:].ljust(i,"0"))
    else:
        return int(s[:p]+s[p+1:p+i+1])

a = []
for i in range(n):
    s = input()
    if "." not in s:
        a.append(int(s)*10**9)
    else:
        a.append(point_shift(s,9))

memo = [[0,0] for _ in range(n)]
for i in range(n):
    t = a[i]
    while t%2 == 0:
        t //= 2
        memo[i][0] += 1
    while t%5 == 0:
        t //= 5
        memo[i][1] += 1

l0 = [[0]*100 for _  in range(100)]
for i in range(n):
    l0[memo[i][0]][memo[i][1]] += 1

l1 = copy.deepcopy(l0)
for i in range(100):
    for j in range(98,-1,-1):
        l1[i][j] += l1[i][j+1]
for i in range(98,-1,-1):
    for j in range(100):
        l1[i][j] += l1[i+1][j]


ans = 0
for i in range(100):
    for j in range(100):
        x0,y0 = i,j
        x1,y1 = max(0,18-x0),max(0,18-y0)
        if x0 >= 9 and y0 >= 9:
            ans += l0[x0][y0]*(l1[x1][y1]-1)
        else:
            ans += l0[x0][y0]*l1[x1][y1]
print(ans//2)

Buggy submission (verdict: Runtime Error):
import copy
n = int(input())
def point_shift(s,i):
    tale = len(s[p+1:])
    if tale <= i:
        return int(s[:p]+s[p+1:].ljust(i,"0"))
    else:
        return int(s[:p]+s[p+1:p+i+1])

a = []
for i in range(n):
    s = input()
    if "." not in s:
        a.append(int(s)*10**9)
    else:
        a.append(point_shift(s,9))

memo = [[0,0] for _ in range(n)]
for i in range(n):
    t = a[i]
    while t%2 == 0:
        t //= 2
        memo[i][0] += 1
    while t%5 == 0:
        t //= 5
        memo[i][1] += 1

l0 = [[0]*100 for _  in range(100)]
for i in range(n):
    l0[memo[i][0]][memo[i][1]] += 1

l1 = copy.deepcopy(l0)
for i in range(100):
    for j in range(98,-1,-1):
        l1[i][j] += l1[i][j+1]
for i in range(98,-1,-1):
    for j in range(100):
        l1[i][j] += l1[i+1][j]

ans = 0
for i in range(100):
    for j in range(100):
        x0,y0 = i,j
        x1,y1 = 18-x0,18-y0
        if x0 >= 9 and y0 >= 9:
            ans += l0[x0][y0]*(l1[x1][y1]-1)
        else:
            ans += l0[x0][y0]*l1[x1][y1]
print(ans//2)

Buggy submission (verdict: Runtime Error):
import copy
n = int(input())
l = []
for i in range(n):
    a = str(input())
    if "." not in a:
        l.append(float(a))
    else:
        dot = a.index(".")
        if len(a)-dot-1 <= 4:
            l.append(float(a))
        else:
            flag = 1
            for j in range(dot+5,len(a)):
                if a[j] != "0":
                    flag = 0
            if flag: l.append(float(a)) 
n = len(l)
a = [int(l[i]*10**4) for i in range(n)]
memo = [[0,0] for _ in range(n)]
for i in range(n):
    t = a[i]
    while t%2 == 0:
        t //= 2
        memo[i][0] += 1
    while t%5 == 0:
        t //= 5
        memo[i][1] += 1
a.sort()
memo.sort()
mem2 = [[0]*9 for _ in range(9)]
p = 0
for i in range(n):
    if memo[i][0] >= 8 and memo[i][1] >= 8:
        p += 1
    else:
        mem2[memo[i][0]][memo[i][1]] += 1
mems = copy.deepcopy(mem2)


for i in range(8,-1,-1):
    for j in range(7,-1,-1):
        mems[i][j] += mems[i][j+1]
for i in range(7,-1,-1):
    for j in range(8,-1,-1):
        mems[i][j] += mems[i+1][j]

s = 0
for i in range(9):
    for j in range(9):
        if i >= 4 and j >= 4:
            s += mem2[i][j] * (mems[8-i][8-j]-1)
        else:
            s += mem2[i][j] * mems[8-i][8-j]
s = s//2
s += p*(p-1)//2+p*(n-p)
print(s)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
import copy
n = int(input())
l = []
for i in range(n):
    a = str(input())
    if "." not in a:
        l.append(Decimal(a))
    else:
        dot = a.index(".")
        if len(a)-dot-1 <= 4:
            l.append(Decimal(a))
        else:
            flag = 1
            for j in range(dot+5,len(a)):
                if a[j] != "0":
                    flag = 0
            if flag: l.append(Decimal(a)) 
n = len(l)
a = [int(l[i]*10**4) for i in range(n)]
memo = [[0,0] for _ in range(n)]
for i in range(n):
    t = a[i]
    while t%2 == 0:
        t //= 2
        memo[i][0] += 1
    while t%5 == 0:
        t //= 5
        memo[i][1] += 1
a.sort()
memo.sort()
mem2 = [[0]*9 for _ in range(9)]
p = 0
for i in range(n):
    if memo[i][0] >= 8 and memo[i][1] >= 8:
        p += 1
    else:
        mem2[memo[i][0]][memo[i][1]] += 1
mems = copy.deepcopy(mem2)


for i in range(8,-1,-1):
    for j in range(7,-1,-1):
        mems[i][j] += mems[i][j+1]
for i in range(7,-1,-1):
    for j in range(8,-1,-1):
        mems[i][j] += mems[i+1][j]

s = 0
for i in range(9):
    for j in range(9):
        if i >= 4 and j >= 4:
            s += mem2[i][j] * (mems[8-i][8-j]-1)
        else:
            s += mem2[i][j] * mems[8-i][8-j]
s = s//2
s += p*(p-1)//2+p*(n-p)
print(s)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
import copy
n = int(input())
l = []
for i in range(n):
    a = str(input())
    if "." not in a:
        l.append(Decimal(a))
    else:
        dot = a.index(".")
        if len(a)-dot-1 <= 4:
            l.append(Decimal(a))
        else:
            flag = 1
            for j in range(dot+5,len(a)):
                if a[j] != "0":
                    flag = 0
            if flag: l.append(Decimal(a)) 
n = len(l)
a = [int(l[i]*10**4) for i in range(n)]
memo = [[0,0] for _ in range(n)]
for i in range(n):
    t = a[i]
    while t%2 == 0:
        t //= 2
        memo[i][0] += 1
    while t%5 == 0:
        t //= 5
        memo[i][1] += 1
a.sort()
memo.sort()
mem2 = [[0]*9 for _ in range(9)]
p = 0
for i in range(n):
    if memo[i][0] >= 8 and memo[i][1] >= 8:
        p += 1
    else:
        mem2[memo[i][0]][memo[i][1]] += 1
mems = copy.deepcopy(mem2)


for i in range(8,-1,-1):
    for j in range(7,-1,-1):
        mems[i][j] += mems[i][j+1]
for i in range(7,-1,-1):
    for j in range(8,-1,-1):
        mems[i][j] += mems[i+1][j]

s = 0
for i in range(9):
    for j in range(9):
        if i >= 4 and j >= 4:
            s += mem2[i][j] * (mems[8-i][8-j]-1)
        else:
            s += mem2[i][j] * mems[8-i][8-j]
s = s//2
s += p*(p-1)//2+p*(n-p)
print(s)