Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03436 (python)

Fixed submission:
from collections import deque
H,W = map(int,input().split())
grid = [0] * H
num_black = 0
for i in range(H):
    s = input()
    for j in range(len(s)):
        if s[j] == '#':
            num_black += 1
    grid[i] = list(s)
time_grid = [[-1] * W for _ in range(H)]
time_grid[0][0] = 0
queue = deque()
queue.append([0,0,0])
while queue:
    y,x,t = queue.popleft()
    for next_y, next_x in [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]:
        if 0 <= next_x < W and 0 <= next_y < H and grid[next_y][next_x] == '.':
            queue.append([next_y,next_x,t+1])
            time_grid[next_y][next_x] = t+1
            grid[next_y][next_x] = '#'
if time_grid[H-1][W-1] != -1:
    print(H*W-time_grid[-1][-1]-1-num_black)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
H,W = map(int,input().split())
grid = [0] * H
num_black = 0
for i in range(H):
    s = input()
    for j in range(len(s)):
        if s[j] == '#':
            num_black += 1
    grid[i] = list(s)
time_grid = [[-1] * W for _ in range(H)]
time_grid[0][0] = 0
queue = deque()
queue.append([0,0,0])
while queue:
    y,x,t = queue.popleft()
    for next_y, next_x in [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]:
        if 0 <= next_x < W and 0 <= next_y < H and grid[next_y][next_x] == '.':
            queue.append([next_y,next_x,t+1])
            time_grid[next_y][next_x] = t+1
            grid[next_y][next_x] = '#'
if time_grid[H][W] != -1:
    print(H*W-time_grid[-1][-1]-1-num_black)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
H,W = map(int,input().split())
grid = [0] * H
num_black = 0
for i in range(H):
    s = input()
    for j in range(len(s)):
        if s[j] == '#':
            num_black += 1
    grid[i] = list(s)
time_grid = [[0] * W for _ in range(H)]
queue = deque()
queue.append([0,0,0])
while queue:
    y,x,t = queue.popleft()
    for next_y, next_x in [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]:
        if next_y == H-1 and next_x == W-1:
            time = t+1
            break
        if 0 <= next_x < W and 0 <= next_y < H and grid[next_y][next_x] == '.':
            queue.append([next_y,next_x,t+1])
            grid[next_y][next_x] = '#'
print(H*W-time-1-num_black)

Buggy submission (verdict: Runtime Error):
from collections import deque
H,W = map(int,input().split())
grid = [0] * H
num_black = 0
for i in range(H):
    s = input()
    for j in range(len(s)):
        if s[j] == '#':
            num_black += 1
    grid[i] = list(s)
time_grid = [[0] * W for _ in range(H)]
queue = deque()
queue.append([0,0,0])
while queue:
    y,x,t = queue.popleft()
    for next_y, next_x in [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]:
        if next_y == H-1 and next_x == W-1:
            time = t+1
            break
        if 0 <= next_x < W and 0 <= next_y < H and grid[next_y][next_x] == '.':
            queue.append([next_y,next_x,t+1])
            grid[next_y][next_x] = '#'
print(H*W-time-1-num_black)
Problem p03608 (python)

Fixed submission:
from itertools import permutations
n_node, n_edge, R = map(int,input().split())
r_ls = list(map(int,input().split()))
for i in range(R):
    r_ls[i] -= 1
ad_mat = [[float('inf')]*n_node for _ in range(n_node)]
for i in range(n_node):
    ad_mat[i][i] = 0
for i in range(n_edge):
    a,b,c = map(int,input().split())
    ad_mat[a-1][b-1] = c
    ad_mat[b-1][a-1] = c

# ワーシャルフロイド
for stop in range(n_node):
    for start in range(n_node):
        for end in range(n_node):
            ad_mat[start][end] = min(ad_mat[start][end],ad_mat[start][stop]+ad_mat[stop][end])

ans = float('inf')
for path in permutations(r_ls):
    cost = 0
    for i in range(R-1):
        cost += ad_mat[path[i]][path[i+1]]
    ans = min(ans,cost)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import permutations
