malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   const int MD = 1000000007;   int n, a[N];   long long s[N], k;   int ft[N];   long long all[N];   int gt(int first) {     int res = 0;     for (int i = first; i >= 0; i &= i + 1, --i) res += ft[i];     return res;   }   void upd(int first, int v) {     for (int i = first; i < N; i |= i + 1) ft[i] += v;   }   long long chk(long long first) {     memset(ft, 0, sizeof ft);     for (int _tmp = (n), i = (0); i <= _tmp; ++i) all[i] = s[i];     sort(all, all + n + 1);     upd(lower_bound(all, all + n + 1, s[0]) - all, +1);     long long res = 0;     for (int _tmp = (n), i = (1); i <= _tmp; ++i) {       res += gt(upper_bound(all, all + n + 1, s[i] - first) - all - 1);       upd(lower_bound(all, all + n + 1, s[i]) - all, +1);     }     return res;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     for (int _tmp = (n), i = (1); i <= _tmp; ++i) {       cin >> a[i];       s[i] = a[i] + s[i - 1];     }     long long l = -1e14, r = 1e14, rs = 0;     while (l <= r) {       long long m = (l + r) / 2;       if (chk(m) >= k) {         l = m + 1;         rs = m;       } else {         r = m - 1;       }     }     cout << rs << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool F[2001][2001];   bool D[2001][2001];   int C[2001];   vector<int> V[2001];   int n;   void f(int v, int c) {     if (C[v]) return;     C[v] = c;     V[c].push_back(v);     for (int i = 1; i <= n; ++i)       if (F[v][i]) f(i, c);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     int k;     cin >> k;     while (k--) {       int a, b;       cin >> a >> b;       F[a][b] = 1;       F[b][a] = 1;     }     cin >> k;     while (k--) {       int a, b;       cin >> a >> b;       D[a][b] = 1;       D[b][a] = 1;     }     int ans = 0;     for (int i = 1; i <= n; ++i) {       f(i, i);       int t = V[i].size();       for (int j = 0; j < t; ++j)         for (int l = 0; l < t; ++l)           if (D[V[i][j]][V[i][l]]) goto skip;       ans = max(ans, t);     skip:;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[5010], n, s = 0, i;   int main() {     cin >> n >> i;     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (i = 0; i < n; i++) s += a[i] != a[(i + n / 2) % n];     cout << s << endl;     for (i = 0; i < n; i++) cout << a[i] <<     << a[(i + n / 2) % n] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     map<int, vector<pair<int, int> > > mapa;     for (int i = 0; i < n; i++) {       int suma = 0;       for (int j = i; j < n; j++) {         suma += v[j];         mapa[suma].push_back({j, i});       }     }     vector<pair<int, int> > maxRes;     for (auto i : mapa) {       auto vec = i.second;       sort(vec.begin(), vec.end());       vector<pair<int, int> > usable;       for (int j = 0; j < vec.size(); j++) {         if (usable.size() == 0) {           usable.push_back(vec[j]);         } else {           if (usable.back().first < vec[j].second) {             usable.push_back(vec[j]);           }         }       }       if (usable.size() > maxRes.size()) {         maxRes = usable;       }     }     cout << maxRes.size() << endl;     for (auto i : maxRes) cout << i.second + 1 <<     << i.first + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline bool invowel(char ch) {     ch = tolower(ch);     return (ch ==  a  || ch ==  e  || ch ==  i  || ch ==  o  || ch ==  u );   }   inline bool isprime(int n) {     if (n < 2 || (n % 2 == 0 && n != 2)) return false;     for (int i = 3; i * i <= n; i += 2)       if (n % i == 0) return false;     return true;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());     int t;     t = 1;     while (t--) {       int n, i;       cin >> n;       vector<int> x(n), y(n);       for (i = 0; i < n; i++) {         cin >> x[i] >> y[i];       }       if (n & 1) {         cout <<  No n ;         break;       }       for (i = 0; i < n / 2; i++) {         if (x[0] + x[n / 2] != x[i] + x[i + n / 2] ||             y[0] + y[n / 2] != y[i] + y[i + n / 2]) {           cout <<  No n ;           return 0;         }       }       cout <<  Yes n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long r;     cin >> r;     vector<long long> ans;     for (int i = 1; i < sqrt(r); i++) {       long long rem = r - ((i * i) + i + 1);       if (rem % 2 == 0 && rem > 0) {         ans.push_back(i);         ans.push_back(rem / 2);         break;       }     }     if (ans.empty())       cout <<  NO ;     else       for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10, mod = 1e9 + 7;   int n, m, k, t;   char a[maxn];   long long h[maxn], h1[maxn], xp[maxn];   long long get(long long h[], int pos, int len, int len1) {     return (h[pos + len - 1] - h[pos - 1] * xp[len1] % mod + mod) % mod;   }   int cnt[maxn];   int main() {     int i, j;     xp[0] = 1;     for (i = 1; i < maxn; i++) xp[i] = xp[i - 1] * 229 % mod;     scanf( %d%s , &n, a + 1);     h[0] = h1[0] = 1;     for (i = 1; i <= n; i++) {       if (a[i] ==  0 ) {         h[i] = h[i - 1] * 229 % mod + (i & 1) + 1;         h1[i] = h1[i - 1] * 229 % mod + (i & 1 ^ 1) + 1;         cnt[i] = cnt[i - 1] + 1;       } else         h[i] = h[i - 1], h1[i] = h1[i - 1], cnt[i] = cnt[i - 1];     }     int q;     scanf( %d , &q);     while (q--) {       int l1, l2, len;       scanf( %d%d%d , &l1, &l2, &len);       if (get(h, l1, len, cnt[l1 + len - 1] - cnt[l1 - 1]) ==           get(((l1 ^ l2) & 1 ? h1 : h), l2, len,               cnt[l2 + len - 1] - cnt[l2 - 1])) {         puts( Yes );       } else         puts( No );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   vector<vector<pair<long long, long long>>> graph;   long long ok[10][10];   long long fine[10][10][10][10];   bitset<(long long)(2e5 + 5)> incoming[10][10];   long long answer = 0;   vector<long long> temp;   void dfs() {     if (temp.size() == k) {       answer++;       return;     }     long long ind = temp.size() + 1;     for (long long i = 0; i < ind; i++) {       bool flag = true;       for (long long j = 1; j < ind; j++) {         if (!fine[ind][i][j][temp[j - 1]]) {           flag = false;           break;         }       }       if (!flag) continue;       if (ok[ind][i]) {         temp.push_back(i);         dfs();         temp.pop_back();       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m >> k;     graph.resize(n + 1);     for (long long i = 0; i < m; i++) {       long long u, v, w;       cin >> u >> v >> w;       graph[u].push_back({w, v});     }     for (long long i = 1; i < n + 1; i++) {       if (graph[i].size() == 0) {         cout << 0 <<   n ;         return 0;       }       sort(graph[i].begin(), graph[i].end());     }     for (long long i = 1; i < k + 1; i++)       for (long long j = 0; j < i; j++) ok[i][j] = 1;     for (long long out = 1; out < k + 1; out++) {       for (long long i = 1; i < n + 1; i++) {         if (graph[i].size() == out) {           for (long long j = 0; j < graph[i].size(); j++) {             long long ver = graph[i][j].second;             if (incoming[out][j][ver]) {               ok[out][j] = 0;               continue;             }             incoming[out][j][ver] = 1;           }         }       }     }     for (long long a = 1; a < k + 1; a++)       for (long long b = 0; b < a; b++)         for (long long c = a; c < k + 1; c++)           for (long long d = 0; d < c; d++) {             if ((incoming[a][b] & incoming[c][d]) == 0) {               fine[a][b][c][d] = fine[c][d][a][b] = 1;             }           }     dfs();     cout << answer <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   void in(long long int *a, long long int n) {     for (long long int i = 0; i < n; i++) {       cin >> a[i];     }   }   void out(long long int *a, long long int n) {     for (long long int i = 0; i < n; i++) {       cout << a[i] <<    ;     }   }   long long int count(long long int n) {     long long int add = 0;     while (n > 0) {       if (n % 10 == 9)         add = add + 1;       else         break;       n = n / 10;     }     return add;   }   int main() {     fast();     long long int tc = 1;     while (tc--) {       long long int n, m;       cin >> n >> m;       n = n * (n + 1) / 2;       long long int t = m % n;       for (long long int i = 1; i <= m; i++) {         if (t < i) break;         t = t - i;       }       cout << t <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int kol[10], ans = -1, ans0 = 0;   vector<int> a, b;   int main() {     memset(kol, 0, sizeof(kol));     char c;     while (cin >> c) kol[c -  0 ]++;     for (int i = 1; i < 10; i++) {       vector<int> c, d;       int K1[10], K2[10], res = 0, nul = 0;       for (int j = 0; j < 10; j++) {         K1[j] = kol[j];         K2[j] = kol[j];       }       if (K1[i] > 0 && K2[10 - i] > 0) {         c.push_back(i);         d.push_back(10 - i);         K1[i]--;         K2[10 - i]--;         res++;         for (int j = 0; j < 10; j++) {           while (K1[j] > 0 && K2[9 - j] > 0) {             K1[j]--;             K2[9 - j]--;             c.push_back(j);             d.push_back(9 - j);             res++;           }         }       }       while (K1[0] > 0 && K2[0] > 0) {         K1[0]--;         K2[0]--;         res++;         nul++;       }       for (int j = 0; j < 10; j++) {         while (K1[j] > 0) {           K1[j]--;           c.push_back(j);         }         while (K2[j] > 0) {           K2[j]--;           d.push_back(j);         }       }       if (res > ans) {         ans = res;         ans0 = nul;         a.swap(c);         b.swap(d);       }     }     for (int i = a.size() - 1; i >= 0; i--) cout << a[i];     for (int i = 0; i < ans0; i++) cout << 0;     cout << endl;     for (int i = a.size() - 1; i >= 0; i--) cout << b[i];     for (int i = 0; i < ans0; i++) cout << 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     long n, k;     cin >> t;     while (t--) {       cin >> n >> k;       bool win = true;       if (k % 3 == 0) {         int np = n % (k + 1);         if (np % 3 == 0 && np != k) win = false;       } else {         int np = n % 3;         if (np == 0) win = false;       }       puts(win ?  Alice  :  Bob );     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1010, max_range = 1000001;   int edge[maxn][3 * maxn], reached[maxn], start[3 * maxn], len[3 * maxn],       vert[3 * maxn][2], n, m, res;   FILE *in;   int nb(int v, int e) {     if (vert[e][0] == v)       return vert[e][1];     else       return vert[e][0];   }   int dfs(int sz, int x, int v) {     reached[v] = 1;     if (v == n) return 1;     int e, u;     for (int i = 1; i <= edge[v][0]; i++) {       e = edge[v][i];       u = nb(v, e);       if (reached[u] == 0 && x >= start[e] && x - start[e] <= len[e] - sz) {         if (dfs(sz, x, u) == 1) return 1;       }     }     return 0;   }   bool check(int sz) {     int res = 0;     for (int i = 1; i <= m; i++)       if (len[i] >= sz) {         memset(reached, 0, sizeof(reached));         res = dfs(sz, start[i], 1);         if (res == 1) break;       }     return res == 1;   }   void init() {     int x, y, l, r;     fscanf(in,  %d %d , &n, &m);     for (int i = 1; i <= m; i++) {       fscanf(in,  %d %d %d %d , &x, &y, &l, &r);       edge[x][0]++;       edge[x][edge[x][0]] = i;       edge[y][0]++;       edge[y][edge[y][0]] = i;       start[i] = l;       len[i] = r - l + 1;       vert[i][0] = x;       vert[i][1] = y;     }   }   int solve() {     int l = 0, r = max_range, s = (l + r) / 2;     while (r - l > 1) {       if (check(s))         l = s;       else         r = s;       s = (l + r) / 2;     }     return s;   }   int main() {     in = stdin;     init();     res = solve();     if (res == 0)       printf( Nice work, Dima! n );     else       printf( %d , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct pt {     int x, y;     pt() {}     pt(int x, int y) : x(x), y(y) {}   };   int get_pos(int i, int n) {     if (i >= n) i -= n;     return ((i >= 0) ? i : n - i - 1);   }   void solve() {     int n;     cin >> n;     vector<pt> v(n);     for (int i = 0; i < n; ++i) {       cin >> v[i].x >> v[i].y;     }     if (n & 1) {       cout <<  NO ;       return;     }     for (int i = 0; i < n; ++i) {       pt a = v[get_pos(i, n)], b = v[get_pos(i + 1, n)];       pt c = v[get_pos(i + n / 2, n)], d = v[get_pos(i + n / 2 + 1, n)];       int A1 = b.y - a.y, B1 = b.x - a.x;       int A2 = c.y - d.y, B2 = c.x - d.x;       if (!(A1 == A2 && B1 == B2)) {         cout <<  No  << endl;         return;       }     }     cout <<  YES ;   }   int main() {     int t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   map<long long, long long> mp1, mp2;   long long n, k;   long long a[200001];   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> k;     long long res = 0;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = n; i >= 1; --i) {       res += mp1[a[i] * k];       if (a[i] % k == 0) mp1[a[i]] += mp2[a[i] * k];       if (a[i] % (k * k) == 0) ++mp2[a[i]];     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void in(T &x) {     bool f = 0;     x = 0;     char c = getchar();     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) {       f = 1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     if (f) x = -x;     return;   }   template <typename T1, typename T2>   void in(T1 &x, T2 &y) {     in(x);     return in(y);   }   template <typename T1, typename T2, typename T3>   void in(T1 &x, T2 &y, T3 &z) {     in(x);     in(y);     return in(z);   }   template <typename T1, typename T2, typename T3, typename T4>   void in(T1 &x, T2 &y, T3 &z, T4 &w) {     in(x);     in(y);     in(z);     return in(w);   }   int a[200009], b[200009], d[200009];   int main() {     int n, k, cnt = 0;     in(n, k);     for (int i = 0; i < n; i++) in(a[i]);     for (int i = 0; i < n; i++) in(b[i]);     int j = 0;     for (int i = 0; i < n; i++)       if (a[i] <= b[i])         k--;       else         d[j++] = a[i] - b[i];     sort(d, d + j);     for (int i = 0; i < j && k > 0; i++) cnt += d[i], k--;     for (int i = 0; i < n; i++) cnt += min(a[i], b[i]);     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   inline long long read() {     long long x = 0;     char c = getchar(), f = 1;     for (; c <  0  ||  9  < c; c = getchar())       if (c ==  - ) f = -1;     for (;  0  <= c && c <=  9 ; c = getchar()) x = x * 10 + c -  0 ;     return x * f;   }   inline void write(long long x) {     static char buf[20];     int len = 0;     if (x < 0) putchar( - ), x = -x;     for (; x; x /= 10) buf[len++] = x % 10 +  0 ;     if (!len)       putchar( 0 );     else       while (len) putchar(buf[--len]);   }   inline void writesp(long long x) {     write(x);     putchar(   );   }   inline void writeln(long long x) {     write(x);     putchar(  n );   }   struct Query {     int l, r, id;   } q[200010];   long long s[200010], inv[200010], power[200010];   int a[200010];   int pos[200010], len[200010];   long long cur[200010], sum[200010];   int ans[200010];   int n, m;   bool cmp(Query a, Query b) { return a.r < b.r; }   long long calc(int l, int r) {     return (s[r] - s[l - 1] + 1000000007) * inv[l - 1] % 1000000007;   }   int main() {     n = read();     m = read();     for (int i = 1; i <= n; i++) a[i] = read();     s[0] = 0;     inv[0] = power[0] = 1;     for (int i = 1; i <= n; i++) {       inv[i] = inv[i - 1] * ((1000000007 + 1) / 2) % 1000000007;       power[i] = power[i - 1] * 2 % 1000000007;       s[i] = (s[i - 1] + (a[i] * power[i - 1] % 1000000007) + 1000000007) %              1000000007;     }     for (int i = 1; i <= m; i++) q[i].l = read(), q[i].r = read(), q[i].id = i;     std::sort(q + 1, q + m + 1, cmp);     int tot = 0, last = 1;     for (int i = 1; i <= n; i++) {       pos[++tot] = i;       len[tot] = 1;       cur[tot] = a[i];       sum[tot] = (sum[tot - 1] + cur[tot] % 1000000007 + 1000000007) % 1000000007;       while (tot > 1 && cur[tot] >= 0) {         if ((len[tot - 1] > 30 && cur[tot] > 0) ||             (cur[tot - 1] + (cur[tot] << len[tot - 1])) > 0x7fffffff)           cur[tot - 1] = 0x7fffffff;         else           cur[tot - 1] = (cur[tot - 1] + (cur[tot] << len[tot - 1]));         sum[tot - 1] = (sum[tot - 1] + (sum[tot] - sum[tot - 1] + 1000000007) *                                            power[len[tot - 1]]) %                        1000000007;         len[tot - 1] += len[tot];         --tot;       }       while (last <= m && q[last].r <= i) {         int l = 1, r = tot;         while (l < r) {           int mid = (l + r + 1) >> 1;           if (pos[mid] <= q[last].l)             l = mid;           else             r = mid - 1;         }         ans[q[last].id] = ((sum[tot] - sum[l] + 1000000007) * 2 +                            calc(q[last].l, pos[l] + len[l] - 1)) %                           1000000007;         ++last;       }     }     for (int i = 1; i <= m; i++) writeln(ans[i]);     putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int left[n], right[n];     int leftOpen = 0, leftClose = 0, rightOpen = 0, rightClose = 0;     for (int i = 0; i < n; i++) {       cin >> left[i];       cin >> right[i];       if (left[i])         leftOpen += 1;       else         leftClose += 1;       if (right[i])         rightOpen += 1;       else         rightClose += 1;     }     int minCount = 0;     if (leftOpen > leftClose)       minCount += leftClose;     else       minCount += leftOpen;     if (rightOpen > rightClose)       minCount += rightClose;     else       minCount += rightOpen;     cout << minCount << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[202020], f[202020];   int s[202020];   bool br[202020];   int n, doe, ans;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]), ++f[a[i]];     doe = 1;     while (f[doe] != 0) ++doe;     for (int i = 1; i <= n; ++i) {       if (f[a[i]] == 1 && br[a[i]] == 0) {         s[i] = a[i];         br[a[i]] = 1;         continue;       }       if (a[i] < doe && br[a[i]] == 0) {         s[i] = a[i];         br[a[i]] = 1;         --f[a[i]];         continue;       }       ++ans;       s[i] = doe;       --f[a[i]];       br[doe] = 1;       ++doe;       while (f[doe] != 0) ++doe;     }     printf( %d n , ans);     printf( %d , s[1]);     for (int i = 2; i <= n; ++i) printf(  %d , s[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct ljb {     int dest, flow, cost;     ljb *next, *other;   };   int n, s, ans1, ans2, flag[10000], cost[10000], flow[10000], u[100000],       hh[10000], lim[10000];   ljb *p, *head[10000], *tail[10000], *hu[10000];   string ct, cs[10000];   void push(int x, int y, int z, int w) {     ljb *p, *q;     p = new ljb;     p->dest = y;     p->flow = z;     p->cost = w;     p->next = 0;     tail[x]->next = p;     tail[x] = p;     q = new ljb;     q->dest = x;     q->flow = 0;     q->cost = -w;     q->next = 0;     tail[y]->next = q;     tail[y] = q;     p->other = q;     q->other = p;   }   void spfa() {     int rc, fc, uu;     ljb *p;     while (true) {       memset(flow, 0, sizeof(flow));       for (int i = 0; i <= s; i++) cost[i] = 2147483647;       memset(flag, 0, sizeof(flag));       cost[0] = 0;       flow[0] = 2147483647;       rc = 1;       fc = 1;       u[rc] = 0;       while (rc <= fc) {         flag[u[rc]] = 0;         p = head[u[rc]]->next;         while (p != 0) {           if ((p->flow > 0) && (cost[u[rc]] + p->cost < cost[p->dest])) {             cost[p->dest] = cost[u[rc]] + p->cost;             flow[p->dest] = min(flow[u[rc]], p->flow);             hu[p->dest] = p;             if (flag[p->dest] == 0) {               ++fc;               u[fc] = p->dest;               flag[p->dest] = 1;             }           }           p = p->next;         }         ++rc;       }       if (flow[s] == 0) break;       ans1 += flow[s];       ans2 += flow[s] * cost[s];       uu = s;       while (uu != 0) {         hu[uu]->flow -= flow[s];         hu[uu]->other->flow += flow[s];         uu = hu[uu]->other->dest;       }     }   }   int main() {     string ct;     cin >> ct;     cin >> n;     for (int i = 1; i <= n; i++) cin >> cs[i] >> lim[i];     s = n + 27;     for (int i = 0; i <= s; i++) {       p = new ljb;       p->dest = 0;       p->cost = 0;       p->flow = 0;       p->next = 0;       p->other = 0;       head[i] = p;       tail[i] = p;     }     for (int i = 1; i <= n; i++) push(0, i, lim[i], 0);     for (int i = 1; i <= n; i++) {       memset(hh, 0, sizeof(hh));       for (int j = 0; j < cs[i].size(); j++) ++hh[cs[i][j] - 96];       for (int j = 1; j <= 26; j++) push(i, j + n, hh[j], i);     }     memset(hh, 0, sizeof(hh));     for (int i = 0; i < ct.size(); i++) ++hh[ct[i] - 96];     for (int i = 1; i <= 26; i++) push(i + n, s, hh[i], 0);     spfa();     if (ans1 != ct.size()) ans2 = -1;     cout << ans2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   void ro(vector<string> &b) {     vector<string> c(N, string(N,    ));     for (int i = 0; i < N; i++) {       for (int j = N - 1; j >= 0; j--) {         c[N - 1 - j][i] = b[i][j];       }     }     b = c;   }   void fl(vector<string> &b) { reverse(b.begin(), b.end()); }   int main() {     cin >> N;     vector<string> b1(N), b2(N);     int i;     for (i = 0; i < N; i++) {       string s;       cin >> s;       b1[i] = s;     }     for (i = 0; i < N; i++) {       string s;       cin >> s;       b2[i] = s;     }     for (i = 0; i < 4; i++) {       ro(b1);       if (b1 == b2) {         break;       }     }     if (i >= 4) {       fl(b1);       for (i = 0; i < 4; i++) {         ro(b1);         if (b1 == b2) {           break;         }       }     }     cout << (i < 4 ?  Yes  :  No ) << endl;     return (0);   }
#include <bits/stdc++.h>   using namespace std;   const int M = 100005;   int read() {     int x = 0, flag = 1;     char c;     while ((c = getchar()) <  0  || c >  9 )       if (c ==  - ) flag = -1;     while (c >=  0  && c <=  9 )       x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();     return x * flag;   }   int n, m, q, l[M], r[M], u[M], d[M];   char s[M];   void get(int n, int *a) {     scanf( %s , s + 1);     for (int i = 1; i <= n; i++) a[i] = (s[i] ==  R );   }   int cal() {     int f0 = 0, f1 = 0, g0, g1;     for (int i = 1; i <= m; i++) f0 += u[i], f1 += (!u[i]);     for (int i = 1; i <= n; i++) {       g0 = f0;       g1 = f1;       f0 = min(g0, g1 + m) + l[i] + r[i];       f1 = min(g0 + m, g1) + (!l[i]) + (!r[i]);     }     for (int i = 1; i <= m; i++) f0 += d[i], f1 += (!d[i]);     return min(f0, f1);   }   signed main() {     n = read();     m = read();     q = read();     get(n, l);     get(n, r);     get(m, u);     get(m, d);     int ans = cal();     swap(n, m);     swap(l, u);     swap(r, d);     ans = min(ans, cal());     printf( %d n , ans);   }