CodeChef starters 6. Problem Even tuples. Problem code:ETUP

Contest Page | CodeChef.

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    while(n--){
        vector<long long> even={0};
        vector<long long> odd={0};
        even.reserve(1e6);
        odd.reserve(1e6);
        int p,q;
        cin>>p>>q;
        for(long long i=1;i<=p;i++){
            long long j;
            cin>>j;
            if((j&1)==0){
                even.push_back(even[i-1]+1);
                odd.push_back(odd[i-1]);
            }
            else{
                even.push_back(even[i-1]);
                odd.push_back(odd[i-1]+1);
            }
        }
        while(q--){
            unsigned long long sums=0;
            int a,b;
            cin>>a>>b;
            int e=0,o=0;
            e=even[b]-even[a-1];
            o=odd[b]-odd[a-1];
            sums+=((e*(e-1)*(e-2))/6);
            sums+=(((o*(o-1))*e)/2);
            cout<<sums<<endl;
        }
        }
 }

I dont understand where my answer went wrong.
Can someone help me.

u have made mistake in prefix sum I guess

For the queries you have taken int even and odd . When you do even*(even-1) it can exceed the integer limit. You had to take long long.