Language: C++

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[502][12];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0)
        break;
        for(int i=0;i<n;i++)
        {
            scanf("%s",a[i]);
            //printf("%s\n",a[i]);
        }
        //蛻、譁ュ譏ッ蜷ヲ譏ッ豁」蠎?        int flag=0;
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if(strcmp(a[i],a[j])==0)
                {
                    continue;
                }
                else if(strcmp(a[i],a[j])<0)
                {
                    int len=strlen(a[j]);
                    int flag1=0;
                    for(int k=0;k<len;k++)
                    {
                        if(a[i][k]!=a[j][k])
                        {
                            flag1=1;
                            break;
                        }
                    }
                    if(flag1==0)
                    {
                        flag=1;
                        break;
                    }
                }
                else
                {
                    int len=strlen(a[j]);
                    int flag5=0;
                    for(int k=0;k<len;k++)
                    {
                        if(a[i][k]!=a[j][k])
                        {
                            flag5=1;
                            break;
                        }
                    }
                    if(flag5==0)
                    continue;
                    else
                    {
                        flag=1;
                     break;
                    }

                }

            }
            if(flag==1)
            break;
        }
        if(flag==0)
        printf("yes\n");
        else
        {
            int flag1=0;
            int flag3=0,flag2=0;
            for(int i=0;i<n;i++)
            {
                for(int j=i+1;j<n;j++)
                {
                    if(strcmp(a[i],a[j])==0)
                    continue;
                    else if(strcmp(a[i],a[j])<0)
                    {
                        int len=strlen(a[i]);
                        int flag4=0;
                        for(int k=0;k<len;k++)
                        {
                            if(a[i][k]!=a[j][k])
                            {
                                flag4=1;
                                break;
                            }
                        }
                        if(flag4==0)
                        continue;
                        else
                        {
                            flag1=1;
                            flag3=1;
                            printf("no\n");
                            break;
                        }
                    }
                    else
                    {
                        int len=strlen(a[j]);
                        flag2=0;
                       for(int k=0;k<len;k++)
                       {
                           if(a[j][k]!=a[i][k])
                           {
                               flag2=1;

                               break;
                           }
                       }
                       if(flag2==0)
                       {
                           flag3=1;
                           printf("no\n");
                           break;
                       }
                    }
                }
                if(flag1==1)
                {
                    break;
                }
                if(flag2==0)
                {
                    break;
                }
            }
            if(flag3==0)
            printf("yes\n");
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:25: error: 'flag' was not declared in this scope; did you mean 'flag1'?
   41 |                         flag=1;
      |                         ^~~~
      |                         flag1
a.cc:61:25: error: 'flag' was not declared in this scope; did you mean 'flag5'?
   61 |                         flag=1;
      |                         ^~~~
      |                         flag5
a.cc:68:16: error: 'flag' was not declared in this scope
   68 |             if(flag==1)
      |                ^~~~
a.cc:71:12: error: 'flag' was not declared in this scope
   71 |         if(flag==0)
      |            ^~~~