Problem

Source: Russian TST 2019, Day 4 P2

Tags: combinatorics, permutations



For each permutation $\sigma$ of the set $\{1, 2, \ldots , N\}$ we define its correctness as the number of triples $1 \leqslant i < j < k \leqslant N$ such that the number $\sigma(j)$ lies between the numbers $\sigma(i)$ and $\sigma(k)$. Find the difference between the number of permutations with even correctness and the number of permutations with odd correctness if a) $N = 2018$ and b) $N = 2019$.