Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
#include<complex>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    map<char, int> mp;
    rep(i, h) rep(j, w) {
        char tmp_c;
        cin >> tmp_c;
        ++mp[tmp_c];
    }
    if ( h == 1 && w == 1 ) {
        cout << "Yes" << endl;
        return 0;
    }
    int one_cnt = 0;
    int two_cnt = 0;
    int four_cnt = 0;
    for ( auto tmp_mp : mp ) {
        int tmp_num = tmp_mp.second;
        four_cnt += tmp_num / 4;
        tmp_num -= tmp_num / 4 * 4;
        two_cnt += tmp_num / 2;
        tmp_num -= tmp_num / 2 * 2;
        one_cnt += tmp_num;
    }
    if ( h == 1 ) {
        if ( w % 2 == 1 ) {
            if ( one_cnt == 1 ) {
                cout << "Yes" << endl;
                return 0;
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if ( one_cnt == 0 ) {
                cout << "Yes" << endl;
                return 0;
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if ( w == 1 ) {
        if ( h % 2 == 1 ) {
            if ( one_cnt == 1 ) {
                cout << "Yes" << endl;
                return 0;
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if ( one_cnt == 0 ) {
                cout << "Yes" << endl;
                return 0;
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    else if ( h % 2 == 0 && w % 2 == 0 ) {
        if ( h == 2 && w == 2 ) {
            if ( four_cnt == 1 || two_cnt == 2 || onw_cnt == 4 ) {
                cout << "Yes" << endl;
                return 0;
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        }
        else if ( four_cnt == 0 || two_cnt != 0 || one_cnt != 0 ) {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }
    else if ( h % 2 == 1 && w % 2 == 1 ) {
        if ( four_cnt * 4 < ( h - 1 ) * ( w - 1 ) ) {
            cout << "No"<< endl;
            return 0;
        }
        if ( four_cnt * 4 > ( h - 1 ) * ( w - 1 ) ) {
            two_cnt += four_cnt * 4 - ( h -1 ) * ( w - 1 );
        }
//        cout << four_cnt << " " << two_cnt << " " << one_cnt << endl;
        if ( two_cnt * 2 != h + w - 1 ) {
            cout << "No" << endl;
            return 0;
        }
        if ( one_cnt != 1 ) {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    }
    else if ( h % 2 == 0 && w % 2 == 1 ) {
        if ( four_cnt * 4 < h * ( w - 1 ) ) {
            cout << "No"<< endl;
            return 0;
        }
        if ( four_cnt * 4 > h * ( w - 1 ) ) {
            two_cnt += four_cnt * 4 - h * ( w - 1 );
        }
//        cout << four_cnt << " " << two_cnt << " " << endl;
        if ( two_cnt * 2 != h ) {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    }
    else {
        if ( four_cnt * 4 < w * ( h - 1 ) ) {
            cout << "No"<< endl;
            return 0;
        }
        if ( four_cnt * 4 > w * ( h - 1 ) ) {
            two_cnt += four_cnt * 4 - w * ( h - 1 );
        }
        if ( two_cnt * 2 != w ) {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:90:51: error: 'onw_cnt' was not declared in this scope; did you mean 'one_cnt'?
   90 |             if ( four_cnt == 1 || two_cnt == 2 || onw_cnt == 4 ) {
      |                                                   ^~~~~~~
      |                                                   one_cnt