plz help why my code given wrong answer,???

#include <bits/stdc++.h>

using namespace std;

int main()

{

ios_base::sync_with_stdio(false);

cin.tie(0);

int t;cin>>t;

while(t–)

{

unsigned long long n,k,ans;

cin>>n>>k;

if(k%2==0)

{

ans=(n+((k/2)-1))*(n+(k/2))+n;
}
else
{
ans=(n+(k/2))*(n+(k/2)+1)-n;

}

cout<<ans<<endl;

}

return 0;

}