WA in BUY1GET1

I am getting wrong Answer in the problem BUY1GET1 . This is my code

        #include<iostream>
        #include<vector>
        #include<string.h>
        #include<algorithm>

        using namespace std;

        struct S{
         char st[200];
        };

        int main(){
            std::ios_base::sync_with_stdio(false);
            long int num,k,t;
            vector <S> s;
            S str;
            int t1;
            cin>>t1;
            for(int i=0;i<t1;i++)
            {
                cin>>str.st;
                s.push_back(str);
            }

              for(int i=0;i<t1;i++)
            {

                if(strlen(s.at(i).st)==1)
                {
                    cout<<"1"<<endl;
                    continue;
                }

                    num=0;
                    k=1;
                    t=1;

               sort( s.at(i).st , s.at(i).st+strlen(s.at(i).st) );
                while( k<strlen(s.at(i).st) )
                {
                    t=1;


                while( (s.at(i).st[k-1]==s.at(i).st[k])  && ( k<strlen(s.at(i).st) ) )
                {
                    t++;
                    k++;
                }


                    if(t%2==0)
                        num+=(t/2);
                    else
                        num+=( (t/2)+1 );

                    k++;

                    if(k==strlen(s.at(i).st))
                        num++;

                }

                cout<<num<<endl;

            }

        return 0;
        }

My program gives the following output for the input string as

INPUT

1
ssassa

OUTPUT

3

I assume, this is as expected. Would like to know where it went wrong…
And my apologies for complicating the code by using both STL containers and C-Style arrays…

Thanks.

For large inputs your code is not giving correct answers.
ex:-
2
qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiop qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiop
qwertyuiopqwertyuiop (qwertyuiop x 20 [On the same line])
qwertyuiopqwertyuiopqwertyuiop (qwertyuiop x 3)
120
16

The output should be:-
100
20
So just check your code and try optimizing it. The logic i guess is correct try without using STL containers.