# Summary Power : What’s wrong with my code?

**URL:** <https://discuss.codechef.com/t/summary-power-what-s-wrong-with-my-code/126056>\
**Category:** general\
**Tags:** sumpower\
**Created:** [October 21, 2026, 8:36am UTC](https://discuss.codechef.com/t/summary-power-what-s-wrong-with-my-code/126056 "2026-10-21T08:36:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bt23cse026](https://discuss.codechef.com/user_avatar/discuss.codechef.com/bt23cse026/32/358804_2.png) [@bt23cse026](https://discuss.codechef.com/u/bt23cse026)\
**Post date:** [October 21, 2026, 8:36am UTC](https://discuss.codechef.com/t/summary-power-what-s-wrong-with-my-code/126056/1 "2026-10-21T08:36:49Z")

</div>

Summary Power : What’s wrong with my code?

```auto
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t ;cin>>t;
    while(t--){
        int n,k;cin>>n>>k;
        vector<char>v(n);
        vector<int>c(n);
        c[0]=1;
        for(int i=0;i<n;i++){
            cin>>v[i];
            if(i>0){
                if(v[i]==v[i-1])
                c[i]+=c[i-1];
                else 
                c[i]=c[i-1]+1;
            }
        }
        

        int ct = 0;
        for(int i = 0;i<k;i++){
            int a = c[i];
            int b = c[n-k+i];
            ct+=b-a;
        }
        cout<<ct<<endl;
        
    }
    return 0 ; 
}

```
