Problem: Example

Input

3 5 4
3
6
12


Output

Hanako

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;

int main(){
  int n, a, b;
  long long grandy = 0;
  cin >> n >> a >> b;
  int piles[n];
  int over = 0;
  REP(i, n) cin >> piles[i];

  if (a == b){
    REP(i, n) grandy ^= piles[i] % (a+1);
    cout << (grandy == 0 ? "Jiro" : "Hanako") << endl;
    return 0;
  }

  if (a > b){
    REP(i, n) {
      grandy ^= piles[i] % (b+1);
      if(piles[i] > b) over++;
    }
    if (grandy != 0 or over != 0){
      cout << "Hanako" << endl;
    } else cout << "Jiro" << endl;
    return 0;
  }

  int maxim;
  REP(i, n){
    grandy ^= piles[i] % (a+1);
    if(piles[i] > a) { over++; maxim = piles[i]; }
  }
  if(over > 1) cout << "Jiro" << endl;
  else if(over == 0) cout << (grandy == 0 ? "Jiro" : "Hanako") << endl;
  else {
    grandy ^= maxim % (a+1);
    if(maxim - grandy <= a and grandy <= a)
      cout << "Hanako" << endl;
    else
      cout << "Jiro" << endl;
  }
  return 0;
}