#include #include #include #include #include using namespace std; typedef long long ll; const int maxn = 204800; int n,m,k; int num[maxn], sum[maxn]; bool judge(int L, int R) { int cnt = sum[R] - sum[L-1]; return cnt >= k; } int main(){ int T; scanf("%d", &T); while(T--) { scanf("%d%d%d", &n, &m, &k); sum[0] = 0; for(int i = 1; i <= n; ++i) { scanf("%d",&num[i]); if(num[i] >= m) sum[i] = sum[i-1] + 1; else sum[i] = sum[i-1]; } ll cnt = 0; for(int i = 1; i + k - 1 <= n; i++) { int l = i + k - 1; int r = n + 1; int tmp = n; if(!judge(i, n)) continue; while(l < r) { int mid = (l + r) >> 1; if(judge(i, mid)) { tmp = mid; r = mid; } else { l = mid + 1; } } cnt += (n - tmp + 1); } printf("%I64d\n", cnt); } return 0; }