if X >= Y:

# print(2*Y - X)

in this code you are you printing y when the target is greater than the chocolates he actually sold . agar target 4 ka h and he sold 5 chocolates tab toh xtra 2 rs wali condition valid ho jayegi instead of y…it should be like if target is 5 and he sold 7 chocolates the total amount should be …5 + 2* 2 = 5+4 =9…and if the target is more than he sold then it should be y … help me anyone in resolving this .

### My code

``````# cook your dish here
t = int(input())
for i in range(t):
x , y = map(int,input().split())
if x >=y:
print(y)
else:
print(x + 2*y)

#   if X >= Y:
#     print(Y)
# else:
#     print(2*Y - X)

``````

Learning course: Basic Math using Python
Problem Link: CodeChef: Practical coding for everyone

@vishakha522
The logic is if y>x
the answer would be x + (y-x)*2;
else

yeah thanks for telling.
even I also got the same logic after going deep into it.

include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin>>t;
while (t–){
int x,y,ans;
cin>>x>>y;
ans = y;
if(y>x){
ans += (y-x);
cout<<ans<<endl;
}
else{
cout<<1*y<<endl;
}
}
return 0;
}