Source Code
#include<bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ll long long


int main() {

    IOS

    int t;cin>>t;
    while(t--){
        int n,k;cin>>n>>k;
        int ans=--k/2;
        cout<<(ans<=n/2?ans:0)<<"\n";
    }



}

Copy
Ramadan Candies HusseinSaad
GNU G++17
4 ms
376 KB
Wrong Answer