#include #include int num[200005],mark[200005]; int main(){ int t; scanf("%d",&t); while(t--){ int n,m,k; memset(mark,0,sizeof(mark)); scanf("%d%d%d",&n,&m,&k); __int64 f=0; __int64 ans=0; for(int i=1;i<=n;i++){ scanf("%d",&num[i]); if(num[i]>=m)ans++; mark[ans]=i; if(ans>=k)f+=mark[ans-k]+1; } printf("%I64d\n",f); } return 0; }