n_node, n_edge, R = map(int,input().split())
r_ls = list(map(int,input().split()))
for i in range(R):
    r_ls[i] -= 1
ad_mat = [[float('inf')]*n_edge for _ in range(n_node)]
for i in range(n_node):
    ad_mat[i][i] = 0
for i in range(n_edge):
    a,b,c = map(int,input().split())
    ad_mat[a-1][b-1] = c
    ad_mat[b-1][a-1] = c

# ワーシャルフロイド
for start in range(n_node):
    for end in range(n_node):
        for stop in range(n_node):
            ad_mat[start][end] = min(ad_mat[start][end],ad_mat[start][stop]+ad_mat[stop][end])

ans = float('inf')
for path in permutations(r_ls):
    cost = 0
    for i in range(R-1):
        cost += ad_mat[path[i]][path[i+1]]
    ans = min(ans,cost)
print(ans)
Problem p03638 (python)

Fixed submission:
from collections import deque
H,W = map(int,input().split())
n = int(input())
a_ls = list(map(int, input().split()))
color_q = deque()
for color, times in enumerate(a_ls,1):
    for _ in range(times):
        color_q.append(color)
ans_mat = [[0] * W for _ in range(H)]
for y in range(H):
    for x in range(W):
        ans_mat[y][x] = color_q.popleft()
for i,y in enumerate(range(H)):
    ans_ls = ans_mat[y]
    if i % 2 == 1:
        ans_ls = ans_ls[::-1]
    ans_ls = list(map(str,ans_ls))
    print(' '.join(ans_ls))

Buggy submission (verdict: Runtime Error):
from collections import deque
H,W = map(int,input().split())
n = int(input())
a_ls = list(map(int, input().split()))
color_q = deque()
for color, times in enumerate(a_ls,1):
    for _ in range(times):
        color_q.append(color)
ans_mat = [[0] * W for _ in range(W)]
for y in range(H):
    for x in range(W):
        ans_mat[y][x] = color_q.popleft()
for i,y in enumerate(range(H)):
    ans_ls = ans_mat[y]
    if i % 2 == 1:
        ans_ls = ans_ls[::-1]
    ans_ls = list(map(str,ans_ls))
    print(' '.join(ans_ls))
Problem p03786 (python)

Fixed submission:
import numpy as np 
n = int(input())
size_ls = list(map(int, input().split()))
size_ls.sort()
csum_size = list(np.cumsum(size_ls))

can_ls = [0] * n
can_ls[-1] = 1
for i in range(n-1):
    if 2 * csum_size[i] >= size_ls[i+1]:
        can_ls[i] = 1
ans = 0
for i in range(n-1,-1,-1):
    if can_ls[i] != 1:
        break
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np 
n = int(input())
size_ls = list(map(int, input().split()))
size_ls.sort()
csum_size = list(np.cumsum(size_ls))

# とりあえず、与えられたインデックスの生き物が全部食べることをできるか返す関数
def isOK(start):
    res = True
    for i in range(start, n-1):
            if not 2 * csum_size[i] >= size_ls[i + 1]:
                res = False
                break
    return res

ans = 1
for i in range(n-1):
    if isOK(i):
        ans += 1
print(ans)
Problem p03828 (python)

Fixed submission:
mod = 1000000000 + 7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

n = int(input())
dat = [0] * 2000 # 約数として求められたある数の合計

# N! の各要素の素因数分解をする
res = 1
for i in range(1, n + 1):
    d = factorization(i)
    for j in range(len(d)):
        dat[d[j][0]] += d[j][1]

for i in range(2, n + 1):
    res *= (dat[i] + 1)
    res %= mod

print(res)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    # 上のループを通した後にtempが1じゃなかったら、だけど、nが素数以外にそんなケースある？
    if temp!=1:
        arr.append([temp, 1])
    
    # 素数だったときの処理
    if arr == []:
        arr.append([n,1])

    return arr

def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
F = factorial(n)
factor_ls = factorization(F)
ls = [factor[1] for factor in factor_ls]
num_factor = 1
for i in ls:
    num_factor *= (i + 1)
