# April Long One 2022

## Ezio and Guards

#### [https://www.codechef.com/APRIL221D/problems/MANIPULATE](https://www.codechef.com/APRIL221D/problems/MANIPULATE) <a href="#https-www.codechef.com-april221d-problems-manipulate" id="https-www.codechef.com-april221d-problems-manipulate"></a>

{% tabs %}
{% tab title="C++" %}
```cpp
#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        int x, y;
        cin >> x >> y;
        if (x >= y) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}
```
{% endtab %}

{% tab title="C#" %}
```csharp
public static void Main() {
    int testcases = Convert.ToInt32(Console.ReadLine());
    for (int i = 0; i < testcases; i++) {
        // your code goes here
        string[] inputs = Console.ReadLine().Split();
        int x = int.Parse(inputs[0]);
        int y = int.Parse(inputs[1]);
        if (x >= y)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}
```
{% endtab %}
{% endtabs %}

## The Cooler Dilemma 1

#### [https://www.codechef.com/APRIL221D/problems/WATERCOOLER1](https://www.codechef.com/APRIL221D/problems/WATERCOOLER1)

{% tabs %}
{% tab title="C++" %}
```cpp
#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        int x, y, z;
        cin >> x >> y >> z;
        if (x * z < y)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}
```
{% endtab %}

{% tab title="C#" %}
```csharp
public static void Main() {
    int testcases = Convert.ToInt32(Console.ReadLine());
    for (int i = 0; i < testcases; i++) {
        // your code goes here
        string[] inputs = Console.ReadLine().Split();
        int x = int.Parse(inputs[0]);
        int y = int.Parse(inputs[1]);
        int z = int.Parse(inputs[2]);
        if (x * z < y)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}
```
{% endtab %}
{% endtabs %}

## The Cooler Dilemma 2

#### [https://www.codechef.com/APRIL221D/problems/WATERCOOLER2](https://www.codechef.com/APRIL221D/problems/WATERCOOLER2) <a href="#https-www.codechef.com-april221d-problems-watercooler2" id="https-www.codechef.com-april221d-problems-watercooler2"></a>

{% tabs %}
{% tab title="C++" %}
```cpp
#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        int a, b;
        cin >> a >> b;
        if (b % a == 0) {
            int p = b / a - 1;
            if (p < 0) {
                cout << 0 << endl;
            } else {
                cout << p << endl;
            }
        } else {
            int p = b / a;
            cout << p << endl;
        }
    }
    return 0;
}
```
{% endtab %}

{% tab title="C#" %}
```csharp
public static void Main() {
    int testcases = Convert.ToInt32(Console.ReadLine());
    for (int i = 0; i < testcases; i++) {
        // your code goes here
        string[] inputs = Console.ReadLine().Split();  // input
        int a = int.Parse(inputs[0]);
        int b = int.Parse(inputs[1]);
        if (b % a == 0) {
            int p = b / a - 1;
            if (p < 0)
                Console.WriteLine(0);
            else
                Console.WriteLine(p);
        } else {
            int p = b / a;
            Console.WriteLine(p);
        }
    }
}
```
{% endtab %}
{% endtabs %}

## Dazzling GCD Pair

#### [https://www.codechef.com/APRIL221D/problems/NOTUNIT](https://www.codechef.com/APRIL221D/problems/NOTUNIT)

{% tabs %}
{% tab title="C++" %}
```cpp
#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        long a, b, i = -1;
        cin >> a >> b;
        if (a % 2 == 0) {
            if (a + 2 <= b)
                cout << a << " " << a + 2;
            else
                cout << i;
        } else if (a % 3 == 0) {
            if (a + 3 <= b)
                cout << a << " " << a + 3;
            else
                cout << i;
        } else {
            if (a + 3 <= b)
                cout << a + 1 << " " << a + 3;
            else
                cout << i;
        }
        cout << endl;
    }
    return 0;
}
```
{% endtab %}

