Just find it

Can somebody help me why my code gives runtime error in codechef platform and Run successfully on other IDE’s.
JUST FIND IT:https://www.codechef.com/CFUS2020/problems/CFS2002/

My Code:

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
ll n,t;
cin>>t;
while(t–)
{
cin>>n;
vector<pair<ll,ll>>v;
ll a[n],as[n],m=0,mx=0;
for(ll i=0;i<n;i++)
{
cin>>a[i];
as[i]=a[i];
v.push_back({a[i],i});
}
for(ll i=1;i<n;i++)
as[i]+=as[i-1];
sort(v.begin(),v.end());
for(ll i=1;i<n;i++)
{
if(v[i].first==v[i-1].first)
{
m=as[v[i].second]-a[v[i].second]-as[v[i-1].second];
if(v[i].first%2==1 && m%2==1)
mx=max(mx,m);
else if((m%2==1 && (v[i].second-v[i-1].second-1)%2==1 )||(m%2==0 && (v[i].second-v[i-1].second-1)%2==0))
mx=max(mx,m);
}

    }
    cout<<mx<<endl;
    
}
return 0;

}

you need to provide custom input when you run on codechef ide or else it gives you any verdict when you run.

format your code by three backticks before and after code ```