malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     scanf( %I64d , &a);     scanf( %I64d , &b);     if (a == b) {       printf( 1 n );       return 0;     }     long long cnt = 0, ans = 1;     for (long long i = b; i >= a + 1; i--) {       cnt++;       if (i % 10 == 0) {         printf( 0 n );         return 0;       }       ans *= i % 10;       ans %= 10;     }     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int X[] = {1, 0, -1, 0, 1, -1, -1, 1};   int Y[] = {0, 1, 0, -1, 1, 1, -1, -1};   void MN(long long int &a, long long int b) {     if (a > b) a = b;   }   void MX(long long int &a, long long int b) {     if (a < b) a = b;   }   void MN(int &a, int b) {     if (a > b) a = b;   }   void MX(int &a, int b) {     if (a < b) a = b;   }   long long int MOD(long long int a, long long int b) {     return a >= 0 ? a % b : (b - abs(a % b)) % b;   }   int OneD(int row, int col, int t_n_o_r) { return row * t_n_o_r + col; }   int main() {     int n, o = 0;     scanf( %d , &n);     unsigned long long int res = 0;     vector<int> seq(n);     for (int i = 0; i < n; i++) {       scanf( %d , &seq[i]);       if (seq[i] & 1) o++;     }     sort(seq.begin(), seq.end());     if (o & 1) o--;     for (int i = n - 1; i >= 0; i--) {       if (seq[i] & 1) {         if (o > 0) {           res += seq[i];           o--;         }       } else         res += seq[i];     }     printf( %lld n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double a, b, c, s, r;   double A, B, C;   double eps = 1e-3;   double pi = acos(-1.0);   struct Point {     double x, y;   } p[10];   double disP2P(Point a, Point b) {     return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));   }   int sgn(double x) {     if (fabs(x) < eps) return 0;     if (x > 0) return 1;     return -1;   }   double fgcd(double a, double b) {     if (sgn(b) == 0) return a;     return fgcd(b, fmod(a, b));   }   int main() {     for (int i = 0; i < 3; ++i) {       cin >> p[i].x >> p[i].y;     }     a = disP2P(p[0], p[1]);     b = disP2P(p[1], p[2]);     c = disP2P(p[2], p[0]);     double x = (a + b + c) / 2;     s = sqrt(x * (x - a) * (x - b) * (x - c));     r = a * b * c / 4 / s;     A = acos(1 - a * a / 2 / r / r);     B = acos(1 - b * b / 2 / r / r);     C = 2 * pi - A - B;     double ang = fgcd(A, fgcd(B, C));     double ans = pi / ang * r * r * sin(ang);     printf( %.7f n , ans);   }
#include<bits/stdc++.h>   using namespace std;   typedef long long ll;   const int Max = 35010;   const ll INF  = 1e17 + 10;      bool sw; ll dp[2][Max];   int A[Max];      int L , R , F;   deque<int> dq[Max];      void moveto(int l , int r)   {    //cout <<  to   << l <<  ,  << r <<   n ;    while(L > l)    {     L--;     if(dq[A[L]].size() > 0) F += dq[A[L]].front();     dq[A[L]].push_front(L);     if(dq[A[L]].size() > 1) F -= dq[A[L]].front();    }    while(R < r)    {     R++;     if(dq[A[R]].size() > 0) F -= dq[A[R]].back();     dq[A[R]].push_back(R);     if(dq[A[R]].size() > 1) F += dq[A[R]].back();    }    while(R > r)    {     if(dq[A[R]].size() > 1) F -= dq[A[R]].back();     dq[A[R]].pop_back();     if(dq[A[R]].size() > 0) F += dq[A[R]].back();     R--;    }    while(L < l)    {     if(dq[A[L]].size() > 1) F += dq[A[L]].front();     dq[A[L]].pop_front();     if(dq[A[L]].size() > 0) F -= dq[A[L]].front();     L++;    }   }      void solve(int l , int r , int tl , int tr)   {    if(r < l) return;    int mid = (l + r) >> 1;    int opt = -1; ll ans = INF;    for(int i = min(tr , mid - 1) ; i >= tl ; i--)    {     //cout <<  res   << i + 1 <<  ,  << mid <<   =  ;     moveto(i + 1 , mid);     //cout << F <<   n ;     ll nans = F + dp[!sw][i];     if(nans <= ans) opt = i , ans = nans;    }    dp[sw][mid] = ans;       moveto(opt + 1 , mid);    solve(l , mid - 1 , tl , opt);    moveto(opt + 1 , mid);    solve(mid + 1 , r , opt , tr);   }   int main()   {    int n , k; cin >> n >> k;    for(int i = 1 ; i <= n ; i++) cin >> A[i];    //for(int i = 1 ; i <= n ; i++) dp[sw][i] = INF;       L = 1 , R = 1 , F = 0 , dq[A[1]].push_back(1);           for(int i = 1 ; i <= n ; i++)    {     moveto(1 , i);     dp[sw][i] = F;    }    //cout <<   n ;    for(int i = 1 ; i < k ; i++)    {     moveto(1 , n);     sw = !sw;     solve(1 , n , 0 , n - 1);     //for(int i = 1 ; i <= n ; i++) cout << dp[sw][i] <<    ; cout <<   n ;    }    cout << dp[sw][n] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int countnode(map<int, vector<int>> m, int x, int parent) {     int count = 1;     for (auto i : m[x]) {       if (i != parent) count += countnode(m, i, x);     }     return count;   }   int main() {     int t;     cin >> t;     while (t--) {       int n, x;       cin >> n >> x;       map<int, vector<int>> m;       for (int i = 0; i < n - 1; i++) {         int a, b;         cin >> a >> b;         m[a].push_back(b);         m[b].push_back(a);       }       if (m[x].size() == 1 || m[x].size() == 0)         cout <<  Ayush  << endl;       else {         if (countnode(m, x, x) % 2 == 0)           cout <<  Ayush  << endl;         else           cout <<  Ashish  << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long cumdp[2005];   long long cumpd[2005];   long long dp[2005][2005];   long long pd[2005][2005];   const long long mod = 1e9 + 7;   int main() {     long long n, m;     cin >> n >> m;     for (int width = 2; width <= m; width++) {       dp[1][width] = 1;       pd[1][width] = 1;     }     for (int len = 2; len <= n; len++) {       long long sum = 0;       for (int width = 2; width <= m; width++) {         sum += dp[len - 1][width];         sum %= mod;         dp[len][width] = dp[len][width - 1] + sum;         pd[len][width] = dp[len][width] - dp[len - 1][width];       }     }     long long ans = 0;     for (int base = 1; base <= m; base++) {       for (int len = 1; len <= n; len++) {         cumdp[len] = cumdp[len - 1] + dp[len][base];         cumdp[len] %= mod;         cumpd[len] = cumpd[len - 1] + pd[len][base];         cumpd[len] %= mod;       }       long long cur = 0;       for (int cen = 1; cen <= n; cen++) {         cur += (cumdp[cen] * cumpd[n - cen + 1]) % mod;         cur %= mod;       }       cur *= (m - base + 1);       cur %= mod;       ans += cur;       ans %= mod;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int C[200005], L[200005], N[200005];   inline int findSet(int i) { return (N[i] == i) ? i : (N[i] = findSet(N[i])); }   inline void unionSet(int i, int j) { N[findSet(i)] = findSet(j); }   int main() {     int n, m;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , C + i);       N[i] = i;     }     N[n] = n;     scanf( %d , &m);     int op, k, a;     while (m--) {       scanf( %d %d , &op, &k);       if (op == 1) {         scanf( %d , &a);         --k;         while (k < n and a) {           if (a > C[k] - L[k]) {             a -= C[k] - L[k];             L[k] = C[k];             unionSet(k, k + 1);             k = findSet(k);           } else {             L[k] += a;             a = 0;           }         }       } else {         printf( %d n , L[--k]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int M = 200179;   int n, q, k, t;   int p[M], b[M];   vector<int> pb[M];   set<int> last;   int main() {     scanf( %d , &n);     for (int t = 0; t < n; t++) {       scanf( %d%d , &p[t], &b[t]);       pb[p[t]].push_back(t);     }     last.insert(-1);     for (int p = 1; p <= n; p++)       if (pb[p].size()) last.insert(*pb[p].rbegin());     for (scanf( %d , &q); q; q--) {       scanf( %d , &k);       vector<int> esc(k);       for (int i = 0; i < k; i++)         if (scanf( %d , &esc[i]), pb[esc[i]].size())           last.erase(*pb[esc[i]].rbegin());       pair<int, int> ans = {0, 0};       if (last.size() > 1) {         auto iw = last.rbegin();         int win = p[*iw];         ans = {win, b[*upper_bound(pb[win].begin(), pb[win].end(), *++iw)]};       }       cout << ans.first <<     << ans.second << endl;       for (int i = 0; i < k; i++)         if (pb[esc[i]].size()) last.insert(*pb[esc[i]].rbegin());     }   }
#include <bits/stdc++.h>   using namespace std;   long long x[200001], y[200001], dp[200001], n;   bool s[200001];   long long find_upper_bound(long long l, long long r, long long value) {     long long mid, index = 1;     while (l <= r) {       mid = l + (r - l) / 2;       if (x[mid] >= value) {         index = mid;         r = mid - 1;       } else         l = mid + 1;     }     return index;   }   int main() {     int t;     t = 1;     while (t--) {       dp[0] = 0;       cin >> n;       for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> s[i];       long long ans = (x[n] + 1) % 998244353, temp;       for (int i = 1; i <= n; i++) {         temp = find_upper_bound(1, i, y[i]);         dp[i] = x[i] - y[i];         if (temp != i)           dp[i] = (dp[i] + (dp[i - 1] - dp[temp - 1] + 998244353) % 998244353) %                   998244353;         if (s[i]) ans = (ans + dp[i]) % 998244353;         dp[i] = (dp[i] + dp[i - 1]) % 998244353;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long xa, xb, ya, yb, xc, yc, t;   long long cp(long long x1, long long x2, long long y1, long long y2) {     return x1 * y2 - x2 * y1;   }   int main() {     cin >> xa >> ya >> xb >> yb >> xc >> yc;     t = cp(xc - xa, xb - xa, yc - ya, yb - ya);     if (t == 0) {       cout <<  TOWARDS  << endl;     }     if (t < 0) {       cout <<  LEFT  << endl;     }     if (t > 0) {       cout <<  RIGHT  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char c[2000007];   set<int> s;   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < 2000007; i++) {       s.insert(i);     }     set<int>::iterator it;     int maxy = 0;     for (int i = 0; i < n; i++) {       string l;       cin >> l;       int k;       scanf( %d , &k);       while (k--) {         int x;         scanf( %d , &x);         while (1) {           it = s.lower_bound(x);           if (it != s.end() && (*it) <= l.length() + x - 1) {             c[*it] = l[(*it) - x];             maxy = max(maxy, *it);             s.erase(it);           } else             break;         }       }     }     c[maxy + 1] =   0 ;     for (int i = 1; i <= maxy; i++) {       if (s.find(i) != s.end()) c[i] =  a ;     }     printf( %s n , c + 1);   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int inf = 0x3f3f3f3f;   inline long long read() {     register long long x = 0, f = 1;     register char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);     return x * f;   }   void write(long long x) {     if (x < 0) x = -x, putchar( - );     if (x >= 10) write(x / 10);     putchar(x % 10 +  0 );   }   void writeln(long long x) {     write(x);     puts(  );   }   const int maxn = 1e4 + 233;   struct node {     int x, y, opt, id;     bool operator<(const node &w) const {       return x < w.x || (x == w.x && y < w.y);     }   } a[maxn * 2], c;   int ans[maxn], n;   node operator-(node a, node b) { return (node){a.x - b.x, a.y - b.y, 0, 0}; }   int cross(node a, node b) { return a.x * b.y - a.y * b.x; }   bool cmp(node a, node b) { return cross(a - c, b - c) > 0; }   void work(int l, int r) {     if (l > r) return;     int p = min_element(a + l, a + r + 1) - a;     swap(a[l], a[p]);     c = a[l];     sort(a + l + 1, a + r + 1, cmp);     int cnt1 = 0, cnt2 = 0, k = r;     while (!(c.opt != a[k].opt && cnt1 == cnt2)) {       if (c.opt == a[k].opt)         cnt1++;       else         cnt2++;       k--;     }     if (c.opt == 1)       ans[a[k].id] = c.id;     else       ans[c.id] = a[k].id;     work(l + 1, k - 1);     work(k + 1, r);   }   int main() {     n = read();     for (register int i = (0); i < int(2 * n); ++i) {       a[i].x = read();       a[i].y = read();       a[i].opt = i < n ? 0 : 1;       a[i].id = i < n ? i + 1 : i - n + 1;     }     work(0, 2 * n - 1);     for (register int i = (1); i <= int(n); ++i) writeln(ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int m = 10000 * 100000 + 7;   int main() {     string s;     cin >> s;     int n = s.length();     long long p = 0, q = 1;     for (int i = n - 1; i > 0; --i) {       if (s[i] ==  1 ) p = (p + q) % m;       q = q * 2 % m;     }     if (s[0] ==  1 ) p = (p + q) % m;     cout << p * q % m;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int count;     int n;     int rub;     int a[100000];     int b[100000];     int a_1234[4] = {0, 0, 0, 0};     int sum = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> rub;       a_1234[rub - 1]++;     }     sum = a_1234[3] + a_1234[2];     a_1234[0] -= a_1234[2];     if (a_1234[0] < 0) a_1234[0] = 0;     sum += a_1234[1] / 2;     a_1234[1] = a_1234[1] % 2;     sum += (a_1234[1] * 2 + a_1234[0]) / 4;     if ((a_1234[1] * 2 + a_1234[0]) % 4 != 0) sum++;     cout << sum;     getchar();     getchar();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct $ {     $() {       ios_base::sync_with_stdio(false);       cin.tie(nullptr);     }   } $;   const int N = 100002;   int n, m;   vector<int> a[N];   vector<int> pri[N];   vector<int> ans;   vector<tuple<int, int>> where[N];   const int NPR = 20;   int primes[NPR] = {       2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19, 23, 25, 27, 29, 31, 32, 36, 37,   };   int mod[NPR], cnt[NPR];   int main() {     cin >> n >> m;     for (int i = 0; i < n; ++i) {       int k;       cin >> k;       a[i].resize(k);       for (int j = 0; j < k; ++j) {         cin >> a[i][j];         where[a[i][j]].emplace_back(i, j);       }       for (int j = 0; j < NPR; ++j)         if (k % primes[j] == 0) pri[i].emplace_back(j);     }     ans.resize(m + 1);     for (int i = 0; i < n; ++i) {       const auto &v = a[i];       int ki = int(v.size());       for (int j = 0; j < ki; ++j) {         int x = v[j];         if (ans[x]) continue;         ans[x] = 1;         auto wit = begin(where[x]);         for (int start = -2, stop = -2; wit != end(where[x]); ++wit) {           int row, off;           tie(row, off) = *wit;           if (row != stop) {             start = stop = row;             fill(begin(cnt), end(cnt), 0);           }           for (int prq : pri[stop]) {             if (mod[prq] == off % primes[prq]) {               ++cnt[prq];             } else {               for (; cnt[prq]; ++start) {                 for (int prp : pri[start]) --cnt[prp];               }               cnt[prq] = 1;               mod[prq] = off % primes[prq];             }           }           ++stop;           ans[x] = max(ans[x], stop - start);         }       }     }     for (int i = 1; i <= m; ++i) {       cout << ans[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   int nrg, nrv;   string s;   bool gg(int pos) {     if (pos < 2) return 0;     return ((s[pos] >=  0  && s[pos] <=  9 ) &&             (s[pos - 1] >=  0  && s[pos - 1] <=  9 ) && (s[pos - 2] ==  . ));   }   deque<int> dg;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> s;     for (int i = 0; i < s.size(); ++i) {       if (s[i] >=  a  && s[i] <=  z ) continue;       int l = i;       while (i < s.size() && !(s[i] >=  a  && s[i] <=  z )) ++i;       --i;       int r = i;       if (gg(r)) {         nrv = nrv + (s[r] -  0 ) + 10 * (s[r - 1] -  0 );         r -= 3;       }       int ex = 1;       while (r >= 0 && !(s[r] >=  a  && s[r] <=  z )) {         if (s[r] !=  . ) nrg = nrg + ex * (s[r] -  0 ), ex = ex * 10;         --r;       }     }     nrg += nrv / 100;     nrv %= 100;     do {       dg.push_front(nrg % 10);       nrg /= 10;     } while (nrg);     for (int i = 0; i < dg.size(); ++i) {       if (i && (dg.size() - i) % 3 == 0) cout <<  . ;       cout << dg[i];     }     if (nrv) {       cout <<  . ;       if (nrv < 10) cout <<  0 ;       cout << nrv;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long read() {     char c;     long long num, f = 1;     while (c = (char)getchar(), !isdigit(c))       if (c ==  - ) f = -1;     num = (long long)(c -  0 );     while (c = (char)getchar(), isdigit(c)) num = num * 10 + (long long)(c -  0 );     return num * f;   }   long long n, m;   vector<long long> a;   long long greaterCount(long long m) {     vector<long long> s(2 * n + 1);     long long sum = n, result = 0, add = 0;     s[sum] = 1;     for (long long i = 0; i < n; i++) {       if (a[i] < m)         sum--, add -= s[sum];       else         add += s[sum], sum++;       result += add;       s[sum]++;     }     return result;   }   void work() {     n = read();     m = read();     a = vector<long long>(n);     for (long long i = 0; i < n; i++) a[i] = read();     cout << greaterCount(m) - greaterCount(m + 1) << endl;     return;   }   signed main() {     long long T = 1;     for (long long Case = 1; Case <= T; Case++) {       work();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, j, x, y, z, m, n, k, l, r, f, mi = 1e9;   int a[200];   bool pr(int n) {     for (int i = 2; i * i <= n; i++)       if (n % i == 0) return true;     return false;   }   int main() {     scanf( %d , &n);     a[1] = a[2] = a[3] = -1;     a[4] = 1;     for (int i = 5; i < 100; i++) {       int t = -1;       if (pr(i)) t = 1;       for (int j = 4; j <= i / 2; j++)         if (pr(j) && pr(i - j)) t = max(t, a[j] + a[i - j]);       a[i] = t;     }     while (n--) {       scanf( %d , &m);       int ans;       if (m < 20)         ans = a[m];       else {         ans = m / 4;         m = m % 4;         if (m == 1) ans--;         if (m == 3) ans--;       }       printf( %d n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   const long long dx[] = {-2, -1, 1, 2, -2, 1, -1, 2};   const long long dy[] = {-1, -2, 2, 1, 1, -2, 2, -1};   const long long Mod = 1e9 + 7;   const long long N = 5e5;   const long long inf = 1e9 + 1;   const long long N_N = 1e2;   long long n, m, x, y, cnt;   int main() {     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       cin >> x >> y;       cnt = max(cnt, y + x);     }     cout << max(cnt, m);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[50];   int main() {     int f = 2, ct[110];     ct[0] = 0;     ct[1] = 0;     ct[2] = 1;     for (int i = 3; i <= 101; i++) {       ct[i] = ct[i - 1] + f;       f++;     }     string s;     int n, m;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> s;       m = s[0] - 96;       a[m]++;     }     int sum = 0, dis, l;     for (int i = 1; i <= 26; i++) {       if (a[i] != 0) {         dis = a[i] / 2;         l = a[i] - dis;         sum += (ct[l] + ct[dis]);       }     }     cout << sum << endl;     return 0;   }
#include <algorithm>   #include <cmath>   #include <cstring>   #include <iostream>   #include <limits>   #include <queue>   #include <set>   #include <sstream>   #include <stack>   #include <unordered_map>   #include <utility>   #include <vector>      using namespace std;      typedef long long ll;   typedef vector<int> vi;   typedef vector<int>::iterator vit;   typedef vector<vector<int>> vii;      #define REP(i, a, b) for (int i = a; i < b; i++)   #define VECITR(itr, v) for (vit itr = v.begin(); itr != v.end(); itr++)   #define PB push_back   #define MP make_pair   #define F first   #define S second   #define sq(a) ((a) * (a))      int gcd(int a, int b)   {       if (b == 0)           return a;       return gcd(b, a % b);   }      string next_valid_bracket_sequence(const string &x)   {       string s = x;       int n = s.size();       int d = 0;       for (int i = n - 1; i >= 1; i--)       {           if (s[i] ==  ) )               d++;           else           {               d--;               if (d > 0)               {                   s[i] =  ) ;                   s = s.substr(0, i + 1);                   REP(j, 0, (n - i - d) / 2) { s +=  ( ; }                   REP(j, 0, (n - i + d - 2) / 2) { s +=  ) ; }                   if (s.size() < n) return s +  ) ;                   return s;               }           }       }          return   ;   }      ll modulo(ll x, ll m)    {       int r = x % m;       return r < 0 ? r + m : r;   }         int dfs(vector<vector<bool>> &change, vector<string> &arr, int i, int j, int k)   {       return 0;   }         void run()   {       ll n; cin >> n;       ll copy = n;          while(n % 4 == 0 && n > 4)            n /= 4;          if (n == 2 || n == 4) { cout <<  YES n ; return; }          n = copy;          if (n % 2 == 0 && (n / 2) == sq(ll(sqrt(double(n / 2))))) { cout <<  YES n ; return; }       if (n % 4 == 0 && (n / 4) == sq(ll(sqrt(double(n / 4))))) { cout <<  YES n ; return; }       else cout <<  NO n ;   }      int main()   {       cin.tie(NULL);       ios_base::sync_with_stdio(false);          int t = 1;       cin >> t;          REP(i, 0, t) { run(); }   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     static int r, sign;     static char c;     r = 0, c = getchar(), sign = 1;     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) sign = -1, c = getchar();     while (c >=  0  && c <=  9 ) r = r * 10 + (c -  0 ), c = getchar();     return r * sign;   }   template <typename T>   inline void print(T *a, int n) {     for (int i = 1; i < n; ++i) cout << a[i] <<    ;     cout << a[n] << endl;   }   const int mod = (int)1e9 + 7;   int n, x = 0, y = 0;   char m[4][10010 + 1];   int f[2][64];   inline int get(int x, int p) { return (x >> (p - 1) * 2) & 3; }   inline void add(int &x, int y) {     x += y;     if (x >= mod) x -= mod;   }   int solve() {     memset(f, 0, sizeof f);     f[0][0] = 1;     for (int i = 1; i <= n; ++i) {       memset(f[i & 1], 0, sizeof f[i & 1]);       for (int j = 0; j < 64; ++j) {         if (!f[i & 1 ^ 1][j]) continue;         for (int k = 0; k < 64; ++k) {           bool ok = true;           for (int x = 1; ok && x <= 3; ++x) {             if (get(j, x) == 1 && get(k, x) != 2) ok = false;             if (get(k, x) == 2 && get(j, x) != 1) ok = false;             if (m[x][i] !=  X  && get(k, x) == 0) ok = false;             if (m[x][i] ==  X  && get(k, x) != 0) ok = false;           }           if (get(k, 1) == 3 && get(k, 2) != 3) ok = false;           if (get(k, 2) != 3 && get(k, 3) == 3) ok = false;           if (get(k, 2) == 3 && get(k, 1) != 3 && get(k, 3) != 3) ok = false;           if (get(k, 1) == 3 && get(k, 2) == 3 && get(k, 3) == 3) ok = false;           if (!ok) continue;           add(f[i & 1][k], f[i & 1 ^ 1][j]);         }       }     }     int ans = 0;     for (int i = 0; i < 64; ++i) {       bool ok = true;       for (int x = 1; ok && x <= 3; ++x)         if (get(i, x) == 1) ok = false;       if (!ok) continue;       add(ans, f[n & 1][i]);     }     return ans;   }   const int dir[8][2] = {{0, 1},   {1, 0},  {-1, 0}, {0, -1},                          {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};   int main(int argc, char *argv[]) {     scanf( %d , &n);     scanf( %s n%s n%s n , m[1] + 1, m[2] + 1, m[3] + 1);     for (int i = 1; !x && i <= n; ++i)       for (int j = 1; j <= 3; ++j)         if (m[j][i] ==  O ) x = j, y = i;     m[x][y] =  X ;     int ans = solve();     if (x == 2 && y > 1 && y < n) {       bool need = true;       for (int i = 0; i < 8; ++i) {         int nx = x + dir[i][0], ny = y + dir[i][1];         if (m[nx][ny] ==  X ) need = false;       }       if (need) {         for (int i = 0; i < 8; ++i) {           int nx = x + dir[i][0], ny = y + dir[i][1];           m[nx][ny] =  X ;         }         ans -= 2 * solve() % mod;         if (ans < 0) ans += mod;       }     }     printf( %d n , ans);     fclose(stdin);     fclose(stdout);     return 0;   }