print(num_factor % (10**9 + 7))
Problem p04015 (python)

Fixed submission:
N,ave = map(int,input().split())
card_ls = list(map(int, input().split()))
#dp[i+1][n][s] := i番目までのカード(0idx)からn枚使って合計がsとなるパターンの数
dp = [[[0]*(ave*N+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for n in range(N):
        for s in range(ave*N+1):
            # i番目を新しく使う
            if s+card_ls[i] < ave*N+1:
                dp[i+1][n+1][s+card_ls[i]] += dp[i][n][s]
            # i番目を使わない
            dp[i+1][n][s] += dp[i][n][s]

#print(dp)
ans = 0
for n in range(1,N+1):
    ans += dp[N][n][n*ave]
print(ans)

Buggy submission (verdict: Runtime Error):
N,ave = map(int,input().split())
card_ls = list(map(int, input().split()))
#dp[i+1][n][s] := i番目までのカード(0idx)からn枚使って合計がsとなるパターンの数
dp = [[[0]*(ave*N+1) for _ in range(N+1)] for _ in range(N+1)]
dp[1][1][card_ls[0]] = 1
dp[1][0][0] = 1
for i in range(1,N):
    for n in range(N):
        for s in range(ave*N+1):
            # i番目を新しく使う
            if s+card_ls[i] < ave*N+1:
                dp[i+1][n+1][s+card_ls[i]] += dp[i][n][s]
            # i番目を使わない
            dp[i+1][n][s] += dp[i][n][s]

#print(dp)
ans = 0
for n in range(1,N+1):
    ans += dp[N][n][n*ave]
print(ans)
Problem p04020 (python)

Fixed submission:
n = int(input())
ls = [0] * n
for i in range(n):
    a = int(input())
    ls[i] = a

ans = 0
for i in range(n-1):
    if ls[i] % 2 == 1 and ls[i+1] > 0:
        ls[i] += 1
        ls[i+1] -= 1
    ans += ls[i] // 2
ans += ls[-1] // 2
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ls = [0] * N
for i in range(N):
    a = int(input())
    ls[i] = a

def return_ans(ls):
    ans = 0
    n = len(ls)
    if n > 1:
        for i in range(n-1):
            if ls[i] % 2 == 1 and ls[i+1] > 0:
                ls[i] += 1
                ls[i+1] -= 1
            ans += ls[i] // 2
    ans += ls[-1]//2
    return ans

now_ls = []
ans = 0
for i in range(N):
    if ls[i] != 0:
        now_ls.append(ls[i])
    else:
        ans += return_ans(now_ls)
        now_ls = []
if now_ls:
    ans += return_ans(now_ls)

print(ans)
Problem p02615 (python)

Fixed submission:
def main():
    N=int(input())
    A=list(map(int,input().split()))

    A.sort(reverse=True)

    res=A[0]

    counter=1

    while counter<=N-2:
        index = (counter + 1) // 2
        res+=A[index]
        counter+=1

    print(res)

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    N=int(input())
    A=list(map(int,input().split()))

    A.sort(reversed=True)

    res=0
    res+=A[0]
    res+=A[1]*(N-2)
    print(res)

if __name__=="__main__":
    main()
Problem p02640 (python)

Fixed submission:
import sys

def main():
    X,Y=map(int,input().split())
    crane=(Y-2*X)/2
    if crane!=int(crane):
        print("No")
        sys.exit()
    turtle=X-crane
    if crane>=0 and turtle>=0:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
C:\Users\kouya\Anaconda3\python.exe C:/Users/kouya/pywork/atcoder/past/Contest170.py
2 100
No

Process finished with exit code 0
Problem p02642 (python)

Fixed submission:
from collections import deque
import math

def main():
    N=int(input())
    A=list(map(int,input().split()))

    A.sort(reverse=True)

    Amax=max(A)

    dp=[0]*Amax

    tmp=-1
    res=0
    for i in range(len(A)):
        a=A.pop()
        if a==tmp:
            continue
        if dp[a-1]==0:
            if len(A)>0:
                if A[len(A)-1]!=a:
                    res+=1
            else:
                res+=1
            m=2
            while (a*m)<=Amax:
                dp[a*m-1]=1
                m+=1
        tmp=a

    print(res)
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
import math
import numpy as np

def main():
    N=int(input())
    A=list(map(int,input().split()))

    A.sort()

    Amax=max(A)

    dp=np.array([0 for _ in range(Amax)])

    tmp=-1
    res=0
    for i in range(len(A)):
        a=A.pop(0)
        if a==tmp:
            continue
        if dp[a-1]==0:
            if len(A)>0:
                if A[0]!=a:
                    res+=1
            else:
                res+=1
            m=2
            while (a*m)<=Amax:
                dp[a*m-1]=1
                m+=1
        tmp=a

    print(res)
if __name__=="__main__":
    main()
Problem p02647 (python)

Fixed submission:
def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))


    for _ in range(K):
        counter=[0 for _ in range(N)]

        for i in range(len(A)):
            left=max(0,i-A[i])
            right=min(N-1,i+A[i])
            counter[left]+=1
            if right+1<N:
                counter[right+1]-=1
        for i in range(len(counter)-1):
            counter[i+1]+=counter[i]

        if counter==A:
            break
        else:
            A=counter

    for i in range(N):
        if i!=N-1:
            print(str(A[i])+" ",end="")
        else:
            print(A[i])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np


def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))


    for _ in range(K):
        counter=[0 for _ in range(N)]

        for i in range(len(A)):
            left=max(0,i-A[i])
            right=min(N-1,i+A[i])
            counter[left]+=1
            if right+1<N:
                counter[right+1]-=1
        for i in range(len(counter)-1):
            counter[i+1]+=counter[i]

        if counter==A:
            break
        else:
            A=counter

    for i in range(N):
        if i!=N-1:
            print(str(A[i])+" ",end="")
        else:
            print(A[i])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np


