Can anyone find what’s wrong in this code I tried for every possible test case but after submission it gives WA for large numbers

```
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n,k;
ll mod=1000000007;
cin>>n>>k;
ll a=(ll)floor((float)k/2);
ll b=(ll)ceil((float)k/2);
ll ans=(((n*n)%mod+(2*a*n)%mod)%mod+((b-1)*b)%mod)%mod;
if(n==0)
ans=(k*(k-1))%mod;
cout<<ans<<endl;
}
}
```