Problem: Example

Input

3 5 4
3
6
12


Output

Hanako

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	if (A == B) {
		int res = 0;
		for (int i = 0, S; i < N; i++) {
			cin >> S;
			res ^= S % (A + 1);
		}
		cout << (res ? "Hanako" : "Jiro") << endl;
	}
	else if (A > B) {
		bool flag = false;
		int res = 0;
		for (int i = 0, S; i < N; i++) {
			cin >> S;
			if (S > B) flag = true;
			res ^= S % (B + 1);
		}
		cout << (flag || res ? "Hanako" : "Jiro") << endl;
	}
	else {
		int cnt = 0;
		int res = 0;
		vector<int> S(N);
		for (int i = 0; i < N; i++) {
			cin >> S[i];
			if (S[i] > A) cnt++;
			res ^= S[i] % (A + 1);
		}
		if (cnt == 0) {
			cout << (res ? "Hanako" : "Jiro") << endl;
		}
		else if (cnt >= 2 || res == 0) {
			cout << "Jiro" << endl;
		}
		else {
			for (int i = 0; i < N; i++) {
				if (S[i] > A) {
					int tmp = S[i] % (A + 1); tmp ^= res;
					cout << (tmp <= A && S[i] - tmp <= A && S[i] > tmp ? "Hanako" : "Jiro") << endl;
				}
			}
		}
	}
	return 0;
}