def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))


    for _ in range(K):
        counter=[0 for _ in range(N)]

        for i in range(len(A)):
            left=max(0,i-A[i])
            right=min(N-1,i+A[i])
            counter[left]+=1
            if right+1<N:
                counter[right+1]-=1
        for i in range(len(counter)-1):
            counter[i+1]+=counter[i]

        if counter==A:
            break
        else:
            A=counter

    print(A)

if __name__ == "__main__":
    main()
Problem p02664 (python)

Fixed submission:
def main():
    S=input()
    res=""

    for i in range(len(S)):
        if S[i]=="?":
            if len(S)==1:
                res+="D"
                continue
            if i==0:
                if S[i+1]=="?":
                    res+="P"
                else:
                    res+="D"
            elif i==len(S)-1:
                res+="D"
            else:
                if res[i-1]=="P":
                    res+="D"
                elif S[i+1]=="?":
                    res+="P"
                else:
                    res+="D"
        else:
            res+=S[i]
    print(res)

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S=input()
    res=""

    for i in range(len(S)):
        if S[i]=="?":
            if i==0:
                if S[i+1]=="?":
                    res+="P"
                else:
                    res+="D"
            elif i==len(S)-1:
                res+="D"
            else:
                if res[i-1]=="P":
                    res+="D"
                elif S[i+1]=="?":
                    res+="P"
                else:
                    res+="D"
        else:
            res+=S[i]
    print(res)

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S=input()
    res=""

    for i in range(len(S)):
        if S[i]=="?":
            if i==0:
                if S[i+1]=="?":
                    res+="P"
                else:
                    res=+"D"
            elif i==len(S)-1:
                res+="D"
            else:
                if res[i-1]=="P":
                    res+="D"
                elif S[i+1]=="?":
                    res+="P"
                else:
                    res+="D"
        else:
            res+=S[i]
    print(res)

if __name__=="__main__":
    main()
Problem p02703 (python)

Fixed submission:
from heapq import heappop,heappush

