malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0;     bool t = false;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) t = true, ch = getchar();     while (ch <=  9  && ch >=  0 ) x = x * 10 + ch - 48, ch = getchar();     return t ? -x : x;   }   int s[1010000], a[1010000], b[1010000], n, k;   char ch[1010000];   bool vis[1010000];   int eql[1010000];   void output() {     for (int i = 1; i <= k; ++i)       if (!eql[i])         for (int j = 1; j <= k; ++j)           if (!vis[j]) {             eql[i] = j;             vis[j] = true;             break;           }     for (int i = 1; i <= k; ++i) putchar(eql[i] + 96);     puts(  );   }   void clear() {     for (int i = 1; i <= k; ++i) eql[i] = 0, vis[i] = false;   }   int main() {     int T = read();     while (T--) {       k = read();       scanf( %s , ch + 1);       n = strlen(ch + 1);       for (int i = 1; i <= n; ++i) s[i] = ch[i] - 96;       scanf( %s , ch + 1);       for (int i = 1; i <= n; ++i) a[i] = ch[i] - 96 - (i == n);       scanf( %s , ch + 1);       for (int i = 1; i <= n; ++i) b[i] = ch[i] - 96;       clear();       int p = -1;       for (int i = 1; i <= n; ++i) {         if (i > 1) {           if (eql[s[i - 1]] && eql[s[i - 1]] != a[i - 1]) break;           if (!eql[s[i - 1]] && vis[a[i - 1]]) break;           eql[s[i - 1]] = a[i - 1];           vis[a[i - 1]] = true;         }         if (eql[s[i]])           if (eql[s[i]] > a[i]) p = i;         if (!eql[s[i]])           for (int j = a[i] + 1; j <= k; ++j)             if (!vis[j]) {               p = i;               break;             }       }       if (p == -1)         puts( NO );       else {         clear();         for (int i = 1; i < p; ++i) eql[s[i]] = a[i], vis[a[i]] = true;         if (!eql[s[p]])           for (int i = a[p] + 1; i <= k; ++i)             if (!vis[i]) {               eql[s[p]] = i, vis[i] = true;               break;             }         for (int i = p + 1; i <= n; ++i)           if (!eql[s[i]])             for (int j = 1; j <= k; ++j)               if (!vis[j]) {                 eql[s[i]] = j;                 vis[j] = true;                 break;               }         for (int i = 1; i <= n; ++i) s[i] = eql[s[i]];         bool chk = true;         for (int i = 1; i <= n; ++i)           if (s[i] > b[i]) {             puts( NO );             chk = false;             break;           } else if (s[i] < b[i]) {             puts( YES );             output();             chk = false;             break;           }         if (chk) puts( YES ), output();       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   pair<int, int> a[1000];   double findarea(pair<int, int> a, pair<int, int> b, pair<int, int> c) {     return ((double)a.first * (b.second - c.second) +             (double)b.first * (c.second - a.second) +             (double)c.first * (a.second - b.second)) /            2.0;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d %d , &a[i].first, &a[i].second);     double ans = 0;     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++) {         double maxright = -1, maxleft = -1;         for (int k = 0; k < n; k++) {           if (k != i && k != j) {             double area = findarea(a[i], a[j], a[k]);             if (area < 0)               maxleft = max(maxleft, -area);             else               maxright = max(maxright, area);           }         }         if (maxright >= 0 && maxleft >= 0) ans = max(ans, maxleft + maxright);       }     printf( %.6lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 100000 + 5;   const long long inf = 9e17;   long long ans = inf, l, r, mid1, mid2;   vector<long long> g[maxn], v;   long long n, m;   inline long long cost(long long mid) {     long long cnt = mid - g[0].size(), tmp = 0;     v.clear();     for (int i = 1; i <= m; i++) {       for (int j = 0; j < g[i].size(); j++) {         if (g[i].size() - j >= mid) {           --cnt;           tmp += g[i][j];         } else           v.push_back(g[i][j]);       }     }     sort(v.begin(), v.end());     for (int i = 0; i < cnt; i++) tmp += v[i];     return tmp;   }   int main() {     long long a, b;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a >> b;       m = max(m, a);       g[a].push_back(b);     }     for (int i = 0; i <= m; i++) sort(g[i].begin(), g[i].end());     l = g[0].size(), r = n;     while (l < r) {       mid1 = (l + l + r) / 3;       mid2 = (l + r + r) / 3;       if (cost(mid1) > cost(mid2)) {         if (l == mid1)           break;         else           l = mid1;       } else {         if (r == mid2)           break;         else           r = mid2;       }     }     ans = inf;     for (int i = l; i <= r; i++) ans = min(ans, cost(i));     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, a, b, c;   long long f[120001], n, i, q, x, y, l, r, nom;   bool abcde;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     s =  What are you doing at the end of the world? Are you busy? Will you save            us? ;     a =  What are you doing while sending   ;     b =   ? Are you busy? Will you send   ;     c =   ? ;     f[0] = s.size();     for (i = 1; i <= 100000; i++) {       f[i] = f[i - 1] * 2 + a.size() + b.size() + c.size();       if (f[i - 1] > 1000000000000000000LL) break;     }     cin >> q;     while (q--) {       cin >> x >> y;       l = 1;       r = 9000000000000000000LL;       if (f[x] != 0) r = f[x];       if (f[x] != 0 && y > f[x]) {         cout <<  . ;         continue;       }       abcde = false;       for (i = x - 1; i >= 0; i--) {         if (l <= y && y <= l + a.size() - 1) {           abcde = true;           cout << a[y - l];           break;         }         if (f[i] == 0) {           l += a.size();           if (f[i - 1] != 0)             r = l + f[i - 1] * 2 + a.size() + b.size() + c.size() - 1;           continue;         }         if (l + a.size() + f[i] <= y && y <= r - c.size() - f[i]) {           abcde = true;           cout << b[y - (l + a.size() + f[i])];           break;         }         if (r - c.size() + 1 <= y && y <= r) {           abcde = true;           cout << c[y - (r - c.size() + 1)];           break;         }         if (l + a.size() <= y && y <= r - c.size() - f[i] - b.size()) {           l += a.size();           r -= c.size() + f[i] + b.size();         } else {           l += a.size() + f[i] + b.size();           r -= c.size();         }       }       if (!abcde) cout << s[y - l];     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 7;   int sg[N];   int main() {     int T, n, k;     scanf( %d , &T);     while (T--) {       scanf( %d %d , &n, &k);       bool flag = true;       if (k % 3 == 0) {         int t = (k / 3 - 1) * 3 + 4;         int s = n % t;         if (s == t - 4)           flag = false;         else if (s < t - 4 && s % 3 == 0)           flag = false;       } else {         if (n % 3 == 0) flag = false;       }       if (flag)         printf( Alice n );       else         printf( Bob n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct TreeNode {     int val;     TreeNode* left;     TreeNode* right;     TreeNode(int x) : val(x), left(NULL), right(NULL) {}   };   struct ListNode {     int val;     ListNode* next;     ListNode(int x) : val(x), next(NULL) {}   };   int nxt() {     int x;     cin >> x;     return x;   }   long long nxtLong() {     long long x;     cin >> x;     return x;   }   string nxtStr() {     string x;     cin >> x;     return x;   }   char nxtChar() {     char x;     cin >> x;     return x;   }   double nxtDouble() {     double x;     cin >> x;     return x;   }   long double nxtLDouble() {     long double x;     cin >> x;     return x;   }   TreeNode* makeTree(int n) {     queue<TreeNode*> tree_nodes;     TreeNode* root;     if (n) {       root = new TreeNode(nxt());       tree_nodes.push(root);     } else {       return NULL;     }     while (!tree_nodes.empty()) {       TreeNode* node = tree_nodes.front();       tree_nodes.pop();       bool left;       cin >> left;       if (left) {         node->left = new TreeNode(nxt());         tree_nodes.push(node->left);       }       bool right;       cin >> right;       if (right) {         node->right = new TreeNode(nxt());         tree_nodes.push(node->right);       }     }     return root;   }   ListNode* makeLinkedList(int n) {     ListNode* list = new ListNode(0);     ListNode* dummy = list;     for (int i = 0; i < n; ++i) {       list->next = new ListNode(nxt());       list = list->next;     }     return dummy->next;   }   char ans[2000001];   void solve() {     int n = nxt();     int len = 0;     while (n--) {       string s = nxtStr();       int m = nxt();       int l = s.length();       int y = 0;       while (m--) {         int x = nxt();         x--;         len = max(len, x + l);         for (int i = max(x, y); i < x + l; ++i) {           ans[i] = s[i - x];         }         y = x + l;       }     }     for (int i = 0; i < len; ++i) {       if (!ans[i]) {         cout <<  a ;       } else {         cout << ans[i];       }     }     cout << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout << fixed << setprecision(9);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class Solver {    public:     void solve() {       cin >> n;       long long sign = 1;       long long C = n;       long long three_to_i = 1;       for (long long i = 1; i <= n; i++) {         long long term = 2LL * (sign < 0 ? sign + mod : sign) * C;         term %= mod;         term *= powmod(3, n * n - n * i + i);         term %= mod;         ans += term;         ans %= mod;         sign = -sign;         C = next_C(n, i + 1LL, C);       }       C = 1;       sign = -1;       for (long long i = 0; i < n; i++) {         long long term = C;         term *= 3 * (sign < 0 ? sign + mod : sign);         term %= mod;         term *= calc_term(i, three_to_i);         term %= mod;         ans += term;         ans %= mod;         three_to_i *= 3LL;         three_to_i %= mod;         C = next_C(n, i + 1LL, C);         sign = -sign;       }       cout << ans << endl;     }     long long calc_term(long long i, long long three_to_i) {       long long k1 = 1 - three_to_i;       if (k1 < 0) k1 += mod;       long long ans = powmod(k1, n);       long long a2 = powmod(mod - three_to_i, n);       ans = ans - a2;       if (ans < 0) ans += mod;       return ans;     }     long long powmod(long long x, long long n) {       n %= (mod - 1LL);       long long base = x;       long long ans = 1;       while (n) {         if (1LL & n) {           ans *= base;           ans %= mod;         }         base *= base;         base %= mod;         n >>= 1;       }       return ans;     }     long long next_C(long long n, long long k, long long cnk_1) {       if (k == 0 || k == n) return 1LL;       cnk_1 *= n - k + 1LL;       cnk_1 %= mod;       cnk_1 *= powmod(k, mod - 2);       return cnk_1 % mod;     }     long long mod = 998244353;     long long n;     long long ans = 0;   };   int main() {     Solver sol;     sol.solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300000 + 10;   const int mod = 1e9 + 7;   int n, q;   char s[N];   long long sum[N];   long long pw[N], fibo[N], pw2[N], pw3[N];   int main() {     scanf( %d%d , &n, &q);     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i) {       sum[i] = sum[i - 1] + (s[i] ==  1 );     }     for (int i = 1; i <= 2e5; ++i) {       if (i == 1)         fibo[i] = 1;       else         fibo[i] = fibo[i - 1] * 2;       fibo[i] %= mod;       pw[i] = pw[i - 1] + fibo[i];       pw[i] %= mod;     }     while (q--) {       int l, r;       scanf( %d%d , &l, &r);       long long num1 = sum[r] - sum[l - 1];       long long num0 = (r - l + 1) - num1;       long long ans = pw[num1];       ans %= mod;       if (num0) ans += pw[num1] * pw[num0] % mod;       ans %= mod;       printf( %lld n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const long long int INF = 1e12;   long long int mod(long long int a) {     if (a >= 0)       return a;     else       return (-1 * a);   }   void swap(long long int a, long long int b) {     long long int temp = a;     a = b;     b = temp;   }   long long int power(long long int a, long long int b) {     long long int result = 1;     while (b) {       if (b % 2) result = (result % MOD) * (a % MOD);       a = ((a % MOD) * (a % MOD)) % MOD;       b = b / 2;     }     return result;   }   bool power_check(long long int a) {     bool ans = true;     while (a > 1) {       if (a % 2 == 0) {         a = a / 2;       } else {         ans = false;         break;       }     }     return ans;   }   void solve() {     int n;     cin >> n;     string s;     cin >> s;     int c = 0;     for (int i = 0; i < n; ++i) {       if (s[i] ==  0 ) c++;     }     if (c != n - c) {       cout << 1 <<   n ;       cout << s <<   n ;       return;     }     cout << 2 <<   n ;     cout << s[0] <<    ;     for (int i = 1; i < n; ++i) {       cout << s[i];     }     cout <<   n ;     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int qqq;     qqq = 1;     while (qqq--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 3e5 + 10;   const double eps = 1e-8;   using namespace std;   struct edge {     int t, v;     edge *next;   } e[MAXN << 1], *h[MAXN], *o = e;   void add(int x, int y, int vul) {     o->t = y;     o->v = vul;     o->next = h[x];     h[x] = o++;   }   long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   int n, m, q;   int dirx[] = {-1, 1, 0, 0};   int diry[] = {0, 0, -1, 1};   int del[2000005], pos[2000006];   int a[305][305];   vector<pair<int, int> > q1[2000006], q2[2000005];   int f[MAXN];   int find1(int x) {     if (x == f[x])       return x;     else       return f[x] = find1(f[x]);   }   void cal_add(int x) {     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         a[i][j] = 0, f[(i - 1) * m + j] = (i - 1) * m + j;     for (int i = 0; i < q1[x].size(); i++) {       int x1 = (q1[x][i].first - 1) / m + 1;       int x2 = q1[x][i].first - (x1 - 1) * m;       a[x1][x2] = 1;       int num = 1;       for (int j = 0; j < 4; j++) {         int xx = x1 + dirx[j];         int yy = x2 + diry[j];         if (xx >= 1 && xx <= n && yy >= 1 && yy <= m && a[xx][yy] == 1) {           int y = (xx - 1) * m + yy;           int t1 = find1(q1[x][i].first);           int t2 = find1(y);           if (t1 == t2) continue;           f[t1] = t2;           num--;         }       }       del[q1[x][i].second] += num;     }   }   void cal_del(int x) {     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         a[i][j] = 0, f[(i - 1) * m + j] = (i - 1) * m + j;     for (int i = 0; i < q2[x].size(); i++) {       int x1 = (q2[x][i].first - 1) / m + 1;       int x2 = q2[x][i].first - (x1 - 1) * m;       a[x1][x2] = 1;       int num = 1;       for (int j = 0; j < 4; j++) {         int xx = x1 + dirx[j];         int yy = x2 + diry[j];         if (xx >= 1 && xx <= n && yy >= 1 && yy <= m && a[xx][yy] == 1) {           int y = (xx - 1) * m + yy;           int t1 = find1(q2[x][i].first);           int t2 = find1(y);           if (t1 == t2) continue;           f[t1] = t2;           num--;         }       }       del[q2[x][i].second] -= num;     }   }   int main() {     n = read();     m = read();     q = read();     int num = 0;     int x, y, c;     for (int i = 1; i <= q; i++) {       x = read();       y = read();       c = read();       pos[i] = (x - 1) * m + y;       num = c;       if (a[x][y] == c) continue;       q1[c].push_back(make_pair(pos[i], i));       q2[a[x][y]].push_back(make_pair(pos[i], i));       a[x][y] = c;     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         q2[a[i][j]].push_back(make_pair((i - 1) * m + j, q + 1));     for (int i = 0; i <= num; i++) reverse(q2[i].begin(), q2[i].end());     for (int i = 0; i <= num; i++) cal_add(i);     for (int i = 0; i <= num; i++) cal_del(i);     int ans = 1;     for (int i = 1; i <= q; i++) ans += del[i], printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     cin >> q;     while (q--) {       string s;       cin >> s;       set<int> ans;       for (int i = 1; i < s.size() - 1; i++) {         if (s[i] ==  w  && s[i - 1] ==  t  && s[i + 1] ==  o ) {           if (i + 3 < s.size() && s[i + 2] ==  n  && s[i + 3] ==  e ) {             ans.insert(i + 1);             i = i + 2;           } else             ans.insert(i);         } else if (s[i] ==  n  && s[i - 1] ==  o  && s[i + 1] ==  e )           ans.insert(i);       }       cout << ans.size() << endl;       set<int>::iterator it;       for (it = ans.begin(); it != ans.end(); it++) cout << *it + 1 <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   int adjL[201][210];   int visited[201];   int broken[201][201];   int edge[200][2];   int R[200][2];   int fine[201];   int dfs(int v, int c) {     int i;     int a;     visited[v] = c;     for (i = 1; i <= adjL[v][0]; i++) {       a = adjL[v][i];       if (visited[a] != 0 || broken[v][a]) continue;       dfs(a, c);     }     return 0;   }   int dfs_loop(int n) {     int i, j;     int c;     for (i = 1; i <= n; i++) visited[i] = 0;     c = 1;     for (i = 1; i <= n; i++)       if (visited[i] == 0) {         dfs(i, c);         c++;       }     return 0;   }   int main() {     int n, m, k;     int i, j;     int a, b;     scanf( %d%d , &n, &m);     for (i = 0; i < m; i++) {       scanf( %d%d , &a, &b);       adjL[a][++adjL[a][0]] = b;       adjL[b][++adjL[b][0]] = a;       edge[i][0] = a;       edge[i][1] = b;     }     scanf( %d , &k);     for (i = 0; i < k; i++) scanf( %d%d , &R[i][0], &R[i][1]);     for (i = 1; i <= n; i++) fine[i] = 0;     for (i = 0; i < m; i++) {       a = edge[i][0];       b = edge[i][1];       broken[a][b] = broken[b][a] = 1;       dfs_loop(n);       broken[a][b] = broken[b][a] = 0;       for (j = 0; j < k; j++)         if (visited[R[j][0]] != visited[R[j][1]]) fine[j + 1]++;     }     for (i = 1; i <= k; i++) printf( %d n , fine[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[300100];   int main() {     int n, m;     while (~scanf( %d %d n , &n, &m)) {       gets(s);       int len = strlen(s);       int ans = 0;       for (int i = 1; i < len; i++) {         if (s[i] ==  .  && s[i - 1] ==  . ) ans++;       }       char op[3];       int t;       while (m--) {         scanf( %d %s , &t, op);         t--;         if (op[0] ==  . ) {           if (s[t] ==  . ) {             printf( %d n , ans);             continue;           }           if ((t - 1 >= 0 && s[t - 1] ==  . ) && (t + 1 < len && s[t + 1] ==  . ))             ans += 2;           else if ((t - 1 >= 0 && s[t - 1] ==  . ) ||                    (t + 1 < len && s[t + 1] ==  . ))             ans++;         } else if (s[t] ==  . ) {           if ((t - 1 >= 0 && s[t - 1] ==  . ) && (t + 1 < len && s[t + 1] ==  . ))             ans -= 2;           else if ((t - 1 >= 0 && s[t - 1] ==  . ) ||                    (t + 1 < len && s[t + 1] ==  . ))             ans -= 1;         }         s[t] = op[0];         printf( %d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     cin >> q;     while (q--) {       vector<vector<int> > grid;       int h, w;       cin >> h >> w;       grid.assign(h, vector<int>(w, 0));       for (int i = 0; i < h; i++) {         for (int j = 0; j < w; j++) {           scanf( %d , &grid[i][j]);         }       }       int diff1 = 0;       int diff2 = 0;       for (int j = 0; j < w; j++) {         diff1 += grid[h / 2 - 1][j] - grid[h / 2][j];         diff2 += grid[0][j] - grid[h - 1][j];       }       if (abs(diff1) > abs(diff2))         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   vector<int> fa;   int n, m, q, g[300][300], x, y, c;   int id(int x, int y) { return x * m + y; }   int in(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }   int find(int x) { return fa[x] == x ? x : (fa[x] = find(fa[x])); }   int merge(int x, int y) {     int xx = find(x), yy = find(y);     if (xx == yy) {       return 0;     } else {       fa[xx] = yy;       return 1;     }   }   int ADD(int x, int y) {     int p = id(x, y);     if (fa[p] != INF) return 0;     fa[p] = p;     static int dx[] = {0, 0, 1, -1};     static int dy[] = {1, -1, 0, 0};     int r = 1;     for (int i = (int)0; i < (int)4; ++i) {       int nx = x + dx[i], ny = y + dy[i];       int pp = id(nx, ny);       if (in(nx, ny) && fa[pp] != INF) {         r -= merge(p, pp);       }     }     return r;   }   struct P {     int x, y, p;     P(int x_, int y_, int p_) : x(x_), y(y_), p(p_) {}   };   int main() {     scanf( %d%d%d , &n, &m, &q);     fa.resize(n * m);     memset(g, 0, sizeof(g));     vector<vector<P>> add(1), del(1);     int pc = 0, cc = 0;     for (int i = (int)0; i < (int)q; ++i) {       scanf( %d%d%d , &x, &y, &c);       --x, --y;       if (c != pc) {         pc = c;         ++cc;         add.emplace_back(vector<P>{}), del.emplace_back(vector<P>{});       }       c = cc;       if (g[x][y] != c) {         del[g[x][y]].emplace_back(x, y, i);         add[c].emplace_back(x, y, i);         g[x][y] = c;       }     }     vector<int> df(q, 0);     for (int i = (int)0; i < (int)n; ++i)       for (int j = (int)0; j < (int)m; ++j) add[0].emplace_back(i, j, 0);     for (int c = (int)1; c < (int)cc + 1; ++c) {       if (add[c].empty()) continue;       fill(fa.begin(), fa.end(), INF);       for (auto &p : add[c]) {         df[p.p] = ADD(p.x, p.y);       }     }     df[0] += 1;     for (int c = (int)0; c < (int)cc + 1; ++c) {       fill(fa.begin(), fa.end(), INF);       unordered_set<int> xx;       for (auto &p : del[c]) {         xx.insert(id(p.x, p.y));       }       for (auto &p : add[c]) {         if (!xx.count(id(p.x, p.y))) ADD(p.x, p.y);       }       int n = del[c].size();       for (int i = (int)n - 1; i >= (int)0; --i) {         auto &p = del[c][i];         df[p.p] -= ADD(p.x, p.y);       }     }     int cnt = 0;     for (int i = (int)0; i < (int)q; ++i) {       cnt += df[i];       printf( %d n , cnt);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N;     cin >> N;     string inst;     cin >> inst;     int total = 0;     for (int i = 0; i < N; i++) {       for (int j = i + 1; j < N; j++) {         int ct_u = 0;         int ct_l = 0;         for (int k = i; k <= j; k++) {           if (inst[k] ==  U ) {             ct_u++;           } else if (inst[k] ==  D ) {             ct_u--;           } else if (inst[k] ==  L ) {             ct_l--;           } else if (inst[k] ==  R ) {             ct_l++;           }         }         if (ct_u == 0 && ct_l == 0) total++;       }     }     cout << total << endl;     return 0;   }