Language: C++

#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

void draw2(vector<vector<char>>& res, int s, int t) {
	res[s][t] = 'a';
	res[s][t + 1] = 'a';
	res[s][t + 2] = 'b';
	res[s + 1][t + 2] = 'b';
	res[s + 2][t + 1] = 'd';
	res[s + 2][t + 2] = 'd';
	res[s + 1][t] = 'c';
	res[s + 2][t] = 'c';
}

void draw1(vector<vector<char>>& res, int s, int t) {
	res[s][t] = 'a';
	res[s+1][t] = 'a';
	res[s + 2][t + 1] = 'd';
	res[s + 2][t + 2] = 'd';
}

void draw7(vector<vector<char>>& res, int s, int t) {
	REP(i, 2) {
		REP(j, 2) {
			draw1(res, s + i * 3, t + j * 3);
		}
	}
	res[s + 6][t + 0] = 'e';
	res[s + 6][t + 1] = 'e';
	res[s + 6][t + 2] = 'f';
	res[s + 6][t + 3] = 'f';
	res[s + 6][t + 4] = 'g';
	res[s + 6][t + 5] = 'g';

	res[s + 0][t + 6] = 'e';
	res[s + 1][t + 6] = 'e';
	res[s + 2][t + 6] = 'f';
	res[s + 3][t + 6] = 'f';
	res[s + 4][t + 6] = 'g';
	res[s + 5][t + 6] = 'g';
}

void draw8(vector<vector<char>>& res, int s, int t) {
	REP(i, 2) {
		REP(j, 2) {
			draw1(res, s + i * 3, t + j * 3);
		}
	}
	res[s + 6][t + 0] = 'e';
	res[s + 7][t + 0] = 'e';
	res[s + 7][t + 1] = 'f';
	res[s + 7][t + 2] = 'f';
	res[s + 6][t + 3] = 'g';
	res[s + 6][t + 4] = 'g';
	res[s + 6][t + 5] = 'h';
	res[s + 7][t + 5] = 'h';

	res[s + 0][t + 6] = 'e';
	res[s + 0][t + 7] = 'e';
	res[s + 1][t + 7] = 'f';
	res[s + 2][t + 7] = 'f';
	res[s + 3][t + 6] = 'g';
	res[s + 4][t + 6] = 'g';
	res[s + 5][t + 6] = 'h';
	res[s + 5][t + 7] = 'h';

}

void draw4(vector<vector<char>>& res, int s, int t) {
	res[s + 0][t + 0] = 'i';
	res[s + 1][t + 0] = 'i';
	res[s + 0][t + 1] = 'j';
	res[s + 1][t + 1] = 'j';
	res[s + 2][t + 2] = 'i';
	res[s + 3][t + 2] = 'i';
	res[s + 2][t + 3] = 'j';
	res[s + 3][t + 3] = 'j';

	res[s + 2][t + 0] = 'k';
	res[s + 2][t + 1] = 'k';
	res[s + 3][t + 0] = 'l';
	res[s + 3][t + 1] = 'l';
	res[s + 0][t + 2] = 'k';
	res[s + 0][t + 3] = 'k';
	res[s + 1][t + 2] = 'l';
	res[s + 1][t + 3] = 'l';

}

void draw5(vector<vector<char>>& res, int s, int t) {
	res[s + 0][t + 0] = 'i';
	res[s + 1][t + 0] = 'i';
	res[s + 0][t + 1] = 'j';
	res[s + 0][t + 2] = 'j';
	res[s + 1][t + 2] = 'k';
	res[s + 1][t + 3] = 'k';
	res[s + 0][t + 4] = 'l';
	res[s + 1][t + 4] = 'l';

	res[s + 2][t + 0] = 'm';
	res[s + 2][t + 1] = 'm';
	res[s + 4][t + 0] = 'n';
	res[s + 4][t + 1] = 'n';

	res[s + 2][t + 3] = 'o';
	res[s + 2][t + 4] = 'o';
	res[s + 4][t + 3] = 'p';
	res[s + 4][t + 4] = 'p';

	res[s + 2][t + 2] = 'q';
	res[s + 3][t + 2] = 'q';
	

}
int main() {
	IOS;
	ll n;
	cin >> n;
	ll m = n % 3;
	if (n == 2) {
		put(-1);
		return 0;
	} else if (n == 4 || n == 10) {
		vector<vector<char>> res(n, vector<char>(n, '.'));
		if (n == 10) {
			draw1(res, 0, 0);
			draw2(res, 0, 3);
			draw1(res, 3, 3);
			draw2(res, 3, 0);
			draw4(res, 6, 6);
		} else {
			draw4(res, 0, 0);
		}
		REP(i, n) {
			REP(j, n) {
				cout << res[i][j];
			}
			cout << "\n";
		}
	} else if(n==5||n==11){
		res[0].at(10000);
		vector<vector<char>> res(n, vector<char>(n, '.'));
		if (n == 11) {
			draw1(res, 0, 0);
			draw2(res, 0, 3);
			draw1(res, 3, 3);
			draw2(res, 3, 0);
			draw5(res, 6, 6);
		} else {
			draw5(res, 0, 0);
		}
		REP(i, n) {
			REP(j, n) {
				cout << res[i][j];
			}
			cout << "\n";
		}
	} else {
		vector<vector<char>> res(n, vector<char>(n, '.'));
		if (m == 0) {
			REP(i, n / 3) {
				int s = i * 3;
				int t = s;
				draw1(res, s, t);
			}
		} else {
			REP(i, n / 3 - 2) {
				int s = i * 3;
				int t1 = s;
				int t2 = s + 3;
				if (i == n / 3 - 3) {
					t2 = 0;
				}
				draw1(res, s, t1);
				draw2(res, s, t2);
			}
			int tmp = (n / 3 - 2) * 3;
			if (m == 1) {
				draw7(res, tmp, tmp);
			} else {
				draw8(res, tmp, tmp);
			}
		}
		REP(i, n) {
			REP(j, n) {
				cout << res[i][j];
			}
			cout << "\n";
		}
	}
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:171:17: error: 'res' was not declared in this scope
  171 |                 res[0].at(10000);
      |                 ^~~