def main():
    N,M,S=map(int,input().split())
    G=[[] for _ in range(N)]
    for i in range(M):
        U,V,A,B=map(int,input().split())
        G[U-1].append([V-1,A,B])
        G[V-1].append([U-1,A,B])
    C=[]
    D=[]
    for _ in range(N):
        c,d=map(int,input().split())
        C.append(c)
        D.append(d)

    MaxMoney=2500

    dp=[[float('inf') for __ in range(MaxMoney+1)] for _ in range(N)]

    cost=0
    money=min(S,MaxMoney)
    que=[]
    heappush(que,(cost,0,money)) #cost,node,money
    dp[0][money] = 0

    while len(que)>0:
        cost,node,money=heappop(que)

        stop_money=min(money+C[node],MaxMoney)
        stop_cost=cost+D[node]
        if stop_cost<dp[node][stop_money]:
            dp[node][stop_money]=stop_cost
            heappush(que,(stop_cost,node,stop_money))

        for to_node,to_money,to_cost in G[node]:
            money_=min(money-to_money,MaxMoney)
            if money_<0:
                continue
            cost_=cost+to_cost
            if dp[to_node][money_]<=cost_:
                continue

            dp[to_node][money_]=cost_
            heappush(que,(cost_,to_node,money_))

    for i in range(1,N):
        print(min(dp[i]))




if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
from heapq import heappop,heappush

def main():
    N,M,S=map(int,input().split())
    G=[[] for _ in range(N)]
    for i in range(M):
        U,V,A,B=map(int,input().split())
        G[U-1].append([V-1,A,B])
        G[V-1].append([U-1,A,B])
    C=[]
    D=[]
    for _ in range(N):
        c,d=map(int,input().split())
        C.append(c)
        D.append(d)

    MaxMoney=2500

    dp=[[float('inf') for __ in range(MaxMoney+1)] for _ in range(N)]

    cost=0
    money=S
    que=[]
    heappush(que,(cost,0,money)) #cost,node,money
    dp[0][money] = 0

    while len(que)>0:
        cost,node,money=heappop(que)

        stop_money=min(money+C[node],MaxMoney)
        stop_cost=cost+D[node]
        if stop_cost<dp[node][stop_money]:
            dp[node][stop_money]=stop_cost
            heappush(que,(stop_cost,node,stop_money))

        for to_node,to_money,to_cost in G[node]:
            money_=min(money-to_money,MaxMoney)
            if money_<0:
                continue
            cost_=cost+to_cost
            if dp[to_node][money_]<=cost_:
                continue

            dp[to_node][money_]=cost_
            heappush(que,(cost_,to_node,money_))

    for i in range(1,N):
        print(min(dp[i]))




if __name__=="__main__":
    main()
Problem p03035 (python)

Fixed submission:
def main():
    inp=list(map(lambda x:int(x),input().split()))
    A=inp[0]
    B=inp[1]

    res=B
    if A>=6 and A<=12:
        res=res//2
    elif A<=5:
        res=0

    print(res)

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    inp=list(map(lambda x:int(x),input().split()))
    A=inp[0]
    B=inp[1]

    res=B
    if 6<=B=<12:
        res=res//2
    elif B<=5:
        res=0

    print(res)

if __name__=="__main__":
    main()
Problem p03040 (python)

Fixed submission:
from heapq import heappush,heappop
def main():
    Q=int(input())

    ab_list=[]
    query_type=[]

    for i in range(Q):
        query=list(map(int,input().split()))
        query_type.append(query[0])
        if query[0]==1:
            ab_list.append((query[1],query[2]))

    #query_type->[1,1,2,1,2]
    #ab_list->[(a,b),(a,b),(a,b)]

    L=[]
    R=[]

    ini=0

    counter=0
    ab_pointer=0
    minF=0
    for i in query_type:
        if i==1:
            a_new=ab_list[ab_pointer][0]
            b_new=ab_list[ab_pointer][1]
            heappush(L,-1*a_new)
            heappush(R,a_new)
            Lmax=-1*heappop(L)
            Rmin=heappop(R)
            if Lmax<=Rmin:
                heappush(L,-1*Lmax)
                heappush(R,Rmin)
            else:
                heappush(L,-1*Rmin)
                heappush(R,Lmax)
            delta=abs(Lmax-Rmin)
            minF+=delta+b_new
            ab_pointer+=1
        else:
            minX=-1*heappop(L)
            print(str(minX)+" "+str(minF))
            heappush(L,-1*minX)



