#include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i) #define MP make_pair #define PB push_back #define SZ(x) (int((x).size())) #define ALL(x) (x).begin(), (x).end() #define X first #define Y second template inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } template inline bool RD(T &ret) { char c; int sgn; if (c = getchar(), c == EOF) return 0; while (c != '-' && (c<'0' || c>'9')) c = getchar(); sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0'); while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0'); ret *= sgn; return 1; } template inline void PT(T x) { if (x < 0) putchar('-') ,x = -x; if (x > 9) PT(x / 10); putchar(x % 10 + '0'); } const int INF = 0x3f3f3f3f; typedef long long LL; typedef pair pii; typedef long double LD; const int N = 2e5 + 100; int a[N]; int main() { int T; cin >> T; while(T --) { int n; RD(n); int nd, K; RD(nd), RD(K); for(int i = 1; i <= n; i ++) { RD(a[i]); a[i] = a[i] >= nd; } int r = 0; LL ans = 0; int cur = 0; for(int l = 1; l <= n; l ++) { while(r <= n && cur < K) cur += a[++ r]; if(cur == K) ans += n - r + 1; else break; cur -= a[l]; } printf("%lld\n", ans); } }