malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool isprime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i = i + 6) {       if (n % i == 0 || n % (i + 2) == 0) return false;     }     return true;   }   bool sec(const pair<long long, long long> &a,            const pair<long long, long long> &b) {     return a.second > b.second;   }   long long po(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     srand(time(NULL));     long long n;     cin >> n;     long long a[n], b[n], i, an = 0, m = 998244353;     for (i = 0; i < n; i++) {       cin >> a[i];       a[i] = a[i] * (i + 1) * (n - i);     }     for (i = 0; i < n; i++) cin >> b[i];     sort(b, b + n);     sort(a, a + n);     for (i = 0; i < n; i++) {       an += ((a[n - 1 - i] % m) * b[i]) % m;       an = an % m;     }     cout << an;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 2e5 + 5;   const long long MOD = 1e9 + 7;   const long long INF = 1e18;   mt19937 rnd(time(0));   signed main() {     long long q;     cin >> q;     while (q--) {       long long d, mod;       cin >> d >> mod;       long long c = 1;       long long lg = 0;       while ((1ll << lg) <= d) {         c = (c * (min(d, (1ll << (lg + 1)) - 1) - (1ll << lg) + 2ll)) % mod;         lg++;       }       c--;       if (c < 0) {         c += mod;       }       cout << c <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     char ch = getchar();     int h = 0, t = 1;     while ((ch >  9  || ch <  0 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) t = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) h = h * 10 + ch -  0 , ch = getchar();     return h * t;   }   const int N = 2001000;   struct edge {     int next, to;   } a[N];   int n, m, Ans, du[N], head[N], cnt = 1;   int dep[N], vis[N], fa[N], ed[N], ve[N];   void link(int x, int y) {     a[++cnt] = (edge){head[x], y};     head[x] = cnt;   }   void dfs(int x) {     for (int i = head[x]; i; i = a[i].next) {       int R = a[i].to;       if (R == fa[x]) continue;       if (!dep[R])         dep[R] = dep[x] + 1, fa[R] = x, ed[R] = i, dfs(R);       else if (dep[R] < dep[x]) {         vis[R] = ve[i] = ve[i ^ 1] = 1;         for (int p = x; p != R; p = fa[p])           vis[p] = 1, ve[ed[p]] = ve[ed[p] ^ 1] = 1;       }     }   }   void calctree(int x, int rt) {     if (!vis[x]) vis[x] = 2;     int s = 0;     for (int i = head[x]; i; i = a[i].next)       if (!ve[i]) ve[i] = ve[i ^ 1] = 1, calctree(a[i].to, rt), s++;     Ans += (s >> 1) + (x == rt && s & 1);   }   void calccircle(int x) {     vis[x] = 3;     for (int i = head[x]; i; i = a[i].next) {       int R = a[i].to;       if (R == fa[x]) continue;       if (vis[R] == 1)         dep[R] = dep[x] + 1, fa[R] = x, calccircle(R);       else if (vis[R] == 3 && dep[R] < dep[x]) {         int s = (du[R] > 2);         for (int p = x; p != R; p = fa[p]) s += (du[p] > 2);         Ans += (s < 2);       }     }   }   int main() {     n = read();     m = read();     for (int i = 1; i <= m; i++) {       int x = read(), y = read();       link(x, y);       link(y, x);       du[x]++;       du[y]++;     }     for (int i = 1; i <= n; i++)       if (!dep[i]) dep[i] = 1, dfs(i);     for (int i = 1; i <= n; i++)       if (vis[i]) calctree(i, i);     for (int i = 1; i <= n; i++)       if (!vis[i]) calctree(i, i);     for (int i = 1; i <= n; i++)       if (vis[i] == 1) dep[i] = 1, fa[i] = 0, calccircle(i);     printf( %d %d n , Ans, m);   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     cin >> n >> m;     cout << min(n, m) + 1 << endl;     for (int i = 0; i < min(n, m) + 1; i++) {       cout << i <<     << min(n, m) - i << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long int a[100];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int m = a[0];     for (int i = 1; i < n; i++) {       if (a[i] > m) {         m = a[i];       }     }     int o = 0;     for (int i = 0; i < n; i++) {       o = o + (m - a[i]);     }     cout << o;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 500005, maxd = 20;   int jump[maxd][maxn], range[maxd][maxn];   int a[maxn], L[maxn], lmin[maxd][maxn];   int n;   int getminL(int a, int b) { return L[a] < L[b] ? a : b; }   int getmin(int a, int b) {     int k = b - a + 1 ? 31 - __builtin_clz(b - a + 1) : 0;     return getminL(lmin[k][a], lmin[k][b - (1 << k) + 1]);   }   int main() {     int i, x, d, ld;     scanf( %d , &n);     for (ld = 0; (1 << ld) <= n; ++ld)       ;     for (i = 1; i <= n; ++i) scanf( %d , a + i), a[i + n] = a[i];     for (i = 1; i <= n + n; ++i) L[i] = max(i - a[i], 0), lmin[0][i] = i;     for (d = 1; d < ld; ++d)       for (i = 1; i <= n + n - (1 << d) + 1; ++i)         lmin[d][i] = getminL(lmin[d - 1][i], lmin[d - 1][i + (1 << (d - 1))]);     for (i = 1; i <= n + n; ++i) {       jump[0][i] = getmin(L[i], i);       range[0][i] = L[i];       for (d = 1; range[d - 1][i]; ++d)         jump[d][i] = jump[d - 1][jump[d - 1][i]],         range[d][i] = range[d - 1][jump[d - 1][i]];     }     long long ans = 0;     for (i = n; i < n + n; ++i)       for (d = ld - 1, x = i, ++ans; d >= 0; --d)         if (range[d][x] > i - n + 1) ans += 1 << d, x = jump[d][x];     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int OO = 1e9;   const long long INF = 1e18;   const int irand(int lo, int hi) {     return ((double)rand() / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;   }   const long long lrand(long long lo, long long hi) {     return ((double)rand() / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;   }   template <typename T>   T getnum() {     int sign = 1;     T ret = 0;     char c;     do {       c = getchar();     } while (c ==     || c ==   n );     if (c ==  - )       sign = -1;     else       ret = c -  0 ;     while (1) {       c = getchar();       if (c <  0  || c >  9 ) break;       ret = 10 * ret + c -  0 ;     }     return sign * ret;   }   inline void ini(int& x) { x = getnum<int>(); }   inline void scani(int& x) { scanf( %d , &x); }   int n, m;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     if (n * m > 2 && (n == 1 || m == 1)) {       cout << 1 << endl;       cout << n <<     << m <<   1 1  << endl;       if (n == 1) {         for (int j = 1; j <= m; j += 1) cout << 1 <<     << j << endl;       } else {         for (int i = 1; i <= n; i += 1) cout << i <<     << 1 << endl;       }       cout <<  1 1  << endl;     } else if ((n * m) & 1) {       cout << 1 << endl;       cout << n <<     << m <<   1 1  << endl;       for (int i = 1; i <= n; i += 1) {         if (i & 1) {           for (int j = 1; j <= m; j += 1) {             cout << i <<     << j << endl;           }         } else {           for (int j = m; j >= 1; j -= 1) {             cout << i <<     << j << endl;           }         }       }       cout <<  1 1  << endl;     } else {       cout << 0 << endl;       cout <<  1 1  << endl;       if (m & 1) {         for (int i = 1; i <= n; i += 1) {           if (i & 1) {             for (int j = 2; j <= m; j += 1) cout << i <<     << j << endl;           } else {             for (int j = m; j >= 2; j -= 1) cout << i <<     << j << endl;           }         }         for (int i = n; i >= 1; i -= 1) cout << i <<     << 1 << endl;       } else {         for (int j = 1; j <= m; j += 1) {           if (j & 1) {             for (int i = 2; i <= n; i += 1) cout << i <<     << j << endl;           } else {             for (int i = n; i >= 2; i -= 1) cout << i <<     << j << endl;           }         }         for (int j = m; j >= 1; j -= 1) cout << 1 <<     << j << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   const long long Inf = 1e18;   const int N = 2e5 + 10;   const int mod = 0;   long long gi() {     long long x = 0, o = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   template <typename T>   bool chkmax(T &a, T b) {     return a < b ? a = b, 1 : 0;   };   template <typename T>   bool chkmin(T &a, T b) {     return a > b ? a = b, 1 : 0;   };   int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }   int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }   void inc(int &a, int b) { a = (a + b >= mod ? a + b - mod : a + b); }   void dec(int &a, int b) { a = (a - b < 0 ? a - b + mod : a - b); }   int n, x[N], sum[N];   long long a[N], t, b[N];   int main() {     cin >> n >> t;     for (int i = 1; i <= n; i++) a[i] = gi();     for (int i = 1; i <= n; i++) x[i] = gi();     for (int i = 1; i <= n; i++) {       if (x[i] < i) return puts( No ), 0;       sum[i]++;       sum[x[i]]--;     }     for (int i = 1; i <= n; i++) {       sum[i] += sum[i - 1];       b[i] = a[i] + t;       if (sum[i]) b[i] = a[i + 1] + t;       chkmax(b[i], b[i - 1] + 1);     }     for (int i = 1; i <= n; i++)       if (x[i] != n && b[x[i]] >= a[x[i] + 1] + t) return puts( No ), 0;     puts( Yes );     for (int i = 1; i <= n; i++) printf( %lld  , b[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sum, n, m, i, j, ans, a[1000001], v[1000001], cnt[1000001];   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     for (i = 1; i <= n; i++)       for (j = i + 1; j <= n; j++) cnt[abs(a[i] - a[j])]++;     for (i = 1; i <= 1e6; i++) {       sum = 0;       for (j = i; j <= 1e6; j += i) sum += cnt[j];       if (sum > (m + 1) * m / 2) continue;       for (j = 1; j <= n; j++) {         if (v[a[j] % i] == i) ans++;         v[a[j] % i] = i;       }       if (ans <= m) {         printf( %d , i);         return 0;       }       ans = 0;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 1e6, mod = 1e9 + 7, inf = 1e10;   long long int a[N], dp[N];   int main() {     long long int n, mn = 0, mx = -1, ans_1 = 0, ans_2 = 0, cnt, clk, clr;     cin >> n;     for (long long int i = 1; i * i * i <= n; i++) {       if (n % i == 0) {         for (long long int j = 1; j * j <= (n / i); j++) {           long long int k = n / (i * j);           if (i * j * k == n) {             cnt = (i + 1) * (j + 2) * (k + 2);             if (mn == 0) mn = cnt;             mn = min(mn, cnt);             mx = max(mx, cnt);             clk = (i + 2) * (j + 1) * (k + 2);             mn = min(mn, clk);             mx = max(mx, clk);             clr = (i + 2) * (j + 2) * (k + 1);             mn = min(mn, clr);             mx = max(mx, clr);           }         }       }     }     ans_1 = mn - n;     ans_2 = mx - n;     cout << ans_1 <<    ;     return cout << (ans_2), 0;   }
#include <bits/stdc++.h>   int arr[150];   int temp[150];   int main() {     int n, m;     std::cin >> n >> m;     for (int i = 0; i < n; ++i) {       int a, b;       std::cin >> a >> b;       for (int j = a; j <= b; ++j) arr[j]++;     }     int cnt = 0;     for (int i = 1; i <= m; ++i) {       if (!arr[i]) temp[cnt++] = i;     }     std::cout << cnt << std::endl;     for (int i = 0; i < cnt; ++i) {       if (!i)         std::cout << temp[i];       else         std::cout <<     << temp[i];     }     if (cnt) std::cout << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 6000;   int dp[N][N], len[N], dep[N], sz[N], n, k, val[N];   char S[N * 300];   char *s[N];   struct Edge {     int L, len;     int to;     Edge(int L = 0, int len = 0, int to = 0) : L(L), len(len), to(to) {}   } d[N][26];   inline int idx(int c) { return c -  a ; }   void dfs(int x) {     sz[x] = val[x];     for (int i = 0; i <= sz[x]; i++) dp[x][i] = dep[x] * i * (i - 1) / 2;     for (int i = 0; i < 26; i++)       if (d[x][i].to) {         int u = d[x][i].to;         dep[u] = dep[x] + d[x][i].len;         dfs(u);         sz[x] += sz[u];         for (int i = sz[x]; i >= 0; i--) {           int xx = 0;           for (int j = 0; j <= sz[u] && j <= i; j++)             xx = max(xx, dp[x][i - j] + dp[u][j] + j * (i - j) * dep[x]);           dp[x][i] = xx;         }       }   }   int xb;   int main() {     scanf( %d%d , &n, &k);     s[0] = S;     xb = 1;     for (int i = 1; i <= n; i++) {       s[i] = s[i - 1] + len[i - 1];       scanf( %s , s[i]);       len[i] = strlen(s[i]);       int q = 1;       for (int j = 0; j < len[i];) {         int c = idx(s[i][j]);         if (d[q][c].to) {           for (int k = 0; k < d[q][c].len && j + k <= len[i]; k++)             if (s[i][j + k] != S[d[q][c].L + k]) {               int p = d[q][c].to;               d[q][c].to = ++xb;               int nq = xb;               if (j + k < len[i]) d[nq][idx(s[i][j + k])].to = ++xb;               d[nq][idx(S[d[q][c].L + k])].to = p;               if (j + k < len[i]) {                 d[nq][idx(s[i][j + k])].L = (&s[i][j + k]) - S;                 d[nq][idx(s[i][j + k])].len = len[i] - j - k;               }               d[nq][idx(S[d[q][c].L + k])].L = d[q][c].L + k;               d[nq][idx(S[d[q][c].L + k])].len = d[q][c].len - k;               d[q][c].len = k;               break;             }         } else {           d[q][c].L = (&s[i][j]) - S;           d[q][c].len = len[i] - j;           d[q][c].to = ++xb;         }         j += d[q][c].len;         q = d[q][c].to;       }       val[q]++;     }     dfs(1);     printf( %d n , dp[1][k]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, j = 0, k = 0, l = 0, m = 0, n, t = 0, sum = 0, r = 0, q = 0, p = 0,                z = 0;   int a[2000005];   vector<int> v;   int main() {     ios_base::sync_with_stdio(false);     string s, f, g;     cin >> m >> f >> g;     n = g.size();     if (g[n - 1] ==  k )       t = 0;     else       t = 1;     if (t == 1) {       if (m < 30)         cout <<  12 ;       else if (m == 31)         cout <<  7 ;       else         cout <<  11 ;     } else {       if (m == 5 || m == 6)         cout <<  53 ;       else         cout <<  52 ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, n;   short ans = 0;   int main() {     cin >> a >> b;     while (b > 0) {       if (b == 1) {         ans = 0;         break;       }       if (b % a != 0) {         ans = 1;         break;       }       ++n;       b = b / a;     }     if (ans == 0) {       cout <<  YES  << endl;       cout << n - 1;     } else       cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int Nmax = 2e5 + 17;   inline int sqr(int x) { return x * x; }   int main(void) {     int a[6];     for (int i = 0; i < 6; i++) cin >> a[i];     cout << sqr(a[0] + a[1] + a[2]) - sqr(a[0]) - sqr(a[2]) - sqr(a[4]);   }
#include <bits/stdc++.h>   using std::cin;   using std::cout;   using std::ios;   using std::sort;   const int MAX = 1e3 + 2;   int a[MAX];   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL), cout.tie(NULL);     int n = 0;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + n + 1);     cout << a[(n + 1) / 2] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, K;   int hardcode[11] = {0, 1, 0, 1, 2, 0, 2, 0, 1, 0, 1};   int get_sprague_1(int val) {     int tmp = val;     while (tmp % 4 == 0) {       tmp /= 4;     }     if (val <= 10) {       return hardcode[val];     } else if (tmp == 6 || (val % 4 == 0 && tmp % 2 == 1 && tmp != 3)) {       return 2;     } else {       return (val + 1) % 2;     }   }   int get_sprague_2(int val) {     if (val == 1) {       return 1;     } else if (val == 2) {       return 2;     } else {       return (val + 1) % 2;     }   }   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     cin >> N >> K;     int xorv = 0;     if (K % 2 == 1) {       for (int a = 1; a <= N; a++) {         int x;         cin >> x;         xorv ^= get_sprague_1(x);       }     } else {       for (int a = 1; a <= N; a++) {         int x;         cin >> x;         xorv ^= get_sprague_2(x);       }     }     if (xorv == 0) {       cout <<  Nicky ;     } else {       cout <<  Kevin ;     }   }
#include <bits/stdc++.h>   using namespace std;   namespace zzc {   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch - 48;       ch = getchar();     }     return x * f;   }   const int maxn = 2e5 + 5;   int ans = 0x3f3f3f3f;   char s[3][maxn];   int nxt[3][maxn], len[3], overlap[3][3];   void init(int id) {     for (int i = 2, j = 0; i <= len[id]; i++) {       while (j && s[id][i] != s[id][j + 1]) j = nxt[id][j];       if (s[id][i] == s[id][j + 1]) j++;       nxt[id][i] = j;     }   }   int kmp(int x, int y) {     int j = 0;     for (int i = 1; i <= len[x]; i++) {       while (j && s[x][i] != s[y][j + 1]) j = nxt[y][j];       if (s[x][i] == s[y][j + 1]) j++;       if (j == len[y]) return len[y];     }     return j;   }   int calc(int x, int y, int z) {     if (overlap[x][y] == len[y] && overlap[y][z] == len[z])       return len[x];     else if (overlap[x][y] == len[y])       return len[x] + len[z] - overlap[x][z];     else if (overlap[y][z] == len[z])       return len[x] + len[y] - overlap[x][y];     else       return len[x] + len[y] + len[z] - overlap[x][y] - overlap[y][z];   }   void work() {     for (int i = 0; i <= 2; i++)       scanf( %s , s[i] + 1), len[i] = strlen(s[i] + 1), init(i);     for (int i = 0; i <= 2; i++)       for (int j = 0; j <= 2; j++)         if (i != j) overlap[i][j] = kmp(i, j);     ans = min(ans, calc(0, 1, 2));     ans = min(ans, calc(0, 2, 1));     ans = min(ans, calc(1, 0, 2));     ans = min(ans, calc(1, 2, 0));     ans = min(ans, calc(2, 0, 1));     ans = min(ans, calc(2, 1, 0));     printf( %d n , ans);   }   }  // namespace zzc   int main() {     zzc::work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[5][101][101];   int sd[5][3];   int main() {     scanf( %d , &n);     for (int t = 1; t <= 4; t++) {       char ss[101];       for (int i = 1; i <= n; i++) {         scanf( %s , ss + 1);         for (int j = 1; j <= n; j++) {           int f = ss[j] -  0 ;           a[t][i][j] = f;         }       }     }     for (int t = 1; t <= 4; t++) {       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++) {           if (((i - 1) * n + j) % 2 == 1 && a[t][i][j] == 0) sd[t][1]++;           if (((i - 1) * n + j) % 2 == 0 && a[t][i][j] == 1) sd[t][1]++;           if (((i - 1) * n + j) % 2 == 1 && a[t][i][j] == 1) sd[t][2]++;           if (((i - 1) * n + j) % 2 == 0 && a[t][i][j] == 0) sd[t][2]++;         }     }     int ans = 1e9;     if (sd[1][1] + sd[2][1] + sd[3][2] + sd[4][2] < ans)       ans = sd[1][1] + sd[2][1] + sd[3][2] + sd[4][2];     if (sd[1][1] + sd[3][1] + sd[2][2] + sd[4][2] < ans)       ans = sd[1][1] + sd[3][1] + sd[2][2] + sd[4][2];     if (sd[1][1] + sd[4][1] + sd[3][2] + sd[2][2] < ans)       ans = sd[1][1] + sd[4][1] + sd[3][2] + sd[2][2];     if (sd[1][2] + sd[2][2] + sd[3][1] + sd[4][1] < ans)       ans = sd[1][2] + sd[2][2] + sd[3][1] + sd[4][1];     if (sd[1][2] + sd[3][2] + sd[2][1] + sd[4][1] < ans)       ans = sd[1][2] + sd[3][2] + sd[2][1] + sd[4][1];     if (sd[1][2] + sd[4][2] + sd[3][1] + sd[2][1] < ans)       ans = sd[1][2] + sd[4][2] + sd[3][1] + sd[2][1];     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dist(double x1, double y1, double x2, double y2) {     return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));   }   bool have(long long x1, long long y1, long long x2, long long y2, long long x,             long long y) {     long long A = y1 - y2;     long long B = x2 - x1;     long long C = (x1 * y2 - x2 * y1);     if (A * x + B * y + C != 0LL) return false;     long long a = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);     long long b = (x1 - x) * (x1 - x) + (y1 - y) * (y1 - y);     long long c = (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y);     if (b > a || c > a) return false;     if (b > c) swap(b, c);     return (16LL * b >= c);   }   bool solve() {     long long x1[4], y1[4], x2[4], y2[4];     for (int i = 1; i <= 3; i++) {       int a, b, c, d;       scanf( %d%d%d%d , &a, &b, &c, &d);       x1[i] = a, y1[i] = b, x2[i] = c, y2[i] = d;     }     int p = -1, q = -1, l = -1;     for (int i = 1; i <= 3; i++)       for (int j = i + 1; j <= 3; j++) {         if (x1[i] == x1[j] && y1[i] == y1[j]) p = i, q = j;         if (x1[i] == x2[j] && y1[i] == y2[j]) p = i, q = j;         if (x2[i] == x1[j] && y2[i] == y1[j]) p = i, q = j;         if (x2[i] == x2[j] && y2[i] == y2[j]) p = i, q = j;       }     if (p == -1 || q == -1) return false;     l = 1;     if (p == 1 && q == 2) l = 3;     if (p == 1 && q == 3) l = 2;     if (x1[p] == x2[q] && y1[p] == y2[q])       swap(x1[q], x2[q]), swap(y1[q], y2[q]);     else if (x2[p] == x1[q] && y2[p] == y1[q])       swap(x1[p], x2[p]), swap(y1[p], y2[p]);     else if (x2[p] == x2[q] && y2[p] == y2[q])       swap(x1[q], x2[q]), swap(y1[q], y2[q]), swap(x1[p], x2[p]),           swap(y1[p], y2[p]);     double a = dist(x1[p], y1[p], x2[p], y2[p]);     double b = dist(x1[q], y1[q], x2[q], y2[q]);     double c = dist(x2[p], y2[p], x2[q], y2[q]);     double cs = (a * a + b * b - c * c) / 2.0 / a / b;     if (cs >= 0 && cs < 1) {       if (have(x1[p], y1[p], x2[p], y2[p], x1[l], y1[l]) &&           have(x1[q], y1[q], x2[q], y2[q], x2[l], y2[l]))         return true;       if (have(x1[p], y1[p], x2[p], y2[p], x2[l], y2[l]) &&           have(x1[q], y1[q], x2[q], y2[q], x1[l], y1[l]))         return true;     }     return false;   }   int main() {     int t;     scanf( %d , &t);     for (int i = 0; i < t; i++) {       int gd = solve();       if (gd)         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int ct = 0, i, j;     map<char, int> mp1;     int len = s.length();     int bc, rc, gc;     gc = rc = bc = 0;     for (i = 0; i < len; i++) {       if (s[i] ==  R ) rc++;       if (s[i] ==  G ) gc++;       if (s[i] ==  B ) bc++;     }     if (gc > 0 && bc > 0 && rc > 0)       printf( BGR n );     else if (gc == 0) {       if (rc == 0)         printf( B );       else if (bc == 0)         printf( R );       else if (rc == 1 && bc == 1)         printf( G );       else if (rc > 1 && bc == 1)         printf( BG );       else if (bc > 1 && rc == 1)         printf( GR );       else         printf( BGR );     } else if (bc == 0) {       if (gc == 0)         printf( R );       else if (rc == 0)         printf( G );       else if (gc == 1 && rc == 1)         printf( B );       else if (rc > 1 && gc == 1)         printf( BG );       else if (gc > 1 && rc == 1)         printf( BR );       else         printf( BGR );     } else if (rc == 0) {       if (gc == 0)         printf( B );       else if (bc == 0)         printf( G );       else if (gc == 1 && bc == 1)         printf( R );       else if (bc > 1 && gc == 1)         printf( GR );       else if (gc > 1 && bc == 1)         printf( BR );       else         printf( BGR );     }     return 0;   }