if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
from heapq import heappush,heappop
def main():
    Q=int(input())

    ab_list=[]
    query_type=[]

    for i in range(Q):
        query=list(map(int,input().split()))
        query_type.append(query[0])
        if query[0]==1:
            ab_list.append((query[1],query[2]))

    #query_type->[1,1,2,1,2]
    #ab_list->[(a,b),(a,b),(a,b)]

    L=[]
    R=[]

    ini=0

    counter=0
    ab_pointer=0
    minF=0
    for i in query_type:
        if i==1:
            if counter==0:
                ini=ab_list[ab_pointer][0]
                counter+=1
                minF+=ab_list[ab_pointer][1]
            elif counter==1:
                L.append(-1*min(ini,ab_list[ab_pointer][0]))
                R.append(max(ini,ab_list[ab_pointer][0]))
                counter+=1
                delta=abs(-1*L[0]-R[0])
                minF+=delta+ab_list[ab_pointer][1]
            else:
                a_new=ab_list[ab_pointer][0]
                b_new=ab_list[ab_pointer][1]
                heappush(L,-1*a_new)
                heappush(R,a_new)
                Lmax=-1*heappop(L)
                Rmin=heappop(R)
                if Lmax<=Rmin:
                    heappush(L,-1*Lmax)
                    heappush(R,Rmin)
                else:
                    heappush(L,-1*Rmin)
                    heappush(R,Lmax)
                delta=abs(Lmax-Rmin)
                minF+=delta+b_new
            ab_pointer+=1
        else:
            if counter<=1:
                print(str(ini)+" "+str(minF))
            else:
                print(str(-1*heappop(L))+" "+str(minF))



if __name__=="__main__":
    main()
Problem p02588 (python)

Fixed submission:
# A

from decimal import *

n = int(input())
a_l = [int(Decimal(input()) * 10**9) for x in range(n)]

list = [[0] * 19 for _ in range(19)]
cs_list = [[0] * 19 for _ in range(19)]
b_l = [0, 0] * n

for i in range(n):
    _t2 = 0
    _t5 = 0
    _a = a_l[i]
    while _a % 2 == 0 and _t2 < 18:
        _t2 += 1
        _a /= 2

    _a = a_l[i]
    while _a % 5 == 0 and _t5 < 18:
        _t5 += 1
        _a /= 5
    
    list[_t2][_t5] += 1
    b_l[i] = [_t2, _t5]

for i in range(19):
    for j in range(19):
        for k in range(i+1):
            for l in range(j+1):
                cs_list[k][l] += list[i][j]

ans = 0
for i in range(n):
    _t,_f = b_l[i]
    if _t >= 9 and _f >= 9:
        ans -= 1
    ans += cs_list[18-_t][18-_f]
        
print(ans // 2)

Buggy submission (verdict: Runtime Error):
# A

n = int(input())
a_l = [int(float(input()) * 10**9) for x in range(n)]

list = [[0] * 18 for x in range(18)]
b_l = [0, 0] * n

for i in range(n):
    _t2 = 0
    _t5 = 0
    _a = a_l[i]
    while _a % 2 == 0 and _t2 < 18:
        _t2 += 1
        _a /= 2

    _a = a_l[i]
    while _a % 5 == 0 and _t5 < 18:
        _t5 += 1
        _a /= 5
    
    list[_t2][_t5] += 1
    b_l[i] = [_t2, _t5]
    
ans = 0
for i in range(n):
    _t,_f = b_l[i]
    for j in range(18-_t,19):
        for k in range(18-_f,19):
            ans += list[j][k]
    if _t >= 9 and _f >= 9:
        ans -= 1
        
print(ans // 2)