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



Sample input:
5
7.5
2.4
17.000000001
17
16.000000000


Sample output:
3

Submission status: Runtime Error

Solution code:
def power_mod(a,b):
  ans = 0
  while not a%b:
    a=a//b
    ans += 1
  return ans

#print(power_mod(12,2))

N = int(input())
A = [int(float(input())*(10**9)) for _ in range(N)]

ta = [[0]*27 for _ in range(27)]
dp = [[0]*27 for _ in range(27)]

for a in A:
  m2 = power_mod(a,2)
  m5 = power_mod(a,5)
  ta[m2][m5] += 1
  dp[m2][m5] += 1
  
for i in range(26):
  dp[26][25-i] = dp[26][25-i] + dp[26][25-i]
  dp[25-i][26] = dp[25-i][26] + dp[25-i][26]
  
for i in range(26):
  for j in range(26):
    dp[25-i][25-j] = dp[25-i][25-j]+ dp[25-i][26-j] + dp[26-i][25-j] - dp[26-i][26-j]

#for t in ta:
#  print(t)
#for d in dp:
#  print(d)
  
ans = 0
for i in range(27):
  for j in range(27):
    #if ta[i][j]:
    #  print(i,j,ta[i][j],dp[max(0, 18-i)][max(0,18-j)],((i>8) and (j>8)))
    ans += ta[i][j] * (dp[max(0, 18-i)][max(0,18-j)] - ((i>8) and (j>8)))
    
