# Help me in solving ROCPAPSCI problem

### My issue

#include<bits/stdc++.h>
using namespace std;
int main(){
long long int T;
cin>>T;
while(T–){
long long int N;
cin>>N;
string s;
cin>>s;
long long int count=N;
for(int i=0;i<N;i+=2){
if(s[i]==s[i+1]){
count–;

``````        }
}

cout<<count<<endl;
``````

}
return 0;
}

### My code

``````#include<bits/stdc++.h>
using namespace std;
int main(){
long long int T;
cin>>T;
while(T--){
long long int N;
cin>>N;
string s;
cin>>s;
long long int count=N;
for(int i=0;i<N;i+=2){
if(s[i]==s[i+1]){
count--;

}
}

cout<<count<<endl;
}
return 0;
}
``````

@anon45344766
plzz refer my c++ code

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

int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
int cnt=1;
int ans=0;
for(int i=1;i<n;i++)
{
if(s[i]==s[i-1])
{
cnt++;
}
else
{
ans+=(ceil(cnt*1.0/2.0));
cnt=1;
}
}
ans+=(ceil(cnt*1.0/2.0));
cout<<ans<<endl;
}
return 0;
}``````

Here ,the step making the code wrong is your incrementing logic
1)Where here whenever there are same two consecutive moves you are not allowed to play same move.
2)So you have to increment twice only when two consecutive condition are their other than that you have to increment normally.
example:
RRRR normal_score =4
you check first two Rs and then you have to change R at index 1 and then check from index 2 for the next step.
by this you have to subtract 2 from normal score
then it is 4-2=2;