Problem: Example

Input

3 5 4
3
6
12


Output

Hanako

Solution (in CPP):

Solution:
#include <iostream>
using namespace std;

long long N, A, B, T[1 << 17];

int main() {
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) cin >> T[i];

	if (A > B) {
		bool ok1 = true; long long mask = 0;
		for (int i = 0; i < N; i++) { if (T[i] > B) ok1 = false; mask ^= T[i]; }

		if (ok1 == false) cout << "Hanako" << endl;
		else if (mask == 0) cout << "Jiro" << endl;
		else cout << "Hanako" << endl;
	}
	else if (A == B) {
		long long mask = 0;
		for (int i = 0; i < N; i++) mask ^= (T[i] % (A + 1));
		
		if (mask == 0) cout << "Jiro" << endl;
		else cout << "Hanako" << endl;
	}
	else if (A < B) {
		bool ok1 = true; long long mask = 0;
		for (int i = 0; i < N; i++) { if (T[i] > A) ok1 = false; mask ^= T[i]; }

		if (ok1 == true) {
			if (mask != 0) cout << "Hanako" << endl;
			else cout << "Jiro" << endl;
		}
		else {
			long long mask2 = 0, t = -1, cnt = 0;
			for (int i = 0; i < N; i++) {
				if (T[i] > A) { cnt++; t = T[i]; }
				else mask2 ^= T[i];
			}
			if (cnt == 1 && (t - mask2) >= 1 && (t - mask2) <= A && mask2 <= A) cout << "Hanako" << endl;
			else cout << "Jiro" << endl;
		}
	}
	return 0;
}