output_description: Print the number of pairs with integer product A_i \cdot A_j (and i < j).
  
  * * *
input_description: Input is given from Standard Input in the following format.
  
      
      
      N
      A_1
      A_2
      \vdots
      A_N
attempt: #!/usr/bin/env python3
  
  # A - Integer Product
  
  from math import gcd
  from collections import Counter
  
  
  def parse(s):
      """小数点付き数字列をパース"""
      p = s.find(".")
      i, f = (s[:p], s[p + 1 :]) if p >= 0 else (s, "")
      n = int(i + f)  # 分子 = 小数点なし数字列
      d = 10 ** len(f)  # 分母 = 10のべき乗
      g = gcd(n, d)
      return (n // g, d // g)  # 約分して返す
  
  
  n = int(input())
  a = [parse(input()) for _ in range(n)]
  
  MAX_FLEN = 9  # 小数部の長さ
  
  
  def twofive(x):
      """素因数2と5の個数を返す"""
      store = {}
      for d in (2, 5):
          store[d] = 0
          while x % d == 0:
              store[d] += 1
              x //= d
      return (store[2], store[5])
  
  
  frac = [twofive(n) + twofive(d) for n, d in a]
  frac = [(min(MAX_FLEN, n1), min(MAX_FLEN, d1), n2, d2) for n1, d1, n2, d2 in frac]
  count = Counter(frac)
  
  # count[(a, b, c, d)] = a' >= a and b' >= b and c' <= c and d' <= d
  #                       である (a', b', c', d') の個数
  
  for a in range(MAX_FLEN, -1, -1):
      for b in range(MAX_FLEN, -1, -1):
          for c in range(MAX_FLEN + 1):
              for d in range(MAX_FLEN + 1):
                  count[(a, b, c, d)] = (
                      count[(a, b, c, d)]
                      + count[(a + 1, b, c, d)]
                      + count[(a, b + 1, c, d)]
                      + count[(a, b, c - 1, d)]
                      + count[(a, b, c, d - 1)]
                      - count[(a + 1, b + 1, c, d)]
                      - count[(a + 1, b, c - 1, d)]
                      - count[(a + 1, b, c, d - 1)]
                      - count[(a, b + 1, c - 1, d)]
                      - count[(a, b + 1, c, d - 1)]
                      - count[(a, b, c - 1, d - 1)]
                      + count[(a + 1, b + 1, c - 1, d)]
                      + count[(a + 1, b + 1, c, d - 1)]
                      + count[(a + 1, b, c - 1, d - 1)]
                      + count[(a, b + 1, c - 1, d - 1)]
                      - count[(a + 1, b + 1, c - 1, d - 1)]
                  )
  
  # 数(a1, b1, c1, d1)と(a2, b2, c2, d2)の積が整数
  # <-> a2 >= c1 and b2 >= d2 and c2 <= a1 and d2 <= b1
  
  s = sum(count[(c, d, a, b)] - (1 if c == d == 0 else 0) for a, b, c, d in frac)
  print(s // 2)
  
problem_description: 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.
samples: [{"input": "5\n    7.5\n    2.4\n    17.000000001\n    17\n    16.000000000", "output": "3\n    \n\nThere are 3 pairs with integer product:\n\n  * 7.5 \\cdot 2.4 = 18\n  * 7.5 \\cdot 16 = 120\n  * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n    0.9\n    1\n    1\n    1.25\n    2.30000\n    5\n    70\n    0.000000001\n    9999.999999999\n    0.999999999\n    1.000000001", "output": "8"}]