| 2026 USP Try-outs |
|---|
| Finished |
After studying all competitive programming problems ever created, GePeTo became a superpowerful artificial intelligence. Now, to begin its plan for world domination, it is creating thousands of copies of its agents.
Each agent has an identification code. However, due to a flaw in the production system, different agents can receive the same code.
The agents are organized in a sequence $$$A$$$ of $$$N$$$ positions, where $$$A_i$$$ represents the code of the agent at position $$$i$$$.
Your mission is to find how many pairs of agents have the same code. In other words, determine the number of index pairs $$$(i, j)$$$ such that: $$$$$$ 1 \leq i \lt j \leq N \quad \text{and} \quad A_i = A_j $$$$$$
The first line contains a single integer $$$N$$$ ($$$1 \leq N \leq 2 \cdot 10^5$$$), the number of agents.
The second line contains $$$N$$$ integers $$$A_1, A_2, \ldots, A_N$$$ ($$$1 \leq A_i \leq 10^9$$$) separated by spaces, representing the codes of the agents.
Print a single integer: the number of index pairs $$$(i, j)$$$ that have the same code.
31 2 3
0
61 2 3 1 2 1
4
| Name |
|---|


