{"problem":{"name":"Counting of Subarrays","description":{"content":"For a sequence $S$ of positive integers and positive integers $k$ and $l$, $S$ is said to belong to _level_ $(k,l)$ when one of the following conditions is satisfied: *   The length of $S$ is $1$, an","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc037_f"},"statements":[{"statement_type":"Markdown","content":"For a sequence $S$ of positive integers and positive integers $k$ and $l$, $S$ is said to belong to _level_ $(k,l)$ when one of the following conditions is satisfied:\n\n*   The length of $S$ is $1$, and its only element is $k$.\n*   There exist sequences $T_1,T_2,...,T_m$ ($m \\geq l$) belonging to level $(k-1,l)$ such that the concatenation of $T_1,T_2,...,T_m$ in this order coincides with $S$.\n\nNote that the second condition has no effect when $k=1$, that is, a sequence belongs to level $(1,l)$ only if the first condition is satisfied.\nGiven are a sequence of positive integers $A_1,A_2,...,A_N$ and a positive integer $L$. Find the number of subsequences $A_i,A_{i+1},...,A_j$ ($1 \\leq i \\leq j \\leq N$) that satisfy the following condition:\n\n*   There exists a positive integer $K$ such that the sequence $A_i,A_{i+1},...,A_j$ belongs to level $(K,L)$.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $2 \\leq L \\leq N$\n*   $1 \\leq A_i \\leq 10^9$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $L$\n$A_1$ $A_2$ $...$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc037_f","tags":[],"sample_group":[["9 3\n2 1 1 1 1 1 1 2 3","22\n\nFor example, both of the sequences $(1,1,1)$ and $(2)$ belong to level $(2,3)$, so the sequence $(2,1,1,1,1,1,1)$ belong to level $(3,3)$."],["9 2\n2 1 1 1 1 1 1 2 3","41"],["15 3\n4 3 2 1 1 1 2 3 2 2 1 1 1 2 2","31"]],"created_at":"2026-03-03 11:01:14"}}