Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int,input().split())
c=[]
for i in range N:
  c[i]=0
for j in A:
  c[j-1]+=1

for C in c:
  print(C)
  

Fixed submission:
N = int(input())
A = map(int,input().split())
c=[]
for i in range (N):
  c.append(0)
for j in A:
  c[j-1]+=1

for C in c:
  print(C)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
for i in range(1,max(A)+1):
  print(A.count(i))
for j in range(max(A)+1,N+1):
  print(0)

Fixed submission:
N = int(input())
A = map(int,input().split())
c=[]
for i in range (N):
  c.append(0)
for j in A:
  c[j-1]+=1

for C in c:
  print(C)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
for i in range(1,N):
  print(A.count(i))
print(0)

Fixed submission:
N = int(input())
A = map(int,input().split())
c=[]
for i in range (N):
  c.append(0)
for j in A:
  c[j-1]+=1

for C in c:
  print(C)
Buggy python submission (verdict: Runtime Error):
N= input()
for i in range 3:
  if N[i]=='7':
    print('Yes')
    exit()

print('No')

Fixed submission:
N = input()
if N[0]!=('7') and N[1]!=('7') and N[2]!=('7'):
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
S = input()
c = True
for i in range (len(S)//2):
  if S[i]=S[len(S)//2-i-1]=S[len(S)//2+1+i]=S[len(S)-i-1]:
    c = True
  else:
    c = False
if (c):
  print('Yes')
else:
  print('No')

Fixed submission:
S = input()
c = True
for i in range (len(S)//2):
  if S[i]==S[len(S)//2-i-1]==S[len(S)//2+1+i]==S[len(S)-i-1]:
    c = True
  else:
    c = False
    break
if (c):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N=int(input())
X= list(map(int,input().split()))
cnt = 1000000
for j in range(100):
    t = 0
    for i in li:
        t += (i-(j+1))**2
    if t <= cnt:
        cnt = t
print(cnt)


Fixed submission:
N=int(input())
X= list(map(int,input().split()))
cnt = 1000000
for j in range(100):
    t = 0
    for i in X:
        t += (i-(j+1))**2
    if t <= cnt:
        cnt = t
print(cnt)

Buggy python submission (verdict: Runtime Error):
N =int(input())
X = list(map(int,input().split()))
c = 100000000
for i in range(1,101):
  t=0
  for j in X:
    t += (j-i)**2

  if t=<c:
    t=c
print(c)


Fixed submission:
N=int(input())
X= list(map(int,input().split()))
cnt = 1000000
for j in range(100):
    t = 0
    for i in X:
        t += (i-(j+1))**2
    if t <= cnt:
        cnt = t
print(cnt)

Buggy python submission (verdict: Runtime Error):
N =int(input())
X = map(int,input().split())
c = 100000000
for i in range(1,101):
  t=0
  for j in X:
    t += (j-i)**2

  if t=<c:
    t=c
print(c)


Fixed submission:
N=int(input())
X= list(map(int,input().split()))
cnt = 1000000
for j in range(100):
    t = 0
    for i in X:
        t += (i-(j+1))**2
    if t <= cnt:
        cnt = t
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range (N):
  for j in range (i+1,N):
    if A[i]==A[j]:
      print('NO')
      exit()
      
print('YES')
 



Fixed submission:
N =int(input())
A =list(map(int ,input().split()))
s =set(A)
if len(A) >len(s):
    print('NO')
else:
    print('YES')
Buggy python submission (verdict: Runtime Error):
def AC(N,M):
  if N = M:
    return ('Yes')
  else:
    return ('No')
  

Fixed submission:
A,B = map(int,input().split())
if A==B:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))
c=0
for i in range(N):
  m=min(P[:i+1])
  if P[i]==m:
    c+=1
    
print(c)

Fixed submission:
N=int(input())
P=list(map(int,input().split()))
c=0
m=max(P)
for i in range(N):
  m=min(m,P[i])
  if P[i]==m:
    c+=1
    
print(c)
Buggy python submission (verdict: Runtime Error):
A,B,C = int(input())
if A+B+C >=22:
  print('bust')
else:
  print('win')

Fixed submission:
A,B,C =map(int,input().split())
if A+B+C>=22:
  print('bust')
else:
  print('win')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
C=[0]*N
for i in range(N):
  C[i]=A.index(i+1)+1
print(*C)



Fixed submission:
N=int(input())
A=list(map(int,input().split()))
C=[0]*N
for i in range(N):
  C[A[i]-1]=i+1
print(*C)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
C=[]
for i in range(N):
  C.append(A.index(i+1)+1)
print(*C)



Fixed submission:
N=int(input())
A=list(map(int,input().split()))
C=[0]*N
for i in range(N):
  C[A[i]-1]=i+1
print(*C)
Buggy python submission (verdict: Runtime Error):
S = input()
if S = 'Sunny':
  print('Cloudy')
elif S = 'Cloudy':
  print('Rainy')
else:
  print('Sunny')


Fixed submission:
S = input()
if S =='Sunny':
  print('Cloudy')
elif S == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
c=[K-Q]*N

for i in range(Q):
  A=int(input())-1
  for r in range(N):
    if r==A:
      c[r]+=1
    
for k in range(N):
  if c[k]>0:
    c[k]='Yes'
  else:
    c[k]='No'
    
for j in range(N):
  print(c[j])
    
    

Fixed submission:
N,K,Q=map(int,input().split())
c=[K-Q]*N

for i in range(Q):
  A=int(input())-1
  c[A]+=1
    
for k in range(N):
  if c[k]>0:
    c[k]='Yes'
  else:
    c[k]='No'
    
for j in range(N):
  print(c[j])

Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
c=[K]*N
d=[0]*N
for i in range(Q):
  A=int(input())-1
  for j in range(N):
    if j!=A:
      c[j]-=1
      
for k in range(N):
  if c[k]<=0:
    d[k]='No'
  else:
    d[k]='Yes'
    
for r in range(N):
  print(d[r])
    
      
      
  

Fixed submission:
N,K,Q=map(int,input().split())
c=[K-Q]*N

for i in range(Q):
  A=int(input())-1
  c[A]+=1
    
for k in range(N):
  if c[k]>0:
    c[k]='Yes'
  else:
    c[k]='No'
    
for j in range(N):
  print(c[j])
Buggy python submission (verdict: Runtime Error):
print(3*(input()**2))


Fixed submission:
print(3*(int(input())**2))

Buggy python submission (verdict: Runtime Error):
print(3*input()**2)

Fixed submission:
print(3*(int(input())**2))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
A0=max(A)
for i in range(N):
  if A[i]!=A0:
    print(A0)
  else:
    A.remove(A0)
    A1=max(A)
    print(max(A))
    A.append(A1)

Fixed submission:
N=int(input())
A=[int(input()) for i in range(N)]
B=sorted(A)
A0=B[N-1]
A1=B[N-2]
for i in range(N):
  if A[i]!=A0:
    print(A0)
  else:
    print(A1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]

for k in range(N):
  A0=A[0]
  A.remove(A0)

  print(max(A))
  A.append(A0)

Fixed submission:
N=int(input())
A=[int(input()) for i in range(N)]
B=sorted(A)
A0=B[N-1]
A1=B[N-2]
for i in range(N):
  if A[i]!=A0:
    print(A0)
  else:
    print(A1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
B=[]
for k in range(N):
  A0=A[0]
  A.remove(A0)

  print(max(A))
  A.append(A0)

Fixed submission:
N=int(input())
A=[int(input()) for i in range(N)]
B=sorted(A)
A0=B[N-1]
A1=B[N-2]
for i in range(N):
  if A[i]!=A0:
    print(A0)
  else:
    print(A1)
Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
count_max = 0

for k in range(len(s)):
    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        count=0
print(count_max)


Fixed submission:
S = input()
count = 0
count_max = 0

for k in range(len(S)):
    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        count=0
print(count_max)
Buggy python submission (verdict: Runtime Error):
N,M,C= map(int,input().split())
B= list(map(int,input().split()))
now = 0
for i in range(N):
  A=list(map(int,input().split()))
    ans = C
    for j in range(M):
        ans += A[j]*B[j]
    if (ans)>0:
        now += 1
print(now)


Fixed submission:
N,M,C= map(int,input().split())
B= list(map(int,input().split()))
now = 0
for i in range(N):
    A=list(map(int,input().split()))
    ans = C
    for j in range(M):
        ans += A[j]*B[j]
    if (ans)>0:
        now += 1
print(now)
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
c=[]
for i in range(1,abs(A-B)+1):
  if A%i==0 and B%i==0:
    c.append(i)
    
print(c[-K])


Fixed submission:
A,B,K=map(int,input().split())
c=[]
for i in range(1,min(A,B)+1):
  if A%i==0 and B%i==0:
    c.append(i)
    
print(c[-K])
Buggy python submission (verdict: Runtime Error):
N,x = map(int, input().split())
A = sorted(map(int, input().split()))

S = 0
c = 0

for i in range(N):
  S += A[i]
  
if S < x:
  print(N-1)
else:
  for i in range(N):
    b = x - A[i]
    if b > 0:
      c += 1
      x -= A[i]
    elif b == 0:
      count += 1  
      break
    else:
      break
  print(c)


Fixed submission:
N,x = map(int, input().split())
A = sorted(map(int, input().split()))

S = 0
c = 0

for i in range(N):
  S += A[i]
  
if S < x:
  print(N-1)
else:
  for i in range(N):
    b = x - A[i]
    if b > 0:
      c += 1
      x -= A[i]
    elif b == 0:
      c += 1  
      break
    else:
      break
  print(c)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input(),split())
e=(d-b)
f=(c-a)
print(c-e,d+f,a-e,b+f)

Fixed submission:
a,b,c,d=map(int,input().split())
e=(d-b)
f=(c-a)
print(c-e,d+f,a-e,b+f)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a<=b<0:
  if 
  print('Negative' if (-1)**(a-b-1)==-1 else 'Positive')
elif a<=0<=b:
  print('Zero')
else:
  print('Positive')

Fixed submission:
a,b=map(int,input().split())
if a<=b<0:
  print('Negative' if (-1)**(a-b-1)==-1 else 'Positive')
elif a<=0<=b:
  print('Zero')
else:
  print('Positive')
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
def prime_factors(N): #素因数 1を含まないことに注意
    ret = []
    middle = int( N**(1/2))
    tmp = N
    for i in range(2, middle+1):
        if tmp%i == 0:
            t = 1
            while tmp%i == 0:
                tmp //= i
                t *= i
            ret.append(t)
    if tmp != 1:
        ret.append(tmp)
    return ret

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def main():
    N = int( input())
    P = prime_factors(2*N)
    M = len(P)
    ans = 2*N-1
    for p in product( range(2), repeat=M):
        x = 1
        for i, t in enumerate(p):
            if t == 1:
                x *= P[i]
        y = N*2//x
        if x == 1:
            if y-1 < ans:
                ans = y-1
            continue
        if y == 1:
            if x-1 < ans:
                ans = x-1
            continue
        _, a, b = xgcd(x,y)
        now = -a*x
        # print(x, y, a, b)
        if a < 0:
            pass
        else:
            now = -b*y
        if now < ans:
            ans = now
    print(ans)
        
        
if __name__ == '__main__':
    main()


Fixed submission:
from itertools import product
def prime_factors(N): #素因数 1を含まないことに注意
    ret = []
    middle = int( N**(1/2))
    tmp = N
    for i in range(2, middle+1):
        if tmp%i == 0:
            t = 1
            while tmp%i == 0:
                tmp //= i
                t *= i
            ret.append(t)
    if tmp != 1:
        ret.append(tmp)
    return ret

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def main():
    N = int( input())
    # print("start")
    P = prime_factors(2*N)
    M = len(P)
    ans = 2*N-1
    # print(M)
    for p in product( range(2), repeat=M):
        x = 1
        for i, t in enumerate(p):
            if t == 1:
                x *= P[i]
        y = N*2//x
        if x == 1:
            if y-1 < ans:
                ans = y-1
            continue
        if y == 1:
            if x-1 < ans:
                ans = x-1
            continue
        _, a, b = xgcd(x,y)
        now = -a*x
        # print(x, y, a, b)
        if a < 0:
            pass
        else:
            now = -b*y
        if now < ans:
            ans = now
    print(ans)
        
        
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a
 
def union(A, x, y):
#    bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)だと無限ループ。
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

def main():
    N, Q = map( int, input().split())
    TUV = [ tuple( map( int, input().split())) for _ in range(Q)]
    G = [ i for i in range(N)]
    ANS = []
    for t, u, v in TUV:
        if t == 0:
            union(T,u,v)
        else:
            if find(T,u) == find(T,v):
                ANS.append(1)
            else:
                ANS.append(0)
    print("\n".join( map( str, ANS)))
        
if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a
 
def union(A, x, y):
#    bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)だと無限ループ。
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

def main():
    N, Q = map( int, input().split())
    TUV = [ tuple( map( int, input().split())) for _ in range(Q)]
    G = [ i for i in range(N)]
    ANS = []
    for t, u, v in TUV:
        if t == 0:
            union(G,u,v)
        else:
            if find(G,u) == find(G,v):
                ANS.append(1)
            else:
                ANS.append(0)
    print("\n".join( map( str, ANS)))
        
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import Counter
from numba import njit

@njit
def solve(S, C):
    if C["R"] == 3:
        print(3)
    elif C["R"] == 2:
        if S[1] == "S":
            print(1)
        else:
            print(2)
    elif C["R"] == 1:
        print(1)
    else:
        print(0)

def main():
    S = input()
    C = Counter(S)
    solve(S,C)
    
if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter
def main():
    S = input()
    C = Counter(S)
    if C["R"] == 3:
        print(3)
    elif C["R"] == 2:
        if S[1] == "S":
            print(1)
        else:
            print(2)
    elif C["R"] == 1:
        print(1)
    else:
        print(0)
        
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
def solve(P, C, K, Checked, s):
    B = []
    B.append( C[s])
    now = P[s]
    Checked[s] = True
    while now != s:
        B.append(C[now])
        Checked[now] = True
        now = P[now]
    sumB = sum(B)
    L = len(B)
    accB = [0] + list( accumulate(B))
    ret = B[0]
    for i in range(L):
        for j in range(i+1,L+1):
            if j - i > K:
                continue
            if accB[j] - accB[i] > ret:
                ret = accB[j] - accB[i]
    accRB = [0] + list( accumulate(B[::-1]))
    # print(B, accB, accRB)
    # print(ret)
    for i in range(L+1):
        for j in range(L+1):
            if i==0 and j==0:
                continue
            if i + j > K:
                continue
            t = accB[i] + accRB[j]
            if sumB > 0:
                t += (K-(i+j))//L*sumB
            if t > ret:
                ret = t
                # print(i,j,ret)
    return ret
        
    
def main():
    N, K = map( int, input().split())
    P = list( map( lambda x: int(x)-1, input().split()))
    C = list( map( int, input().split()))
    Checked = [False]*N
    ans = C[0]
    for s in range(N):
        if Checked[s]:
            continue
        ans_s = solve(P, C, K, Checked, s)
        if ans_s > ans:
            ans = ans_s
    print(ans)
if __name__ == '__main__':
    main()


Fixed submission:
from itertools import accumulate
def solve(P, C, K, Checked, s):
    B = []
    B.append( C[s])
    now = P[s]
    Checked[s] = True
    while now != s:
        B.append(C[now])
        Checked[now] = True
        now = P[now]
    sumB = sum(B)
    L = len(B)
    accB = [0] + list( accumulate(B))
    ret = B[0]
    for i in range(L):
        for j in range(i+1,L+1):
            if j - i > K:
                continue
            if accB[j] - accB[i] > ret:
                ret = accB[j] - accB[i]
    accRB = [0] + list( accumulate(B[::-1]))
    # print(B, accB, accRB)
    # print(ret)
    for i in range(L+1):
        for j in range(L+1):
            if i==0 and j==0:
                continue
            if i + j > K:
                continue
            t = accB[i] + accRB[j]
            if sumB > 0:
                t += (K-(i+j))//L*sumB
            if t > ret:
                ret = t
                # print(i,j,ret)
    return ret
        
    
def main():
    N, K = map( int, input().split())
    P = list( map( lambda x: int(x)-1, input().split()))
    C = list( map( int, input().split()))
    Checked = [False]*N
    ans = C[0]
    for s in range(N):
        if Checked[s]:
            continue
        ans_s = solve(P, C, K, Checked, s)
        if ans_s > ans:
            ans = ans_s
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    R, C, K = map( int, input().split())
    V = [[0]*C for _ in range(R)]
    for _ in range(K):
        r, c, v = map( int, input().split())
        V[r-1][c-1] = v
    dp0 = [[0]*(C+1) for _ in range(R+1)]
    dp1 = [[0]*(C+1) for _ in range(R+1)]
    dp2 = [[0]*(C+1) for _ in range(R+1)]
    dp3 = [[0]*(C+1) for _ in range(R+1)]
    for r in range(1,R+1):
        m = 0
        for c in range(1,C+1):
            m = max(m,dp0[r-1][c], dp1[r-1][c], dp2[r-1][c], dp3[r-1][c])
            dp0[r][c] = max(m, dp0[r][c-1])
            dp1[r][c] = max(dp1[r][c-1], dp0[r][c]+V[r-1][c-1])
            dp2[r][c] = max(dp2[r][c-1], dp1[r][c-1]+V[r-1][c-1])
            dp3[r][c] = max(dp3[r][c-1], dp2[r][c-1]+V[r-1][c-1])
    # print(dp0)
    # print(dp1)
    # print(dp2)
    # print(dp3)
    print( max( max(dp0[R]), max(dp1[R]), max(dp2[R]), max(dp3[R])))
if __name__ == '__main__':
    main()


Fixed submission:
def main():
    R, C, K = map( int, input().split())
    V = [[0]*C for _ in range(R)]
    for _ in range(K):
        r, c, v = map( int, input().split())
        V[r-1][c-1] = v
    dp0 = [[0]*(C+1) for _ in range(R+1)]
    dp1 = [[0]*(C+1) for _ in range(R+1)]
    dp2 = [[0]*(C+1) for _ in range(R+1)]
    dp3 = [[0]*(C+1) for _ in range(R+1)]
    for r in range(1,R+1):
        m = 0
        for c in range(1,C+1):
            m = max(m,dp0[r-1][c], dp1[r-1][c], dp2[r-1][c], dp3[r-1][c])
            dp0[r][c] = max(m, dp0[r][c-1])
            dp1[r][c] = max(dp1[r][c-1], dp0[r][c]+V[r-1][c-1])
            dp2[r][c] = max(dp2[r][c-1], dp1[r][c-1]+V[r-1][c-1])
            dp3[r][c] = max(dp3[r][c-1], dp2[r][c-1]+V[r-1][c-1])
    # print(dp0)
    # print(dp1)
    # print(dp2)
    # print(dp3)
    print( max( max(dp0[R]), max(dp1[R]), max(dp2[R]), max(dp3[R])))
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def fact2(a, b):
    c2 = 0
    c5 = 0
    while a%2 == 0:
        a //= 2
        c2 += 1
    while a%5 == 0:
        a //= 5
        c5 += 1
    return min(c2-b, 9), min(c5-b,9)

def main():
    N = int( input())
    A2 = [0]*N
    A5 = [0]*N
    AS = [0]*N
    for i in range(N):
        a = input()
        if '.' in a:
            b, c = a.split('.')
            if int(c) == 0:
                pass
            else:
                c = chr( int(c))
                AS[i] = len(c)
                b += c
        else:
            b = a
        # A2[i], A5[i] = fact( int(b))
        # print(b)
        A2[i], A5[i] = fact2( int(b), AS[i])

    R = [ [0]*19 for _ in range(19)]
    for i in range(N):
        a, b = A5[i]+9, A2[i]+9
        R[a][b] += 1
    AR = [ [0]*19 for _ in range(19)]
    for i in range(18,-1,-1):
        for j in range(17,-1,-1):
            R[i][j] = R[i][j] + R[i][j+1]
    for j in range(18):
        for i in range(17,-1,-1):
            R[i][j] += R[i+1][j]
    ans = 0
    # print("\n".join( [" ".join( map( str, a)) for a in AR]))
    for k in range(N):
        i, j = A5[k], A2[k]
        if i <= 9 and j <= 9:
            ans += R[-i+9][-j+9]
            # print(-i+9,-j+9)
        if AS[k] == 0:
            ans -= 1
    print(ans//2)

# 2
# 10.73741824 
# 3051.7578125
# 2**30, 2**15

if __name__ == '__main__':
    main()


Fixed submission:
def fact2(a, b):
    c2 = 0
    c5 = 0
    while a%2 == 0:
        a //= 2
        c2 += 1
    while a%5 == 0:
        a //= 5
        c5 += 1
    return min(c2-b, 9), min(c5-b,9)

def main():
    N = int( input())
    A2 = [0]*N
    A5 = [0]*N
    AS = [0]*N
    for i in range(N):
        a = input()
        if '.' in a:
            b, c = a.split('.')
            if int(c) == 0:
                pass
            else:
                AS[i] = len(c)
                b += c
        else:
            b = a
        # A2[i], A5[i] = fact( int(b))
        # print(b)
        A2[i], A5[i] = fact2( int(b), AS[i])

    R = [ [0]*19 for _ in range(19)]
    for i in range(N):
        a, b = A5[i]+9, A2[i]+9
        R[a][b] += 1
    AR = [ [0]*19 for _ in range(19)]
    for i in range(18,-1,-1):
        for j in range(17,-1,-1):
            R[i][j] = R[i][j] + R[i][j+1]
    for j in range(19):
        for i in range(17,-1,-1):
            R[i][j] += R[i+1][j]
    ans = 0
    # print("\n".join( [" ".join( map( str, a)) for a in AR]))
    for k in range(N):
        i, j = A5[k], A2[k]
        if i <= 9 and j <= 9:
            ans += R[-i+9][-j+9]
            # print(-i+9,-j+9)
        if AS[k] == 0:
            ans -= 1
    print(ans//2)

# 2
# 10.73741824 
# 3051.7578125
# 2**30, 2**15

if __name__ == '__main__':
    main()