#K34392. Round-Robin Tournament Matches

    ID: 25299 Type: Default 1000ms 256MiB

Round-Robin Tournament Matches

Round-Robin Tournament Matches

In a round-robin tournament, every pair of distinct players plays exactly one match. Given the number of players \(P\), your task is to calculate the total number of matches that will be held.

The total number of matches can be computed using the formula:

\( \frac{P \times (P - 1)}{2} \)

For example, if there is only 1 player, there are 0 matches; if there are 2 players, there is 1 match etc. Note that if the number of players is 0 (or less than 1), the result should be 0.

inputFormat

The input consists of a single integer \(P\) (\(0 \leq P \leq 10^7\) for instance), representing the number of players in the tournament. The integer is provided via standard input.

outputFormat

Output a single integer representing the total number of matches in the tournament. The output should be written to standard output.

## sample
1
0