#C7978. Digit Sum Pairs

    ID: 51908 Type: Default 1000ms 256MiB

Digit Sum Pairs

Digit Sum Pairs

Given a list of integers, your task is to count the maximum number of unique pairs such that both numbers in each pair have equal digit sums. Each integer can be used at most once for pairing. The digit sum of a non-negative integer (n) is defined as (\mathrm{digit_sum}(n) = \sum_{d \in \text{digits}(n)} d).

Write a program that reads input from standard input (stdin), computes the number of pairs, and prints the result to standard output (stdout).

inputFormat

The input consists of two lines. The first line contains a single integer (n) ((1 \le n \le 10^5)), representing the number of integers. The second line consists of (n) space-separated integers.

outputFormat

Output a single integer that represents the maximum number of unique pairs that can be formed such that in each pair the two integers have equal digit sums.## sample

6
34 12 52 41 71 23
2