print(ans//2)

Submission status: Runtime Error

Solution code:
cand = list(set([2**x * 5**y for x in range(18)
                 for y in range(8) if 2**x * 5**y <= 200000]))
cand.sort()


def f(n):
    cnt = 0
    while True:
        x = n * cand[cnt]
        if x.is_integer():
            return cand[cnt]
        else:
            cnt += 1


def div(n, bl=True):
    if bl and not n.is_integer():
        return (0, 0)
    else:
        n = int(n)
        two = format(n, 'b')[::-1].find('1')
        n = n >> two
        cnt = 0
        while n % 5 == 0:
            n //= 5
            cnt += 1
        return (two, cnt)


n = int(input())
arr = [float(input()) for _ in range(n)]

x = [div(x) for x in arr]
y = [div(x, False) for x in [f(x) for x in arr]]
z = [div(x * 2**y1 * 5**z, False) for x, (y1, z) in zip(arr, y)]


ans = 0
for i in range(len(y)):
    for j in range(i + 1, len(y)):
        (a, b), (c, d) = y[i], y[j]
        if a == 0 and b == 0 and c == 0 and d == 0:
            ans += 1
        elif a + c <= z[i][0] + z[j][0] and b + d <= z[i][1] + z[j][1]:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import math

cand = list(set([2**x * 5**y for x in range(18) for y in range(8) if 2**x * 5**y <= 200000]))
cand.sort()


def f(n):
    cnt = 0
    while True:
        x = n * cand[cnt]
        if x.is_integer():
            return cand[cnt]
        else:
            cnt += 1


def div(n, bl=True):
    if bl and not n.is_integer():
        return (0, 0)
    else:
        n = int(n)
        two = format(n, 'b')[::-1].find('1')
        n = n >> two
        cnt = 0
        while n % 5 == 0:
            n //= 5
            cnt += 1
        return (two, cnt)


n = int(input())
arr = [float(input()) for _ in range(n)]
arr = [x for x in arr if min(x - int(x), math.ceil(x) - x) >= 0.000005 or x == int(x)]

x = [div(x) for x in arr]
y = [div(x, False) for x in [f(x) for x in arr]]
z = [div(x * 2**y1 * 5**z, False) for x, (y1, z) in zip(arr, y)]


ans = 0
for i in range(len(y)):
    for j in range(i + 1, len(y)):
        (a, b), (c, d) = y[i], y[j]
        if a == 0 and b == 0 and c == 0 and d == 0:
            ans += 1
        elif a + c <= z[i][0] + z[j][0] and b + d <= z[i][1] + z[j][1]:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import bisect
from heapq import heappush, heappop
n = int(input())
a = []
for i in range(n):
    temp = float(input()) * (10**9)
    if temp%1 == 0:
        # print(temp)
        a.append(int(temp))
b = []
d = {0:0,1:0,2:0,3:0,4:0,5:0}
p = [[]for i in range(19)]
for i in a:
    cnt2 = 0
    cnt5 = 0
    while i%2 == 0:
        i //= 2
        cnt2 += 1
    while i%5 == 0:
        i //= 5
        cnt5 += 1
    p[min(19,cnt2)].append(-cnt5)
    # d[min(5,cnt5)] += 1
    # b.append([cnt2,cnt5])
# print(b)
# print(d)
ans = 0
for i in range(19):
    p[i] = sorted(p[i])
# print(p)
for i in range(19):
    while p[i]:
        t = p[i].pop()
        # print(t)
        # for j in p[i]:
        for k in range(max(0,18-i),19):
            # print(k,p[k],t,bisect.bisect_right(p[k],-18-t))
            ans += bisect.bisect_right(p[k],-18-t)
print(ans)
# for i in range(len(a)-1):
#     for j in range(i+1,len(a)):
#         if a[i] > 0 and a[j] > 0 and a[i]*a[j] %(10**8) == 0:
#             ans += 1
#             # print(a[i],a[j])
# print(ans)
# print(a)

Submission status: Runtime Error

Solution code:
cand = list(set([2**x * 5**y for x in range(18) for y in range(8) if 2**x * 5**y <= 200000]))
cand.sort()


def f(n):
    cnt = 0
    while True:
        x = n * cand[cnt]
        if x.is_integer():
            return cand[cnt]
        else:
            cnt += 1


def div(n, bl=True):
    if bl and not n.is_integer():
        return (0, 0)
    else:
        n = int(n)
        two = format(n, 'b')[::-1].find('1')
        n = n >> two
        cnt = 0
        while n % 5 == 0:
            n //= 5
            cnt += 1
        return (two, cnt)


n = int(input())
arr = [float(input()) for _ in range(n)]
arr = [x for x in arr if min(x - int(x), math.ceil(x) - x) >= 0.000005 or x == int(x)]

x = [div(x) for x in arr]
y = [div(x, False) for x in [f(x) for x in arr]]
z = [div(x * 2**y1 * 5**z, False) for x, (y1, z) in zip(arr, y)]


ans = 0
for i in range(len(y)):
    for j in range(i + 1, len(y)):
        (a, b), (c, d) = y[i], y[j]
        if a == 0 and b == 0 and c == 0 and d == 0:
            ans += 1
        elif a + c <= z[i][0] + z[j][0] and b + d <= z[i][1] + z[j][1]:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = float(input())
B=[]
for i in range(N):
    b_int, b_frac = str(A[i]).split(".")
    if len(str(b_frac))<=4:
        B.append(round(float(A[i])*(10**4)))
floatans=0
for i in range(len(B)):
    for j in range(i+1,len(B)):
        if (B[i]*B[j])%(10**8)==0:
            floatans+=1
print(floatans)

Submission status: Runtime Error

Solution code:
def how(c):
    if float(c).is_integer() == True:
        return int(float(c)),0
    else:
        dot=0
        while c[dot]!=".":
            dot+=1
        c = list(c)
        del c[dot]
        c ="".join(c)
        return int(c),len(c)-dot

def lo2(n):
    count = 0
    while n%2==0:
        n=n//2
        count+=1
    return count

def lo5(n):
    count=0
    while n%5==0:
        n=n//5
        count+=1
    return count

N = int(input())

A = []

for i in range(N):
    A.append(how(input()))


ruiseki = [[0]*80 for i in range(80)]

motoseisuu=0
for i in range(N):
    ruiseki[A[i][1]-lo2(A[i][0])+60][A[i][1]-lo5(A[i][0])+60]+=1
    if A[i][1]==0:
        motoseisuu +=1

for i in range(1,80):
    for j in range(1,80):
        ruiseki[i][j]=ruiseki[i-1][j]+ruiseki[i][j-1]-ruiseki[i-1][j-1]+ruiseki[i][j]


ans = 0
for i in range(N):
    ans+=ruiseki[lo2(A[i][0])+60-A[i][1]][lo5(A[i][0])+60-A[i][1]]

print((ans-motoseisuu)//2)

Submission status: Runtime Error

Solution code:
def solve(g,h,su):
    P=200003
    su=su+(g*h)%P
    return su

n=int(input())
l=list(map(int,input().split()))
su=0
for i in range(n-1):
    for j in range(i+1,n):
        su=solve(l[i],l[j],su)    
print(su)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

bool is_int(long double v) {
  return (floor(v) == v);
}


pair<int, int> foo(long double input)
{
#if 0
    long double integral = floor(input);
    long double frac = input - integral;
    int precision = 1e10;
    int v = frac * precision;
    int gcd_ = gcd(v, precision);

    int denominator = precision / gcd_;
    int numerator = integral * denominator + round(frac * precision) / gcd_;
    pair<int, int> p = {numerator, denominator};
#endif
    pair<int, int> p = {1, 1};
    return p;
}

signed main() {
  int N; cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; ++i) {
    long double x; cin >> x;
    A[i] = foo(x);
  }
  sort(A.rbegin(), A.rend());

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      auto [n1, d1] = A[i];
      auto [n2, d2] = A[j];
      if (n1 % d2 == 0 && n2 % d1 == 0) ++cnt;
      if (n2 < d1) break;
    }
  }
  cout << cnt << endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

