#include <bits/stdc++.h>
using namespace std;
unsigned long long fun(unsigned long long k){
unsigned long long x = 1000000007;
return ((k*k)%x + k)%x;
}
int main() {
// your code goes here
int t;
cin>>t;
unsigned long long x = 1000000007;
while(t>0){
t--;
unsigned long long n,k;
cin>>n>>k;
unsigned long long ans = 0;
if(n == 0)
ans = fun(k-1);//k(k-1)
else if(k %2 != 0)
{
ans = ((fun(n+(k/2) )%x) - n)%x; //(n+k/2)(n+k/2 + 1)
}
else{
ans = (fun(n+(k/2)-1)%x + n%x)%x; //(n+k/2-`1)(n+k/2)
}
cout<<ans<<endl;
}
return 0;
}
what is wrong with this code?
i am getting WA for large numbers…