#include #include #include #include #include #include #define LL long long #define pb push_back using namespace std; const int N = 200010; int a[N], cnt[N], n, m, k; int bs(int x, int s) { int l = x, r = n; int ret = -1; while (l <= r) { int mid = (l + r) >> 1; if (cnt[mid] - cnt[s - 1] >= k) { ret = mid; r = mid - 1; } else l = mid + 1; } return ret; } int main() { int T; scanf("%d", &T); while (T--) { scanf("%d%d%d", &n, &m, &k); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); for (int i = 1; i <= n; ++i) { cnt[i] = cnt[i - 1]; if (a[i] >= m) ++cnt[i]; } LL ans = 0; for (int i = 1; i <= n + 1 - k; ++i) { int pos = bs(i + k - 1, i); if (pos > 0) ans += n - pos + 1; } printf("%I64d\n", ans); } return 0; }