Suitable pairs
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
We call a pair of non-negative integers suitable if there is at least one common digit in their decimal notation (not necessarily in the same digit). Let there be given n non-negative numbers a[1]
, a[2]
, ..., a[n]
. Consider all possible pairs (a[i]
, a[j]
) (1 ≤ i < j ≤ n).
Write a program that will determine the number of all suitable pairs.
Input
The first line contains positive integer n, not greater than 10^6
. Second line contains n nonnegative integers, not greater 999.
Output
Print the number of suitable pairs.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 581
Acceptance rate 18%