#include #include #include #include #include #include #define mp(a,b) make_pair(a,b) using namespace std; typedef long long LL; typedef double db; const int maxn=200005; int a[maxn]; int s[maxn]; int main() { int t,n,m,k; cin>>t; while (t--) { scanf("%d%d%d",&n,&m,&k); int tot=0; for(int i=1;i<=n;i++){ int p; scanf("%d",&p); if(p>=m){ a[i]=1; tot++; s[tot]=i; } else a[i]=0; } s[tot+1]=n+1; LL ans=0; for(int i=k;i<=tot;i++){ ans+=(LL)s[i-k+1]*(s[i+1]-s[i]); } printf("%I64d\n",ans); } }