The Stack Overflow podcast is back! Listen to an interview with our new CEO.
8 of 12 problem title

Aliens at the train

I solved this problem on spoj and was just on the border of time limit. I want to know any improvements for my code in context of competitive programming and c/c++ language.

How can I speed up the I/O and how can I shorten my code?

#include <cstdio>
#include <deque>
using namespace std;

int main()
{
    int t,siz;
    scanf("%d",&t);
    long long int at,bt,sum=0,max=0,maxsum=0,peep=0;
    deque<int> people;
    while(t--){
        sum=max=maxsum=peep=0;
        people.clear();
        scanf("%lld%lld",&at,&bt);
        while(at--){
            scanf("%lld",&peep);
            people.push_back(peep);
            if(sum+peep<=bt)
            {
                sum+=peep;
            }
            else{
                siz=people.size()-1;
                if(max==siz){
                    maxsum=maxsum<sum?maxsum:sum;
                }
                else if(max<siz){
                    maxsum=sum;
                max=siz;
                }
                sum+=peep;
                while(sum>bt){
                    sum-=people.front();
                    people.pop_front();
                }
            }
        }
        siz=people.size();
        if(max==siz){
            maxsum=maxsum<sum?maxsum:sum;
        }
        else if(max<siz){
            maxsum=sum;
            max=siz;
        }
        printf("%lld %lld\n",maxsum,max);
    }
return 0;
}