#include #include #include #include using namespace std; long long T,a[200005],go[200005]; long long n,m,kk; int main() { cin >> T; while (T-->0) { cin >> n >> m >> kk; for (int i=1;i<=n;i++) { int x; scanf("%d",&x); if (x>=m) a[i]=1; else a[i]=0; go[i]=go[i-1]+a[i]; } long long j=0; long long ans=0; for (int i=1;i<=n;i++) { while (go[i]-go[j+1]>=kk) j++; if (go[i]-go[j]==kk) ans=ans+(j+1); } cout << ans << endl; } return 0; }