bool is_int(long double v) {
  return (floor(v) == v);
}


pair<int, int> foo(long double input)
{
    long double integral = floor(input);
    long double frac = input - integral;
    int precision = 1e10;
    int v = frac * precision;
#if 0
    int gcd_ = gcd(v, precision);

    int denominator = precision / gcd_;
    int numerator = integral * denominator + round(frac * precision) / gcd_;
    pair<int, int> p = {numerator, denominator};
#endif
    pair<int, int> p = {1, 1};
    return p;
}

signed main() {
  int N; cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; ++i) {
    long double x; cin >> x;
    A[i] = foo(x);
  }
  sort(A.rbegin(), A.rend());

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      auto [n1, d1] = A[i];
      auto [n2, d2] = A[j];
      if (n1 % d2 == 0 && n2 % d1 == 0) ++cnt;
      if (n2 < d1) break;
    }
  }
  cout << cnt << endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

bool is_int(long double v) {
  return (floor(v) == v);
}


pair<int, int> foo(long double input)
{
    long double integral = floor(input);
    long double frac = input - integral;
    int precision = 1e10;
    int v = frac * precision;
    int gcd_ = gcd(v, precision);
#if 0

    int denominator = precision / gcd_;
    int numerator = integral * denominator + round(frac * precision) / gcd_;
    pair<int, int> p = {numerator, denominator};
#endif
    pair<int, int> p = {1, 1};
    return p;
}

signed main() {
  int N; cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; ++i) {
    long double x; cin >> x;
    A[i] = foo(x);
  }
  sort(A.rbegin(), A.rend());

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      auto [n1, d1] = A[i];
      auto [n2, d2] = A[j];
      if (n1 % d2 == 0 && n2 % d1 == 0) ++cnt;
      if (n2 < d1) break;
    }
  }
  cout << cnt << endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy

def process(num):
    cnt_2 = 0
    cnt_5 = 0

    while num%2 == 0:
        num = num//2
        cnt_2 += 1
    
    while num%5 == 0:
        num = num//5
        cnt_5 += 1
    
    return cnt_2-15, cnt_5-15
    # return min(9,cnt_2-9), min(9,cnt_5-9)


def solve(lst):  # fix inputs here
    console("----- solving ------")

    grid = [[0 for _ in range(30)] for _ in range(30)]

    console(lst)
    for num in lst:
        x,y = process(num)
        console(x,y)
        grid[x+15][y+15] += 1
    # return a string (i.e. not a list or matrix)

    # console(np.array(grid))

    res = 0

    for i in range(-14,14):
        for j in range(-14,14):
            smaller_cnt = 0
            # smaller_cnt -= grid[10+i][10+j]
            for x in range(15-i,30):
                for y in range(15-j,30):
                    smaller_cnt += grid[x][y]
            # val = grid[10+i][10+j] * smaller_cnt + (grid[10+i][10+j] * (grid[10+i][10+j] - 1))
            if i >= 0 and j >= 0:
                val = grid[15+i][15+j] * (smaller_cnt - grid[15+i][15+j]) 
                val += (grid[15+i][15+j] * (grid[15+i][15+j]-1))
            else:
                val = (grid[15+i][15+j]) * smaller_cnt
            if val != 0:
                console(i,j,smaller_cnt,val)
            # val = max(0,val)
            res += val
    console(res)
    return res//2


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

