Problem: Example

Input

3 5 4
3
6
12


Output

Hanako

Solution (in CPP):

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

int n, A, B, s[100005];

signed main(){
  
  cin>>n>>A>>B;
  
  for(int i=0;i<n;i++) cin>>s[i];
  
  if( A == B ){
    
    int x = 0;
    
    for(int i=0;i<n;i++){
      
      x ^= s[i] % ( A + 1 );
      
    }
    
    if( x == 0 ) cout<<"Jiro"<<endl;
    else cout<<"Hanako"<<endl;
    
  }
  
  if( A > B ){
    
    int flag = 0;
    
    for(int i=0;i<n;i++)
      if( s[i] > B ) flag = 1;
    
    if( flag == 1 ) cout<<"Hanako"<<endl;
    else{
      
      int x = 0;
    
      for(int i=0;i<n;i++) x ^= s[i];
      
      if( x == 0 ) cout<<"Jiro"<<endl;
      else cout<<"Hanako"<<endl;
      
    }
    
  }

  if( A < B ){
    
    int cnt = 0, idx;
    
    for(int i=0;i<n;i++)
      if( A < s[i] ) cnt++, idx = i;
    
    if( cnt > 1 ) cout<<"Jiro"<<endl;
    else{
      
      if( cnt == 1 ){
	
	if( s[idx] - A <= A ){
	  
	  int x = 0;
    
	  for(int i=0;i<n;i++)
	    if( s[i] <= A ) x ^= s[i];

	  if( s[idx] > x && s[idx] - x <= A && x <= A ) cout<<"Hanako"<<endl;
	  else cout<<"Jiro"<<endl;
	  
	} else cout<<"Jiro"<<endl;
	
      }else{
	
	int x = 0;
    
	for(int i=0;i<n;i++)
	  if( s[i] <= A ) x ^= s[i];

	if( x == 0 ) cout<<"Jiro"<<endl;
	else cout<<"Hanako"<<endl;
	
      }
      
    }
    
  }
      
  return 0;
}