malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2222, mod = 998244353;   int add(int x, int y) {     x += y;     return x >= mod ? x - mod : x;   }   int mul(int x, int y) { return 1ll * x * y % mod; }   int qpow(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = mul(ans, a);       a = mul(a, a), b >>= 1;     }     return ans;   }   int f[maxn][maxn], g[maxn], h[maxn], n, p, q, a, b, pp[maxn], pq[maxn],       cc[maxn];   int main() {     cin >> n >> a >> b;     p = mul(a, qpow(b, mod - 2));     q = add(1, mod - p);     for (int i = pp[0] = pq[0] = 1; i <= n; i++)       pp[i] = mul(pp[i - 1], p), pq[i] = mul(pq[i - 1], q);     f[0][0] = 1;     for (int i = 0; i < n; i++) {       for (int j = 0; j <= i; j++) {         f[i + 1][j + 1] = add(f[i + 1][j + 1], mul(f[i][j], pq[i - j]));         f[i + 1][j] = add(f[i + 1][j], mul(f[i][j], pp[j]));       }     }     g[1] = 1, g[2] = 0;     for (int i = 3; i <= n; i++) {       g[i] = 1;       for (int j = 1; j < i; j++) g[i] = add(g[i], mod - mul(g[j], f[i][j]));       cc[i] = 1ll * i * (i - 1) / 2 % mod;     }     cc[2] = 1;     h[1] = 0, h[2] = 1;     for (int i = 3; i <= n; i++) {       for (int j = 1; j < i; j++) {         h[i] =             add(h[i], mul(mul(f[i][j], g[j]),                           add(h[j], add(h[i - j], add(cc[i], mod - cc[i - j])))));       }       h[i] = add(h[i], mul(g[i], cc[i]));       h[i] = mul(h[i], qpow(add(1, mod - g[i]), mod - 2));     }     cout << h[n];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   vector<int> g[100005];   int siz[100005];   bool era[100005];   long long rans;   int col[100005];   int calc(int v, int p) {     int cnt = 1;     for (int i = 0; i < (int)g[v].size(); i++) {       int to = g[v][i];       if (to == p || era[to]) continue;       cnt += calc(to, v);     }     siz[v] = cnt;     return cnt;   }   pair<int, int> fnd(int v, int p, int t) {     pair<int, int> res = make_pair(1e9, -1);     int cnt = 1, mx = 0;     for (int i = 0; i < (int)g[v].size(); i++) {       int to = g[v][i];       if (to == p || era[to]) continue;       res = min(res, fnd(to, v, t));       cnt += siz[to];       mx = max(mx, siz[to]);     }     mx = max(mx, t - cnt);     res = min(res, make_pair(mx, v));     return res;   }   void solve(int v, int lev) {     calc(v, -1);     int s = fnd(v, -1, siz[v]).second;     era[s] = 1;     col[s] = lev;     for (int i = 0; i < (int)g[s].size(); i++) {       if (era[g[s][i]]) continue;       solve(g[s][i], lev + 1);     }     era[s] = 0;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       int a, b;       scanf( %d %d , &a, &b);       g[a].push_back(b);       g[b].push_back(a);     }     solve(1, 1);     for (int i = 1; i <= n; i++)       if (col[i] > 26) {         puts( Impossible! );         return 0;       }     for (int i = 1; i <= n; i++) printf( %c  , col[i] - 1 +  A );     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> v(n);       for (int i = 0; i < n; i++) cin >> v[i];       long long ans = 0;       for (int i = 30; i >= 0; i--) {         vector<int> v1;         int cnt1 = 0, cnt2 = 0;         for (int x : v) {           if (x & (1 << i)) {             cnt1++;           } else {             cnt2++;             v1.push_back(x);           }         }         ans += (1LL * cnt1 * (cnt1 - 1));         int len = v.size();         while (len--) v.pop_back();         for (int x : v1) v.push_back(x);       }       cout << ans / 2 <<   n ;       ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int tree[4 * 200005], cs[200005], ar[200005];   struct dt {     int b, e, h, id, res;   } st[100005];   bool cmp1(dt x, dt y) { return x.b < y.b; }   bool cmp2(dt x, dt y) { return x.id < y.id; }   void update(int nd, int b, int e, int x, int v) {     if (b > x || e < x) return;     if (b == x && e == x) {       tree[nd] = v;       return;     }     int left = 2 * nd;     int right = 2 * nd + 1;     int md = (b + e) / 2;     update(left, b, md, x, v);     update(right, md + 1, e, x, v);     tree[nd] = max(tree[left], tree[right]);   }   int query(int nd, int b, int e, int x, int y) {     if (e < x || b > y) return 0;     if (b >= x && e <= y) return tree[nd];     int left = 2 * nd;     int right = 2 * nd + 1;     int md = (b + e) / 2;     int p1 = query(left, b, md, x, y);     int p2 = query(right, md + 1, e, x, y);     return max(p1, p2);   }   int main() {     int n;     scanf( %d , &n);     set<int> ss;     for (int i = 1; i <= n; i++) {       int b, h, e;       scanf( %d%d , &b, &h);       e = b + h - 1;       st[i].b = b;       st[i].e = e;       st[i].h = h;       st[i].id = i;       st[i].res = -1;       ss.insert(b);       ss.insert(e);     }     map<int, int> mp;     set<int>::iterator it;     int m = 0;     for (it = ss.begin(); it != ss.end(); it++) mp[*it] = ++m;     sort(st + 1, st + n + 1, cmp1);     int sz = ss.size();     for (int i = 1; i <= n; i++) {       int v = mp[st[i].b];       ar[v] = 1;       int u = mp[st[i].e];       update(1, 1, sz, v, u);     }     cs[0] = 0;     for (int i = 1; i <= sz; i++) cs[i] = cs[i - 1] + ar[i];     for (int i = n; i >= 1; i--) {       int b = mp[st[i].b];       int e = mp[st[i].e];       int p = query(1, 1, sz, b, e);       int res = cs[p] - cs[b - 1];       st[i].res = res;       update(1, 1, sz, b, p);     }     sort(st + 1, st + n + 1, cmp2);     for (int i = 1; i <= n; i++) {       if (i == n)         printf( %d n , st[i].res);       else         printf( %d  , st[i].res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long modpow(long long a, long long n, long long temp) {     long long res = 1, y = a;     while (n > 0) {       if (n & 1) res = (res * y) % temp;       y = (y * y) % temp;       n /= 2;     }     return res % temp;   }   long long ison(long long mask, long long pos) { return (mask & (1 << pos)); }   long long cbit(long long n) {     long long k = 0;     while (n) n &= (n - 1), k++;     return k;   }   long long nbit(long long n) {     long long k = 0;     while (n) n /= 2, k++;     return k;   }   long long mod = 1e9 + 7;   int sgn(long long x) { return x < 0 ? -1 : !!x; }   long long c[200005];   long long d[200005];   long long bit[500005], n, bit2[500005];   void upd(long long ind, long long val) {     if (ind == 0) return;     while (ind <= n) {       bit[ind] += val;       ind += (ind & -ind);     }   }   long long qu(long long ind) {     long long k = 0;     while (ind > 0) {       k += bit[ind];       ind -= (ind & -ind);     }     return k;   }   void upd2(long long ind, long long val) {     if (ind == 0) return;     while (ind <= n) {       bit2[ind] += val;       ind += (ind & -ind);     }   }   long long qu2(long long ind) {     long long k = 0;     while (ind > 0) {       k += bit2[ind];       ind -= (ind & -ind);     }     return k;   }   long long xo(long long i) {     if ((i & 3) == 0) return i;     if ((i & 3) == 1) return 1;     if ((i & 3) == 2) return i + 1;     return 0;   }   int main() {     long long k, a, b, l, r, t, i, q;     cin >> n >> k >> a >> b >> q;     while (q--) {       cin >> t;       if (t == 1) {         long long d1, d2;         cin >> d1 >> d2;         long long x1 = min(b, c[d1] + d2);         long long x2 = min(a, d[d1] + d2);         upd(d1, x1 - c[d1]);         upd2(d1, x2 - d[d1]);         c[d1] = x1;         d[d1] = x2;       } else {         long long r1;         cin >> r1;         long long ans = 0;         ans += qu(r1 - 1);         ans += (qu2(n) - qu2(r1 + k - 1));         cout << ans << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char arr[55][55];   int dp[55][55][55][55];   int f(int ind, int let, int dig, int sim) {     if (ind == n) {       if (let && dig && sim)         return 0;       else         return 1e9;     }     if (dp[ind][let][dig][sim] != -1) return dp[ind][let][dig][sim];     int &ret = dp[ind][let][dig][sim];     ret = 1e9;     for (int i = 0; i < m; i++) {       if (arr[ind][i] >=  a  && arr[ind][i] <=  z )         ret = min(ret, f(ind + 1, let + 1, dig, sim) + min(i, m - i));       else if (arr[ind][i] >=  0  && arr[ind][i] <=  9 )         ret = min(ret, f(ind + 1, let, dig + 1, sim) + min(i, m - i));       else         ret = min(ret, f(ind + 1, let, dig, sim + 1) + min(i, m - i));     }     return ret;   }   int main() {     while (scanf( %d %d , &n, &m) == 2) {       memset(dp, -1, sizeof dp);       for (int i = 0; i < n; i++) scanf( %s , &arr[i]);       int ans = f(0, 0, 0, 0);       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[500005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, i, j, k, l, m;     long long t;     cin >> t;     long long pret = t;     while (t--) {       cin >> n >> k;       for (i = 1; i <= n; i++) cin >> a[i];       int flag1 = 0;       int flag2 = 0;       for (i = 1; i <= n; i++) {         if (a[i] == k) {           flag1 = 1;         }         if (a[i] != k) {           flag2 = 1;         }       }       if (flag1 == 0) {         cout <<  no n ;         continue;       }       if (flag2 == 0) {         cout <<  yes n ;         continue;       }       a[n + 1] = 0;       int flag = 0;       for (i = 1; i <= n - 1; i++) {         if (min(a[i], a[i + 1]) >= k) {           flag = 1;           break;         }       }       for (i = 2; i <= n - 1; i++) {         vector<long long> v;         v.push_back(a[i - 1]);         v.push_back(a[i + 1]);         v.push_back(a[i]);         sort(v.begin(), v.end());         if (v[1] >= k) flag = 1;       }       if (flag)         cout <<  yes n ;       else         cout <<  no n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 110000;   const double EPS = 1E-7;   struct pt {     int x, y;   };   int n;   pt p[MAXN];   int l[MAXN], r[MAXN];   long long r_sums[MAXN];   inline long long vec(pt a, pt b, pt c) {     return (b.x - a.x) * 1ll * (c.y - a.y) - (b.y - a.y) * 1ll * (c.x - a.x);   }   inline bool between(pt p, pt a, pt b, pt q) {     return vec(p, a, q) > 0 && vec(p, q, b) > 0;   }   inline long long sum_r(int lt, int rt) {     long long res = r_sums[rt];     if (lt) res -= r_sums[lt - 1];     return res;   }   long long solve(pt q) {     int j = 0;     for (int i = 0; i < n; ++i) {       j = max(j, i + 1);       while (j + 1 < n && !between(p[i], p[i + 1], p[j + 1], q)) ++j;       r[i] = j;       l[i] = j + 1;     }     for (int i = 0; i < n; ++i) {       r_sums[i] = 0;       if (i) r_sums[i] += r_sums[i - 1];       r_sums[i] += r[i];     }     long long ans = 0;     j = 0;     for (int i = 0; i < n; ++i) {       while (j < n && r[j] < l[i]) ++j;       if (l[i] < n && j < n) {         int left = j, right = r[i];         if (left > right) continue;         ans += sum_r(left, right);         ans -= (right - left + 1) * 1ll * (l[i] - 1);       }     }     return ans;   }   bool inside(pt q) {     bool res = false;     for (int i = 0; i < n; ++i) {       pt a = p[i], b = p[(i + 1) % n];       if (min(a.y, b.y) <= q.y && max(a.y, b.y) >= q.y) {         if (q.y != a.y && q.y != b.y) {           double cx = a.x + (b.x - a.x) * ((q.y - a.y) * 1. / (b.y - a.y));           if (cx >= q.x - EPS) res ^= true;         } else {           if (a.y == q.y && a.x > q.x || b.y == q.y && b.x > q.x)             if (max(a.y, b.y) > q.y) res ^= true;         }       }     }     return res;   }   int main() {     cin >> n;     for (int i = 0; i < n; ++i) scanf( %d%d , &p[i].x, &p[i].y);     reverse(p, p + n);     int ts;     cin >> ts;     for (int tt = 0; tt < ts; ++tt) {       pt q;       scanf( %d%d , &q.x, &q.y);       long long ans = 0;       if (inside(q)) ans = solve(q);       printf( %I64d n , ans);     }   }
#include <bits/stdc++.h>   const int maxn = 1e3 + 10;   using namespace std;   int n, x[110], y[110], cnt1, cnt2, sum1, sum2;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x[i] >> y[i];       if (x[i] % 2 == 1) {         cnt1++;       }       if (y[i] % 2 == 1) {         cnt2++;       }       sum1 += x[i];       sum2 += y[i];     }     if (cnt1 % 2 == 0 && cnt2 % 2 == 0) {       if (sum1 % 2 == 0 && sum2 % 2 == 0) {         cout <<  0 ;         return 0;       } else {         for (int i = 0; i < n; i++) {           if (x[i] % 2 == 0 && y[i] % 2 == 1) {             cout <<  1 ;             return 0;           } else if (x[i] % 2 == 1 && y[i] % 2 == 0) {             cout <<  1 ;             return 0;           }         }       }     } else if (cnt1 % 2 == 1 && cnt2 % 2 == 1) {       for (int i = 0; i < n; i++) {         if (x[i] % 2 == 0 && y[i] % 2 == 1) {           cout <<  1 ;           return 0;         } else if (x[i] % 2 == 1 && y[i] % 2 == 0) {           cout <<  1 ;           return 0;         }       }     }     cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class X, class Y>   bool minimize(X &x, const Y &y) {     X eps = 1e-9;     if (x > y + eps) {       x = y;       return true;     } else       return false;   }   template <class X, class Y>   bool maximize(X &x, const Y &y) {     X eps = 1e-9;     if (x + eps < y) {       x = y;       return true;     } else       return false;   }   template <class T>   T Abs(const T &x) {     return (x < 0 ? -x : x);   }   const int BASE = (1LL << (8));   struct Number {     unsigned char d[3];     Number(int x = 0) {       for (int i = 0, _n = (3); i < _n; i++) {         d[i] = x & 255;         x >>= 8;       }     }     Number operator+(const Number &x) const {       Number res;       int rem = 0;       for (int i = 0, _n = (3); i < _n; i++) {         int tmp = rem + d[i] + x.d[i];         res.d[i] = tmp & 255;         rem = tmp > 255;       }       return res;     }     Number operator-(const Number &x) const {       Number res;       int rem = 0;       for (int i = 0, _n = (3); i < _n; i++) {         int tmp = d[i] - rem - x.d[i];         res.d[i] = tmp < 0 ? tmp + BASE : tmp;         rem = tmp < 0;       }       return res;     }     bool operator==(const Number &x) const {       for (int i = 0, _n = (3); i < _n; i++)         if (d[i] != x.d[i]) return false;       return true;     }     int value(void) const {       int res = 0;       for (int i = (2), _a = (0); i >= _a; i--) res = (res << 8) ^ d[i];       return res;     }   };   long long value[1000100], asked;   int ___left[1000100], ___right[1000100], n;   Number numZero[62][1000100];   void loadTree(void) {     cin >> n >> asked;     for (int i = (2), _b = (n); i <= _b; i++) {       int p;       long long w;       cin >> p >> w;       value[i] = value[p] ^ w;     }   }   void prepare(void) {     sort(value + 1, value + n + 1);     for (int j = 0, _n = (62); j < _n; j++)       for (int i = (1), _b = (n); i <= _b; i++) {         numZero[j][i] = numZero[j][i - 1];         if (!(((value[i]) >> (j)) & 1)) numZero[j][i] = numZero[j][i] + 1;       }     for (int i = (1), _b = (n); i <= _b; i++) ___right[i] = n;   }   void process(void) {     long long res = 0;     for (int pos = (62 - 1), _a = (0); pos >= _a; pos--) {       long long total = 0;       for (int i = (1), _b = (n); i <= _b; i++) {         int bit = (((value[i]) >> (pos)) & 1);         int zero = (numZero[pos][___right[i]] - numZero[pos][___left[i]]).value();         int need = bit == 0 ? zero : ___right[i] - ___left[i] - zero;         total += need;         if (total > asked) break;       }       int newBit = total >= asked ? 0 : 1;       if (asked > total) asked -= total;       res |= (1LL * newBit) << pos;       for (int i = (1), _b = (n); i <= _b; i++) {         int need = newBit ^ (((value[i]) >> (pos)) & 1);         int zero = (numZero[pos][___right[i]] - numZero[pos][___left[i]]).value();         if (need == 1)           ___left[i] += zero;         else           ___right[i] = ___left[i] + zero;       }     }     cout << res << endl;   }   int main(void) {     ios::sync_with_stdio(false);     cin.tie(NULL);     loadTree();     prepare();     process();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long i, j, k, r, c, c1, c2, cnt, ans, x, y, p, t;     vector<vector<long long>> v, a, b;     unordered_map<long long, set<pair<long long, long long>>> m;     vector<long long> re, q;     cin >> t;     i = 0;     while (i < t) {       cin >> r >> c;       j = 0;       while (j < r) {         p = 0;         while (p < c) {           cin >> k;           q.push_back(0);           re.push_back(k);           p++;         }         a.push_back(q);         b.push_back(q);         q.clear();         v.push_back(re);         re.clear();         j++;       }       j = 0;       a[0][0] = 0;       m[0].insert(make_pair(0, 0));       while (j < r) {         p = 0;         while (p < c) {           if (j + 1 < r) {             a[j + 1][p] = 1 + a[j][p];             m[1 + a[j][p]].insert(make_pair(j + 1, p));           }           if (p + 1 < c) {             a[j][p + 1] = 1 + a[j][p];             m[1 + a[j][p]].insert(make_pair(j, p + 1));           }           p++;         }         j++;       }       j = r - 1;       b[r - 1][c - 1] = 0;       m[0].insert(make_pair(r - 1, c - 1));       while (j >= 0) {         p = c - 1;         while (p >= 0) {           if (j - 1 >= 0) {             b[j - 1][p] = 1 + b[j][p];             m[1 + b[j][p]].insert(make_pair(j - 1, p));           }           if (p - 1 >= 0) {             b[j][p - 1] = 1 + b[j][p];             m[1 + b[j][p]].insert(make_pair(j, p - 1));           }           p--;         }         j--;       }       unordered_map<long long, set<pair<long long, long long>>>::iterator it;       set<pair<long long, long long>>::iterator u;       set<pair<long long, long long>> s;       it = m.begin();       cnt = 0;       if ((r + c - 2) % 2 == 0) {         k = (r + c - 2) / 2;       }       while (it != m.end()) {         c1 = 0;         c2 = 0;         if (it->first != k) {           s = it->second;           u = s.begin();           while (u != s.end()) {             if (v[(*u).first][(*u).second] == 0) {               c1++;             } else {               c2++;             }             u++;           }           if (c1 <= c2) {             u = s.begin();             while (u != s.end()) {               if (v[(*u).first][(*u).second] == 0) {                 v[(*u).first][(*u).second] = 1;               }               u++;             }             cnt = cnt + c1;           } else {             u = s.begin();             while (u != s.end()) {               if (v[(*u).first][(*u).second] == 1) {                 v[(*u).first][(*u).second] = 0;               }               u++;             }             cnt = cnt + c2;           }         }         it++;       }       cout << cnt << endl;       v.clear();       a.clear();       b.clear();       re.clear();       m.clear();       q.clear();       i++;     }     return (0);   }
#include <bits/stdc++.h>   using namespace std;   int a[10];   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     string b;     cin >> b;     for (int i = 0; i < n; i++) {       a[b[i] -  0 ] = 1;     }     bool flag = (((a[1] || a[2] || a[3]) && (a[0])) ||                  ((a[1] || a[2] || a[3]) && (a[1] || a[4] || a[7])) &&                      ((a[3] || a[9] || a[6]) && (a[7] || a[0] || a[9])));     if (flag)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   template <class T>   inline T biton(T n, T pos) {     return n | ((T)1 << pos);   }   template <class T>   inline T bitoff(T n, T pos) {     return n & ~((T)1 << pos);   }   template <class T>   inline T ison(T n, T pos) {     return (bool)(n & ((T)1 << pos));   }   template <class T>   inline T gcd(T a, T b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   template <typename T>   string NumberToString(T Number) {     ostringstream second;     second << Number;     return second.str();   }   inline int nxt() {     int aaa;     scanf( %d , &aaa);     return aaa;   }   inline long long int lxt() {     long long int aaa;     scanf( %lld , &aaa);     return aaa;   }   inline double dxt() {     double aaa;     scanf( %lf , &aaa);     return aaa;   }   template <class T>   inline T bigmod(T p, T e, T m) {     T ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % m;       p = (p * p) % m;     }     return (T)ret;   }   int ar[1000010];   vector<int> v;   vector<pair<int, int> > edge;   int cnt[1000010];   int mark[1000010];   set<int> st;   int get(int x) {     for (int i = x - 1; i >= 1; i--) {       if (st.find(i) == st.end() && !mark[i]) {         mark[i] = 1;         return i;       }     }     return -1;   }   int main() {     int n = nxt();     for (int i = 1; i < n; i++) {       int a = nxt();       int b = nxt();       if (a > b) swap(a, b);       if (b != n) {         cout <<  NO  << endl;         return 0;       }       if (a == b && b == n) {         cout <<  NO  << endl;         return 0;       }       st.insert(a);       cnt[a]++;       if (cnt[a] == 0) v.push_back(a);     }     for (int i = n - 1; i >= 1; i--) {       vector<int> ok;       if (cnt[i]) {         ok.push_back(i);         cnt[i]--;         while (cnt[i]--) {           int val = get(i);           if (val == -1) {             printf( NO n );             return 0;           }           ok.push_back(val);         }         sort(ok.begin(), ok.end());         for (int i = 1; i < ok.size(); i++) {           edge.push_back(make_pair(ok[i], ok[i - 1]));         }         edge.push_back(make_pair(n, ok[0]));       }     }     if (edge.size() != n - 1) {       printf( NO n );       return 0;     }     printf( YES n );     for (auto it : edge) {       printf( %d %d n , it.first, it.second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool check(long long x, long long y, long long x1, long long y1) {     if (x != 0 && y != 0 && x1 % x == 0 && y1 % y == 0 && x1 / x >= 0 &&         y1 / y >= 0 && x1 / x == y1 / y)       return 1;     if (x == 0 && y == 0 && y1 == 0 && x1 == 0) return 1;     if (x == 0 && y != 0 && x1 == 0 && y1 % y == 0 && y1 / y >= 0) return 1;     if (x != 0 && y == 0 && y1 == 0 && x1 % x == 0 && x1 / x >= 0) return 1;     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long a, b;     cin >> a >> b;     string s;     cin >> s;     long long a1 = 0, b1 = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  U )         b1++;       else if (s[i] ==  D )         b1--;       else if (s[i] ==  R )         a1++;       else         a1--;     }     for (int i = 0; i < s.size(); i++) {       long long a2 = a, b2 = b;       for (int j = i; j >= 0; j--) {         if (s[j] ==  U )           b2--;         else if (s[j] ==  D )           b2++;         else if (s[j] ==  R )           a2--;         else           a2++;       }       if (check(a1, b1, a2, b2)) {         cout <<  Yes  << endl;         return 0;       }     }     if (a == 0 && b == 0)       cout <<  Yes  << endl;     else       cout <<  No  << endl;   }