This is my code for PAIRSUM2
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n,q;
cin>>n>>q;
unsigned long long b[n-1];
unsigned long long int k;
for(int i=0;i<n-1;i++){
cin>>k;
b[i]=k;
}
while(q--){
int x,y;
cin>>x>>y;
if(abs(x-y)&1==1){
int z = max(x,y);
int z1 = min(x,y);
unsigned int check = 1;
long long ans = 0;
for(int i=z1-1;i<z-1;i++){
if(check%2==0){
ans -= b[i];
}
else{
ans += b[i];
}
check++;
}
cout<<ans<<endl;
}
else{
cout<<"UNKNOWN"<<endl;
}
}
}
return 0;
}
I am getting TLE for the second sub task ?