# Rectangle | CodeChef Solution

Hello coders, today we are going to solve Rectangle CodeChef Solution whose Problem Code is RECTANGL.

Contents

You are given four integersÂ a,Â b,Â cÂ andÂ d. Determine if there’s a rectangle such that the lengths of its sides areÂ a,Â b,Â cÂ andÂ dÂ (in any order).

## Input Format

• The first line of the input contains a single integerÂ TÂ denoting the number of test cases. The description ofÂ TÂ test cases follows.
• The first and only line of each test case contains four space-separated integersÂ a,Â b,Â cÂ andÂ d.

## Output Format

For each test case, print a single line containing one stringÂ “YES”Â orÂ “NO”.

## Constraints

• 1 â‰¤Â TÂ â‰¤ 1,000
• 1 â‰¤Â a,Â b,Â c,Â dÂ â‰¤ 10,000

Subtask #1 (100 points):Â original constraints

Example

Sample Input

``````3
1 1 2 2
3 2 2 3
1 2 2 2``````

Sample Output

``````YES
YES
NO``````

## Solution – Rectangle | CodeChef Solution

### C++

```#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main(){
int t, a, b, c, d;
cin >> t;
while (t--){
cin >> a >> b >> c >> d;
if ((a == b && c == d) || (a == c && b == d) || (a == d && b == c))
printf("%s\n", "YES");
else
printf("%s\n", "NO");
}
return 0;
}```

### Python

```# cook your dish here
for _ in range(int(input())):
a, b, c, d = map(int, input().split())
if a==b and c==d:
print("YES")
elif a==c and b==d:
print("YES")
elif a==d and b==c:
print("YES")
else:
print("NO")```

### Java

```/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner input=new Scanner(System.in);
int T=input.nextInt();
int a[]=new int[T];
int b[]=new int[T];
int c[]=new int[T];
int d[]=new int[T];
for(int i=0;i<T;i++){
a[i]=input.nextInt();
b[i]=input.nextInt();
c[i]=input.nextInt();
d[i]=input.nextInt();
if(a[i]+b[i]==c[i]+d[i]){
System.out.println("YES");
}
else if(a[i]+c[i]==b[i]+d[i]){
System.out.println("YES");
}
else if(a[i]+d[i]==b[i]+c[i]){
System.out.println("YES");
}
else{
System.out.println("NO");
}

}
}
}
```

Disclaimer: The above Problem (Rectangle) is generated by CodeChef but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.