#include #define rpt(i,l,r) for(int i=l;i<=r;i++) #define N 200005 int T,n,m,k,l,r,a[N],tmp; long long ans; void mvl(){ if(a[l++]>=m) tmp--; } void mvr(){ if(a[++r]>=m) tmp++; } int main(){ scanf("%d",&T); while(T--){ scanf("%d%d%d",&n,&m,&k); rpt(i,1,n) scanf("%d",&a[i]); l=1;r=0;ans=0;tmp=0; rpt(i,1,n-k+1){ while(tmp=k) ans+=n-r+1; mvl(); } printf("%I64d\n",ans); } }