#include #include #include #include #include #include #include using namespace std; #define ll long long int num[200005]; int main() { int tt; scanf("%d",&tt); while(tt--) { int n,m,k; scanf("%d %d %d",&n,&m,&k); memset(num,0,sizeof num); for(int i=1;i<=n;i++) { scanf("%d",&num[i]); } int j=1; int numm=0; ll sum=0; for(int i=1;j<=n&&i<=n;) { if(num[j]>=m)numm++; while(numm>=k) { sum=sum+(ll)(n-j+1); if(num[i]>=m)numm--; i++; } j++; } printf("%I64d\n",sum); } return 0; }