**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.