# for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
nrows = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    # lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
grid = []
for _ in range(nrows):
    grid.append(10**6 * int(10**9 * float(input())))

res = solve(grid)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
print(res)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

bool is_int(long double v) {
  return (floor(v) == v);
}


pair<int, int> foo(long double input)
{
    long double integral = floor(input);
    long double frac = input - integral;
    int precision = 1e10;
    int v = frac * precision;
    int gcd_ = gcd(v, precision);

    int denominator = precision / gcd_;
    int numerator = integral * denominator + round(frac * precision) / gcd_;
    pair<int, int> p = {numerator, denominator};
    return p;
}

signed main() {
  int N; cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; ++i) {
    long double x; cin >> x;
    A[i] = foo(x);
  }
  sort(A.rbegin(), A.rend());

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      auto [n1, d1] = A[i];
      auto [n2, d2] = A[j];
      if (n1 % d2 == 0 && n2 % d1 == 0) ++cnt;
      if (n2 < d1) break;
    }
  }
  cout << cnt << endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
from collections import defaultdict
import sys

input = sys.stdin.buffer.readline

n = int(input())
jisho = defaultdict(int)
for _ in range(n):
    s = input()
    if int(float(s)) == float(s):
        num = int(float(s))
        cnt2 = 0
        cnt5 = 0
    else:
        a, b = s.split(".")
        keta = len(b)
        cnt2 = -keta
        cnt5 = -keta
        a = int(a)
        b = int(b)
        num = a * pow(10, keta) + b
    while True:
        if num % 5 == 0:
            num //= 5
            cnt5 += 1
        else:
            break
    while True:
        if num % 2 == 0:
            num //= 2
            cnt2 += 1
        else:
            break
    if cnt5 <= -11 or cnt2 <= -11:
        continue
    cnt2 = min(10, cnt2)
    cnt5 = min(10, cnt5)
    jisho[(cnt2, cnt5)] += 1
ans = 0
for i in range(21):
    i -= 10
    for j in range(21):
        j -= 10
        kouho1 = jisho[(i, j)]
        if kouho1 == 0:
            continue
        for k in range(21):
            k -= 10
            for l in range(21):
                l -= 10
                kouho2 = jisho[(k, l)]
                if kouho2 == 0:
                    continue

                if i + k >= 0 and j + l >= 0:
                    if (i, j) == (k, l):
                        ans += kouho1 * (kouho2 - 1)
                    else:
                        ans += kouho1 * kouho2

print(ans // 2)

Submission status: Runtime Error

Solution code:
import numpy as np
n=int(input())
a=[]
b=[]
c=[]
z=0
for i in range(n):
  tempa=input().split(".")
  if(len(tempa)==1):
    z=z+1
    a.append(int(tempa[0]))
  else:
    ta=int(tempa[1])
    if ta==0:
      z=z+1
      a.append(int(tempa[0]))
    else:
      b.append(int("".join(tempa)))
      c.append(10**len(tempa[1]))
nz=n-z
r=n*(n-1)//2
fz=nz*z
a=np.array(a)
b=np.array(b)
c=np.array(c)
oab=np.outer(a,b)
fz=fz-np.count_nonzero(oab%c==0)
for j in range(nz-1):
  for k in range(j+1,nz):
    tempb=b[j]*b[k]
    tempc=c[j]*c[k]
    if (tempb % tempc) >0:
      fz=fz+1
print(r-fz)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

bool is_int(long double v) {
  return (floor(v) == v);
}


long mygcd(long a, long b) {
    if (a == 0)
        return b;
    else if (b == 0)
        return a;

    if (a < b)
        return gcd(a, b % a);
    else
        return gcd(b, a % b);
}

pair<int, int> foo(double input)
{
    long double integral = std::floor(input);
    long double frac = input - integral;
    const long precision = 1e9; // This is the accuracy.
    int gcd_ = mygcd(round(frac * precision), precision);

    int denominator = precision / gcd_;
    int numerator = integral * denominator + round(frac * precision) / gcd_;
    pair<int, int> p = {numerator, denominator};
    return p;
}

signed main() {
  int N; cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; ++i) {
    long double x; cin >> x;
    A[i] = foo(x);
  }
  sort(A.rbegin(), A.rend());

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      auto [n1, d1] = A[i];
      auto [n2, d2] = A[j];
      if (n1 % d2 == 0 && n2 % d1 == 0) ++cnt;
      if (n2 < d1) break;
    }
  }
  cout << cnt << endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
