malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool check(int x, pair<int, int> a) { return a.first <= x && x <= a.second; }   signed main() {     int n;     scanf( %d , &n);     vector<pair<int, pair<int, int>>> vert;     vector<pair<int, pair<int, int>>> hor;     while (n--) {       int x1, y1, x2, y2;       scanf( %d%d%d%d , &x1, &y1, &x2, &y2);       if (x1 > x2) swap(x1, x2);       if (y1 > y2) swap(y1, y2);       if (x1 == x2) {         vert.push_back({x1, {y1, y2}});       } else {         hor.push_back({y1, {x1, x2}});       }     }     if (signed(hor.size()) < signed(vert.size())) swap(hor, vert);     vector<bitset<5000>> inter(signed(vert.size()));     for (int i = 0; i < signed(vert.size()); ++i)       for (int j = 0; j < signed(hor.size()); ++j)         inter[i][j] = check(hor[j].first, vert[i].second) &&                       check(vert[i].first, hor[j].second);     long long ans = 0;     for (int i = 0; i < signed(vert.size()); ++i)       for (int j = i + 1; j < signed(vert.size()); ++j) {         int cnt = (inter[i] & inter[j]).count();         ans += cnt * (cnt - 1) / 2;       }     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int f(long long int a, long long int b) {     long long int z = b, x = 0;     while (z > 1) {       z /= 2;       x++;     }     long long int y = pow(2, x);     if (a == b)       return a;     else if (y <= a)       return f(a - y, b - y) + y;     else if (pow(2, x + 1) - 1 <= b)       return pow(2, x + 1) - 1;     else       return y - 1;   }   int main() {     long long int i, n, a, b;     cin >> n;     while (n--) {       cin >> a >> b;       long long int x = f(a, b);       cout << x << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, a, cnt = 0, tmp;     scanf( %lld%lld%lld , &n, &m, &a);     cnt = (m / a) * (n / a);     if (n % a != 0) cnt += (m / a);     if (m % a != 0) cnt += (n / a);     if (m % a != 0 && n % a != 0) cnt += 1;     printf( %lld n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int number[120], prime[120], primecounter = 0;   void sieve() {     for (int i = 0; i <= 100; i++) number[i] = 1;     number[0] = 0;     number[1] = 0;     for (int i = 4; i <= 100; i = i + 2) number[i] = 0;     for (int i = 3; i * i <= 100; i = i + 2) {       for (int j = 2 * i; j <= 100; j = j + i) {         if (number[j] == 1) number[j] = 0;       }     }     for (int i = 2; i <= 100; i = i + 1) {       if (number[i] == 1) {         primecounter++;         prime[primecounter] = i;       }     }   }   int main(void) {     sieve();     char line[50];     int save[100 + 20];     int yes = 0, no = 0, s;     for (int i = 1; prime[i] <= 53; i++) {       printf( %d n , prime[i]);       fflush(stdout);       scanf( %s , line);       if (strcmp( yes , line) == 0) {         yes++;         s = prime[i];       } else         no++;     }     if (yes == 0) {       printf( prime n );       fflush(stdout);       return 0;     } else if (yes > 1) {       printf( composite n );       fflush(stdout);       return 0;     } else if (yes == 1) {       int v = s * s;       if (v <= 100) {         printf( %d n , v);         fflush(stdout);         scanf( %s , line);         if (strcmp( yes , line) == 0) {           printf( composite n );           fflush(stdout);           return 0;         } else {           printf( prime n );           fflush(stdout);           return 0;         }       } else {         printf( prime n );         fflush(stdout);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<char, int> > vec(100);   int n;   bool check(vector<bool> &bitmask) {     bool flag = 1;     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         if (vec[i].first == vec[j].first) {           if (vec[i].second != vec[j].second) {             if (bitmask[vec[i].second - 1] == 1 ||                 bitmask[vec[j].second - 1] == 1) {               continue;             } else {               flag = 0;               return flag;             }           } else {             continue;           }         } else {           if (vec[i].second == vec[j].second) {             if ((vec[i].first ==  R  || vec[j].first ==  R ) && bitmask[5] == 1) {               continue;             } else if ((vec[i].first ==  G  || vec[j].first ==  G ) &&                        bitmask[6] == 1) {               continue;             } else if ((vec[i].first ==  B  || vec[j].first ==  B ) &&                        bitmask[7] == 1) {               continue;             } else if ((vec[i].first ==  Y  || vec[j].first ==  Y ) &&                        bitmask[8] == 1) {               continue;             } else if ((vec[i].first ==  W  || vec[j].first ==  W ) &&                        bitmask[9] == 1) {               continue;             } else {               flag = 0;               return flag;             }           } else {             if ((vec[i].first ==  R  || vec[j].first ==  R ) && bitmask[5] == 1) {               continue;             } else if ((vec[i].first ==  G  || vec[j].first ==  G ) &&                        bitmask[6] == 1) {               continue;             } else if ((vec[i].first ==  B  || vec[j].first ==  B ) &&                        bitmask[7] == 1) {               continue;             } else if ((vec[i].first ==  Y  || vec[j].first ==  Y ) &&                        bitmask[8] == 1) {               continue;             } else if ((vec[i].first ==  W  || vec[j].first ==  W ) &&                        bitmask[9] == 1) {               continue;             } else if (bitmask[vec[i].second - 1] == 1 ||                        bitmask[vec[j].second - 1] == 1) {               continue;             } else {               flag = 0;               return flag;             }           }         }       }     }     return flag;   }   int solve() {     vector<bool> counter(10, 0);     int ans = 100;     while (1) {       if (check(counter)) {         int cnt = 0;         for (int i = 0; i < 10; i++) {           if (counter[i] == 1) {             cnt++;           }         }         ans = min(ans, cnt);       }       int i = 0;       while (i < 10 && counter[i] == 1) counter[i++] = 0;       if (i == 10) break;       counter[i] = 1;     }     return ans;   }   int main() {     int t = 1;     while (t--) {       cin >> n;       for (int i = 0; i < n; i++) {         cin >> vec[i].first >> vec[i].second;       }       int ans = solve();       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 300000;   int n, m, q, p[MAXN + 3], rk[MAXN + 3], dia[MAXN + 3], type, x, y,       dist[MAXN + 3];   bool flag[MAXN + 3];   vector<int> adj[MAXN + 3];   int ceil(int n) {     if (!n) return 0;     return (n - 1) / 2 + 1;   }   int find(int x) { return (p[x] == x ? x : (p[x] = find(p[x]))); }   void join(int x, int y) {     x = find(x);     y = find(y);     if (x == y) return;     if (rk[x] < rk[y]) swap(x, y);     rk[x] += rk[y];     p[y] = x;   }   void join2(int x, int y) {     x = find(x);     y = find(y);     if (x == y) return;     if (rk[x] < rk[y]) swap(x, y);     dia[x] = max(max(dia[x], dia[y]), ceil(dia[x]) + ceil(dia[y]) + 1);     rk[x] += rk[y];     p[y] = x;   }   int calDia(int p) {     queue<int> q;     q.push(p);     flag[p] = true;     dist[p] = 0;     int u, v;     while (!q.empty()) {       u = q.front();       q.pop();       for (int i = 0; i < (int)adj[u].size(); ++i) {         v = adj[u][i];         if (!flag[v]) {           flag[v] = true;           dist[v] = dist[u] + 1;           q.push(v);         }       }     }     q.push(u);     flag[u] = false;     dist[u] = 0;     while (!q.empty()) {       u = q.front();       q.pop();       for (int i = 0; i < (int)adj[u].size(); ++i) {         v = adj[u][i];         if (flag[v]) {           flag[v] = false;           dist[v] = dist[u] + 1;           q.push(v);         }       }     }     return dist[u];   }   int main() {     scanf( %d %d %d , &n, &m, &q);     for (int i = 1; i <= n; ++i) p[i] = i, rk[i] = 1;     for (int i = 1; i <= m; ++i) {       scanf( %d %d , &x, &y);       join(x, y);       adj[x].push_back(y);       adj[y].push_back(x);     }     for (int i = 1; i <= n; ++i)       if (find(i) == i) {         dia[i] = calDia(i);       }     while (q-- > 0) {       scanf( %d %d , &type, &x);       if (type == 1) {         printf( %d n , dia[find(x)]);       } else {         scanf( %d , &y);         join2(x, y);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   ostream &operator<<(ostream &os, const vector<T> &v) {     for (T i : v) os << i <<  ,  ;     return os;   }   template <class T>   ostream &operator<<(ostream &os, const set<T> &v) {     for (T i : v) os << i <<    ;     return os;   }   template <class T>   ostream &operator<<(ostream &os, const multiset<T> &v) {     for (T i : v) os << i <<    ;     return os;   }   template <class T, class second>   ostream &operator<<(ostream &os, const pair<T, second> &v) {     os << v.first <<     << v.second;     return os;   }   template <class T, class second>   ostream &operator<<(ostream &os, const map<T, second> &v) {     for (auto i : v) os <<  (  << i.first <<   =>   << i.second <<  )  <<    ;     return os;   }   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   int n, k;   long long x;   vector<long long> v;   void solve() {     int zero = 0, pos = 0, neg = 0;     for (long long &i : v) {       if (i == 0)         zero++;       else if (i > 0)         pos++;       else         neg++;     }     if (zero > k) {       for (long long &i : v) cout << i <<    ;       cout <<   n ;       return;     }     if (zero) {       if (neg % 2 == 1) {         for (long long &i : v)           if (i == 0 && k > 0) i += x, k--;       } else {         bool f = 0;         for (long long &i : v) {           if (i == 0 && k > 0) {             if (f == 0)               i -= x;             else               i += x;             f = 1;             k--;           }         }       }     }     int f = 0;     for (long long &i : v)       if (i < 0) f ^= 1;     if (f == 0) {       int idx = 0;       for (int i = 0; i < n; i++) {         if (abs(v[i]) < abs(v[idx])) idx = i;       }       if (v[idx] < 0) {         while (v[idx] <= 0 && k > 0) {           v[idx] += x;           k--;         }       } else {         while (v[idx] >= 0 && k > 0) {           v[idx] -= x;           k--;         }       }     }     set<pair<long long, int>> s;     for (int i = 0; i < n; i++) {       s.insert({abs(v[i]), i});     }     while (k > 0) {       auto it = *s.begin();       s.erase(s.begin());       if (v[it.second] < 0)         v[it.second] -= x;       else         v[it.second] += x;       s.insert({abs(v[it.second]), it.second});       k--;     }     for (long long &i : v) cout << i <<    ;     cout <<   n ;   }   int main() {     fast();     cin >> n >> k >> x;     for (int i = 0; i < n; i++) {       long long a;       cin >> a;       v.push_back(a);     }     solve();   }
#include <bits/stdc++.h>   using namespace std;   struct BookInfo {     int t;     int a;     int b;     int i;   };   struct CombinedBook {     int t;     BookInfo b1;     BookInfo b2;     bool isCombined;   };   int main() {     ios_base::sync_with_stdio(0);     cout << fixed << setprecision(10);     cerr << fixed << setprecision(10);     cin.tie(0);     int n, k;     cin >> n >> k;     vector<BookInfo> allBooks;     int aliceLikes = 0;     int bobLikes = 0;     for (int i = 0; i < n; i++) {       BookInfo info;       cin >> info.t >> info.a >> info.b;       info.i = i + 1;       if (info.a) {         aliceLikes++;       }       if (info.b) {         bobLikes++;       }       allBooks.push_back(info);     }     if (aliceLikes < k || bobLikes < k) {       cout << -1 << endl;       return 0;     }     sort(allBooks.begin(), allBooks.end(),          [](const BookInfo &a, const BookInfo &b) -> bool { return a.t < b.t; });     vector<BookInfo> aliceBooks;     vector<BookInfo> bobBooks;     vector<CombinedBook> combined;     vector<BookInfo> other;     for (BookInfo &book : allBooks) {       if (book.a && book.b) {         CombinedBook item;         item.t = book.t;         item.b1 = book;         item.b2 = book;         item.isCombined = false;         combined.push_back(item);       } else if (!book.a && !book.b) {         other.push_back(book);       } else if (book.a) {         aliceBooks.push_back(book);       } else if (book.b) {         bobBooks.push_back(book);       }     }     for (int i = 0; i < n; i++) {       if (i < aliceBooks.size() && i < bobBooks.size()) {         CombinedBook item;         item.isCombined = true;         item.b1 = aliceBooks[i];         item.b2 = bobBooks[i];         item.t = item.b1.t + item.b2.t;         combined.push_back(item);       } else if (i < aliceBooks.size()) {         other.push_back(aliceBooks[i]);       } else if (i < bobBooks.size()) {         other.push_back(bobBooks[i]);       }     }     if (combined.size() < k) {       cout << -1 << endl;       return 0;     }     sort(combined.begin(), combined.end(),          [](const CombinedBook &a, const CombinedBook &b) -> bool {            return a.t < b.t;          });     vector<int> result;     int sum = 0;     int leftLikes = k;     for (int i = 0; i < k; i++) {       sum += combined[i].t;     }     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   const signed int inf = (signed)((1u << 31) - 1);   const signed long long llf = (signed long long)((1ull << 61) - 1);   const double eps = 1e-6;   const int binary_limit = 128;   template <typename T>   inline bool readInteger(T& u) {     char x;     int aFlag = 1;     while (!isdigit((x = getchar())) && x !=  -  && x != -1)       ;     if (x == -1) {       ungetc(x, stdin);       return false;     }     if (x ==  - ) {       x = getchar();       aFlag = -1;     }     for (u = x -  0 ; isdigit((x = getchar())); u = (u << 1) + (u << 3) + x -  0 )       ;     ungetc(x, stdin);     u *= aFlag;     return true;   }   int n;   char a[1005];   char b[1005];   map<char, char> ctc;   const char utl =  a  -  A ;   inline void init() {     gets(a);     gets(b);     for (int i = 0; a[i]; i++) {       ctc[a[i]] = b[i];       ctc[a[i] - utl] = b[i] - utl;     }   }   inline void solve() {     gets(a);     for (int i = 0; a[i]; i++) {       if ((a[i] >=  a  && a[i] <=  z ) || (a[i] >=  A  && a[i] <=  Z )) {         putchar(ctc[a[i]]);       } else {         putchar(a[i]);       }     }   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     int i;     scanf( %d , &n);     if (n == 2) {       printf( -1 n );       return 0;     } else {       printf( 6 n10 n15 n );       for (i = 0; i < n - 3; i++) printf( %d n , 15 * (i + 2));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void input(vector<long long>& v, long n) {     for (long long i = 0; i < n; i++) {       long long in;       cin >> in;       v.push_back(in);     }   }   void output(vector<long long> v) {     for (long long i = 0; i < v.size(); i++) cout << v[i] <<    ;   }   long long max_of_three(long long a, long long b, long long c) {     if (a >= b && a >= c)       return a;     else if (b >= a && b >= c)       return b;     else       return c;   }   long long max_of_4(long long a, long long b, long long c, long long d) {     if (a >= b && a >= c && a >= d)       return a;     else if (b >= a && b >= c && b >= d)       return b;     else if (c >= a && c >= d && c >= b)       return c;     else       return d;   }   map<long long, long long> frequency(vector<long long> v) {     map<long long, long long> m;     for (long long i = 0; i < v.size(); i++) {       if (m.find(v[i]) != m.end())         m[v[i]]++;       else {         m.insert({v[i], 1});       }     }     return m;   }   long long max_occuring_int(std::map<long long, long long> m) {     long long max_x = 0;     long long i = 0, n = m.size();     std::map<long long, long long>::iterator it = m.begin();     for (i = 0; i < n; i++) {       if (it->second > max_x) max_x = it->second;       it++;     }     return max_x;   }   vector<long long> give_unique_in_vector(vector<long long> v) {     sort((v).begin(), (v).end());     auto it = unique((v).begin(), (v).end());     v.resize(std::distance(v.begin(), it));     vector<long long> x = v;     return x;   }   bool isVowel(char c) {     return (c ==  a  | c ==  e  || c ==  i  || c ==  o  || c ==  u  || c ==  y  ||             c ==  A  || c ==  E  || c ==  I  || c ==  O  || c ==  U  || c ==  Y );   }   string removeWord(string str, string word) {     if (str.find(word) != string::npos) {       size_t p = -1;       string tempWord = word +    ;       while ((p = str.find(word)) != string::npos)         str.replace(p, tempWord.length(),   );       tempWord =     + word;       while ((p = str.find(word)) != string::npos)         str.replace(p, tempWord.length(),   );     }     return str;   }   long long calc(long long i, long long j, long long n) {     return (i + 1 - 1) * n + j + 1;   }   bool compare_descending(long long a, long long b) { return a > b; }   void solve() {     int n, k, i;     string s;     cin >> n >> k >> s;     if (n - k < k - 1) {       for (i = k - 1; i < n - 1; i++) cout <<  RIGHT n ;       for (i; i >= 0; i--) {         cout <<  PRINT   << s[i] << endl;         if (i != 0) cout <<  LEFT n ;       }     } else {       for (i = k - 1; i > 0; i--) cout <<  LEFT n ;       for (i; i < n; i++) {         cout <<  PRINT   << s[i] << endl;         if (i != n - 1) cout <<  RIGHT n ;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5;   const long long INF = 1e10;   const int MOD = 1e9 + 7;   const double EPS = 1e-7;   const double PI = acos(-1.0);   pair<long long, long long> p[N];   long long n, k, a[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL), cout.tie(NULL);     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> a[i];       p[i] = {a[i], i};     }     sort(p, p + n);     long long ans = LLONG_MIN;     for (int l = 0; l < n; l++) {       for (int r = l; r < n; r++) {         long long sum = 0;         vector<long long> subarr(r - l + 1);         for (int i = l, j = 0; i <= r; i++, j++) {           subarr[j] = a[i];           sum += a[i];         }         sort(subarr.begin(), subarr.end());         for (int i = 0, j = n - 1; i < min(k, r - l + 1ll); i++) {           while (j >= 0 && p[j].second <= r && p[j].second >= l) {             j--;           }           if (j >= 0) {             sum = max(sum, sum - subarr[i] + p[j].first);             j--;           }         }         ans = max(ans, sum);       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200200;   struct BIT {     int a[N];     void add(int x, int v = 1) {       for (; x < N; x += x & -x) {         a[x] += v;       }     }     int kth(int k) {       int x = 0;       for (int i = 18; i >= 0; i--) {         if (x + (1 << i) < N) {           int tot = a[x + (1 << i)];           if (k > tot) {             k -= tot;             x += (1 << i);           }         }       }       return x + 1;     }   };   BIT tr;   pair<int, int> p[N];   pair<pair<int, int>, int> q[N];   int a[N];   int ans[N];   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       p[i].first = -a[i];       p[i].second = i;     }     sort(p, p + n);     int m;     cin >> m;     for (int i = 0; i < m; i++) {       cin >> q[i].first.first >> q[i].first.second;       q[i].second = i;     }     sort(q, q + m);     int x = 0;     for (int i = 0; i < n; i++) {       tr.add(p[i].second + 1);       while (x < m && q[x].first.first == i + 1) {         ans[q[x].second] = a[tr.kth(q[x].first.second) - 1];         x++;       }     }     for (int i = 0; i < m; i++) {       printf( %d n , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<  :  << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<  :  << arg1 <<   | ;     __f(comma + 1, args...);   }   void Ishan_Pandey() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(0);     cout << setprecision(16) << fixed;   }   const long long int N = 200010;   long long int parent[N], rank1[N];   void make_set(long long int v) {     parent[v] = v;     rank1[v] = 0;   }   long long int find_set(long long int v) {     if (v == parent[v]) return v;     return parent[v] = find_set(parent[v]);   }   void union_sets(long long int a, long long int b) {     a = find_set(a);     b = find_set(b);     if (a != b) {       if (rank1[a] < rank1[b]) swap(a, b);       parent[b] = a;       if (rank1[a] == rank1[b]) rank1[a]++;     }   }   void solve() {     long long int n;     cin >> n;     vector<long long int> a(n + 2, 0);     for (long long int i = 1; i <= n; i++) {       cin >> a[i];     }     long long int ans = 0;     for (long long int i = 1; i <= n; i++) a[i] = min(a[i], a[i - 1] + 1);     for (long long int i = n; i >= 1; i--) a[i] = min(a[i], a[i + 1] + 1);     for (long long int i = 1; i <= n; i++) ans = max(ans, a[i]);     cout << ans;   }   int32_t main() {     Ishan_Pandey();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mostFrequent(int arr[], int n) {     sort(arr, arr + n);     int max_count = 1, res = arr[0], curr_count = 1;     for (int i = 1; i < n; i++) {       if (arr[i] == arr[i - 1])         curr_count++;       else {         if (curr_count > max_count) {           max_count = curr_count;           res = arr[i - 1];         }         curr_count = 1;       }     }     if (curr_count > max_count) {       max_count = curr_count;       res = arr[n - 1];     }     return res;   }   unsigned int countDivisors(unsigned int n) {     int cnt = 0;     for (int i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         if (n / i == i)           cnt++;         else           cnt = cnt + 2;       }     }     return cnt;   }   int main() {     int n, a;     long long int back = 0, biceps = 0, chest = 0;     cin >> n;     for (int i = 1; i <= (n); ++i) {       cin >> a;       if (i % 3 == 0) {         back += a;       } else if (i % 3 == 1) {         chest += a;       } else if (i % 3 == 2) {         biceps += a;       }     }     long long int maxi = max(back, max(biceps, chest));     if (maxi == back)       cout <<  back ;     else if (maxi == biceps)       cout <<  biceps ;     else if (maxi == chest)       cout <<  chest ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   const int N = 100005;   int n, x, y, a, b, jc[N], ans;   char s[2];   int ksm(int a, int k) {     int ret = 1;     while (k) {       if (k & 1) ret = 1ll * ret * a % mod;       a = 1ll * a * a % mod;       k >>= 1;     }     return ret;   }   int C(int n, int m) {     return 1ll * jc[n] * ksm(1ll * jc[n - m] * jc[m] % mod, mod - 2) % mod;   }   int main() {     scanf( %d , &n);     jc[0] = 1;     int res = 1, fl1 = 1, fl2 = 1;     for (int i = 1; i < N; ++i) jc[i] = 1ll * jc[i - 1] * i % mod;     for (int i = 1; i <= n; ++i) {       scanf( %s , s);       if (s[0] ==  W ) ++x;       if (s[0] ==  ? ) ++y;       if (s[1] ==  B ) ++a;       if (s[1] ==  ? ) ++b;       if (s[0] ==  ?  && s[1] ==  ? )         res = (res * 2) % mod;       else if (s[0] == s[1])         res = 0;       if (s[0] ==  W  || s[1] ==  B ) fl1 = 0;       if (s[1] ==  W  || s[0] ==  B ) fl2 = 0;     }     res -= fl1;     res -= fl2;     for (int i = max(a, x); i <= min(x + y, a + b); ++i)       (ans += 1ll * C(y, i - x) * C(b, i - a) % mod) %= mod;     printf( %d , ans - res);     return 0;   }