Problem: There are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.  Takahashi says: "there are X animals in total in the garden, and they have Y legs in total." Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.

Submission attempts (in order):
x,y=map(int,input().split()) #input for x=animals, y=legs

c=2 #crane has 2 legs
t=4 #turtle has 4 legs

for i in range (x+1): #loop the number of animals

    a=x-i #the subtraction to get the number of turtle available for every loop starting from i=0

    if (i*c) +(x*a)==y: #the formula to get the amount of legs for both animals in a loop
        print ("yes") #if equals to y then there is a combination of both animals
    else:
        print("no")

x,y= map(int,input().split())
crane= 2
turtle= 4
ans="No"
for i in range(x+1):
    b=x-i
    if cranei + turtleb == y:
        ans = "Yes"
print(ans)

x,y=map(int,input().split()) #input for x=animals, y=legs

c=2 #crane has 2 legs
t=4 #turtle has 4 legs

for i in range (x): #loop the number of animals

    a=x-i #the subtraction to get the number of turtle available for every loop starting from i=0

    if (i*c) +(x*t)==y: #the formula to get the amount of legs for both animals in a loop
        print ("yes") #if equals to y then there is a combination of both animals
    else:
        print("no")

x,y=map(int,input().split()) #input for x=animals, y=legs

c=2 #crane has 2 legs
t=4 #turtle has 4 legs

for i in range (x+1): #loop the number of animals

    a=x-i #the subtraction to get the number of turtle available for every loop starting from i=0

    if i*c +a*t==y: #the formula to get the amount of legs for both animals in a loop
        print ("yes") #if equals to y then there is a combination of both animals
    else:
        print("no")

x,y=map(int,input().split()) #input for x=animals, y=legs

c=2 #crane has 2 legs
t=4 #turtle has 4 legs

for i in range (x): #loop the number of animals

    a=x-i #the subtraction to get the number of turtle available for every loop starting from i=0

    if (i*c) +(x*a)==y: #the formula to get the amount of legs for both animals in a loop
        print ("yes") #if equals to y then there is a combination of both animals
    else:
        print("no")

x,y=map(int,input().split()) #input for x=animals, y=legs

c=2 #crane has 2 legs
t=4 #turtle has 4 legs

for i in range (x+1): #loop the number of animals

    a=x-i #the subtraction to get the number of turtle available for every loop starting from i=0

    if (i*c) +(a*t)==y: #the formula to get the amount of legs for both animals in a loop
        print ("yes") #if equals to y then there is a combination of both animals
    else:
        print("no")

x,y=input().split(" ") #get input for X and Y

if x*2==y: 
    print ("YES")
elif x*4==y:
    print ("YES")
else:
    print ("NO")

# we input the number of animals(A)
# we then input the number of legs(B)
# we set the number of crane = 2 and turtle = 4
# we then compute (crane * i + turtle * j) to see if it's = B
A, B = map(int, input().split())

crane = 2
turtle = 4
ans = 'No'

for i in range(A + 1):
    j = A - i
    if crane * i + turtle * j == B:
        ans = 'Yes'
print(ans)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted