malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long int m, n, f, h[200000], fakt[200000] = {1};   vector<int> v[200000];   long long int fe(long long int m, long long int n) {     if (!n) return 1;     long long int t = fe(m, n / 2);     t = t * t % 1000000007LL;     if (n & 1) t = t * m % 1000000007LL;     return t;   }   long long int comb(long long int m, long long int n) {     return fakt[m] * fe(fakt[n], 1000000007LL - 2) % 1000000007LL *            fe(fakt[m - n], 1000000007LL - 2) % 1000000007LL;   }   long long int find(long long int n) { return comb(n - 1, f - 1); }   long long int rec(int ind, long long int carp, int s) {     if (n / carp < f) return 0;     if (ind == v[n].size()) {       if (s & 1)         return (-find(n / carp) + 1000000007LL) % 1000000007LL;       else         return find(n / carp);     }     return (rec(ind + 1, carp, s) + rec(ind + 1, carp * v[n][ind], s + 1)) %            1000000007LL;   }   int main() {     ios_base::sync_with_stdio(false);     for (int i = 2; i <= 100005; i++)       if (!h[i]) {         for (int j = 2 * i; j <= 100005; j += i) {           v[j].push_back(i);           h[j] = 1;         }       }     for (int i = 1; i <= 100005; i++) fakt[i] = fakt[i - 1] * i % 1000000007LL;     cin >> m;     while (m--) {       cin >> n >> f;       if (f == 1 and n != 1)         cout << 0 << endl;       else if (f == 1)         cout << 1 << endl;       else         cout << rec(0, 1, 0) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long T;     cin >> T;     while (T--) {       long long n, a[100005];       cin >> n;       for (long long i = 1; i <= n; i++) {         cin >> a[i];       }       long long ans = 0;       for (long long i = 1; i < n; i++) {         long long t = a[i] * a[i + 1];         ans = max(ans, t);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Nx = 200005;   int ct[Nx], MMsize, A, B, tree[Nx * 4];   map<int, int> MM;   vector<int> pos[Nx];   int query(int a, int b, int key) {     if (A <= a && b <= B) return tree[key];     if (B < a || b < A) return 0;     int m = (a + b) / 2;     return query(a, m, key * 2) + query(m + 1, b, key * 2 + 1);   }   void insert(int a, int b, int key) {     if (A < a || A > b) return;     tree[key]++;     if (a == b) return;     int m = (a + b) / 2;     insert(a, m, key * 2);     insert(m + 1, b, key * 2 + 1);   }   int main() {     int N;     scanf( %d , &N);     for (int i = 1, v, p; i <= N; i++) {       scanf( %d , &v);       if ((p = MM[v]) == 0) p = MM[v] = ++MMsize;       pos[p].push_back(i);     }     for (map<int, int>::iterator i = MM.begin(); i != MM.end(); i++) {       int p = i->second;       for (vector<int>::iterator j = pos[p].begin(); j != pos[p].end(); j++) {         int v = *j;         for (int k = 1; k < N; k++) {           if ((k * (v - 1) + 2) > N) break;           A = k * (v - 1) + 2;           B = min(N, k * v + 1);           ct[k] += query(1, N, 1);         }       }       for (vector<int>::iterator j = pos[p].begin(); j != pos[p].end(); j++) {         A = *j;         insert(1, N, 1);       }     }     for (int i = 1; i < N; i++) {       printf( %d , ct[i]);       if (i == (N - 1))         putchar(  n );       else         putchar(32);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   vector<int> adj[100002], f, radj[100002];   queue<int> Q1, Q2;   vector<int> vis;   int main(int argc, char **argv) {     cin >> N >> M;     f = vector<int>(N);     for (int i = (0); i < (N); ++i) cin >> f[i];     for (int i = (0); i < (M); ++i) {       int first, second;       cin >> first >> second;       --first, --second;       adj[first].push_back(second);       radj[second].push_back(first);     }     vis = vector<int>(N);     for (int i = (0); i < (N); ++i)       if (f[i] == 1)         Q1.push(i), vis[i] |= 1;       else if (f[i] == 2)         Q2.push(i), vis[i] |= 2;     while (!Q1.empty()) {       int u = Q1.front();       Q1.pop();       for (int i = (0); i < (adj[u].size()); ++i)         if (!(vis[adj[u][i]] & 1) && f[adj[u][i]] != 1) {           vis[adj[u][i]] |= 1;           Q1.push(adj[u][i]);         }     }     while (!Q2.empty()) {       int u = Q2.front();       Q2.pop();       for (int i = (0); i < (radj[u].size()); ++i)         if (!(vis[radj[u][i]] >> 1)) {           vis[radj[u][i]] |= 2;           if (f[radj[u][i]] != 1) Q2.push(radj[u][i]);         }     }     for (int i = (0); i < (N); ++i) printf( %d n , vis[i] == 3);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s;     cin >> s1 >> s;     int a[10] = {0}, b[10] = {0};     for (int i = 0; i < s1.size(); i++) {       int m = s1[i] -  0 ;       if (m == 5 || m == 2)         a[2]++;       else if (m == 6 || m == 9)         a[6]++;       else         a[m]++;     }     for (int i = 0; i < s.size(); i++) {       int m = s[i] -  0 ;       if (m == 5 || m == 2)         b[2]++;       else if (m == 6 || m == 9)         b[6]++;       else         b[m]++;     }     int ans = 1000;     for (int i = 0; i < 10; i++) {       if (a[i]) {         int k = b[i] / a[i];         if (ans > k) ans = k;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> disTime, finTime, depth, a;   vector<vector<int> > graph;   int n, maxSize, tr0[200005], tr1[200005];   vector<bool> vis;   int tim;   void update(int in, int val, int* tr) {     while (in <= maxSize) {       tr[in] += val;       in += (in & (-in));     }   }   int getSum(int in, int* tr) {     int sum = 0;     while (in) {       sum += tr[in];       in -= (in & (-in));     }     return sum;   }   void dfs(int idx, int d) {     vis[idx] = true;     depth[idx] = d;     disTime[idx] = tim++;     for (auto ch : graph[idx]) {       if (vis[ch]) continue;       dfs(ch, d + 1);     }     finTime[idx] = tim;   }   int main() {     int m, u, v, x;     cin >> n >> m;     a.resize(n);     graph.resize(n);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n - 1; i++) {       scanf( %d %d , &u, &v);       graph[u - 1].push_back(v - 1);       graph[v - 1].push_back(u - 1);     }     disTime.resize(n);     finTime.resize(n);     depth.resize(n);     vis.resize(n);     tim = 1;     for (int i = 0; i < n; i++) vis[i] = false;     dfs(0, 0);     maxSize = tim;     for (int i = 0; i < maxSize + 1; i++) tr1[i] = tr0[i] = 0;     for (int i = 0; i < m; i++) {       scanf( %d , &x);       switch (x) {         case 1:           scanf( %d %d , &u, &v);           if (depth[u - 1] % 2) {             update(disTime[u - 1], v, tr1);             update(finTime[u - 1], -v, tr1);             update(disTime[u - 1], -v, tr0);             update(finTime[u - 1], v, tr0);           } else {             update(disTime[u - 1], v, tr0);             update(finTime[u - 1], -v, tr0);             update(disTime[u - 1], -v, tr1);             update(finTime[u - 1], v, tr1);           }           break;         case 2:           scanf( %d , &u);           if (depth[u - 1] % 2)             printf( %d n , (a[u - 1] + getSum(disTime[u - 1], tr1)));           else             printf( %d n , (a[u - 1] + getSum(disTime[u - 1], tr0)));           break;       }     }     disTime.clear();     finTime.clear();     depth.clear();     vis.clear();     graph.clear();     a.clear();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 2010;   int A[M][M];   int col[M];   int diag[M];   int main() {     ios_base::sync_with_stdio(false);     int i, j, k, n;     char str[M];     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %s , str);       for (j = 0; j < n; j++) A[i][j] = str[j] -  0 ;     }     int sum = 0;     for (i = n - 1; i > 0; i--) {       int inv = 0;       for (j = 0; j < i; j++) {         if (A[i][j] != (inv ^ col[j])) {           inv ^= 1;           sum++;           diag[i] ^= 1;           diag[j] ^= 1;           col[j] ^= 1;         }       }     }     memset((col), (0), sizeof(col));     for (i = 0; i < n - 1; i++) {       int inv = 0;       for (j = n - 1; j > i; j--) {         if (A[i][j] != (inv ^ col[j])) {           inv ^= 1;           sum++;           diag[i] ^= 1;           diag[j] ^= 1;           col[j] ^= 1;         }       }     }     for (i = 0; i < n; i++)       if (A[i][i] != diag[i]) sum++;     printf( %d n , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mo = 998244853;   const long long INF = 0x3f3f3f3f;   template <typename _T>   void read(_T &x) {     _T f = 1;     x = 0;     char s = getchar();     while (s >  9  || s <  0 ) {       if (s ==  - ) f = -1;       s = getchar();     }     while (s >=  0  && s <=  9 ) {       x = (x << 3) + (x << 1) + (s ^ 48);       s = getchar();     }     x *= f;   }   long long n, m, fac[4005], inv[4005], f[4005], ans, g[4005];   void init() {     fac[0] = inv[0] = fac[1] = inv[1] = f[1] = 1;     for (long long i = 2; i <= 4e3; i++) {       fac[i] = 1ll * fac[i - 1] * i % mo;       f[i] = 1ll * (mo - mo / i) * f[mo % i] % mo;       inv[i] = 1ll * inv[i - 1] * f[i] % mo;     }   }   long long C(long long x, long long y) {     if (x < 0 || y < 0 || x < y) return 0;     return 1ll * fac[x] * inv[y] % mo * inv[x - y] % mo;   }   signed main() {     init();     read(n);     read(m);     long long d = n - m < 0 ? 0 : n - m;     for (long long i = d; i <= n; i++) g[i] = C(n + m, n - m >= i ? n : n - i);     for (long long i = d; i <= n; i++)       (ans += i * (g[i] - g[i + 1] + mo) % mo) %= mo;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 21;   int n, m, k;   int ls;   bool vis[N];   vector<pair<int, int> > e[N];   void dfs(int u, int sum, int x) {     if (u > n) {       ls++;       return;     }     if (ls >= k) {       return;     }     dfs(u + 1, sum, x);     for (int i = 0; i < (int)e[u].size(); ++i) {       int w = e[u][i].first, v = e[u][i].second;       if (sum + w <= x && !vis[v]) {         vis[v] = 1;         dfs(u + 1, sum + w, x);         vis[v] = 0;       }     }   }   bool ok(int x) {     ls = 0;     memset(vis, 0, sizeof(vis));     dfs(1, 0, x);     return ls >= k;   }   int main() {     scanf( %d %d %d , &n, &m, &k);     for (int i = 0; i < (m); ++i) {       int u, v, w;       scanf( %d %d %d , &u, &v, &w);       e[u].push_back({w, v});     }     int l = 0, r = 100000;     while (l + 1 < r) {       int mid = l + r >> 1;       if (ok(mid))         r = mid;       else         l = mid;     }     int ans = -1;     if (ok(l) || ok(r)) ans = ok(l) ? l : r;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 450007;   int read() {     int ans = 0, f = 1, c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       ans = ans * 10 + (c -  0 );       c = getchar();     }     return ans * f;   }   int n, k, sum1, sum2;   int x[M], y[M], f[M];   int main() {     n = read();     for (int i = 1; i <= n; i++) {       k = read();       if (k) x[sum1++] = k;     }     for (int i = 1; i <= n; i++) {       k = read();       if (k) y[sum2++] = k;     }     int now = sum1 - 1;     for (int i = 0; i < now; i++) x[sum1++] = x[i];     for (int i = 1; i < sum2; i++) {       int j = f[i];       while (j && y[i] != y[j]) j = f[j];       f[i + 1] = (y[i] == y[j]) ? f[j] + 1 : 0;     }     int j = 0;     for (int i = 0; i < sum1; i++) {       while (j && x[i] != y[j]) j = f[j];       if (x[i] == y[j]) j++;       if (j == sum2) break;     }     if (j == sum2)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod;   long long binPow(long long a, long long q) {     a %= mod;     if (q == 0) return 1;     if (q % 2 == 1)       return a * binPow(a * a, q / 2) % mod;     else       return binPow(a * a, q / 2) % mod;   }   bool prime(int x) {     if (x % 2 == 0) return false;     if (x % 3 == 0) return false;     for (int i = 4; i <= sqrt(x); i++)       if (x % i == 0) return false;     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     if (n > 4 && prime(n) == false) {       cout <<  NO ;       return 0;     }     cout <<  YES n ;     if (n == 1)       cout << 1;     else if (n == 2)       cout << 1 << endl << 2;     else if (n == 3)       cout << 1 << endl << 2 << endl << 3;     else if (n == 4)       cout << 1 << endl << 3 << endl << 2 << endl << 4;     else {       mod = n;       cout << 1 << endl;       int cnt = 2;       while (cnt != n) {         long long t = cnt * binPow(cnt - 1, n - 2) % mod;         t %= n;         cout << t << endl;         cnt++;       }       cout << n;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10, INF = 2147483647;   int a[MAXN];   int main() {     int T, n, i, res = 0;     scanf( %d , &T);     while (T--) {       res = 0;       scanf( %d , &n);       for (i = 1; i <= n; i++) scanf( %d , &a[i]);       sort(a + 1, a + n + 1);       int ed = a[n];       res = a[n];       bool f2 = 0, f3 = 0, f5 = 0;       for (i = 1; i <= n; i++) {         if (a[i] * 2 == ed) f2 = true;         if (a[i] * 3 == ed) f3 = true;         if (a[i] * 5 == ed) f5 = true;       }       if (f2 && f3 && f5) res = max(res, ed / 2 + ed / 3 + ed / 5);       for (i = 1; i <= n; i++)         if (a[n] % a[i] == 0) a[i] = INF;       sort(a + 1, a + n + 1);       while (a[n] == INF) n--;       res = max(res, ed + a[n]);       for (i = n - 1; i >= 1; i--)         if (a[n] % a[i] != 0) {           res = max(res, ed + a[n] + a[i]);           break;         }       printf( %d n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1001;   int n, m, h, A[M], w, a;   int main() {     scanf( %d%d%d , &n, &m, &h);     for (int i = 1; i <= m; i++) scanf( %d , &A[i]), w += A[i];     w--, n--;     a = w - (A[h] - 1);     if (n > w) {       puts( -1 );       return 0;     }     if (n > a) {       puts( 1 );       return 0;     }     double ans = 1.0;     int x = a - n, y = w - n;     for (int i = a + 1; i <= w; i++) ans = ans / (i * 1.0);     for (int i = x + 1; i <= y; i++) ans = ans * (i * 1.0);     printf( %.7lf n , 1.0 - ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k;     cin >> n >> k;     vector<long long int> arr(n);     long long int r = n;     for (long long int i = 0; i < k; i++) {       long long int temp;       cin >> temp;       for (long long int j = temp - 1; j < r; j++) arr[j] = temp;       r = min(r, temp - 1);     }     for (auto z : arr) cout << z <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 23;   const int MOD = 1e9 + 9;   const int MAXN = 1e3 + 100;   struct item {     int val, type, id;     bool operator<(const item &rhs) const { return val > rhs.val; }   };   vector<item> items[2];   vector<item> cart[MAXN];   int main() {     ios_base::sync_with_stdio(0);     int n, k;     cin >> n >> k;     for (int i = 0; i < n; ++i) {       item it;       it.id = i + 1;       cin >> it.val >> it.type;       items[it.type - 1].push_back(it);     }     for (int i = 0; i < 2; ++i) {       sort(items[i].begin(), items[i].end());     }     for (int i = 0; i < min((int)items[0].size(), k); ++i) {       cart[i].push_back(items[0][i]);     }     for (int i = k; i < items[0].size(); ++i) {       cart[k - 1].push_back(items[0][i]);     }     int pnr = items[1].size() - 1, cnr = k - 1;     while (cnr >= 0 && cart[cnr].size() == 0) {       cart[cnr--].push_back(items[1][pnr--]);     }     int pi = 0, ci = 0;     while (pi <= pnr) {       if (ci == k - 1 || cart[ci][0].val <= items[1][pi].val) {         cart[ci].push_back(items[1][pi++]);       } else {         ++ci;       }     }     double anssum = 0;     for (int i = 0; i < k; ++i) {       bool stool = false;       int mn = INF;       for (auto it : cart[i]) {         if (it.type == 1) stool = true;         mn = min(mn, it.val);         anssum += it.val;       }       if (stool) {         anssum -= mn / 2.0;       }     }     cout.precision(1);     cout << fixed << anssum <<   n ;     for (int i = 0; i < k; ++i) {       cout << cart[i].size();       for (auto it : cart[i]) {         cout <<     << it.id;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int K = 64, N = 3e5 + 7;   int a[N];   int sum[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       long long x;       cin >> x;       a[i] = __builtin_popcountll(x);       sum[i] = sum[i - 1] + a[i];     }     long long ans = 0;     int odd = 0, even = 1;     for (int i = 1; i <= n; i++) {       if (sum[i] % 2) {         ans += odd;         odd++;       } else {         ans += even;         even++;       }       int mx = 0, sm = 0;       for (int j = 0; j < K && j < i; j++) {         int cur = i - j;         mx = max(mx, a[cur]);         sm += a[cur];         if (sm % 2 == 0 && 2 * mx > sm) ans--;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int ans = 0, n;   int numDistDig(int n) {     vector<int> arr(10, 0);     while (n > 0) {       arr[n % 10]++;       n /= 10;     }     int ans = 0, i;     for (i = 0; i < 10; i++) ans += (arr[i] > 0);     return ans;   }   void dfs(int num) {     if (num > 0 && num <= n) ans++;     if (ans >= 100000000) return;     int i;     for (i = 0; i < 10; i++) {       int num2 = num * 10 + i;       if (num2 > 0 && numDistDig(num2) <= 2) dfs(num2);     }   }   int main() {     scanf( %d , &n);     dfs(0);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int r, n, d;     int kol = 0;     cin >> n >> d;     int *a = new int[n];     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++)         if (i != j && abs(a[i] - a[j]) <= d) {           kol++;         }     cout << kol;     return 0;   }
#include <bits/stdc++.h>   const int ms = 500500;   std::string str[ms], ans[ms];   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(NULL);     int n;     std::cin >> n;     for (int i = 0; i < n; i++) std::cin >> str[i];     ans[n - 1] = str[n - 1];     for (int i = n - 2; i >= 0; i--) {       int type = 0;       int to = 0;       for (; to < str[i].size() && to < ans[i + 1].size(); to++) {         if (str[i][to] < ans[i + 1][to])           type = 1;         else if (str[i][to] > ans[i + 1][to])           type = 2;         if (type) break;       }       if (type == 0 || type == 2) {         for (int j = 0; j < to; j++) ans[i] += str[i][j];       } else if (type == 1) {         ans[i] = str[i];       }     }     for (int i = 0; i < n; i++) std::cout << ans[i] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 205;   const int P = 998244353;   template <typename T>   void chkmax(T &x, T y) {     x = max(x, y);   }   template <typename T>   void chkmin(T &x, T y) {     x = min(x, y);   }   template <typename T>   void read(T &x) {     x = 0;     int f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -f;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     x *= f;   }   template <typename T>   void write(T x) {     if (x < 0) x = -x, putchar( - );     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );   }   template <typename T>   void writeln(T x) {     write(x);     puts(  );   }   int a[MAXN], w[MAXN];   int dp[MAXN][MAXN], binom[MAXN][MAXN];   int power(int x, int y) {     if (y == 0) return 1;     int tmp = power(x, y / 2);     if (y % 2 == 0)       return 1ll * tmp * tmp % P;     else       return 1ll * tmp * tmp % P * x % P;   }   int getdown(int x, int y) {     int ans = 1;     for (int i = 1; i <= y; i++) ans = 1ll * ans * (x - i + 1) % P;     return ans;   }   int getup(int x, int y) {     int ans = 1;     for (int i = 1; i <= y; i++) ans = 1ll * ans * (x + i - 1) % P;     return ans;   }   void update(int &x, int y) {     x += y;     if (x >= P) x -= P;   }   int main() {     int n, m;     read(n), read(m);     for (int i = 1; i <= n; i++) read(a[i]);     int s = 0, g = 0, b = 0;     for (int i = 1; i <= n; i++) {       read(w[i]), s += w[i];       if (a[i] == 0)         b += w[i];       else         g += w[i];     }     dp[0][0] = 1;     for (int i = 0; i <= m - 1; i++) {       for (int j = 0; j <= i; j++) {         int tmp = dp[i][j], cnt = s + j - (i - j);         update(dp[i + 1][j],                1ll * tmp * (b - (i - j)) % P * power(cnt, P - 2) % P);         update(dp[i + 1][j + 1], 1ll * tmp * (g + j) % P * power(cnt, P - 2) % P);       }     }     for (int i = 0; i <= m; i++) {       binom[i][0] = 1;       for (int j = 1; j <= i; j++)         binom[i][j] = (binom[i - 1][j - 1] + binom[i - 1][j]) % P;     }     for (int i = 1; i <= n; i++) {       int ans = w[i];       if (a[i] == 0) {         for (int j = 0; j <= m; j++) {           if (dp[m][m - j] == 0) continue;           int tmp = dp[m][m - j];           for (int k = 0; k <= j; k++)             update(ans, P - 1ll * tmp * k % P * getdown(w[i], k) % P *                                 getdown(b - w[i], j - k) % P * binom[j][k] % P *                                 power(getdown(b, j), P - 2) % P);         }       } else {         for (int j = 0; j <= m; j++) {           if (dp[m][j] == 0) continue;           int tmp = dp[m][j];           for (int k = 0; k <= j; k++)             update(ans, 1ll * tmp * k % P * getup(w[i], k) % P *                             getup(g - w[i], j - k) % P * binom[j][k] % P *                             power(getup(g, j), P - 2) % P);         }       }       writeln(ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, c = 0;     cin >> n;     if (n == 1 || n == 2)       cout << 0 << endl;     else if (n % 2 == 0) {       int temp = 1;       while (n >= temp * 2) {         temp *= 2;       }       cout << (n - temp) / 2 << endl;     } else       cout << n / 2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   map<pair<int, char>, int> table;   int main() {     string home, away;     int n, x, y, i;     char card, team;     cin >> home >> away;     cin >> n;     for (i = 0; i < n; i++) {       cin >> x >> team >> y >> card;       if (card ==  y ) table[make_pair(y, team)]++;       if (card ==  r ) {         if (table[make_pair(y, team)] < 2)           table[make_pair(y, team)] = 2;         else           continue;       }       if (table[make_pair(y, team)] == 2) {         if (team ==  a )           cout << away <<    ;         else           cout << home <<    ;         cout << y <<     << x << endl;       }     }     return 0;   }