import sys
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
cnt = [[0 for _ in range(20)] for _ in range(20)]
ans = 0
for _ in range(n):
	a = input()
	x, y = 0, 0
	if "." in a:
		i = len(a)-1
		while a[i] != ".":
			i -= 1
			x, y = x-1, y-1
		b = int(a[:i] + a[i+1:])
	else:
		b = int(a)
	#print(b)
	while b%2 == 0 and x < 19:
		x += 1
		b //= 2
	while b%5 == 0 and y < 19:
		y += 1
		b //= 5
	print(x, y)
	x, y = x+9, y+9
	for i in range(18-x, 20):
		for j in range(18-y, 20):
			ans += cnt[i][j]
	cnt[x][y] += 1
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
 
# 浮動小数点の入力
num_list = []
for i in range(a):
  num_list.append(double(input()))
 
count = 0
for i, v_i in enumerate(num_list):
  for j, v_j in enumerate(num_list):
    if i < j:
      if isinstance(v_i*v_j, int):
        count += 1
 
# 出力
print("{}".format(int(count/2)))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math
import bisect

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = [round(float(input())*10**9) for i in range(n)]
c = Counter([i%10**9 for i in a])
ans = 0

for i in c:
	if i!=0:
		for j in range(0,len(a)):
			if i*a[j]%10**18==0:
				ans+=1

c1 = (math.factorial(2)*math.factorial(c[0]-2))
if c1!=0:
	c1 = math.factorial(c[0])//c1

print(ans+c1)

Submission status: Runtime Error

Solution code:
def main():
    from sys import stdin
    from decimal import Decimal
    import numpy as np
    # read
    readline = stdin.readline
    n = int(readline())
    a = [Decimal(readline()) for _ in range(n)]
    a = np.array(a)
    count = 0
    for i in range(n - 1):
        b = a[i + 1:]
        count = count + np.count_nonzero((b * a[i]) % 1 == 0)
    print(count)


main()

Submission status: Runtime Error

Solution code:
N = int(input())
l=[(0,0)]*N
fint=[False]*N
ans = 0
DMOD=10**9

for i in range(N):
    s=input()
    if '.' in s:
        idx = s.index('.')
        ndec=len(s)-1 - idx
        ai = int(s[:idx])
        ad = int(s[idx+1:])
        ad *= 10**(9-ndec)
        fint_i=False
    else:
        ad = 0
        ai = int(s)
        fint_i=True
    fint[i] = fint_i
    l[i]=(ai,ad)
    for j in range(i):
        ai_j,ad_j = l[j]
        fint_j = fint[j]

        if fint_i and fint_j:
            ans += 1
            continue
        a1=ad*ad_j
        c=a1//DMOD
        a1%=DMOD
        a2=ai*ad_j + c
        a2%=DMOD
        a2+=(ad*ai_j)%MOD
        a2%=DMOD
        if a1==0 and a2 == 0:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

int_cnt = 0
int_25 = [[0 for _ in range(10)] for _ in range(10)]
int_10 = [0 for _ in range(10)]
float_25 = [[0 for _ in range(11)] for _ in range(11)]
float_10 = [0 for _ in range(10)]
float22 = [0 for _ in range(10)]
float55 = [0 for _ in range(10)]

