408836: GYM103347 F Playwrite
Description
Willy Shakes was a prominent playwright, but many people never realized he had a very special process for writing 3-act plays. To streamline his writing, he would write many acts, then piece them together after the fact.
Willy would begin by writing $$$N$$$ acts. He would then rate each act on two metrics: comedy and tragedy. For act $$$i$$$, these ratings are given as two integers, $$$c_i$$$ and $$$t_i$$$. To make his plays exciting, he requires a very specific structure, in which each act is strictly more comedic and tragic than the previous.
He can pick any three acts that would follow this structure to make a play. Given the number of acts and the acts that he has written thus far, help Willy determine the number of $$$3$$$-act plays he can create.
InputA single integer $$$1 \leq N \leq 10^5$$$.
$$$N$$$ lines, each containing a $$$c_i$$$ and $$$t_i$$$, where $$$1 \leq c_i, t_i \leq 1000$$$.
OutputA single integer, the number of $$$3$$$-act plays that can be made.
ExampleInput6 1 1 2 1 2 2 3 2 4 3 4 3Output
6Note
Make sure your values aren't overflowing :)