#include #define i64 long long #define lld "%I64d" #define N_MAX 200000 int T, n, i, j, k, s[N_MAX + 1]; i64 m, a, cnt; int main() { scanf("%d", &T); while (T--) { scanf("%d" lld "%d", &n, &m, &k); for (i = 1; i <= n; ++i) scanf(lld, &a), s[i] = s[i - 1] + (a >= m); cnt = j = 0; for (i = k; i <= n; ++i) { while (s[i] - s[j] >= k) ++j; cnt += j; } printf(lld"\n", cnt); } return 0; }