for _ in range(n):
    a = float(input())
    if a % 1 == 0:
        int_cnt += 1
        num = a
        cnt = 0
        while num % 10 == 0:
            cnt += 1
            num //= 10
        int_10[cnt] += 1
        num = a
        cnt2 = 0
        while num % 2 == 0:
            cnt2 += 1
            num //= 2
        num = a
        cnt5= 0
        while num % 5 == 0:
            cnt5 += 1
            num //= 5
        int_25[cnt2][cnt5] += 1
    else:
        a *= 10 ** 9
        a = int(a)
        num = a
        cnt = 9
        while num % 10 == 0:
            cnt -= 1
            num //= 10
        float_10[cnt] += 1
        num = a
        cnt = 9
        while num % 2 == 0:
            cnt -= 1
            num //= 2
        if cnt >= 0:
            cnt2 = cnt
        else:
            cnt2 = 0
            cnt = abs(cnt)
            cnt = min(cnt, 9)
            float22[cnt] += 1
        num = a
        cnt = 9
        while num % 5 == 0:
            cnt -= 1
            num //= 5
        if cnt >= 0:
            cnt5 = cnt
        else:
            cnt5 = 0
            cnt = abs(cnt)
            cnt = min(cnt, 9)
            float55[cnt] += 1
        float_25[cnt2][cnt5] += 1

ans = int_cnt * (int_cnt - 1) // 2

for i in range(10):
    for j in range(10):
        for k in range(i + 1):
            for l in range(j + 1):
                ans += int_25[i][j] * float_25[k][l]

for i in range(1, 10):
    for j in range(1, 10):
        ans += float22[i] * float55[j]


print(ans)

Submission status: Runtime Error

Solution code:
import sys
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
cnt = [[0 for _ in range(15)] for _ in range(15)]
ans = 0
for _ in range(n):
	a = input()
	x, y = 0, 0
	if "." in a:
		i = len(a)-1
		while a[i] != ".":
			i -= 1
			x, y = x-1, y-1
		b = int(a[:i] + a[i+1:])
	else:
		b = int(a)
	while b%2 == 0 and b > 0:
		x += 1
		b //= 2
	while b%5 == 0 and b > 0:
		y += 1
		b //= 5
	#print(x, y)
	x, y = x+9, y+9
	for i in range(18-x, 15):
		for j in range(18-y, 15):
			ans += cnt[i][j]
	cnt[x][y] += 1
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
 
# 浮動小数点の入力
num_list = []
for i in range(a):
  num_list.append(double(input()))
 
count = 0
for i in num_list:
  for j in num_list:
    if i < j:
      if isinstance(i*j, int):
        count += 1
 
# 出力
print("{}".format(int(count/2)))

Submission status: Runtime Error

Solution code:
n = int(input())
cnt = [[0 for _ in range(15)] for _ in range(15)]
ans = 0
for _ in range(n):
	a = input()
	x, y = 0, 0
	if "." in a:
		i = len(a)-1
		while a[i] != ".":
			i -= 1
			x, y = x-1, y-1
		b = int(a[:i] + a[i+1:])
	else:
		b = int(a)
	while b%2 == 0:
		x += 1
		b //= 2
	while b%5 == 0:
		y += 1
		b //= 5
	#print(x, y)
	x, y = x+9, y+9
	for i in range(18-x, 15):
		for j in range(18-y, 15):
			ans += cnt[i][j]
	cnt[x][y] += 1
print(ans)

Submission status: Runtime Error

Solution code:
import copy
n = int(input())
l = []
for i in range(n):
    a = str(input())
    if "." not in a:
        l.append(float(a))
    else:
        dot = a.index(".")
        if len(a)-dot-1 <= 4:
            l.append(float(a))
        else:
            flag = 1
            for j in range(dot+5,len(a)):
                if a[j] != "0":
                    flag = 0
            if flag: l.append(float(a)) 
n = len(l)
a = [int(l[i]*10**4) for i in range(n)]
memo = [[0,0] for _ in range(n)]
for i in range(n):
    t = a[i]
    while t%2 == 0:
        t //= 2
        memo[i][0] += 1
    while t%5 == 0:
        t //= 5
        memo[i][1] += 1
a.sort()
memo.sort()
mem2 = [[0]*9 for _ in range(9)]
p = 0
for i in range(n):
    if memo[i][0] >= 8 and memo[i][1] >= 8:
        p += 1
    else:
        mem2[memo[i][0]][memo[i][1]] += 1
