Language: C++


#include <cmath>
using namespace std;

int main() {
    int H, W;
    char A[110][110];
    cin >> H >> W;

    for(int i=0; i<H; i++){
        for(int j =0; j<W; j++){
            cin >> A[i][j];
        }
    }

    // search row
    int i = 0, j=0, k=0;
    int row[30] = {};
    int flag = 0;
    if(H%2 == 0){
        for(i=0; i<H; i++){
            row[30] = {};
            for(j =0; j<W; j++){
                row[ A[i][j] - '0']++;
            }
            for(k =0; k<26; k++){
                if(row[k]%2 != 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }else{
        for(i=0; i<H; i++){
            row[30] = {};
            for(j =0; j<W; j++){
                row[ A[i][j] - '0']++;
            }
            for(k =0; k<26; k++){
                if(row[k]%2 != 0){
                    if(flag == 0){
                        flag = 1;
                    }else{
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }

    //search col
    int col[30] = {};
    if(W%2 == 0){
        for(j=0; j<W; j++){
            col[30] = {};
            for(i = 0; i<H; i++){
                col[ A[i][j] - 97]++;
            }
            for(k =0; k<26; k++){
                if(col[k]%2 != 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }else{
        for(j=0; j<W; j++){
            col[30] = {};
            for(i =0; i<H; i++){
                col[ A[i][j] - '0']++;
            }
            flag = 0;
            for(k =0; k<26; k++){
                if(col[k]%2 != 0){
                    if(flag == 0){
                        flag = 1;
                    }else{
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     cin >> H >> W;
      |     ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <cmath>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:28:21: error: 'cout' was not declared in this scope
   28 |                     cout << "No" << endl;
      |                     ^~~~
a.cc:28:21: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:28:37: error: 'endl' was not declared in this scope
   28 |                     cout << "No" << endl;
      |                                     ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <cmath>
  +++ |+#include <ostream>
    3 | using namespace std;
a.cc:44:25: error: 'cout' was not declared in this scope
   44 |                         cout << "No" << endl;
      |                         ^~~~
a.cc:44:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:44:41: error: 'endl' was not declared in this scope
   44 |                         cout << "No" << endl;
      |                                         ^~~~
a.cc:44:41: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:62:21: error: 'cout' was not declared in this scope
   62 |                     cout << "No" << endl;
      |                     ^~~~
a.cc:62:21: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:62:37: error: 'endl' was not declared in this scope
   62 |                     cout << "No" << endl;
      |                                     ^~~~
a.cc:62:37: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:79:25: error: 'cout' was not declared in this scope
   79 |                         cout << "No" << endl;
      |                         ^~~~
a.cc:79:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:79:41: error: 'endl' was not declared in this scope
   79 |                         cout << "No" << endl;
      |                                         ^~~~
a.cc:79:41: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:86:5: error: 'cout' was not declared in this scope
   86 |     cout << "Yes" << endl;
      |     ^~~~
a.cc:86:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:86:22: error: 'endl' was not declared in this scope
   86 |     cout << "Yes" << endl;
      |                      ^~~~
a.cc:86:22: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'