Language: C++

#include <cstring>
#include <cstdio>
#include <iostream>

using namespace std;

unsigned char cost[1<<20];
int mask[5][5][6][6];
void gen(){
	memset(cost,-1,sizeof(cost));
	cost[0]=0;
	rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
		int m=(1<<w)-1;
		rep(k,h)mask[i][j][h][w]^=m<<(i+k)*5+j;
	}
	queue<int> Q; Q.push(0); int cnt=0;
	while(!Q.empty()){
		int c=Q.front(),cc=cost[c]; Q.pop();
		rep(i,4)rep(j,5)for(int h=1;h<=4-i;h++)for(int w=1;w<=5-j;w++){
			int nc=c^mask[i][j][h][w];
			if(cost[nc]>cc+1)cost[nc]=cc+1,Q.push(nc);
		}
	}
}
int lim;
int getcost(int c){
	int ret=cost[c&(1<<20)-1],bit=0;
	for(c>>=20;c;c&=c-1)bit++;
	return ret+min(bit,6-bit);
}
void rec(int c,int x,int cnt){
	if(c>>20==0)lim=min(lim,cost[c]+cnt);
	if(x>=5)return;
	
	rep(i,5)for(int j=x;j<5;j++){
		int nc=c^mask[i][x][5-i][j-x+1];
		if(!(nc&1<<20+x))rec(nc,x+1,cnt+1);
	}
	if(!(c&1<<20+x))rec(c,x+1,cnt);
}
int solve(int c){
	lim=getcost(c);
	rec(c,0,0);
	return lim;
}
int main(){
	gen();
	
	int n,ans;
	while(cin>>n,n){
		int c=0,t;
		rep(i,n)rep(j,n){
			cin>>t;
			if(t)c^=1<<i*5+j;
		}
		ans=n<5?cost[c]:solve(c);
		rep(i,ans)cout<<"myon"; cout<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void gen()':
a.cc:12:13: error: 'i' was not declared in this scope
   12 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |             ^
a.cc:12:9: error: 'rep' was not declared in this scope
   12 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |         ^~~
a.cc:12:37: error: 'h' was not declared in this scope
   12 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |                                     ^
a.cc:12:60: error: 'w' was not declared in this scope
   12 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |                                                            ^
a.cc:12:65: error: 'j' was not declared in this scope
   12 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |                                                                 ^
a.cc:16:9: error: 'queue' was not declared in this scope
   16 |         queue<int> Q; Q.push(0); int cnt=0;
      |         ^~~~~
a.cc:4:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    3 | #include <iostream>
  +++ |+#include <queue>
    4 | 
a.cc:16:15: error: expected primary-expression before 'int'
   16 |         queue<int> Q; Q.push(0); int cnt=0;
      |               ^~~
a.cc:16:23: error: 'Q' was not declared in this scope
   16 |         queue<int> Q; Q.push(0); int cnt=0;
      |                       ^
a.cc: In function 'void rec(int, int, int)':
a.cc:35:13: error: 'i' was not declared in this scope
   35 |         rep(i,5)for(int j=x;j<5;j++){
      |             ^
a.cc:35:9: error: 'rep' was not declared in this scope; did you mean 'rec'?
   35 |         rep(i,5)for(int j=x;j<5;j++){
      |         ^~~
      |         rec
a.cc:35:29: error: 'j' was not declared in this scope
   35 |         rep(i,5)for(int j=x;j<5;j++){
      |                             ^
a.cc: In function 'int main()':
a.cc:52:21: error: 'i' was not declared in this scope
   52 |                 rep(i,n)rep(j,n){
      |                     ^
a.cc:52:17: error: 'rep' was not declared in this scope; did you mean 'rec'?
   52 |                 rep(i,n)rep(j,n){
      |                 ^~~
      |                 rec