Problem: Example

Input

3 5 4
3
6
12


Output

Hanako

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

enum Which{
	Hanako,
	Jiro,
};

int N,A,B;
int table[NUM];

int calc_xor(int mod){

	int ret = 0;

	for(int i = 0; i < N; i++){
		ret ^= (table[i]%mod);
	}

	return ret;
}

int main(){

	scanf("%d %d %d",&N,&A,&B);

	for(int i = 0; i < N; i++){
		scanf("%d",&table[i]);
	}

	Which winner;
	bool FLG;

	if(A == B){

		if(calc_xor(A+1) != 0){

			winner = Hanako;

		}else{
			winner = Jiro;
		}
	}else if(A > B){

		FLG = false;

		for(int i = 0; i < N; i++){
			if(table[i] >= B+1){
				FLG = true;
				break;
			}
		}

		if(FLG){

			winner = Hanako;

		}else{

			if(calc_xor(B+1) != 0){

				winner = Hanako;

			}else{

				winner = Jiro;
			}
		}

	}else{ //A < B

		int tmp_count = 0;
		int tmp_index,other_xor;

		for(int i = 0; i < N; i++){
			if(table[i] >= A+1){
				tmp_count++;
				tmp_index = i;
			}
		}

		if(tmp_count >= 2){

			winner = Jiro;

		}else{

			if(tmp_count == 0){

				if(calc_xor(A+1) != 0){

					winner = Hanako;

				}else{

					winner = Jiro;
				}
			}else{ //tmp_count == 1

				FLG = false;

				other_xor = 0;

				for(int i = 0; i < N; i++){
					if(i == tmp_index)continue;
					other_xor ^= (table[i]%(A+1));
				}

				for(int i = 1; i <= A; i++){

					if(table[tmp_index]-i >= A+1)continue;

					if((other_xor^(table[tmp_index]-i)%(A+1)) == 0){

						FLG = true;
						break;
					}
				}

				if(FLG){

					winner = Hanako;

				}else{

					winner = Jiro;
				}
			}
		}
	}

	if(winner == Hanako){

		printf("Hanako\n");

	}else{

		printf("Jiro\n");
	}

	return 0;
}