**Cats and Dogs Codechef Solution:** Chef is a farmer and a pet lover. He has a lot of his favorite pets cats and dogs in the barn. He knows that there are CC cats and DD dogs in the barn. Also, one day went to field and found that there were LL legs of the animals touching the ground. Chef knows that cats love to ride on the dogs. So, they might ride on the dogs, and their legs won’t touch the ground and Chef would miss counting their legs. Chef’s dogs are strong enough to ride at max two cats on their back.

It was a cold foggy morning, when Chef did this counting. So he is now wondering whether he counted the legs properly or not. Specifically, he is wondering whether it is possible that he counted correctly. Please help Chef in finding it.

### Input

- First line of the input contains an integer TT, denoting number of test cases. TT test cases follow.
- The only line of each test case contains three space separated integers C,D,LC,D,L, denoting number of the cats, number of the dogs and number of legs of animals counted by Chef, respectively.

### Output

For each test case, output a single line containing a string **yes** or **no**, according to the situation.

### Constraints

- 1≤T≤1051≤T≤105
- 0≤C,D,L≤1090≤C,D,L≤109

### Sample Input 1

3 1 1 8 1 1 4 1 1 2

### Sample Output 1

yes yes no

### Explanation

**Example 1:** There is one cat and one dog. The number of legs of these animals on the ground are 88, it can be possible when both cat and dog are standing on the ground.

**Example 2:** There is one cat and one dog. The number of legs of these animals on the ground are 44, it can be possible if the cat will ride on the dog, so its legs won’t be counted by Chef, only the dog’s legs will be counted.

**Example 3:** There is one cat and one dog. The number of legs of these animals are 22, it can not be true at all, Chef might have made some mistake. Hence, the answer is **no**

### Cats and Dogs CodeChef Solution in JAVA

import java.util.*; import java.lang.*; import java.io.*; class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc=new Scanner(System.in); int t; t=sc.nextInt(); int c,d,l; for(int i=0;i<t;i++) { c=sc.nextInt(); d=sc.nextInt(); l=sc.nextInt(); int flag=0; int s=(c*4)+(d*4); if(l%4!=0) System.out.println("no"); else { int tot=l/4; int c1=tot-d; if(tot-d<0) { flag=1; } int c2=c-c1; if(c2<0||c2>2*d) { flag=1; } if(flag==1) System.out.println("no"); else System.out.println("yes"); } } } }

### Cats and Dogs CodeChef Solution in CPP

#include <bits/stdc++.h> using namespace std; int main(){ int T; cin>>T; while(T--) { long long int C, D, L; cin>>C>>D>>L; long long int start = 0; long long int limit = (C + D)*4; if(C > (D * 2)){ start = (C - (D * 2) + D)*4; } else { start = D*4; } if(L % 4 == 0 && L >= start && L <= limit) { cout<<"yes\n"; } else { cout<<"no\n"; } } return 0; }

### Cats and Dogs CodeChef Solution in Python

t = int(input()) while t: c,d,l = map(int,input().split()) total = (c+d)*4 mini = max(0,c-d*2) if(total>=l and l%4==0 and (d+mini)*4<=l): print("yes") else: print("no") t-=1

** Disclaimer: **The above Problem

**(Cats and Dogs**

**)**

**is generated by CodeChef but the solution is provided by**

**Chase2learn**.This tutorial is only for

**Educational**and

**Learning**purpose.