#include #include #include #include #include #include #include #include #include #include #include #include #define INF 0X3F3F3F3F #define MOD 1000000007 #define N 100010 #define M 2000100 #define FF(i,a,b) for(int i=a;i<=b;++i) #define RR(i,a,b) for(int i=a;i>=b;--i) #define FJ(i,a,b) for(int i=a;i>1) #define abs(x) ((x<0)?(-x):(x)) #define lson rt<<1,l,mid #define rson rt<<1|1,mid+1,r #define zero(x) (((x)>0?(x):-(x)) #define MP make_pair #define IN freopen("in.txt","r",stdin) #define OUT freopen("out.txt","w",stdout) using namespace std; const double PI=acos(-1.0); const double EPS=1e-8; typedef long long LL; int a[201000],f[201000],b[201000]; int main(){ // IN; int _,n,m,k; LL ans; for(SC(_);_--;){ ans=0; SCCC(n,m,k); CL(a,0);CL(f,0); FF(i,1,n){ SC(b[i]); if(b[i]>=m)a[i]=1; } FF(i,1,n)f[i]=f[i-1]+a[i]; FF(i,1,n-k+1){ int t=lower_bound(f+i+k-1,f+1+n,k+f[i-1])-f; ans+=n-t+1; } printf("%I64d\n",ans); } return 0; }