Language: C++

#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

//! nコで奇数がoコあるときにpにできるか
int win[1000][1000][2];
int solve(int n, int o, int p){
  int& res = win[n][o][p];
  if(res) return res;

  if(n == 2){
	if(p)
	  res = (o==2? 1: -1);
	else
	  res = (o==0? 1: -1);
	return res;
  }

  // e, o
  if(n > o && o >= 1){
	if(solve(n-1, o, p^1) < 0)
	  return res = 1;
  }
  // o, o
  if(o >= 2){
	if(solve(n-1, o-2, p^1) < 0)
	  return res = 1;
  }
  // e, e
  if(n-o >= 2){
	if(solve(n-1, o, p^1) < 0)
	  return res = 1;
  }

  return res = -1;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V;
  cin >> V;
  int E = 0;
  VVI G(V);
  REP(i,V){
	string s;
	cin >> s;
	REP(j,V){
	  if(s[j] == 'Y'){
		++E;
		G[i].PB(j);
	  }
	}
  }
  E /= 2;

  if(V%2 == 1){
	cout << ((V*(V-1)/2 - E)%2==0? "Hanako": "Taro") << endl;
  }
  else{
	vector<bool> vis(V);
	function<int(int)> dfs = [&](int u){
	  int res = 1;
	  vis[u] = true;
	  for(int to: G[u]){
		if(vis[to]) continue;
		res += dfs(to);
	  }
	  return res;
	};

	int n = 0, o = 0;
	REP(i,V)
	  if(!vis[i]){
		++n;
		if(dfs(i)%2)
		  ++o;
	  }

	int p = (V * (V-1) / 2 - E) % 2;
	//cout << n << ","<<o<<","<<p<<endl;
	cout << (solve(n, o, 1^p)>0? "Taro": "Hanako") << endl;
  }

  return 0;
}
#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

//! nコで奇数がoコあるときにpにできるか
int win[1000][1000][2];
int solve(int n, int o, int p){
  int& res = win[n][o][p];
  if(res) return res;

  if(n == 2){
	if(p)
	  res = (o==2? 1: -1);
	else
	  res = (o==0? 1: -1);
	return res;
  }

  // e, o
  if(n > o && o >= 1){
	if(solve(n-1, o, p^1) < 0)
	  return res = 1;
  }
  // o, o
  if(o >= 2){
	if(solve(n-1, o-2, p^1) < 0)
	  return res = 1;
  }
  // e, e
  if(n-o >= 2){
	if(solve(n-1, o, p^1) < 0)
	  return res = 1;
  }

  return res = -1;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V;
  cin >> V;
  int E = 0;
  VVI G(V);
  REP(i,V){
	string s;
	cin >> s;
	REP(j,V){
	  if(s[j] == 'Y'){
		++E;
		G[i].PB(j);
	  }
	}
  }
  E /= 2;

  if(V%2 == 1){
	cout << ((V*(V-1)/2 - E)%2==0? "Hanako": "Taro") << endl;
  }
  else{
	vector<bool> vis(V);
	function<int(int)> dfs = [&](int u){
	  int res = 1;
	  vis[u] = true;
	  for(int to: G[u]){
		if(vis[to]) continue;
		res += dfs(to);
	  }
	  return res;
	};

	int n = 0, o = 0;
	REP(i,V)
	  if(!vis[i]){
		++n;
		if(dfs(i)%2)
		  ++o;
	  }

	int p = (V * (V-1) / 2 - E) % 2;
	//cout << n << ","<<o<<","<<p<<endl;
	cout << (solve(n, o, 1^p)>0? "Taro": "Hanako") << endl;
  }

  return 0;
}

Compiler output:
a.cc:161:10: error: redefinition of 'template<class S, class T> std::istream& operator>>(std::istream&, std::pair<_T1, _T2>&)'
  161 | istream& operator>>(istream& is, pair<S,T>& p){
      |          ^~~~~~~~
a.cc:29:10: note: 'template<class S, class T> std::istream& operator>>(std::istream&, std::pair<_T1, _T2>&)' previously declared here
   29 | istream& operator>>(istream& is, pair<S,T>& p){
      |          ^~~~~~~~
a.cc:165:10: error: redefinition of 'template<class S, class T> std::ostream& operator<<(std::ostream&, const std::pair<_T1, _T2>&)'
  165 | ostream& operator<<(ostream& os, const pair<S,T>& p){
      |          ^~~~~~~~
a.cc:33:10: note: 'template<class S, class T> std::ostream& operator<<(std::ostream&, const std::pair<_T1, _T2>&)' previously declared here
   33 | ostream& operator<<(ostream& os, const pair<S,T>& p){
      |          ^~~~~~~~
a.cc:169:6: error: redefinition of 'template<class T> void maxi(T&, T)'
  169 | void maxi(T& x, T y){
      |      ^~~~
a.cc:37:6: note: 'template<class T> void maxi(T&, T)' previously declared here
   37 | void maxi(T& x, T y){
      |      ^~~~
a.cc:173:6: error: redefinition of 'template<class T> void mini(T&, T)'
  173 | void mini(T& x, T y){
      |      ^~~~
a.cc:41:6: note: 'template<class T> void mini(T&, T)' previously declared here
   41 | void mini(T& x, T y){
      |      ^~~~
a.cc:178:14: error: redefinition of 'const double EPS'
  178 | const double EPS = 1e-10;
      |              ^~~
a.cc:46:14: note: 'const double EPS' previously defined here
   46 | const double EPS = 1e-10;
      |              ^~~
a.cc:179:14: error: redefinition of 'const double PI'
  179 | const double PI  = acos(-1.0);
      |              ^~
a.cc:47:14: note: 'const double PI' previously defined here
   47 | const double PI  = acos(-1.0);
      |              ^~
a.cc:180:10: error: redefinition of 'const LL MOD'
  180 | const LL MOD = 1e9+7;
      |          ^~~
a.cc:48:10: note: 'const LL MOD' previously defined here
   48 | const LL MOD = 1e9+7;
      |          ^~~
a.cc:183:5: error: redefinition of 'int win [1000][1000][2]'
  183 | int win[1000][1000][2];
      |     ^~~
a.cc:51:5: note: 'int win [1000][1000][2]' previously declared here
   51 | int win[1000][1000][2];
      |     ^~~
a.cc:184:5: error: redefinition of 'int solve(int, int, int)'
  184 | int solve(int n, int o, int p){
      |     ^~~~~
a.cc:52:5: note: 'int solve(int, int, int)' previously defined here
   52 | int solve(int n, int o, int p){
      |     ^~~~~
a.cc:215:5: error: redefinition of 'int main()'
  215 | int main(){
      |     ^~~~
a.cc:83:5: note: 'int main()' previously defined here
   83 | int main(){
      |     ^~~~