#include #include #include using namespace std; typedef long long ll; ll f[200006]; int main() { int T; scanf("%d", &T); while(T--) { memset(f, 0,sizeof(f)); ll n, k, m, t; scanf("%I64d%I64d%I64d", &n, &m, &k); for(ll i = 1; i <= n; ++i) { scanf("%I64d", &t); if(t >= m) f[i] = 1; } ll r = 1, l = 0, ans = 0, cnt = 0; for(;;) { while(l <= n) { if(cnt < k) { l++; if(f[l] == 1) cnt++; } if(cnt == k) break; } if(cnt < k) break; ans += (n - l + 1); if(f[r++]) cnt--; } printf("%I64d\n", ans); } return 0; }