#pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define LL __int64 #define fi first #define se second #define lson l,mid,id<<1 #define rson mid+1,r,id<<1|1 #define ls id<<1 #define rs id<<1|1 #define MID(a,b) (((a)+(b))>>1) #define maxx(a,b) ((a)<(b)?(b):(a)) #define minx(a,b) ((a)<(b)?(a):(b)) #define absx(a) ((a)<0?-(a):(a)) #define mk(a,b) make_pair(a,b) #define pb(a) push_back(a) #define itr iterator #define lowbit(x) ((x)&-(x)) typedef unsigned LL ULL; typedef unsigned uint; typedef map mii; typedef pair pii; typedef pair pdd; typedef pair pll; typedef vector vi; template< typename T > inline void read(T &res) { T x=0; bool f=0; char ch=getchar(); while(ch<'0' || ch>'9') {if(ch=='-')f=!f; ch=getchar();} while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();} res = f ? -x : x ; } template< typename T > inline void Max(T &a, T b) {if(a inline void Min(T &a, T b) {if(b>1; const LL SLINF=(ULL) (-1)>>1; const double DINF=(double) 1e50; const double eps=(double) 1e-8; const int maxn=(int) 2e5+20; const int maxm=(int) 3e4+15; inline int sig(double x) {return x<-eps?-1:x>eps;} inline void fadd(LL &x,LL a) {x+=a; if(x>=MOD) x-=MOD;} //--------------start------------------ int n,m,k; int a[maxn],b[maxn]; void work() { int tc; read(tc); while(tc--) { read(n), read(m), read(k); for(int i=1;i<=n;i++) read(a[i]); for(int i=1;i<=n;i++) b[i]=a[i]>=m; LL ans=0; for(int i=2;i<=n;i++) b[i]+=b[i-1]; int p=1; for(int i=k;i<=n;i++) { while(i-p>=k && b[i]-b[p]>=k) p++; if(b[i]-b[p-1]>=k) ans+=p; } cout <