Problem: Example

Input

3 5 4
3
6
12


Output

Hanako

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n, a[N], A, B;

void win()
{
	puts("Hanako");
}
void lose()
{
	puts("Jiro");
}

int main()
{
	scanf("%d%d%d",&n,&A,&B);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	
	int sg = 0, cnt = 0;
	for(int i = 1; i <= n; i++) 
	{
		sg ^= a[i] % (min(A, B) + 1);
		if(a[i] > min(A, B)) cnt++;
	}
	
	if(A == B)
	{
		sg ? win() : lose();
	}
	else if(A > B)
	{
		if(sg) win();
		else if(cnt) win();
		else lose();
	}
	else // A < B
	{
		if(!sg) lose();
		else // win ?
		{
			if(cnt == 0) win();
			else if(cnt > 1) lose();
			else // cnt = 1
			{
				int i = 0; for(i = 1; i <= n; i++) if(a[i] > A) break; // i
				
				int new_ai_sg = (a[i] % (A + 1)) ^ sg;
				
				if(new_ai_sg >= A + 1) lose();
				else
				{
					int fetch = a[i] % (A + 1) - new_ai_sg; 
					while(fetch <= 0) fetch += A + 1;
					if(fetch >= a[i]) lose();
					else if(a[i] - fetch <= A) win();
					else lose();
				}
			}
		}
	}
	
}