mems = copy.deepcopy(mem2)


for i in range(8,-1,-1):
    for j in range(7,-1,-1):
        mems[i][j] += mems[i][j+1]
for i in range(7,-1,-1):
    for j in range(8,-1,-1):
        mems[i][j] += mems[i+1][j]

s = 0
for i in range(9):
    for j in range(9):
        if i >= 4 and j >= 4:
            s += mem2[i][j] * (mems[8-i][8-j]-1)
        else:
            s += mem2[i][j] * mems[8-i][8-j]
s = s//2
s += p*(p-1)//2+p*(n-p)
print(s)

Submission status: Runtime Error

Solution code:
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy

def process(num):
    cnt_2 = 0
    cnt_5 = 0

    while num%2 == 0:
        num = num//2
        cnt_2 += 1
    
    while num%5 == 0:
        num = num//5
        cnt_5 += 1
    
    return cnt_2-9, cnt_5-9


def solve(lst):  # fix inputs here
    console("----- solving ------")

    grid = [[0 for _ in range(20)] for _ in range(20)]

    console(lst)
    for num in lst:
        x,y = process(num)
        console(x,y)
        grid[x+10][y+10] += 1
    # return a string (i.e. not a list or matrix)

    # console(np.array(grid))

    res = 0

    for i in range(-9,9):
        for j in range(-9,9):
            smaller_cnt = 0
            # smaller_cnt -= grid[10+i][10+j]
            for x in range(10-i,20):
                for y in range(10-j,20):
                    smaller_cnt += grid[x][y]
            # val = grid[10+i][10+j] * smaller_cnt + (grid[10+i][10+j] * (grid[10+i][10+j] - 1))
            if i >= 0 and j >= 0:
                val = grid[10+i][10+j] * (smaller_cnt - grid[10+i][10+j]) 
                val += (grid[10+i][10+j] * (grid[10+i][10+j]-1))
            else:
                val = (grid[10+i][10+j]) * smaller_cnt
            if val != 0:
                console(i,j,smaller_cnt,val)
            # val = max(0,val)
            res += val
    console(res)
    return res//2


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

# for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
nrows = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    # lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
grid = []
for _ in range(nrows):
    grid.append(int(10**9 * float(input())))

res = solve(grid)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
print(res)

Submission status: Runtime Error

Solution code:
import sys
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
cnt = [[0 for _ in range(15)] for _ in range(15)]
ans = 0
for _ in range(n):
	a = input()
	x, y = 0, 0
	if "." in a:
		i = len(a)-1
		while a[i] != ".":
			i -= 1
			x, y = x-1, y-1
		b = int(a[:i] + a[i+1:])
	else:
		b = int(a)
	while b%2 == 0:
		x += 1
		b //= 2
	while b%5 == 0:
		y += 1
		b //= 5
	#print(x, y)
	x, y = x+9, y+9
	for i in range(18-x, 15):
		for j in range(18-y, 15):
			ans += cnt[i][j]
	cnt[x][y] += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
cnt = [[0 for _ in range(15)] for _ in range(15)]
ans = 0
for _ in range(n):
	a = input()
	x, y = 0, 0
	if "." in a:
		i = len(a)-1
		while a[i] != ".":
			i -= 1
			x, y = x-1, y-1
		b = int(a[:i] + a[i+1:])
	else:
		b = int(a)
	while b%2 == 0:
		x += 1
		b //= 2
	while b%5 == 0:
		y += 1
		b //= 5
	#print(x, y)
	x, y = x+9, y+9
	for i in range(18-x, 15):
		for j in range(18-y, 15):
			ans += cnt[i][j]
	cnt[x][y] += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
integer = []
decimal = []
cnt = 0

for i in range(n):
  f = float(input())
  if f.is_integer():
    integer += [f]
  else:
    _f = f*10000
    if _f.is_integer():
      decimal += [f]

cnt += math.factorial(len(integer)-1)

for i in decimal:
  for j in integer:
    tmp = i*j
    if tmp.is_integer():
      cnt += 1
  for j in decimal:
    tmp = i*j
    if tmp.is_integer():
      cnt += 1
      

print(cnt)