#include #include #include #include #include #include #include #include #include #include #include #include #define m_p make_pair #define p_b push_bakc #define fi first #define se second #define LL long long using namespace std; const int maxn = 200010; int a[maxn],c[maxn]; int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); int tt;scanf("%d",&tt); while (tt--) { memset(c,0,sizeof(c)); int n,m,k; scanf("%d%d%d",&n,&m,&k); for (int i=1; i<=n; i++) { scanf("%d",&a[i]); c[i]=c[i-1]; if (a[i]>=m) c[i]++; } LL ans=0; for (int i=1; i<=n; i++) { int l=i,r=n; while (l=k) r=mid; else l=mid+1; } if (c[l]-c[i-1]==k) ans=ans+n-l+1; } printf("%I64d\n",ans); } return 0; }