Super Shop

Limits 1s, 512 MB

A super shop sells only 26 items, labeled them from ‘A’ to ‘Z’. The shop stores the list of products bought by every customer as transactions.


This is a companion discussion topic for the original entry at https://toph.co/p/super-shop

unsigned long long int a,t,trans,query,b,c,d,e,jun,sen;
double sum,div;
cin>>t;
for(a=1;a<=t;a++)
{

    cin>>trans>>query;
    string artrans[trans],same,x,y;
    for(b=0;b<trans;b++)
    {
        cin>>artrans[b];
    }
    cout<<"Case "<<a<<':'<<endl;

    while(query--)//for(b=0;b<query;b++)
    {
        cin>>x>>y;
        sum=div=0;
        for(c=0;c<trans;c++)
        {
            jun=sen=0;
            same=artrans[c];
            for(d=0;d<same.size();d++)
            {
                for(e=0;e<x.size();e++)
                {
                    if(x[e]==same[d])
                    {
                        jun++;
                    }
                }
                for(e=0;e<y.size();e++)
                {
                    if(y[e]==same[d])
                    {
                        sen++;
                    }
                }

            }
            if(jun==x.size()&&sen==y.size())
            {
                sum++;
                div++;
            }
            else if(jun==x.size())
            {
                div++;
            }

        }
         std::cout << std::fixed;
         std::cout << std::setprecision(2);
        cout<<sum/div<<endl;
    }

how changes do i have to make to avoid cpu limit

}