You are given a sequence A1,A2,…,AN of length N and an integer K. Count the subsequences of A that have length K and are increasing.
A subsequence is Ai1,Ai2,…,AiK for indices i1<i2<⋯<iK. It is increasing when Ai1<Ai2<⋯<AiK holds, so two equal values can never sit next to each other in it. Two subsequences that use different index sets are counted separately even when their values are identical.