@ritulsingh Your Loop Stops As Soon As small == large there are many scenarios where small will be equal to large but u’ll have still coins left with you.
For Ex You Have 3 Orange 4 Apple 3 Coins
First It Ran It Became 4 Orange And 4 Apple And 2 Coins,As Apple == Orange.You Broke The Loop Now,But Still 2 Coins Are Left…
#include<bits/stdc++.h>
using namespace std;
// 2 baskets n apples m oranges
int main(){
int t;
int n,m,k;
cin>>t;
while(t--){
cin>>n>>m>>k;
while(k>0){
if(n>m){
m++;
k--;
}
else {
n++;
k--;
}
}
cout<<n-m<<endl;
}
return 0;
}
WHY I AM GETTING THIS WRONG ??
t=int(input(""))
for i in range(t):
a,b,k=list(map(int,input().split()))
if(a>b):
print(a-min(b+k,a))
else:
print(b-(min(a+k,b)))