malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   template <typename T>   void rd(T& x) {     long long f = 0, c;     while ((c = getchar()) < 48 || 57 < c) f ^= !(c ^ 45);     x = (c & 15);     while (47 < (c = getchar()) && c < 58) x = x * 10 + (c & 15);     if (f) x = -x;   }   template <typename T>   inline void pt(T x) {     if (x < 0) x = -x, putchar( - );     if (x > 9) pt(x / 10);     putchar(x % 10 + 48);   }   template <typename T>   inline void pt(T x, long long c) {     pt(x), putchar(c);   }   template <typename T>   inline T max(const T& x, const T& y) {     return x < y ? y : x;   }   template <typename T>   inline T min(const T& x, const T& y) {     return x < y ? x : y;   }   const long long N = 2005, P = 1000000007;   long long n, m, f[2][N][N], sum[N][N];   char s[N][N];   long long getsum(long long a, long long b, long long c, long long d) {     if (a > c || b > d) return 0;     return sum[c][d] - sum[c][b - 1] - sum[a - 1][d] + sum[a - 1][b - 1];   }   long long getf0(long long a, long long b, long long c, long long d) {     if (a > c || b > d) return 0;     return f[0][c][d] - f[0][c][b - 1] - f[0][a - 1][d] + f[0][a - 1][b - 1];   }   long long getf1(long long a, long long b, long long c, long long d) {     if (a > c || b > d) return 0;     return f[1][c][d] - f[1][c][b - 1] - f[1][a - 1][d] + f[1][a - 1][b - 1];   }   signed main() {     rd(n), rd(m);     for (long long i = (1); i <= (n); ++i) scanf( %s , s[i] + 1);     if (s[n][m] ==  R ) {       puts( 0 );       return 0;     }     if (n == 1 && m == 1) {       puts( 1 );       return 0;     }     for (long long i = (1); i <= (n); ++i)       for (long long j = (1); j <= (m); ++j)         sum[i][j] =             sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + (s[i][j] ==  R );     f[0][1][1] = 1;     f[1][1][1] = 1;     for (long long i = (1); i <= (n); ++i)       for (long long j = (1); j <= (m); ++j) {         long long l = 1, r = i, ans = i;         while (l <= r) {           long long mid = (l + r) >> 1;           if (getsum(mid + 1, j, n, j) <= n - i)             ans = mid, r = mid - 1;           else             l = mid + 1;         }         (f[1][i][j] += getf0(ans, j, i - 1, j)) %= P;         l = 1, r = j, ans = j;         while (l <= r) {           long long mid = (l + r) >> 1;           if (getsum(i, mid + 1, i, m) <= m - j)             ans = mid, r = mid - 1;           else             l = mid + 1;         }         (f[0][i][j] += getf1(i, ans, i, j - 1)) %= P;         (f[0][i][j] += f[0][i][j - 1] + f[0][i - 1][j] - f[0][i - 1][j - 1]) %= P;         (f[1][i][j] += f[1][i][j - 1] + f[1][i - 1][j] - f[1][i - 1][j - 1]) %= P;       }     pt(((getf0(n, m, n, m) + getf1(n, m, n, m)) % P + P) % P,   n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string arr[55], arr2[55];   vector<pair<int, int> > hasil;   int i, j, n, t, tc, r, x, y, k, c;   void tuker_lr(int x, int y) {     arr[x][y] =  U ;     arr[x + 1][y] =  D ;     arr[x][y + 1] =  U ;     arr[x + 1][y + 1] =  D ;   }   void tuker_ud(int x, int y) {     arr[x][y] =  L ;     arr[x][y + 1] =  R ;     arr[x + 1][y] =  L ;     arr[x + 1][y + 1] =  R ;   }   void l_u_ganjil(int x, int y) {     if (arr[x + 1][y] ==  L ) {       tuker_lr(x, y);       hasil.push_back(make_pair(x, y));     } else if (arr[x + 1][y + 1] ==  U ) {       tuker_ud(x + 1, y);       hasil.push_back(make_pair(x + 1, y));       tuker_lr(x, y);       hasil.push_back(make_pair(x, y));     } else {       l_u_ganjil(x + 1, y + 1);       tuker_ud(x + 1, y);       hasil.push_back(make_pair(x + 1, y));       tuker_lr(x, y);       hasil.push_back(make_pair(x, y));     }   }   void u_d_ganjil(int x, int y) {     if (arr[x][y + 1] ==  U ) {       tuker_ud(x, y);       hasil.push_back(make_pair(x, y));     } else if (arr[x][y + 1] ==  L ) {       l_u_ganjil(x, y + 1);       tuker_ud(x, y);       hasil.push_back(make_pair(x, y));     } else {       u_d_ganjil(x - 1, y + 1);       l_u_ganjil(x, y + 1);       tuker_ud(x, y);       hasil.push_back(make_pair(x, y));     }   }   int main() {     scanf( %d %d , &r, &c);     for (i = 0; i < r; i++) cin >> arr[i];     for (i = 0; i < r; i++) cin >> arr2[i];     if (c % 2 == 1) {       for (j = 0; j < c; j++)         for (i = 0; i < r; i++)           if (arr[i][j] ==  L ) l_u_ganjil(i, j);     } else {       for (j = 0; j < c; j++)         for (i = 0; i < r; i++)           if (arr[i][j] ==  U ) u_d_ganjil(i, j);     }     for (j = 0; j < c; j++) {       for (i = 0; i < r; i++) {         if (arr[i][j] == arr2[i][j])           continue;         else if (arr[i][j] ==  U )           u_d_ganjil(i, j);         else           l_u_ganjil(i, j);       }     }     printf( %d n , hasil.size());     for (i = 0; i < hasil.size(); i++)       printf( %d %d n , hasil[i].first + 1, hasil[i].second + 1);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, i, j;     cin >> n >> m;     for (i = 1; i <= n; i++) {       int c = i / 2;       if (i % 2 != 0) {         for (j = 0; j < m; j++) {           cout <<  # ;         }         cout << endl;       } else if (c % 2 == 0) {         cout <<  # ;         for (j = 1; j < m; j++) {           cout <<  . ;         }         cout << endl;       } else if (c % 2 != 0) {         for (j = 1; j < m; j++) {           cout <<  . ;         }         cout <<  #  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a = 0, b = 0;     int t;     for (int i = 0; i < 3; ++i) {       cin >> t;       a += t;     }     a = (a + 4) / 5;     for (int i = 0; i < 3; ++i) {       cin >> t;       b += t;     }     b = (b + 9) / 10;     cin >> n;     if (a + b > n)       printf( NO );     else       printf( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct name {     int l, r;   } bl[200001];   bool cmp(name n, name m) {     if (n.r == m.r) return n.l < m.l;     return n.r < m.r;   }   int main() {     int n, x, w, ans = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &x, &w);       bl[i].l = x - w;       bl[i].r = x + w;     }     sort(bl + 1, bl + n + 1, cmp);     int cnt = -2e9;     for (int i = 1; i <= n; i++) {       if (cnt <= bl[i].l) {         ans++;         cnt = bl[i].r;       }     }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 1e5 + 5;   long long qpow(long long a, long long b, long long r) {     long long ans = 1, buff = a % r;     while (b) {       if (b & 1) ans = (ans * buff) % r;       buff = (buff * buff) % r;       b >>= 1;     }     return ans;   }   long long f_inv(long long a, long long p) { return qpow(a, p - 2, p); }   string s;   long long k, ans = 0;   int main() {     ios::sync_with_stdio(false);     cin >> s >> k;     if (s[0] ==  -  || s[0] ==  + ) s.erase(s.begin());     long long len = s.length();     for (long long i = 0; i < len; i++) {       if (s[i] ==  0  || s[i] ==  5 ) {         ans += qpow(2, i, mod);         ans %= mod;       }     }     long long x = qpow(2, len, mod);     long long y = qpow(x, k, mod);     x--, y--;     ans = ans * (y * f_inv(x, mod) % mod) % mod;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long inf = 1e9;   const long long N = (1 << 20);   long long mod_expo(long long a, long long b, long long c) {     long long ans = 1;     while (b) {       if (b & (long long)1) ans = (ans * a) % c;       a = (a * a) % c;       b = b >> 1;     }     return ans;   }   long long inverse(long long n) { return mod_expo(n, mod - 2, mod); }   int n;   int total;   int a[N];   long long f[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     total = 1 << 20;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       a[x]++;     }     n = 20;     for (int i = 0; i < total; i++) f[i] = a[i];     for (int i = 0; i < n; i++) {       for (int mask = total - 1; mask >= 0; mask--) {         if ((mask & (1 << i)) == 0) f[mask] += f[mask ^ (1 << i)];       }     }     long long ans = 0;     for (int i = 0; i < total; i++) {       int bits = __builtin_popcount(i);       if (bits % 2)         ans -= mod_expo(2, f[i], mod);       else         ans += mod_expo(2, f[i], mod);       ans %= mod;       ans += mod;       ans %= mod;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   vector<string> vec_splitter(string s) {     s +=  , ;     vector<string> res;     while (!s.empty()) {       res.push_back(s.substr(0, s.find( , )));       s = s.substr(s.find( , ) + 1);     }     return res;   }   void debug_out(vector<string> __attribute__((unused)) args,                  __attribute__((unused)) long long int idx,                  __attribute__((unused)) long long int LINE_NUM) {     cout <<   n ;   }   template <typename Head, typename... Tail>   void debug_out(vector<string> args, long long int idx, long long int LINE_NUM,                  Head H, Tail... T) {     if (idx > 0)       cout <<  ,  ;     else       cout <<  Line(  << LINE_NUM <<  )  ;     stringstream ss;     ss << H;     cout << args[idx] <<   =   << ss.str();     debug_out(args, idx + 1, LINE_NUM, T...);   }   const long long int mod = 1000000007;   const long long int inf = 1e18;   const long long int N = 2e5 + 5;   long long int dp[N][5];   string s;   long long int n;   string abc =  abc ;   long long int go(long long int idx, long long int pos) {     if (pos > 3LL) {       return 0;     }     if (idx == n) {       return (pos == 3LL);     }     long long int &ans = dp[idx][pos];     if (ans != -1) return ans;     ans = 0;     if (s[idx] !=  ? ) {       if (s[idx] == abc[pos]) {         ans += go(idx + 1, pos + 1);         ans %= mod;       }       ans += go(idx + 1, pos);       ans %= mod;     } else {       for (char x =  a ; x <=  c ; x++) {         if (x == abc[pos]) {           ans += go(idx + 1, pos + 1);           ans %= mod;         }         ans += go(idx + 1, pos);         ans %= mod;       }     }     return ans;   }   void HyperBeast() {     memset(dp, -1, sizeof(dp));     cin >> n >> s;     cout << go(0, 0);   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int T = 1;     for (long long int ti = 1; ti <= T; ti++) {       HyperBeast();       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int num[100010];   int num1[100010];   int a[100010];   int main() {     int n;     cin >> n;     int flag = 0;     for (int i = 1; i <= n; i++) {       cin >> num[i];       num1[i] = num[i];     }     sort(num + 1, num + n + 1);     sort(num1 + 1, num1 + n + 1);     int tim = 0;     for (int i = 1; i < n; i++) {       int t = num[i + 1] - num[i];       if (t == 0) tim++;     }     if (tim >= 2) flag = 1;     for (int i = 1; i < n; i++) {       if (num1[i] == num1[i + 1]) {         num1[i]--;         break;       }     }     sort(num1 + 1, num1 + n + 1);     for (int i = 1; i < n; i++) {       if (num1[i] == num1[i + 1] || num1[i] == -1) {         flag = 1;         break;       }     }     if (flag == 1)       cout <<  cslnb  << endl;     else {       long long sum = 0;       for (int i = 1; i <= n; i++) sum += num[i];       long long s = n * (n - 1) / 2;       if ((sum - s) % 2 == 0)         cout <<  cslnb  << endl;       else         cout <<  sjfnb  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     map<int, int> nrs;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       nrs[x]++;     }     int max_times = nrs.begin()->second;     for (auto it : nrs) max_times = max(it.second, max_times);     if (max_times > (n + 1) / 2)       cout <<  NO  << endl;     else       cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct s {     long long col, colf, flag;   } node[100010 << 2];   void build(int l, int r, int tr) {     node[tr].col = node[tr].colf = node[tr].flag = 0;     if (l == r) {       node[tr].col = l;       return;     }     int mid = (l + r) >> 1;     build(l, mid, tr << 1);     build(mid + 1, r, tr << 1 | 1);   }   long long ABS(long long x) {     if (x < 0) return -x;     return x;   }   void pushdown(int tr, int m) {     if (node[tr].flag) {       node[tr << 1].flag += node[tr].flag;       node[tr << 1 | 1].flag += node[tr].flag;       node[tr << 1].colf += node[tr].flag * (m - (m >> 1));       node[tr << 1 | 1].colf += node[tr].flag * (m >> 1);       node[tr].flag = 0;     }     if (node[tr].col) {       node[tr << 1].col = node[tr << 1 | 1].col = node[tr].col;     }   }   void pushup(int tr) {     node[tr].colf = node[tr << 1].colf + node[tr << 1 | 1].colf;     if (node[tr << 1].col == node[tr << 1 | 1].col)       node[tr].col = node[tr << 1].col;     else       node[tr].col = 0;   }   void update(int L, int R, long long val, int l, int r, int tr) {     if (L <= l && r <= R) {       if (node[tr].col) {         node[tr].colf += (r - l + 1) * ABS(node[tr].col - val);         node[tr].flag += ABS(node[tr].col - val);         node[tr].col = val;         return;       }     }     pushdown(tr, r - l + 1);     int mid = (l + r) >> 1;     if (L <= mid) update(L, R, val, l, mid, tr << 1);     if (R > mid) update(L, R, val, mid + 1, r, tr << 1 | 1);     pushup(tr);   }   long long query(int L, int R, int l, int r, int tr) {     if (L <= l && r <= R) {       return node[tr].colf;     }     pushdown(tr, r - l + 1);     long long a, b;     a = 0;     b = 0;     int mid = (l + r) >> 1;     if (L <= mid) {       a = query(L, R, l, mid, tr << 1);     }     if (R > mid) {       b = query(L, R, mid + 1, r, tr << 1 | 1);     }     return (a + b);   }   int main() {     int n, m;     while (scanf( %d%d , &n, &m) != EOF) {       build(1, n, 1);       while (m--) {         int op;         scanf( %d , &op);         if (op == 1) {           int a, b;           long long c;           scanf( %d%d%lld , &a, &b, &c);           update(a, b, c, 1, n, 1);         } else {           int a, b;           scanf( %d%d , &a, &b);           printf( %lld n , query(a, b, 1, n, 1));         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   long double pi = 3.14159265358979323;   int main() {     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     vector<int> a(100000, 0);     vector<int> ans;     for (int i = 0; i < (int)n + m; ++i) {       if (a[i] < k) {         for (int j = 0; j < (int)k - a[i]; ++j) ans.push_back(i);         int t = a[i];         for (int j = i; j < n + i; ++j) a[j] += k - t;       } else if (a[i + 1] == 0) {         for (int j = i; j < n + i; ++j) a[j]++;         ans.push_back(i);       }     }     printf( %d n , ans.size());     for (int i = 0; i < (int)ans.size(); ++i) {       printf( %d  , ans[i] + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     long long sz, ans, x, y;     string s, str =   ;     cin >> n >> x >> y >> s;     str += s[0];     for (i = 1; i < n; i++)       if (s[i - 1] != s[i]) str += s[i];     sz = (long long)str.size();     if (str[0] ==  0 )       sz = (sz >> 1LL) + (sz & 1);     else       sz = sz >> 1LL;     ans = min((sz - 1) * x + y, sz * y);     cout << max(0LL, ans) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double dist(long double x1, long double y1, long double x2,                    long double y2) {     long double D = ((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1));     return sqrt(D);   }   int main() {     const int inf = 1e9;     int n;     cin >> n;     vector<pair<int, pair<pair<int, int>, long double>>> v;     for (int i = 0; i < n; i++) {       int x, y, t;       long double p;       cin >> x >> y >> t >> p;       v.push_back({t, {{x, y}, p}});     }     sort(v.begin(), v.end());     long double ans = 0.0;     vector<long double> dp(n + 1, 0.0);     for (int i = 1; i <= n; i++) dp[i] = v[i - 1].second.second;     dp[0] = 0;     for (int i = 0; i < n; i++) {       for (int j = i - 1; j >= 0; j--) {         long double x1 = (v[i].second.first.first),                     x2 = (v[j].second.first.first);         long double y1 = v[i].second.first.second, y2 = v[j].second.first.second;         if (dist(x1, y1, x2, y2) <= (long double)(v[i].first - v[j].first)) {           dp[i + 1] = max(dp[i + 1], dp[j + 1] + v[i].second.second);         }       }       ans = max(ans, dp[i + 1]);     }     cout << setprecision(14) << ans <<   n ;   }
#include <bits/stdc++.h>   #pragma GCC target( popcnt )   using namespace std;   constexpr int siz = 1 << 9 | 1, INF = 0x7f7f7f7f;   constexpr int fx[4][2] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};   int n, m, sx, sy, cnt;   long long val[9], sum[siz];   int f[21][21][siz];   char c[21][21];   pair<int, int> t[9];   queue<tuple<int, int, int> > q;   inline bool check(char c) { return c ==  .  || c ==  S ; }   inline bool check(int first, int second, int xi, int yi, int k) {     if (xi == t[k].first && yi < t[k].second) return first < xi;     if (first == t[k].first && second < t[k].second) return first > xi;     return false;   }   long long bfs();   signed main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         cin >> c[i][j];         if (c[i][j] ==  S ) {           sx = i;           sy = j;         }         if (isdigit(c[i][j])) {           cnt++;           t[c[i][j] -  0 ] = make_pair(i, j);         }       }     for (int i = 1; i <= cnt; i++) scanf( %lld , &val[i]);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (c[i][j] ==  B ) {           val[++cnt] = -INF;           t[cnt] = make_pair(i, j);         }     for (int i = 1; i < (1 << cnt); i++)       for (int j = 0; j < cnt; j++)         if ((i >> j) & 1) sum[i] += val[j + 1];     printf( %lld n , bfs());     return 0;   }   long long bfs() {     long long res(0);     q.push(make_tuple(sx, sy, 0));     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         for (int k = 0; k < (1 << cnt); k++) f[i][j][k] = -1;     f[sx][sy][0] = 0;     while (!q.empty()) {       int first, second, s;       tie(first, second, s) = q.front();       q.pop();       if (first == sx && second == sy)         res = max(res, sum[s] - f[first][second][s]);       for (int i = 0; i < 4; i++) {         const int xi = first + fx[i][0];         const int yi = second + fx[i][1];         if (xi > 0 && xi <= n && yi > 0 && yi <= m && check(c[xi][yi])) {           int si = s;           for (int j = 0; j < cnt; j++)             if (check(first, second, xi, yi, j + 1)) si ^= (1 << j);           if (f[xi][yi][si] == -1) {             f[xi][yi][si] = f[first][second][s] + 1;             q.push(make_tuple(xi, yi, si));           }         }       }     }     return res;   }
#include <bits/stdc++.h>   using namespace std;   int n, V, offset;   int d[1005];   int u[1000005], v[1000005], cnt = 0;   inline void print(int u, int v) {     ::u[++cnt] = u + offset;     ::v[cnt] = v + offset;   }   int main() {     int i, j;     scanf( %d , &n);     for (i = 1; i <= n; ++i) scanf( %d , d + i);     V = d[n] + 1;     for (offset = 1;; ++offset) {       if (!d[1]) {         offset = V - d[n];         for (i = 1; i < n; ++i) d[i] = d[i + 1];         d[n--] = 0;       }       if (n <= 1) {         for (i = 0; i < d[1]; ++i)           for (j = i + 1; j <= d[1]; ++j) print(i, j);         break;       }       for (i = 1; i <= d[n]; ++i) print(0, i);       for (i = 1; i <= n; ++i) --d[i];       if (!d[1]) {         d[n--] = 0;         if (n <= 1) break;       }     }     printf( %d n , cnt);     for (i = 1; i <= cnt; ++i) printf( %d %d n , u[i], v[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void boost() {     ios_base::sync_with_stdio();     cin.tie(0);   }   const long long MAX = 1e5 + 111;   const long long mod = 1e9 + 7;   map<string, int> maap;   vector<int> g[MAX];   int main() {     boost();     int n;     bool ans = false;     cin >> n;     string a[n + 1];     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       if (a[i][0] ==  O  && a[i][1] ==  O ) {         a[i].erase(0, 2);         a[i].insert(0,  ++ );         ans = true;         break;       }       if (a[i][3] ==  O  && a[i][4] ==  O ) {         a[i].erase(3, 4);         a[i].insert(3,  ++ );         ans = true;         break;       }     }     if (ans == true) {       cout <<  YES n ;       for (int i = 1; i <= n; i++) {         cout << a[i] <<   n ;       }     } else {       cout <<  NO ;     }     exit(0);   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class S>   ostream& operator<<(ostream& os, const pair<T, S>& v) {     return os <<  (  << v.first <<  ,   << v.second <<  ) ;   }   template <class T>   ostream& operator<<(ostream& os, const vector<T>& v) {     os <<  [ ;     for (int i = int(0); i <= int((static_cast<int>((v).size())) - 1); ++i) {       if (i) os <<  ,  ;       os << v[i];     }     return os <<  ] ;   }   template <class T>   bool setmax(T& _a, T _b) {     if (_b > _a) {       _a = _b;       return true;     }     return false;   }   template <class T>   bool setmin(T& _a, T _b) {     if (_b < _a) {       _a = _b;       return true;     }     return false;   }   template <class T>   T gcd(T _a, T _b) {     return _b == 0 ? _a : gcd(_b, _a % _b);   }   struct Node {     vector<Node*> ys;     int h = -1;   };   int main() {     int n, k;     cin >> n >> k;     vector<string> ss(n);     for (int i = int(0); i <= int((n)-1); ++i) cin >> ss[i];     sort((ss).begin(), (ss).end());     vector<int> height(n - 1);     for (int i = int(0); i <= int((n - 1) - 1); ++i) {       int j = 0;       while (j < static_cast<int>((ss[i]).size()) &&              j < static_cast<int>((ss[i + 1]).size()) &&              ss[i][j] == ss[i + 1][j]) {         ++j;       }       height[i] = j;     }     const function<Node*(int, int)> build = [&](int l, int r) {       Node* x = new Node();       if (l + 1 == r) return x;       int h = *min_element(height.begin() + l, height.begin() + r - 1);       x->h = h;       int i = l;       for (int j = int(l); j <= int((r)-1); ++j) {         if (j == r - 1 || height[j] == h) {           x->ys.push_back(build(i, j + 1));           i = j + 1;         }       }       return x;     };     Node* root = build(0, n);     const function<vector<int>(Node*)> solve = [&](Node* x) {       if (x->h < 0) return vector<int>{0, 0};       vector<int> ans{0};       for (Node* y : x->ys) {         vector<int> tmp = solve(y);         vector<int> r(static_cast<int>((ans).size()) +                       static_cast<int>((tmp).size()) - 1);         for (int i = int(0); i <= int((static_cast<int>((ans).size())) - 1); ++i)           for (int j = int(0); j <= int((static_cast<int>((tmp).size())) - 1);                ++j) {             setmax(r[i + j], ans[i] + tmp[j] + i * j * x->h);           }         ans = r;       }       if (static_cast<int>((ans).size()) > k + 1) ans.resize(k + 1);       return ans;     };     vector<int> ans = solve(root);     if (k < static_cast<int>((ans).size())) {       cout << ans[k] << endl;     } else {       cout << 0 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   long long power(long long a, long long b, long long p) {     if (a == 0) return 0;     long long res = 1;     a %= p;     while (b > 0) {       if (b & 1) res = (res * a) % p;       b >>= 1;       a = (a * a) % p;     }     return res;   }   void solve() {     long long n;     cin >> n;     string s;     cin >> s;     string t =   ;     for (long long i = 0; i < s.size(); i++) {       if (i + 1 < s.size()) {         if (s[i] ==  U  && s[i + 1] ==  R ) {           t +=  D ;           i = i + 1;         } else if (s[i] ==  R  && s[i + 1] ==  U ) {           t +=  D ;           i = i + 1;         } else {           t += s[i];         }       } else {         t += s[i];       }     }     cout << t.size() <<   n ;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }