Problem:
Score : 300 points

Problem 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.

Constraints

2 \leq N \leq 200\,000

0 < A_i < 10^4

A_i is given with at most 9 digits after the decimal.

Input

Input is given from Standard Input in the following format.

N
A_1
A_2
\vdots
A_N

Output

Print the number of pairs with integer product A_i \cdot A_j (and i < j).

Sample Input 1

5
7.5
2.4
17.000000001
17
16.000000000

Sample Output 1

3

There are 3 pairs with integer product:

7.5 \cdot 2.4 = 18

7.5 \cdot 16 = 120

17 \cdot 16 = 272

Sample Input 2

11
0.9
1
1
1.25
2.30000
5
70
0.000000001
9999.999999999
0.999999999
1.000000001

Sample Output 2

8

Solution in C++ (GCC 9.2.1) (judge verdict: Runtime Error)

#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void solve() {
    int n;
    cin >> n;
    long double eps = 1e-60;
    // cout << eps << endl;
    // stod
    VVI cnt(21,VI(9));
    string s;
    REP(i,0,n) {
        cin >> s;
        if (s.find('.') == string::npos) {
            int v = stoi(s);
            VI c(2);
            while (v > 0 && v % 2 == 0) {
                c[0]++;
                v /= 2;
            }
            while (v > 0 && v % 5 == 0) {
                c[1]++;
                v /= 5;
            }
            cnt[c[0]+10][c[1]+4]++;
            continue;
        }
        LL v = stol(s.substr(0,s.find('.')));
        string t = s.substr(s.find('.')+1);
        REP(j,0,t.size()) v *= 10;
        // cout << v << endl;
        // cout << t << endl;
        // cout << stoi(t) << endl;
        v += stoi(t);
        // cout << v << endl;
        int mi = t.size();
        VI c(2);
        while (v > 0 && v % 2 == 0) {
            c[0]++;
            v /= 2;
        }
        while (v > 0 && v % 5 == 0) {
            c[1]++;
            v /= 5;
        }
            // cnt[c[0]+10][c[1]+4]++;
        if (c[0]-mi+10 >= 0 && c[1]-mi+4 >= 0) cnt[c[0]-mi+10][c[1]-mi+4]++;
    }
    LL ans = 0;
    REP(i,0,21) REP(j,0,9) {
        REP(k,0,21) REP(l,0,9) {
            if (i + k < 20 || j + l < 8) continue;
            ans += 1LL * cnt[i][j] * cnt[k][l];
            if (i == k && j == l) ans -= cnt[i][j];
            // if (1LL * cnt[i][j] * cnt[k][l]) {
            //     cerr << i << ", " << j << ", " << k << ", " << l << endl;
            // }
        }
        
        // if (cnt[i][j]) {
        //     cerr << i << ", " << j << ": " << cnt[i][j] << endl;
        //     dump(ans);
        // }
    }

    ans /= 2;
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}