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):
#Take the value of X
#Take the value of Y


X, Y = map(int, input().split(" "))

C = (Y-4*X)/-2

T = X - ((Y-4*X)/-2)

total = int(T + C)

if (T<0) or (C<0):
    print("No")
elif (T%1 != 0) or (C%1 != 0):
    print("No")
elif (T+C) == X and (4*T + 2*C) == Y:
    print("Yes")
else:
    print("No")

print(T,C)

C,D=input().split('')
C=int(C)
D=int(D)

numb=4*C
if D>numb:
    print("No.")
else:
    print("Yes.")


X,Y=input().split(' ')

X=int(X)
Y=int(Y)

num=4*A

if B>num:
    print("No")
else:
    print("Yes")

i = list(map(int, input().split()))

Crane = 2
Turtle = 4


X=i[0]
Y=i[1]

C=0
T=0
noAnimal = 0

def Calculate (C,T,Crane,Turtle):
    for C in range(100):
                
        for T in range(100):
            Leg = (T*Turtle)+(C*Crane)
            if Leg > 100:
                return False
            
            if Leg == Y:
                noAnimal = C+T
                return True
    return False
            


print (Calculate(C,T,Crane,Turtle))

#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

#define mt make_tuple
#define pb push_back
#define pf push_front

#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f

#define all(c) c.begin(), c.end()

#define ss second

#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)

#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=100005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int n,m,k;
int main(){
	fast
	cin>>n>>m>>k;
	int sx,sy,ex,ey;
	cin>>sx>>sy>>ex>>ey;
	pii came[n][m];
	sx--;sy--;ex--;ey--;
	char a[n][m];
	FOR0(n){
		for(int j=0;j<m;j++) cin>>a[i][j];
	}
	int vis[n][m];
	mem(vis,-1);
	queue<pair<int,int> >q;
	vis[sx][sy]=0;
	q.push({sx,sy});
	mem(came,-1);
	came[sx][sy]={-1,-1};
	while(!q.empty()){
		pii f=q.front();
		q.pop();
		int x=f.ff,y=f.ss;
		for(int i=1;i<=k;i++){
			int yy=y+i;
			if(yy>=m) break;
			if(a[x][yy]=='@') break;
			else if(vis[x][yy]==-1){
				vis[x][yy]=vis[x][y]+1;
				q.push({x,yy});
				came[x][yy]={x,y};
			}
			else if(came[x][yy]==came[x][y]) break;
		}
		for(int i=1;i<=k;i++){
			int yy=y-i;
			if(yy<0) break;
			if(a[x][yy]=='@') break;
			else if(vis[x][yy]==-1){
				vis[x][yy]=vis[x][y]+1;
				q.push({x,yy});
				came[x][yy]={x,y};
			}
			else if(came[x][yy]==came[x][y]) break;
		}
		for(int i=1;i<=k;i++){
			int xx=x+i;
			if(xx>=n) break;
			if(a[xx][y]=='@') break;
			else if(vis[xx][y]==-1){
				vis[xx][y]=vis[x][y]+1;
				q.push({xx,y});
				came[xx][y]={x,y};
			}
			else if(came[xx][y]==came[x][y]) break;
		}
		for(int i=1;i<=k;i++){
			int xx=x-i;
			if(xx<0) break;
			if(a[xx][y]=='@') break;
			else if(vis[xx][y]==-1){
				vis[xx][y]=vis[x][y]+1;
				q.push({xx,y});
				came[xx][y]={x,y};
			}
			else if(came[xx][y]==came[x][y]) break;
		}
	}
	cout<<vis[ex][ey];
}

X,Y = map(input().split()) #input number of animals and legs

crane_legs = 2
turtle_legs = 4

answer = "No"

for i in range(X+1): #X+1 because it will only consider 0,1,2
    remaining=X-i #
    if crane_legs*i + turtle_legs*remaining == Y:
        answer = "Yes"
#Loop to check combinations of animals is correct

print(answer)

animals= input()
legs= input()

for i in range (len(animals)):

    if int(legs) % 2 ==0: #to check if it's even then there is a possibility of combination
        print ("yes")
    elif int(legs) % 4 ==0:
        print ("yes")
    elif int(legs) % 2 !=0:
        print ("no")
    elif int(legs) % 4 !=0:
        print ("no")

X,Y = map(input().split()) #input number of animals and legs

crane_legs = 2
turtle_legs = 4

answer = "No"

for i in range(X+1): #X+1 because it will only consider 0,1,2
    remaining=X-i #
    if crane_legs*i + turtle_legs*remaining == y:
        answer = "Yes"
#Loop to check combinations of animals is correct

print(answer)

#getting input from user
#cranes and turtle already give the information
#condition yes or no 
X,Y= map(int,input().split())
cranes= 2 # assign 2 to cranes
turtles= 4 # assign 4 to turtle
ans="No"
for i in range(X+1): 
    b=X-i
    if cranes*i + turtles*b == Y:
        ans = "Yes"
print(ans)

# Time complixity O(X)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted