fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t, n,a,p;
  7. cin>>t;
  8. while(t--){
  9. cin>>n>>a;
  10. p = n-a;
  11. if(p < a)
  12. cout<<p<<"\n";
  13. else
  14. cout<<a<<"\n";
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 5432KB
stdin
3
2 1
3 2
3 1
stdout
1
1
1