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 <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, double>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 200
#define offset 80
int bit2d[tam+20][tam+20];
ll tot=0;
int update(int posi,int posj)
{
	for(int i=posi;i<tam;i+=i&(-i))
	{
		for(int j=posj;j<tam;j+=j&(-j))
		{
			bit2d[i][j]++;
		}
	}
}
int query(int posi,int posj)
{
	int tot=0;
	for(int i=posi;i>0;i-=i&(-i))
	{
		for(int j=posj;j>0;j-=j&(-j))
		{
			tot+=bit2d[i][j];
		}
	}
	return tot;
}
void go(string txt)
{

	ll valor=0;
	bool valid=0;
	int pos=0;
	forr(i,0,txt.size())
	{
		if (txt[i]=='.'){
			valid=1;
			continue;
		}
		if (valid)
			pos++;
		valor*=10;
		valor+=(txt[i]-'0');
	}	
	//cout<<valor<<" ";
	int c2,c5;
	c2=c5=0;
	while(valor%2==0)
		valor/=2,c2++;
	while(valor%5==0)
		valor/=5,c5++;
	//cout<<c2<<" "<<c5<<endl;
	int cant2=c2-pos,cant5=c5-pos;

	tot+=query(tam-1,tam-1)-(query(offset-cant2-1,tam-1)+query(tam-1,offset-cant5-1)-query(offset-cant2-1,offset-cant5-1));
	//cout<<query(tam-1,tam-1)<<" "<<(query(offset-cant2,tam-1)+query(tam-1,offset-cant5)-query(offset-cant2,offset-cant5))<<endl;
	//cout<<tot<<" "<<cant2<<" "<<cant5<<endl;
	update(offset+cant2,offset+cant5);
}
int main()
{
	int n;
	cin>>n;
	string num;
	forr(i,0,n)
	{
		cin>>num;
		go(num);
	}
	cout<<tot<<endl;
}