malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2;     cin >> s1 >> s2;     for (int i = 0; i < s1.size(); i++) {       s1[i] = tolower(s1[i]);       s2[i] = tolower(s2[i]);     }     if (s1 < s2) {       cout << -1;     } else if (s2 < s1) {       cout << 1;     } else {       cout << 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const float pi = acos(-1.0);   const int maxn = 1e5 + 5;   int c[maxn];   long long a[5][maxn], b[maxn];   vector<int> vec[maxn];   void dfs(int u, int fa) {     for (auto p : vec[u]) {       if (p != fa) {         c[p] = 6 - c[u] - c[fa];         dfs(p, u);       }     }   }   int main() {     int u, v;     int t, n;     cin >> n;     for (int i = 1; i <= 3; i++)       for (int j = 1; j <= n; j++) cin >> a[i][j];     int fu, fv;     for (int i = 1; i <= n - 1; i++) {       cin >> u >> v;       vec[u].push_back(v);       vec[v].push_back(u);     }     int cnt = 0, cnt1 = 0;     for (int i = 1; i <= n; i++) {       if (vec[i].size() == 2) {         cnt++;       }       if (vec[i].size() == 1) {         fv = i;         cnt1++;       }     }     if (cnt != n - 2 && cnt1 != 2) {       puts( -1 );       return 0;     }     long long res = 1e17, ans = 0;     ;     for (int i = 1; i <= 3; i++) {       for (int j = 1; j <= 3; j++) {         if (i == j) continue;         fu = vec[fv][0];         c[fu] = i, c[fv] = j;         dfs(fu, fv);         ans = 0;         for (int k = 1; k <= n; k++) ans += a[c[k]][k];         if (ans < res) {           res = ans;           for (int k = 1; k <= n; k++) {             b[k] = c[k];           }         }       }     }     printf( %lld n , res);     for (int i = 1; i <= n; i++) cout << b[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b, d[500], s;   int main() {     scanf( %d , &n);     for (int i = 1; i <= 2 * n; i++) scanf( %d , &d[i]);     for (int i = 1; i <= 2 * n; i++)       for (int j = 1; j <= 2 * n; j++)         if (d[i] == d[i + (2 * j - 1)]) s++;     printf( %d , s);     scanf(   );   }
#include <bits/stdc++.h>   template <class T>   T Min(const T &a, const T &b) {     return a < b ? a : b;   }   template <class T>   T Max(const T &a, const T &b) {     return a > b ? a : b;   }   template <class T>   bool Chkmin(T &a, const T &b) {     return a > b ? a = b, 1 : 0;   }   template <class T>   bool Chkmax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   struct fast_input {     static const int L = 1 << 15 | 1;     char buf[L], *l, *r;     fast_input() { l = r = buf; }     void Next(char &c) {       if (l == r) r = (l = buf) + fread(buf, 1, L, stdin);       c = l == r ? (char)EOF : *l++;     }     template <class T>     void operator()(T &x) {       char c, f = 0;       for (Next(c); !isdigit(c); Next(c))         if (c ==  - ) f = 1;       for (x = 0; isdigit(c); Next(c)) x = x * 10 + c -  0 ;       if (f) x = -x;     }   } input;   const int N = 1000 + 3;   const int M = 100000 + 7;   const int MOD = 998244353;   int n, m, a[N], f[N][N], ans[M], b[M];   int Power(int x, int y) {     int ret = 1;     while (y) {       if (y & 1) ret = 1LL * x * ret % MOD;       x = 1LL * x * x % MOD, y >>= 1;     }     return ret;   }   int main() {     int x, y, z;     input(n), input(m);     for (int i = (1), i_end = (n); i <= i_end; ++i) input(a[i]), b[a[i]] = 1;     std::sort(a + 1, a + n + 1);     ans[0] = 1;     for (int i = (m + 1), i_end = (n); i <= i_end; ++i)       ans[0] = 1LL * ans[0] * i % MOD;     for (int i = (2), i_end = (n - m); i <= i_end; ++i)       ans[0] = 1LL * ans[0] * Power(i, MOD - 2) % MOD;     int maxans = 0;     while (ans[maxans++]) {       x = 0;       for (int i = (1), i_end = (n); i <= i_end; ++i)         x |= (a[i] - maxans + 1 >= 0 && b[a[i] - maxans + 1]);       if (!x) {         ans[maxans] = ans[maxans - 1];         continue;       }       f[0][0] = 1, x = 0;       for (int j = (1), j_end = (n); j <= j_end; ++j) {         for (int k = (1), k_end = (m); k <= k_end; ++k) {           while (a[j] - a[x + 1] >= maxans) ++x;           f[j][k] = (f[j - 1][k] + f[x][k - 1]) % MOD;         }         f[j][0] = f[j - 1][0];       }       ans[maxans] = f[n][m];     }     int ret = 0;     for (int i = (1), i_end = (maxans - 2); i <= i_end; ++i)       ret = (ret + 1LL * (ans[i] - ans[i + 1]) * i) % MOD;     printf( %d n , (ret + MOD) % MOD);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct S {     long long prime;     int q, h, ji;   };   S xxx[300000];   priority_queue<S> sum[4];   bool biao[300000];   bool operator<(const S &a, const S &b) { return a.prime > b.prime; }   int main() {     int x, y;     cin >> x;     for (int a = 0; a < x; a++) {       cin >> xxx[a].prime;       xxx[a].ji = a;     }     for (int a = 0; a < x; a++) cin >> xxx[a].q;     for (int a = 0; a < x; a++) cin >> xxx[a].h;     for (int a = 0; a < x; a++) {       sum[xxx[a].q].push(xxx[a]);       sum[xxx[a].h].push(xxx[a]);     }     cin >> y;     while (y--) {       cin >> x;       while (!sum[x].empty() && biao[sum[x].top().ji]) sum[x].pop();       if (sum[x].empty())         cout <<  -1 ;       else {         cout << sum[x].top().prime;         biao[sum[x].top().ji] = 1;         sum[x].pop();       }       y == 0 ? cout << endl : cout <<    ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   long long n, m, a, b, c, k, temp, x, y;   const int MAXN = 1e5 + 11, mod = 1e9 + 7;   inline long long max(long long a, long long b) { return ((a > b) ? a : b); }   inline long long min(long long a, long long b) { return ((a > b) ? b : a); }   inline vector<long long> read(int n) {     vector<long long> v(n);     for (int i = 0; i < v.size(); i++) cin >> v[i];     return v;   }   long long setbits(long long n) {     if (n % 4 == 0) return n;     if (n % 4 == 1) return 1;     if (n % 4 == 2) return n + 1;     if (n % 4 == 3) return 0;     return 1e18;   }   long long getxor(long long x, long long m) {     return setbits(x + m - 1) ^ setbits(x - 1);   }   void sol() {     cin >> n;     long long txor = 0;     for (int i = 0; i < n; i++) {       cin >> x >> m;       txor = txor ^ getxor(x, m);     }     if (txor)       cout <<  tolik ;     else       cout <<  bolik ;     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int test = 1;     for (int i = 1; i <= test; i++) sol();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[101], dif[100], i, unique[101], c = 0;     int min = 0, n, dif1, dif2;     cin >> n;     for (i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     unique[c] = a[0];     c++;     for (i = 1; i < n; i++) {       if (a[i] != a[i - 1]) {         unique[c] = a[i];         c++;       }     }     if (c >= 4) {       cout << -1;     } else if (c == 1) {       cout << 0 << endl;     } else if (c == 2) {       if ((unique[1] - unique[0]) % 2) {         cout << unique[1] - unique[0];       } else {         cout << (unique[1] - unique[0]) / 2;       }     } else {       if (unique[2] - unique[1] == unique[1] - unique[0]) {         cout << unique[2] - unique[1];       } else {         cout << -1 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long n;   int k;   long long a[100050];   int main() {     cin >> n >> k;     for (int i = 1; i <= k; i++) cin >> a[i];     long long A = 1, B = 0, C = 0;     for (int i = 1; i <= k; i++) {       if (n - n % a[i] > C) {         A = 1ll * i, B = n / a[i];         C = n - n % a[i];       }     }     cout << A <<     << B;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, q, A[100005 * 3], B[100005 * 3], ans[100005];   int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }   vector<pair<int, int> > G[100005];   vector<int> E[100005];   pair<int, int> SL(pair<int, int> a) {     int t = gcd(abs(a.first), abs(a.second));     a.first /= t, a.second /= t;     return a;   }   int tr[100005];   void upd(int u, int v) {     for (; u <= n; u += u & -u) tr[u] += v;   }   int qry(int u) {     int r = 0;     for (; u; u -= u & -u) r += tr[u];     return r;   }   map<pair<int, int>, int> mAp;   int main() {     scanf( %d , &n);     for (int i = (1), LIM = (n); i <= LIM; i++) {       int K;       scanf( %d , &K);       for (int j = (0), LIM = (K - 1); j <= LIM; j++) {         scanf( %d%d , &A[j], &B[j]);         if (j) G[i].push_back(SL(make_pair(A[j] - A[j - 1], B[j] - B[j - 1])));       }       G[i].push_back(SL(make_pair(A[0] - A[K - 1], B[0] - B[K - 1])));     }     scanf( %d , &q);     for (int i = (1), LIM = (q); i <= LIM; i++) {       scanf( %d%d , &A[i], &B[i]);       E[B[i]].push_back(i);     }     for (int i = (1), LIM = (n); i <= LIM; i++) {       for (auto u : G[i]) {         int t = mAp[u];         upd(t + 1, 1), upd(i + 1, -1);         mAp[u] = i;       }       for (int u : E[i]) ans[u] = qry(A[u]);     }     for (int i = (1), LIM = (q); i <= LIM; i++) printf( %d n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   string s, ss;   int idx;   int main() {     cin >> s;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  . ) {         idx = i;         break;       }     }     if (s[idx - 1] !=  9 ) {       if (s[idx + 1] <  5 ) {         ss = s.substr(0, idx);       } else {         ss = s.substr(0, idx);         ss[ss.length() - 1]++;       }     } else if (s[idx - 1] ==  9 ) {       cout <<  GOTO Vasilisa. ;     }     cout << ss;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, k, x;   string s;   int main() {     cin >> n >> k >> s;     for (i = 0; i < n; i++) {       if (s[i] ==  # )         x++;       else         x = 0;       if (x == k) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   struct Node {     int u;     map<char, int> child;   };   vector<Node> grafo;   int win[100005], lose[100005];   void addTrie(int u, string &s) {     for (char c : s) {       if (grafo[u].child.count(c) == 0) {         Node novo;         novo.u = grafo.size();         grafo[u].child[c] = grafo.size();         grafo.push_back(novo);       }       u = grafo[grafo[u].child[c]].u;     }   }   void solve(int u) {     if (grafo[u].child.size() == 0) {       win[u] = 0;       lose[u] = 1;     }     for (pair<int, int> par : grafo[u].child) {       int v = par.second;       solve(v);       win[u] = (win[u] || !win[v]);       lose[u] = (lose[u] || !lose[v]);     }   }   int main() {     ios::sync_with_stdio(false);     Node root;     root.u = 0;     grafo.push_back(root);     int n, k;     cin >> n >> k;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       addTrie(0, s);     }     solve(0);     int w = win[0], l = lose[0];     if (w == 0)       cout <<  Second  << endl;     else if (w == 1 && l == 1)       cout <<  First  << endl;     else if (w == 1 && l == 0 && k % 2 != 0)       cout <<  First  << endl;     else       cout <<  Second  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   using v2d = vector<vector<T> >;   template <class T>   bool uin(T &a, T b) {     return a > b ? (a = b, true) : false;   }   template <class T>   bool uax(T &a, T b) {     return a < b ? (a = b, true) : false;   }   mt19937 rng(chrono::system_clock::now().time_since_epoch().count());   const int maxN = 2e5 + 10;   const long long inf = 1e18;   int n;   long long k, a[maxN];   bool check(long long d) {     long long c = 1, x = d - 1, y = 0, sum = 0;     bool ovf = 0;     for (int i = n; i; i--) {       if (a[i] > 0 && (ovf || (long double)sum + (long double)c * a[i] > inf)) {         return 1;       }       if (a[i] > 0) {         sum += c * a[i];       }       if (sum >= k) {         return 1;       }       x++;       y++;       if ((long double)c * x / y > inf) {         ovf = 1;       } else {         __int128 tmp = c;         tmp *= x;         tmp /= y;         c = tmp;       }     }     return sum >= k;   }   void solve() {     cin >> n >> k;     for (int i = 1; i <= (int)(n); ++i) {       cin >> a[i];     }     if (*max_element(a + 1, a + n + 1) >= k) {       cout << 0;       return;     }     long long l = 0, r = inf;     while (r - l > 1) {       long long mid = (l + r) / 2;       if (check(mid)) {         r = mid;       } else {         l = mid;       }     }     cout << r;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int T = 1;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int qr() {     int f = 0, fu = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) fu = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       f = (f << 3) + (f << 1) + c - 48;       c = getchar();     }     return f * fu;   }   const int N = 2e5 + 10;   int a[N], n, k, T;   pair<int, int> b[N];   int main() {     T = qr();     while (T--) {       n = qr(), k = qr();       for (register int i = 1; i <= n; ++i) a[i] = qr();       for (register int i = 1; i <= n; ++i) qr();       sort(a + 1, a + n + 1);       int m = 0;       for (register int i = 1; i <= n; ++i) {         b[++m] = {a[i], 0};         int j = i;         while (a[j] == a[i]) b[m].second++, j++;         i = j - 1;       }       for (register int i = 1; i <= m; ++i) b[i].second += b[i - 1].second;       if (k * 2 >= a[n] - a[1]) {         printf( %d n , n);         continue;       }       vector<int> st(m + 1);       int ans = 0;       for (int i = 1, j = 1; i <= m; i++) {         while (b[i].first - b[j].first > k) j++;         st[i] = max(st[i - 1], b[i].second - b[j - 1].second);         ans = max(ans, b[i].second - b[j - 1].second + st[j - 1]);       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[1000006];   map<pair<long long, long long>, long long> mp;   int main() {     long long n, k;     cin >> n >> k;     if (k == 0 && n != 1) {       cout <<  No solution ;       return 0;     }     if (n == 1) {       cout << k;       return 0;     }     if (k != 1) {       cout << k - 1;       for (int i = 0; i < n - 2; i++) cout << 0;       cout << 1;       return 0;     }     if (k == 1) {       cout << 9;       for (int i = 0; i < n - 2; i++) cout << 0;       cout << 1;       return 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int64_t k;     cin >> k;     int64_t r = 2, c = 3;     cout << r <<     << c << endl;     int64_t arr[2][3];     int64_t ones = ((int64_t)1 << 18) - 1;     arr[0][0] = ones;     arr[0][1] = ((int64_t)1 << 17);     arr[0][2] = 0;     arr[1][0] = k;     arr[1][1] = ones;     arr[1][2] = k;     for (int64_t i = 0; i < r; i++) {       for (int64_t j = 0; j < c; j++) {         cout << arr[i][j] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[2][2];     cin >> a[0][0] >> a[0][1] >> a[1][0] >> a[1][1];     int n[2];     if (!a[0][0] && !a[1][0] && !a[0][1] && !a[1][1]) {       cout <<  0 ;       return 0;     }     for (int i = 0; 1; i++) {       int temp = i * (i - 1) / 2;       if (temp == a[0][0]) {         n[0] = i;         break;       }       if (temp > a[0][0]) {         cout <<  Impossible ;         return 0;       }     }     for (int i = 0; 1; i++) {       int temp = i * (i - 1) / 2;       if (temp == a[1][1]) {         n[1] = i;         break;       }       if (temp > a[1][1]) {         cout <<  Impossible ;         return 0;       }     }     if (n[0] == 0)       if (a[0][1] || a[1][0]) n[0] = 1;     if (n[1] == 0)       if (a[0][1] || a[1][0]) n[1] = 1;     if ((a[0][1] + a[1][0]) != n[0] * n[1]) {       cout <<  Impossible ;       return 0;     }     int base = n[1];     while (1) {       if (a[0][1] > base) {         cout <<  0 ;         n[0]--;         a[0][1] -= base;       } else {         for (int i = 0; i < base - a[0][1]; ++i) cout <<  1 ;         if (n[0] > 0) {           cout <<  0 ;           n[0]--;         }         for (int i = 0; i < a[0][1]; ++i) cout <<  1 ;         for (int i = 0; i < n[0]; ++i) cout <<  0 ;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0;     long long moves = 0;     cin >> n;     vector<long long> arr(n, 0);     for (int i = 0; i < n; i++) cin >> arr[i];     long long last = arr[0];     long long min = INT_MAX;     bool found = false;     for (int i = 1; i < n; i++) {       if (arr[i] < arr[i - 1]) {         if (arr[i] < min) {           min = arr[i];           found = true;         }       }       if (arr[i] > arr[i - 1] || i + 1 == n) {         if (found) {           moves += last - min;           found = false;         }         min = INT_MAX;         last = arr[i];       }     }     cout << moves << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long a, b, r;   int main() {     ios_base::sync_with_stdio(0);     cin >> a >> b >> r;     if (min(a, b) >= 2 * r)       cout <<  First  << endl;     else       cout <<  Second  << endl;     cin.get();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, size_t N>   struct ma : array<T, N> {     T &operator[](size_t n) { return (*static_cast<array<T, N> *>(this))[n]; }   };   template <class T>   string to_str(const T &a) {     ostringstream os;     os << a;     return os.str();   }   template <>   string to_str<long double>(const long double &a) {     ostringstream os;     os.precision(10);     os.setf(ios::fixed);     os << a;     return os.str();   }   template <class T>   T from_str(const string &s) {     istringstream is;     T val;     is >> val;     return val;   }   int cond = (long long)0;   map<int, vector<int> > nei;   int dat[(int)1e5 + 11];   void solve() {     int n, m;     scanf( %d%d , &n, &m);     for (auto i = (0); i < (m); ++i) {       scanf( %d , &dat[i]);     }     long long turn = 0;     for (auto i = (0); i < (m - 1); ++i) {       int a = dat[i], b = dat[i + 1];       turn += abs(a - b);       if (a != b) {         nei[a].push_back(b);         nei[b].push_back(a);       }     }     long long res = turn;     for (auto &it : (nei)) {       auto kol = it.second;       sort((kol).begin(), (kol).end());       int mid = kol.size() / 2;       long long cand1 = 0;       long long cand2 = 0;       for (auto &jt : (kol)) {         cand1 += abs(it.first - jt);         cand2 += abs(jt - kol[mid]);       }       res = min(res, turn + cand2 - cand1);     }     cout << res << endl;   }   void brute() {}   void gen(int i, int n, int k) {}   int main(int argc, char **argv) {     ios::sync_with_stdio(false);     vector<string> args;     int nr_test = -1;     int t = 1;     for (auto i = (1); i <= (argc - 1); ++i) args.push_back(argv[i]);     for (auto &it : (args))       if (it ==  q ) cond = 10000000;     for (auto &it : (args))       if (it ==  all ) t = 1000;     for (auto &it : (args))       if (atoi(it.c_str()) > 0) nr_test = atoi(it.c_str());     for (auto &it : (args))       if (it ==  b ) {         brute();         return 0;       }     for (auto &it : (args))       if (it ==  g  && args.size() >= 4) {         gen(atoi(args[1].c_str()), atoi(args[2].c_str()), atoi(args[3].c_str()));         return 0;       }     for (auto i = (1); i <= (t); ++i) {       if (nr_test == -1 || i <= nr_test) solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     vector<int> v;     int n, d, p = 0, cnt = 0, mx = -1;     cin >> n >> d >> s;     for (int i = 0; i < n; i++)       if (s[i] ==  1 ) v.push_back(i);     for (int i = 1; i < v.size(); i++) {       if (v[i] - v[i - 1] > mx) mx = v[i] - v[i - 1];     }     if (mx > d) {       cout << -1;       return 0;     }     while (p < n - 1) {       p += d;       while (s[p] ==  0 ) p--;       cnt++;     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, pair<int, int> > A[2003 * 2003], B[2003 * 2003];   pair<int, int> a[2003], b[2003];   int m, n, r, s, x, y, i, j, asd;   long long t1, t2, mn;   bool h;   int main() {     cin >> m;     for (i = 1; i <= m; i++) {       cin >> a[i].first;       t1 += a[i].first;       a[i].second = i;     }     cin >> n;     for (i = 1; i <= n; i++) {       cin >> b[i].first;       t2 += b[i].first;       b[i].second = i;     }     for (i = 1; i <= m; i++)       for (j = i + 1; j <= m; j++)         A[++r] = make_pair(a[i].first + a[j].first, make_pair(i, j));     for (i = 1; i <= n; i++)       for (j = i + 1; j <= n; j++)         B[++s] = make_pair(b[i].first + b[j].first, make_pair(i, j));     sort(a + 1, a + m + 1);     sort(b + 1, b + n + 1);     sort(A + 1, A + r + 1);     sort(B + 1, B + s + 1);     if (t1 < t2) {       h = 1;       swap(t1, t2);       swap(m, n);       swap(r, s);       swap(a, b);       swap(A, B);     }     mn = t1 - t2;     for (i = j = 1; i <= m; i++) {       while (abs(t1 - a[i].first + b[j].first - (t2 - b[j].first + a[i].first)) >                  abs(t1 - a[i].first + b[j + 1].first -                      (t2 - b[j + 1].first + a[i].first)) &&              j < n)         j++;       if (mn >           abs(t1 - a[i].first + b[j].first - (t2 - b[j].first + a[i].first))) {         mn = abs(t1 - a[i].first + b[j].first - (t2 - b[j].first + a[i].first));         asd = 1;         x = i;         y = j;       }     }     for (i = j = 1; i <= r && s; i++) {       while (abs(t1 - A[i].first + B[j].first - (t2 - B[j].first + A[i].first)) >                  abs(t1 - A[i].first + B[j + 1].first -                      (t2 - B[j + 1].first + A[i].first)) &&              j < s)         j++;       if (mn >           abs((t1 - A[i].first + B[j].first) - (t2 - B[j].first + A[i].first))) {         mn = abs((t1 - A[i].first + B[j].first) - (t2 - B[j].first + A[i].first));         asd = 2;         x = i;         y = j;       }     }     cout << mn << endl << asd << endl;     if (asd == 1) {       if (!h)         cout << a[x].second <<     << b[y].second;       else         cout << b[y].second <<     << a[x].second;     } else if (asd) {       if (!h) {         cout << A[x].second.first <<     << B[y].second.first << endl;         cout << A[x].second.second <<     << B[y].second.second;       } else {         cout << B[y].second.first <<     << A[x].second.first << endl;         cout << B[y].second.second <<     << A[x].second.second;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, i, j, n, x, y;     cin >> x >> y;     bool c = 0;     char a;     for (i = 0; i < x; i++) {       for (j = 0; j < y; j++) {         cin >> a;         if (a !=  W  && a !=  B  && a !=  G ) c = 1;       }     }     if (c)       puts( #Color );     else       puts( #Black&White );     return 0;   }