malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e6;   long long n, K, d, a[200010];   map<long long, long long> mp;   struct trnode {     long long lc, rc, c, u;   } tr[400010];   long long tot = 0;   void pushdown(long long x) {     long long lc = tr[x].lc, rc = tr[x].rc, c = tr[x].u;     tr[x].u = 0;     tr[lc].c += c;     tr[rc].c += c;     tr[lc].u += c;     tr[rc].u += c;   }   void change(long long x, long long l, long long r, long long fl, long long fr,               long long c, long long op) {     if (l == fl && r == fr) {       if (op)         tr[x].c = c;       else         tr[x].c += c, tr[x].u += c;       return;     }     long long mid = (l + r) / 2;     if (tr[x].u) pushdown(x);     if (fr <= mid)       change(tr[x].lc, l, mid, fl, fr, c, op);     else if (fl > mid)       change(tr[x].rc, mid + 1, r, fl, fr, c, op);     else       change(tr[x].lc, l, mid, fl, mid, c, op),           change(tr[x].rc, mid + 1, r, mid + 1, fr, c, op);     tr[x].c = min(tr[tr[x].lc].c, tr[tr[x].rc].c);   }   long long bt(long long l, long long r) {     long long x = ++tot;     tr[x].c = inf;     if (l != r) {       long long mid = (l + r) / 2;       tr[x].lc = bt(l, mid);       tr[x].rc = bt(mid + 1, r);     }     return x;   }   long long findans(long long x, long long l, long long r) {     if (l == r) return tr[x].c <= K ? l : inf;     if (tr[x].u) pushdown(x);     long long mid = (l + r) / 2;     if (tr[tr[x].lc].c <= K) return findans(tr[x].lc, l, mid);     return findans(tr[x].rc, mid + 1, r);   }   long long L = 1, R = 1, s1[200010], s2[200010], t1 = 0, t2 = 0, la = 1;   int main() {     scanf( %lld %lld %lld , &n, &K, &d);     for (long long i = 1; i <= n; i++) scanf( %lld , &a[i]);     if (d == 0) {       L = 1;       R = 1;       long long l = 1, r = 1;       for (int i = 2; i <= n; i++) {         r = i;         if (a[i] != a[i - 1]) l = i;         if (r - l + 1 > R - L + 1) L = l, R = r;       }       printf( %lld %lld , L, R);       return 0;     }     bt(1, n);     change(1, 1, n, 1, 1, 0, 1);     s1[++t1] = 1;     s2[++t2] = 1;     mp[a[1]] = 1;     for (long long i = 2; i <= n; i++) {       long long tmp = la;       tmp = max(tmp, mp[a[i]] + 1);       if ((a[i] - a[i - 1]) % d != 0) tmp = i;       mp[a[i]] = i;       if (la < tmp) change(1, 1, n, la, tmp - 1, inf, 0), la = tmp;       while (t1 && a[s1[t1]] <= a[i])         change(1, 1, n, s1[t1 - 1] + 1, s1[t1], (a[i] - a[s1[t1]]) / d, 0), t1--;       while (t2 && a[s2[t2]] >= a[i])         change(1, 1, n, s2[t2 - 1] + 1, s2[t2], (a[s2[t2]] - a[i]) / d, 0), t2--;       change(1, 1, n, i, i, 1, 1);       change(1, 1, n, la, i, -1, 0);       s1[++t1] = i;       s2[++t2] = i;       long long l = findans(1, 1, n), r = i;       if (r - l + 1 > R - L + 1) L = l, R = r;     }     printf( %lld %lld , L, R);   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void read(T& x) {     x = 0;     T f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) f = (ch ==  -  ? -1 : 1), ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch - 48, ch = getchar();     x *= f;   }   template <class T, class... Args>   void read(T& x, Args&... args) {     read(x), read(args...);   }   template <class T>   void write(T x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );   }   const int MAXN = 2E5 + 5;   const int MOD = 1E9 + 7;   long long n, num;   double p;   bool check(long long k) {     return (-k * k * k + 3 * k * k + k * (4 + 3 * n * n - 9 * n)) * 10000 >=            num * n * (n - 1) * (n - 2) * 2;   }   signed main() {     cin >> n >> p;     num = llround(p * 10000);     int l = 0, r = n, ans = 0;     while (l <= r) {       int mid = l + r >> 1;       if (check(mid)) {         ans = mid;         r = mid - 1;       } else         l = mid + 1;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using pii = pair<int, int>;   constexpr int MAXN = 1003;   constexpr int MAXC = 10004;   int n;   ll w, b, x;   int c[MAXN];   ll cost[MAXN];   ll dp[MAXN][MAXC];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> w >> b >> x;     for (int i = 0; i < n; ++i) cin >> c[i];     for (int i = 0; i < n; ++i) cin >> cost[i];     memset(dp, -1, sizeof(dp));     dp[0][0] = w;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < MAXC and dp[i][j] > -1; ++j) {         for (ll k = 0; k <= c[i] and dp[i][j] - cost[i] * k >= 0; ++k) {           dp[i + 1][j + k] = max(               dp[i + 1][j + k], min(w + (j + k) * b, dp[i][j] + x - cost[i] * k));         }       }     }     int ans = 0;     for (int j = 0; j < MAXC; ++j) {       if (dp[n][j] != -1) ans = max(ans, j);     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, k;     int nums[1005];     cin >> t;     while (t--) {       cin >> n >> k;       for (int i = 0; i < n; i++) cin >> nums[i];       sort(nums, nums + n);       int sum = 0;       for (int i = 1; i < n; i++) sum += (k - nums[i]) / nums[0];       cout << sum <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, u, v, num_col = 1;   vector<int> adjList[5001];   vector<int> edges[5001];   bitset<5001> vis;   bitset<5001> act;   bitset<5001> col;   void dfs(int nd) {     vis[nd] = 1;     act[nd] = 1;     for (int k = 0; k < adjList[nd].size(); k++) {       int nd_b = adjList[nd][k];       int edge_num = edges[nd][k];       if (!vis[nd_b])         dfs(nd_b);       else if (act[nd_b]) {         num_col = 2;         col[edge_num] = 1;       }     }     act[nd] = 0;   }   int main() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> u >> v;       u--;       v--;       adjList[u].push_back(v);       edges[u].push_back(i);     }     for (int i = 0; i < n; i++) {       if (!vis[i]) dfs(i);     }     cout << num_col << endl;     for (int i = 0; i < m; i++) {       cout << (((int)col[i]) + 1) << (i < m - 1 ?     :   );     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[100005];   int main() {     int n;     while (cin >> n) {       scanf( %s , s);       int ct = 1, n = strlen(s);       bool ok = false;       int cant = 0, ans = 0;       for (int i = 1; i < n; i++) {         if (s[i] == s[i - 1])           ct++;         else {           if (ct >= 3) ok = true;           if (ct >= 2) cant++;           ans++;           ct = 1;         }       }       ans++;       if (ct >= 3) ok = true;       if (ct >= 2) cant++;       if (ok)         ans += 2;       else {         if (cant >= 2)           ans += 2;         else if (cant == 1)           ans++;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int width;     int height;     cin >> height;     cin >> width;     char art[height][width];     for (int i = 0; i < height; i++) {       for (int k = 0; k < width; k++) {         cin >> art[i][k];       }     }     bool found_content = false;     int max_width = width - 1;     int min_width = 0;     int max_height = height - 1;     int min_height = 0;     int collumn = 0;     while (!found_content) {       for (int i = 0; i < height && !found_content; i++) {         if (art[i][collumn] ==  * ) {           min_width = collumn;           found_content = true;         }       }       collumn++;     }     found_content = false;     collumn = width - 1;     while (!found_content) {       for (int i = 0; i < height && !found_content; i++) {         if (art[i][collumn] ==  * ) {           max_width = collumn;           found_content = true;         }       }       collumn--;     }     found_content = false;     int row = 0;     while (!found_content) {       for (int i = 0; i < width && !found_content; i++) {         if (art[row][i] ==  * ) {           min_height = row;           found_content = true;         }       }       row++;     }     found_content = false;     row = height - 1;     while (!found_content) {       for (int i = 0; i < width && !found_content; i++) {         if (art[row][i] ==  * ) {           max_height = row;           found_content = true;         }       }       row--;     }     for (int r = min_height; r <= max_height; r++) {       for (int c = min_width; c <= max_width; c++) {         cout << art[r][c];       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = signed long long int;   const int MX = 7000 + 10, INF = 3e5, A = 100;   ll res;   pair<ll, ll> ab[MX];   int n;   map<ll, pair<int, ll>> m;   vector<ll> v;   bool ad;   int main() {     ios_base::sync_with_stdio(false);     cout.tie(nullptr);     cin.tie(nullptr);     v.reserve(MX);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> ab[i].first;     }     for (int i = 0; i < n; i++) {       cin >> ab[i].second;     }     for (int i = 0; i < n; i++) {       auto& p = m[ab[i].first];       p.first++;       p.second += ab[i].second;     }     for (auto it = m.rbegin(); it != m.rend(); it++) {       auto& p = *it;       ad = false;       if (p.second.first >= 2) {         res += p.second.second;         v.push_back(p.first);       } else {         for (auto i : v) {           if ((p.first & i) == p.first) {             res += p.second.second;             break;           }         }       }     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, x, res = 0, c = 0;     cin >> n >> a >> b;     for (int i = 0; i < n; i++) {       cin >> x;       if (x == 1) {         if (a > 0)           a--;         else if (b > 0) {           c++;           b--;         } else if (c > 0)           c--;         else           res++;       } else if (x == 2) {         if (b > 0)           b--;         else           res += 2;       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   int T[27], A[27][27], P[27], use;   long long Q[1 << 22];   int main() {     int n, k, t;     cin >> n >> k >> t;     string S;     cin >> S;     S =     + S;     for (int i = 1; i <= k; ++i) cin >> T[i];     for (int i = 1; i <= k; ++i)       for (int j = 1; j <= k; ++j) cin >> A[i][j];     memset(P, -1, sizeof(P));     for (int i = 1; i <= n; ++i) {       int x = S[i] -  A  + 1;       for (int j = 1; j <= k; ++j) {         if (P[j] != -1) {           Q[P[j]] += A[j][x];           Q[P[j] | (1 << (j - 1))] -= A[j][x];           Q[P[j] | (1 << (x - 1))] -= A[j][x];           Q[P[j] | (1 << (j - 1)) | (1 << (x - 1))] += A[j][x];         }         P[j] |= (1 << (x - 1));       }       P[x] = 0;       use |= (1 << (x - 1));     }     for (int i = 1; i <= k; ++i) Q[1 << (i - 1)] += T[i];     for (int i = 0; i < k; ++i)       for (int j = 0; j < (1 << k); ++j)         if (j & (1 << i)) Q[j] += Q[j ^ (1 << i)];     int ans = 0;     for (int i = 0; i < (1 << k); ++i)       if ((i & use) == i)         if (Q[i] <= t && i != use) ++ans;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long h[100000];   long long x[100000];   int g[31] = {0, 1, 2, 1, 4, 3, 2, 1, 5, 6,  2, 1, 8, 7,  5,                9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12};   bool mark[100000];   map<int, int> gg;   int grundy(int mask) {     int nmask;     int used[40];     memset(used, 0, sizeof(used));     for (int i = 1; i < 30; i++) {       if (mask & (1 << i)) {         nmask = mask;         for (int k = i; k < 30; k += i)           if (mask & 1 << k) nmask -= (1 << k);         if (gg.count(nmask))           used[gg[nmask]] = 1;         else {           gg[nmask] = grundy(nmask);           used[gg[nmask]] = 1;         }       }     }     for (int i = 0; i < 30; i++) {       if (!used[i]) return i;     }   }   int main() {     int n, c1, s, r, m;     cin >> n;     h[1] = 1;     s = n - (int)sqrt(n);     c1 = s;     for (int i = 2; i * i <= n; i++) {       if (!mark[i]) {         int j;         int p = n;         for (j = 0; p > 0; j++) {           p /= i;         }         h[i] = j - 1;       }       long long k = i * i;       while (k * k < n) {         mark[k] = 1;         k *= i;       }       c1 -= (h[i] + 1) / 2;     }     if (c1 % 2 == 0)       r = 0;     else       r = 1;     for (int i = 1; i * i <= n; i++)       if (!mark[i]) r ^= g[h[i]];     if (r == 0)       cout <<  Petya  << endl;     else       cout <<  Vasya  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5;   const long long inf = 199999999999999999;   const long long mod = 1e9 + 7;   void read() {     freopen( lifeguards.in ,  r , stdin);     freopen( lifeguards.out ,  w , stdout);   }   void solve() {     int coloured[N] = {}, pp[N] = {}, mx = 0, mx1 = 0, attribute = 0, cur = 0;     long long n;     cin >> n;     vector<long long> v(n);     for (auto &i : v) {       cin >> i;       if (i == cur) attribute = 1;       cur = i;     }     if (v[0] == v[n - 1]) attribute = 1;     if (is_sorted(v.begin(), v.end()) && v[0] == v[n - 1]) {       cout <<  1 n ;       for (int i = 0; i < n; ++i) {         cout <<  1  ;       }       return;     }     if (n & 1 ^ 1) {       cout <<  2 n ;       for (int i = 0; i < n; ++i) {         if (i & 1)           cout <<  1  ;         else           cout <<  2  ;       }       return;     } else {       if (attribute) {         cout <<  2 n ;         long long op = 1, borely = 1;         cur = 2;         for (int i = 0; i < n; ++i) {           if (v[i] == v[i - 1] && op) {             if (cur == 2)               cout <<  2  , cur = 2;             else               cout <<  1  , cur = 1;             op ^= 1;             continue;           }           if (cur == 2)             cout <<  1  , cur = 1;           else             cout <<  2  , cur = 2;         }       } else {         cout <<  3 n ;         for (int i = 0; i < n - 1; ++i) {           if (i & 1)             cout <<  1  ;           else             cout <<  2  ;         }         cout << 3;       }     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long T = 1;     cin >> T;     while (T--) {       solve();       cout <<   n ;     }     cerr <<   nTime elapsed:  << 1.0 * clock() / CLOCKS_PER_SEC <<   s. n ;   }
#include <bits/stdc++.h>   using namespace std;   int A[10], B[10];   bool Check(int j) {     memset(B, 0, sizeof(B));     while (j) {       B[j % 10]++;       j /= 10;     }     for (int i = 0; i <= 9; i++)       if (A[i] && B[i]) return true;     return false;   }   int main() {     int res = 0, x, _x;     cin >> x;     _x = x;     while (_x) {       A[_x % 10]++;       _x /= 10;     }     double s = sqrt(x);     for (int i = 1; i <= s; i++) {       if (x % i == 0) {         if (Check(i)) res++;         if (i * i != x && Check(x / i)) res++;       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9 + 5, NMAX = 2e5 + 5, MOD = 998244353, N = 1e9 + 5,                   LOG = 25;   const long double EPS = 1e-8, pi = 3.14159265358979323846;   vector<long long> res;   bool first(long long k, vector<long long> &v) {     long long index = k;     res.clear();     vector<long long> ost;     for (long long i = 0; i < k && index < v.size(); ++i, ++index) {       while (index < v.size() && v[index] <= v[i]) ost.push_back(v[index++]);       if (index == v.size()) return false;       res.push_back(v[index]);       res.push_back(v[i]);     }     while (index < v.size() && v[index] <= res.back()) ost.push_back(v[index++]);     if (index == v.size()) return false;     while (index < v.size()) res.push_back(v[index++]);     for (long long o : ost) res.push_back(o);     return true;   }   signed solve() {     long long n;     cin >> n;     vector<long long> v(n);     for (long long i = 0; i < n; ++i) cin >> v[i];     if (n < 3) {       cout <<  0 n ;       for (long long x : v) cout << x <<    ;       return 0;     }     sort(v.begin(), v.end());     long long l = 0, r = n - 2;     while (l + 1 < r) {       long long m = (l + r) / 2;       if (first(m, v)) {         l = m;       } else {         r = m - 1;       }     }     if (first(r, v)) {       cout << r <<   n ;       for (long long x : res) cout << x <<    ;     } else {       first(l, v);       cout << l <<   n ;       for (long long x : res) cout << x <<    ;     }   }   signed main() {     {       ios_base::sync_with_stdio(0);       cin.tie(0);       cout.tie(0);     }     long long t = 1;     while (t-- > 0) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, s, a, b, c, d, sum, ss;     cin >> n >> m >> s;     sum = 0;     for (a = 1; a <= n && a <= s; a += 2)       for (b = 1; b <= m && a * b <= s; b += 2) {         if (a * b == s) {           sum +=               (n - a + 1) * (m - b + 1) * (((a + 1) / 2) * ((b + 1) / 2) * 2 - 1);           continue;         }         ss = s - a * b;         for (c = 1; c <= n; c += 2) {           if (c < a) {             if (ss % c != 0) continue;             d = ss / c + b;             if (d > m || d % 2 != 1) continue;             sum += (n - a + 1) * (m - d + 1);           } else if (c > a) {             if (ss % (c - a) != 0) continue;             d = ss / (c - a);             if (d >= b || d % 2 != 1) continue;             sum += (n - c + 1) * (m - b + 1);           }         }       }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string s;   vector<int> v;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> s;     s =  *  + s;     for (int i = 1; i * i <= n; i++)       if (n % i == 0) {         v.push_back(i);         if (i != n / i) v.push_back(n / i);       }     sort(v.begin(), v.end());     for (int x : v) reverse(s.begin() + 1, s.begin() + 1 + x);     s.erase(0, 1);     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   bool used[123456];   bool cmp(const vector<int>& a, const vector<int>& b) {     return a.size() < b.size();   }   int main() {     int n;     cin >> n;     vector<int> p(n + 1);     for (int i = 1; i <= n; ++i) cin >> p[i];     vector<vector<int> > circle;     for (int i = 1; i <= n; ++i) {       if (!used[i]) {         used[i] = 1;         int curi = i;         circle.push_back(vector<int>(1, i));         while (!used[p[curi]]) {           curi = p[curi];           circle.back().push_back(curi);           used[curi] = true;         }       }     }     bool ok = false;     for (int i = 0; i < circle.size(); ++i)       ok |= (circle[i].size() == 2 || circle[i].size() == 1);     if (!ok) {       cout <<  NO ;       return 0;     }     sort(circle.begin(), circle.end(), cmp);     if (circle[0].size() == 1) {       cout <<  YES n ;       for (int i = 1; i < circle.size(); ++i)         for (int j = 0; j < circle[i].size(); ++j)           cout << circle[0][0] <<     << circle[i][j] <<   n ;       return 0;     }     for (int i = 0; i < circle.size(); ++i) {       if (circle[i].size() % 2 != 0) {         cout <<  NO ;         return 0;       }     }     cout <<  YES n ;     cout << circle[0][1] <<     << circle[0][0] <<   n ;     for (int i = 1; i < circle.size(); ++i)       for (int j = 0; j < circle[i].size(); ++j)         cout << circle[0][j % 2] <<     << circle[i][j] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   using Vi = vector<int>;   using i64 = long long;   using ll = long long;   using Pi = pair<int, int>;   mt19937 mrand(time(0));   int rnd(int x) { return mrand() % x; }   const int N = 500005;   const int M = 40005;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       Vi a(n);       for (int i = 0; i < n; ++i) cin >> a[i];       int TOP = 30;       Vi bit(TOP);       for (int i = 0; i < n; ++i)         for (int j = 0; j < TOP; ++j)           if (a[i] >> j & 1) ++bit[j];       Vi ans(n + 1);       for (int i = 0; i < TOP; ++i)         for (int j = 1; j < n + 1; ++j)           if (bit[i] % j == 0) ++ans[j];       for (int i = 1; i < n + 1; ++i)         if (ans[i] == TOP) cout << i <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   static const int INF = 0x3f3f3f3f;   static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;   static const long double epsilon = 1e-15;   static const long double pi = acos((long double)-1);   using namespace std;   inline void init_io() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   const int MAX_N = 100001;   int arr[2 * MAX_N];   void rarr(int n) {     for (int(i) = (0); (i) < (n); i++) cin >> arr[i];   }   int main() {     init_io();     int t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       long long ans = 0;       while (n) {         if (n % k) {           ans += n % k;           n = n - n % k;         } else {           ans++;           n /= k;         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 10;   pair<long long, long long> p[maxn];   long long ans[maxn];   int main() {     int n, num = 0, cnt = 0;     long long l, r;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %lld%lld , &l, &r);       p[++num].first = l;       p[num].second = 1;       p[++num].first = r + 1;       p[num].second = -1;     }     sort(p + 1, p + 1 + num);     for (int i = 1; i <= num; i++) {       ans[cnt] += p[i].first - p[i - 1].first;       cnt += p[i].second;     }     for (int i = 1; i <= n; i++) printf( %lld%c , ans[i], i == n ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, f, vis[101][101][101];   char a[1001][1001];   int valid(int x, int y) { return (x >= 1 && x <= n && y >= 1 && y <= m); }   int occupies(int x, int y, int turn) {     y = y + (turn - 1) * 2;     if (valid(x, y) && a[x][y] >=  A  && a[x][y] <=  Z ) return 1;     return 0;   }   void dfs(int curx, int cury, int turn) {     if (cury == m) {       f = 1;       return;     }     if (vis[curx][cury][turn]) return;     if (occupies(curx, cury, turn)) return;     vis[curx][cury][turn] = 1;     if (!occupies(curx, cury + 1, turn)) {       if (valid(curx, cury + 1) && !occupies(curx, cury + 1, turn))         dfs(curx, cury + 1, turn + 1);       if (valid(curx - 1, cury + 1) && !occupies(curx - 1, cury + 1, turn))         dfs(curx - 1, cury + 1, turn + 1);       if (valid(curx + 1, cury + 1) && !occupies(curx + 1, cury + 1, turn))         dfs(curx + 1, cury + 1, turn + 1);     }   }   int main() {     ios::sync_with_stdio(false);     ;     cin.tie(0);     ;     int i, j, t, sx, sy, temp;     string st;     cin >> t;     while (t--) {       memset(vis, 0, sizeof vis);       cin >> m >> temp;       n = 3;       for (i = 1; i <= n; i++) {         cin >> st;         st =     + st;         for (j = 1; j <= m; j++) {           a[i][j] = st[j];           if (a[i][j] ==  s ) {             sx = i;             sy = j;           }         }       }       f = 0;       dfs(sx, sy, 1);       if (f)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }