#include #include #include #include #include #include #include #include #include #include #include #include #define ll o<<1 #define rr o<<1|1 using namespace std; typedef __int64 LL; typedef pair pii; const int MAXN = 2e5 + 10; const int MOD = 1e9 + 7; void add(LL &x, LL y) { x += y; if(x < 0) x += MOD; x %= MOD; } int A[MAXN]; int sum[MAXN]; int main() { int t; scanf("%d", &t); while(t--) { int n, m, k; scanf("%d%d%d", &n, &m, &k); sum[0] = 0; for(int i = 1; i <= n; i++) { scanf("%d", &A[i]); sum[i] = sum[i-1] + (A[i] >= m); } LL res = 0; for(int i = 1; i <= n; i++) { int l = i, r = n, ans = -1; while(r >= l) { int mid = l + r >> 1; if(sum[mid] - sum[i-1] >= k) { ans = mid; r = mid - 1; } else { l = mid + 1; } } if(ans != -1) { res += n - ans + 1; } } printf("%I64d\n", res); } return 0; }