Language: C

#include <stdio.h>

int main(int argc, const char * argv[])
{
    int num;
    int i, j, k, l;
    
    scanf("%d", &num);
    for (l = 0; l < num + 1; l++) {
        char snake[200];
        int bodyacnt = 0;
        int bodybcnt = 0;
        int midcnt = 0;
        int endacnt = 0;
        int endbcnt = 0;
        int nacnt = 0;
        for (i = 0; i < 200; i++) {
            scanf("%c", &snake[i]);
            if (snake[i] == '\n') {
               // printf("%d\n", i);
                break;
            }
        }
        if (snake[0] == '>') {
            if (snake[1] == '\'') {
                for (j = 2; j < i; j++) {
                    if (snake[j] == '=') {
                        bodyacnt++;
                    }
                    else if (snake[j] == '#'){
                        break;
                    }
                }
                else nacnt++;
                for (k = j; k < i; k++) {
                    if (snake[k] == '=') {
                        midcnt++;
                    }
                    else if (snake[k] == '~'){
                        endacnt++;
                        if (endacnt == 2) {
                            nacnt++;
                        }
                    }
                    else nacnt++;
                }
            }
            else if (snake[1] == '^') {
                for (j = 2; j < i / 2; j+=2) {
                    if (snake[j] == 'Q' && snake[j + 1] == '=') {
                        bodybcnt++;
                    }
                    else nacnt++;
                }
                if (snake[i - 2] == '~' && snake[i - 1] == '~' && snake[i - 3] != '~') {
                    endbcnt++;
                }
            }
            else nacnt++;
        }
    
        if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){
            printf("B\n");
        }
        else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) {
            printf("A\n");
        }
        else if (l != 0)printf("NA\n");
    }
    
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:34:17: error: expected '}' before 'else'
   34 |                 else nacnt++;
      |                 ^~~~
main.c:62:13: error: 'bodybcnt' undeclared (first use in this function)
   62 |         if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){
      |             ^~~~~~~~
main.c:62:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:62:29: error: 'endbcnt' undeclared (first use in this function)
   62 |         if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){
      |                             ^~~~~~~
main.c:62:45: error: 'nacnt' undeclared (first use in this function)
   62 |         if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){
      |                                             ^~~~~
main.c:65:18: error: 'bodyacnt' undeclared (first use in this function)
   65 |         else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) {
      |                  ^~~~~~~~
main.c:65:30: error: 'midcnt' undeclared (first use in this function)
   65 |         else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) {
      |                              ^~~~~~
main.c:65:40: error: 'endacnt' undeclared (first use in this function)
   65 |         else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) {
      |                                        ^~~~~~~
main.c: At top level:
main.c:71:5: error: expected identifier or '(' before 'return'
   71 |     return 0;
      |     ^~~~~~
main.c:72:1: error: expected identifier or '(' before '}' token
   72 | }
      | ^