{% tab title="C#" %}
```csharp
public static void Main() {
    int testcases = Convert.ToInt32(Console.ReadLine());
    for (int i = 0; i < testcases; i++) {
        // your code goes here
        string[] inputs = Console.ReadLine().Split();  // input
        var a = long.Parse(inputs[0]);
        var b = long.Parse(inputs[1]);
        var result = -1;
        if (a % 2 == 0) {
            if (a + 2 <= b)
                Console.WriteLine($"{a} {a + 2}");
            else
                Console.WriteLine(result);
        } else if (a % 3 == 0) {
            if (a + 3 <= b)
                Console.WriteLine($"{a} {a + 3}");
            else
                Console.WriteLine(result);
        } else {
            if (a + 3 <= b)
                Console.WriteLine($"{a + 1} {a + 3}");
            else
                Console.WriteLine(result);
        }
    }
}
```
{% endtab %}
{% endtabs %}

## Dazzling AXNODR Challenge

#### [https://www.codechef.com/APRIL221D/problems/AXNODR](https://www.codechef.com/APRIL221D/problems/AXNODR) <a href="#https-www.codechef.com-april221d-problems-axnodr" id="https-www.codechef.com-april221d-problems-axnodr"></a>

{% tabs %}
{% tab title="C++" %}
```cpp
#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        long long n, result = 0;
        cin >> n;
        if (n % 2 == 0)  // even - bitwise XOR
        {
            if (n % 4 == 0)
                result = 3 ^ n;
            else
                result = 3;
        } else  // odd - bitwise AND
        {
            if ((n - 1) % 4 == 0)
                result = (3 ^ (n - 1)) & n;
            else
                result = 3;
        }
        cout << result << endl;
    }
    return 0;
}
```
{% endtab %}

{% tab title="C#" %}
```csharp
public static void Main() {
    int testcases = Convert.ToInt32(Console.ReadLine());
    for (int i = 0; i < testcases; i++) {
        // your code goes here
        long n = long.Parse(Console.ReadLine());
        long result = 0;
        if (n % 2 == 0) {
            if (n % 4 == 0)
                result = 3 ^ n;
            else
                result = 3;
        } else {
            if ((n - 1) % 4 == 0)
                result = (3 ^ (n - 1)) & n;
            else
                result = 3;
        }
        Console.WriteLine(result);
    }
}
```
{% endtab %}
{% endtabs %}

## Prime Sum

#### [https://www.codechef.com/APRIL221D/problems/PRIMESM](https://www.codechef.com/APRIL221D/problems/PRIMESM) <a href="#https-www.codechef.com-april221d-problems-primesm" id="https-www.codechef.com-april221d-problems-primesm"></a>

{% tabs %}
{% tab title="C++" %}
```cpp
#include <bits/stdc++.h>

#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        long long a, b, result;
        cin >> a >> b;
        if (a == 1 || b == 1)
            result = -1;
        else if (__gcd(a, b) == 1)
            result = 1;
        else
            result = 0;

        cout << result << endl;
    }
    return 0;
}
```
{% endtab %}

{% tab title="C#" %}
```csharp
public static void Main() {
    int testcases = Convert.ToInt32(Console.ReadLine());
    for (int i = 0; i < testcases; i++) {
        // your code goes here
        string[] inputs = Console.ReadLine().Split();  // input
        long a = long.Parse(inputs[0]);
        long b = long.Parse(inputs[1]);
        long result;
        if (a == 1 || b == 1)
            result = -1;
        else if (GCD(a, b) == 1)
            result = 1;
        else
            result = 0;
        Console.WriteLine(result);
    }
}

public static long GCD(long a, long b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
```
{% endtab %}
{% endtabs %}

## Pairwise Xors

#### [https://www.codechef.com/APRIL221D/problems/XORABC](https://www.codechef.com/APRIL221D/problems/XORABC) <a href="#https-www.codechef.com-april221d-problems-xorabc" id="https-www.codechef.com-april221d-problems-xorabc"></a>

{% tabs %}
{% tab title="C++" %}
```cpp
#include <iostream>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        long long x;
        cin >> x;
        long long a = x & -(x - 1);
        if (x & 1 || x == a) {
            cout << -1 << endl;
        } else {
            cout << a / 2 << " " << x / 2 << " " << (x - a) / 2 << endl;
        }
    }
    return 0;
}
```
{% endtab %}
{% endtabs %}
