按题意直接模拟即可。

AC code:

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int left = 0, right = s.size() - 1;
    while (left < right) {
        while (left < right && s[left] == ',') {
            left++;
        }
        while (left < right && s[right] == ',') {
            right--;
        }
        if (left < right && s[left] != s[right]) {
            cout << "No" << endl;
            return 0;
        }
        left++;
        right--;
    }
    cout << "Yes" << endl;
    return 0;
}