Dudu is getting in shape for a trip to Thailand, so he weighs himself every morning.
Some stretches of days are good, with the weight going down day after day, and some are bad, with it going up day after day. Others are just weird.
An interval of measurements is weird if it alternates between increasing and decreasing. For example, measurements on consecutive days of [1, 3, 2, 5, 1] form a weird interval. [1, 3, 5, 4] is not weird, because the value increases from 1 to 3 and then increases again from 3 to 5. Every interval of length 1 is weird by definition.
If two neighbouring measurements are equal, that step is neither an increase nor a decrease, so an interval that holds two equal neighbours is not weird.
An interval is identified by its start position and end position, not by its values. If the same list of values appears at two different positions, both intervals are counted.
Given a sequence of integers, count the weird intervals.