Problem: Example

Input

3 5 4
3
6
12


Output

Hanako

Solution (in CPP):

Solution:
#include <iostream>

using namespace std;

int n;
int a, b;
int s[100005];

int main(void)
{
	cin >> n;
	cin >> a >> b;
	for(int i = 1; i <= n; i++) cin >> s[i];
	
	int g = 0;
	for(int i = 1; i <= n; i++) g ^= s[i] % (min(a, b)+1);
	
	if(a == b){
		if(g) cout << "Hanako" << endl;
		else cout << "Jiro" << endl;
		return 0;
	}
	
	int cnt = 0, idx;
	for(int i = 1; i <= n; i++){
		if(s[i] > min(a, b)) cnt++, idx = i;
	}
	if(a > b){
		if(cnt) cout << "Hanako" << endl;
		else{
			if(g) cout << "Hanako" << endl;
			else cout << "Jiro" << endl;
		}
	}
	else{
		if(cnt >= 2) cout << "Jiro" << endl;
		if(cnt == 0){
			if(g) cout << "Hanako" << endl;
			else cout << "Jiro" << endl;
		}
		if(cnt == 1){
			if(g == 0 || s[idx] > 2*a) cout << "Jiro" << endl;
			else{
				int tg = g ^ (s[idx] % (a+1));
				if(tg > a) cout << "Jiro" << endl;
				else if(tg > s[idx]%(a+1)) cout << "Hanako" << endl;
				else cout << "Jiro" << endl;
			}
		}
	}
	return 0;
}