Source Code
#include <iostream>
using namespace std;

int size= 100001;


int main() {

  int Test;

  cin>>Test;
  while(Test>0){
    int ans;
    int n;
    int k;
    cin>>n;
    cin>>k;
    

    if(k/2==n){
      ans = 1;
    }
    else if(k/2>n){
      ans = 0;
    }
    else{
      ans = k/2;
    }
    cout<<ans<<endl;
    ans = 0;
    Test--;
  }
}
Copy
Ramadan Candies King_Of_Asgard
GNU G++17
39 ms
376 KB
Accepted