Language: C++

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:4:9: error: 'memset' was not declared in this scope
    4 |         memset(cost,-1,sizeof(cost));
      |         ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | unsigned char cost[1<<20];
a.cc:6:13: error: 'i' was not declared in this scope
    6 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |             ^
a.cc:6:9: error: 'rep' was not declared in this scope
    6 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |         ^~~
a.cc:6:37: error: 'h' was not declared in this scope
    6 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |                                     ^
a.cc:6:60: error: 'w' was not declared in this scope
    6 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |                                                            ^
a.cc:6:65: error: 'j' was not declared in this scope
    6 |         rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){
      |                                                                 ^
a.cc:10:9: error: 'queue' was not declared in this scope
   10 |         queue<int> Q; Q.push(0); int cnt=0;
      |         ^~~~~
a.cc:10:15: error: expected primary-expression before 'int'
   10 |         queue<int> Q; Q.push(0); int cnt=0;
      |               ^~~
a.cc:10:23: error: 'Q' was not declared in this scope
   10 |         queue<int> Q; Q.push(0); int cnt=0;
      |                       ^
a.cc: In function 'int getcost(int)':
a.cc:23:20: error: 'min' was not declared in this scope
   23 |         return ret+min(bit,6-bit);
      |                    ^~~
a.cc: In function 'void rec(int, int, int)':
a.cc:26:25: error: 'min' was not declared in this scope
   26 |         if(c>>20==0)lim=min(lim,cost[c]+cnt);
      |                         ^~~
a.cc:29:13: error: 'i' was not declared in this scope
   29 |         rep(i,5)for(int j=x;j<5;j++){
      |             ^
a.cc:29:9: error: 'rep' was not declared in this scope; did you mean 'rec'?
   29 |         rep(i,5)for(int j=x;j<5;j++){
      |         ^~~
      |         rec
a.cc:29:29: error: 'j' was not declared in this scope
   29 |         rep(i,5)for(int j=x;j<5;j++){
      |                             ^
a.cc: In function 'int main()':
a.cc:44:15: error: 'cin' was not declared in this scope
   44 |         while(cin>>n,n){
      |               ^~~
a.cc:46:21: error: 'i' was not declared in this scope
   46 |                 rep(i,n)rep(j,n){
      |                     ^
a.cc:46:17: error: 'rep' was not declared in this scope; did you mean 'rec'?
   46 |                 rep(i,n)rep(j,n){
      |                 ^~~
      |                 rec
a.cc:51:41: error: 'cout' was not declared in this scope; did you mean 'cost'?
   51 |                 rep(i,ans)cout<<"myon"; cout<<endl;
      |                                         ^~~~
      |                                         cost
a.cc:51:47: error: 'endl' was not declared in this scope
   51 |                 rep(i,ans)cout<<"myon"; cout<<endl;
      |                                               ^~~~