malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int color[200010];   vector<int> save[200010];   int mark[200010];   map<long long, long long> mark_color;   int main() {     int n, m, k, cnt = 0;     scanf( %d %d %d , &n, &m, &k);     memset(mark, 0, sizeof(mark));     for (int i = (1); i < (n + 1); i++) scanf( %d , &color[i]);     for (int ca = (0); ca < (m); ca++) {       int l, r;       scanf( %d %d , &l, &r);       save[min(l, r)].push_back(max(l, r));       save[max(l, r)].push_back(min(l, r));     }     long long ans = 0;     for (int i = (1); i < (n + 1); i++) {       if (mark[i]) continue;       mark_color.clear();       queue<int> Q;       Q.push(i);       mark_color[color[i]]++;       while (!Q.empty()) {         int now = Q.front();         Q.pop();         int size = save[now].size();         mark[now] = 1;         for (int j = (0); j < (size); j++) {           int iterm = save[now][j];           if (mark[iterm]) continue;           mark_color[color[iterm]]++;           mark[iterm] = 1;           Q.push(iterm);         }       }       long long temp = 0;       long long maxnum = 0;       for (auto it = mark_color.begin(); it != mark_color.end(); it++) {         maxnum = max(maxnum, it->second);         temp += it->second;       }       ans += (temp - maxnum);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int sum, i, j, k, n;     char str[200002];     scanf( %ld , &n);     scanf( %s , &str[0]);     for (i = 0; i < n; i++) {       if (str[i] ==  0 ) {         j++;       } else         k++;     }     if (j > k) j = k;     sum = n - 2 * j;     printf( %ld n , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;       int main(){       int t,n;       scanf( %d ,&t);       while(t--){           scanf( %d ,&n); double ans=0;           vector<double>miners; vector<double>diamonds;           for(int i=0;i<2*n;i++){              double a,b;               scanf( %lf%lf ,&a,&b);               if (a==0){miners.push_back(abs(b));}               if (b==0){diamonds.push_back(abs(a));}           }           sort(miners.begin(),miners.end());           sort(diamonds.begin(),diamonds.end());           for (int i=0;i<n;i++){               ans+=sqrt(miners[i]*miners[i]+diamonds[i]*diamonds[i]);           }           printf( %.15lf n ,ans);       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1050000, P = 998244353, inv2 = (P + 1) / 2;   int n, m, U, cnt[N], f[N], g[N], ans;   char s[21][100005];   inline void read(int &i) {     i = 0;     char c = getchar();     bool j = 0;     for (; !isdigit(c); c = getchar())       if (c ==  - ) j = 1;     for (; isdigit(c); c = getchar()) i = (i << 1) + (i << 3) + c -  0 ;     i = j ? -i : i;   }   void FWT(int *a, int l, int p) {     for (int i = 1; i < l; i <<= 1) {       for (int j = 0; j < l; j += i << 1) {         for (int k = 0; k < i; ++k) {           int x = a[j + k], y = a[i + j + k];           a[j + k] = (x + y) % P;           a[i + j + k] = (x - y + P) % P;           if (p == -1)             a[j + k] = 1ll * a[j + k] * inv2 % P,                   a[i + j + k] = 1ll * a[i + j + k] * inv2 % P;         }       }     }   }   int main() {     read(n);     read(m);     ans = n * m;     U = (1 << n) - 1;     for (int i = 1; i <= n; ++i) scanf( %s , s[i] + 1);     for (int j = 1; j <= m; ++j) {       int x = 0;       for (int i = 1; i <= n; ++i)         if (s[i][j] ==  1 ) x ^= 1 << (n - i);       f[x]++;     }     for (int i = 1; i <= U; ++i) cnt[i] = cnt[i >> 1] + (i & 1);     for (int i = 0; i <= U; ++i) g[i] = min(cnt[i], n - cnt[i]);     FWT(f, U, 1);     FWT(g, U, 1);     for (int i = 0; i <= U; ++i) f[i] = 1ll * f[i] * g[i] % P;     FWT(f, U, -1);     for (int i = 0; i <= U; ++i) ans = min(ans, f[i]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k;     cin >> k;     cout << 7 + (3 * (k - 1)) << endl;     cout << 1 <<     << 1 << endl;     cout << 0 <<     << 1 << endl;     cout << 0 <<     << 0 << endl;     cout << 1 <<     << 0 << endl;     cout << 2 <<     << 2 << endl;     cout << 2 <<     << 1 << endl;     cout << 1 <<     << 2 << endl;     int i = 2;     while (i <= k) {       cout << i <<     << i + 1 << endl;       cout << i + 1 <<     << i << endl;       cout << i + 1 <<     << i + 1 << endl;       i++;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     cin >> q;     while (q--) {       long long n, m;       cin >> n >> m;       long long ans;       if (n < m) {         ans = 0;       } else if (n == m)         ans = m % 10;       else {         int d = m % 10;         int rem[10];         rem[0] = 0;         for (int i = 1; i < 10; ++i) {           rem[i] = (i * d) % 10 + rem[i - 1];         }         long long tot = n / m;         ans = rem[tot % 10] + (tot / 10) * rem[9];       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string x;     cin >> x;     int i, j;     int len = x.size();     int count = 0;     for (i = 0; i < len; i++) {       for (j = 1; j <= len - i; j++) {         string z = x.substr(i, j);         if (z ==  Danil  || z ==  Olya  || z ==  Slava  || z ==  Ann  ||             z ==  Nikita )           count++;       }     }     if (count == 1)       cout <<  Yes ;     else       cout <<  No ;   }
#include <bits/stdc++.h>   using namespace std;   int n, s1, s2;   int a[100005];   bool check(int x) {     int l = -1e9, r = 1e9;     for (int i = n; i >= 1; i--) {       if (l <= a[i] && a[i] <= r) {         l = a[i] - x;         r = a[i] + x;       } else {         l = max(l, a[i] - x);         r = min(r, a[i] + x);       }     }     return (l <= s1 && s1 <= r) || (l <= s2 && s2 <= r);   }   int main() {     scanf( %d%d%d , &n, &s1, &s2);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     int l = abs(s1 - s2), r = 1e9, ans = 1e9;     while (l <= r) {       int mid = (l + r) / 2;       if (check(mid)) {         r = mid - 1;         ans = mid;       } else {         l = mid + 1;       }     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   signed main(void) {     int totNums, cnt = 0;     long long tot = 0, num;     bool zero = false;     std::cin >> totNums;     for (int i = 0; i < totNums; i++) {       std::cin >> num;       if (num == 0) {         ++tot;         zero = true;       } else if (num > 0)         tot += num - 1;       else if (num < 0) {         tot += -1 - num;         ++cnt;       }     }     if ((cnt & 1) && !zero) tot += 2;     std::cout << tot << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int first) { cerr << first; }   void __print(long first) { cerr << first; }   void __print(long long first) { cerr << first; }   void __print(unsigned first) { cerr << first; }   void __print(unsigned long first) { cerr << first; }   void __print(unsigned long long first) { cerr << first; }   void __print(float first) { cerr << first; }   void __print(double first) { cerr << first; }   void __print(long double first) { cerr << first; }   void __print(char first) { cerr <<      << first <<     ; }   void __print(const char *first) { cerr <<     << first <<    ; }   void __print(const string &first) { cerr <<     << first <<    ; }   void __print(bool first) { cerr << (first ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &first) {     cerr <<  { ;     __print(first.first);     cerr <<  , ;     __print(first.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &first) {     int f = 0;     cerr <<  { ;     for (auto &i : first) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   long long check(vector<long long> a, long long n, long long k) {     long long ans = 0;     for (long long i = 1; i < n + 1; i++) {       long long req;       if (a[i] < 0) {         req = -1 * a[i];         ans += req;         a[i + 1] -= req;       } else {         req = a[i] % k;         if (req < k - req) {           ans += req;           a[i + 1] += req;         } else {           ans += k - req;           a[i + 1] -= k - req;         }       }     }     return ans;   }   bool prime[1000010];   vector<long long> factors;   void sieve(long long n) {     memset(prime, true, sizeof(prime));     for (long long p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (long long i = p * p; i <= n; i += p) prime[i] = false;       }     }     for (long long p = 2; p <= n; p++)       if (prime[p]) factors.push_back(p);   }   int main() {     sieve(1000000);     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n;     cin >> n;     vector<long long> a(n + 2);     long long sum = 0;     for (long long i = 1; i < n + 1; i++) {       cin >> a[i];       sum += a[i];     };     vector<long long> prime_divisors;     for (auto &factor : factors) {       if (sum % factor == 0) {         prime_divisors.push_back(factor);         sum /= factor;       }     }     if (sum != 1) prime_divisors.push_back(sum);     long long ans = 1e18;     ;     for (auto &prime_divisor : prime_divisors) {       ans = min(ans, check(a, n, prime_divisor));       ;     }     if (ans == 1e18) ans = -1;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 30;   const int maxn = 105;   const int MOD = 1e9 + 7;   const double eps = 1e-6;   const double pi = acos(-1);   long long n, m;   long long T[maxn][maxn];   long long f[maxn];   void Mul_mat(long long fin[][maxn], long long b[][maxn]) {     long long ans[maxn][maxn];     for (int i = (0); i < (m); ++i)       for (int j = (0); j < (m); ++j) ans[i][j] = 0;     for (int i = (0); i < (m); ++i)       for (int j = (0); j < (m); ++j)         for (int k = (0); k < (m); ++k) {           ans[i][j] = (ans[i][j] + fin[i][k] * b[k][j]) % MOD;         }     for (int i = (0); i < (m); ++i)       for (int j = (0); j < (m); ++j) fin[i][j] = ans[i][j];   }   void Pow_mat(long long n, long long fin[][maxn], long long b[][maxn]) {     long long ans[maxn][maxn];     for (int i = (0); i < (m); ++i)       for (int j = (0); j < (m); ++j) {         if (i != j)           ans[i][j] = 0;         else           ans[i][j] = 1;       }     while (n) {       if (n & 1) Mul_mat(ans, b);       Mul_mat(b, b);       n >>= 1;     }     memcpy(fin, ans, sizeof(ans));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     while (cin >> n >> m) {       if (n < m) {         cout << 1 << endl;         continue;       }       memset(T, 0, sizeof(T));       for (int i = (0); i < (m - 1); ++i) T[i][i + 1] = 1;       T[m - 1][0] = T[m - 1][m - 1] = 1;       long long f[maxn];       for (int i = (0); i < (m - 1); ++i) f[i] = 1;       f[m - 1] = 2;       long long tmp[maxn][maxn];       memset(tmp, 0, sizeof(tmp));       Pow_mat(n - 1, tmp, T);       long long ans = 0;       for (int i = (0); i < (m); ++i) {         ans = (ans + tmp[0][i] * f[i]) % MOD;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> operator-(const pair<int, int>& lhs, const pair<int, int>& rhs) {     return pair<int, int>(lhs.first - rhs.first, lhs.second - rhs.second);   }   int x[19] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 2, 3, 4};   int y[19] = {0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4};   vector<int> ms;   int dp[1 << 19];   bool f(int u) {     if (dp[u] >= 0) return dp[u];     for (auto m : ms) {       if ((m & u) != m) continue;       if (!f(u ^ m)) {         return dp[u] = 1;       }     }     return dp[u] = 0;   }   int main() {     memset(dp, -1, sizeof(dp));     vector<pair<int, int> > ps;     for (int u = 1; u < (1 << 19); u++) {       ps.clear();       for (int i = 0; i < 19; i++) {         if (u & (1 << i)) {           ps.push_back(pair<int, int>(x[i], y[i]));         }       }       if (ps.size() == 1) {         ms.push_back(u);         continue;       }       sort(ps.begin(), ps.end());       pair<int, int> d = ps[1] - ps[0];       if ((d.first == 0 && d.second == 1) || (d.first == 1 && d.second == 0) ||           (d.first == 1 && d.second == 1)) {         bool ok = true;         for (int i = 2; i < ps.size(); i++) {           ok &= (ps[i] - ps[i - 1] == d);         }         if (ok) {           ms.push_back(u);         }       }     }     char buf[10];     int v = 0;     for (int i = 0; i < 19; i++) {       scanf( %s , buf);       if (buf[0] ==  O ) {         v |= 1 << i;       }     }     if (f(v)) {       puts( Karlsson );     } else {       puts( Lillebror );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     long long n;     cin >> n;     long long a[n];     map<long long, long long> m, ans;     vector<long long> v;     for (long long i = 0; i < n; i++) {       cin >> a[i];       if (m[a[i]] == 0 && a[i] <= n) {         m[a[i]] = 1;         ans[i] = a[i];       } else {         v.push_back(i);       }     }     long long j = 0;     for (long long i = 1; i <= n; i++) {       if (m[i] == 0) {         ans[v[j]] = i;         j++;       }     }     for (long long i = 0; i < n; i++) {       cout << ans[i] <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     char c;     int sum = 0;     if (n % 2 == 0) {       int f = 1;       for (int i = 1; i <= n; i++) {         cin >> c;         if (c ==  ( )           sum++;         else           sum--;         if (sum < -1) break;       }       if (sum != 0) f = 0;       if (f)         cout <<  Yes n ;       else         cout <<  No n ;     } else       cout <<  No n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int test;     cin >> test;     while (test--) {       long long x1, x2, y1, y2;       cin >> x1 >> y1 >> x2 >> y2;       cout << (long long)((x2 - x1) * (y2 - y1)) + 1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     int arr[4] = {1, 3, 6, 10};     while (t--) {       int x;       cin >> x;       int num1 = x % 10;       int num2 = 0;       while (x != 0) {         x = x / 10;         num2++;       }       cout << (num1 - 1) * 10 + arr[num2 - 1] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int vv[3003] = {0}, vvv[3003] = {0};     int n, v, m = -1, k;     cin >> n >> v;     while (n--) {       int a, b;       cin >> a >> b;       vv[a] += b;       vvv[a + 1] += b;       m = max(m, a + 1);     }     int ans = 0, mm;     for (int i = 0; i <= m; i++) {       mm = v;       if (vvv[i]) {         if (vvv[i] < mm) {           ans += vvv[i];           mm -= vvv[i];         } else {           ans += mm;           mm = 0;         }       }       if (mm) {         if (vv[i] < mm) {           ans += vv[i];           vvv[i + 1] -= vv[i];         } else {           ans += mm;           vvv[i + 1] -= mm;         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[111111], b[111111], c[111111], d[111111];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     for (int i = 1; i <= n; i++) {       scanf( %d , &b[i]);     }     for (int i = 1; i <= n; i++) {       c[i] = a[i + 1] - a[i];       d[i] = b[i + 1] - b[i];     }     sort(c + 1, c + n);     sort(d + 1, d + n);     if (a[1] != b[1]) {       printf( No n );       return 0;     }     for (int i = 1; i < n; i++) {       if (c[i] != d[i]) {         printf( No n );         return 0;       }     }     printf( Yes n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, ans;   string str;   long long solve() {     cin >> n >> str;     long long x = -1, y = -1;     long long i = 0;     while (i < n) {       if (str[i] ==  1 ) {         x = i;         break;       }       i++;     }     i = n - 1;     while (i >= 0) {       if (str[i] ==  1 ) {         y = i;         break;       }       i--;     }     ans = n;     if (x != -1) {       ans = max(ans, 2 * (x + 1));       ans = max(ans, 2 * (n - x));     }     if (y != -1) {       ans = max(ans, 2 * (y + 1));       ans = max(ans, 2 * (n - y));     }     cout << ans <<   n ;     return 0;   }   signed main() {     ios::sync_with_stdio(0);     long long t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100000 + 10;   int a[MAXN], n;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , a + i);     if (a[n - 1] == 1) {       puts( NO );       return 0;     }     if (n == 1 && a[0] == 0) {       puts( YES n0 );       return 0;     }     int cnt(0), c1(0);     for (int i = 0; i < n && a[i]; ++i) ++c1;     for (int i = n - 1; i >= 0 && !a[i]; --i) ++cnt;     if (c1 + cnt == n && cnt == 2) {       puts( NO );       return 0;     }     puts( YES );     if (cnt == 1) {       printf( %d , a[0]);       for (int i = 1; i < n; ++i) printf( ->%d , a[i]);       puts(  );       return 0;     }     if (cnt >= 3) {       for (int i = 0; i < n - 3; ++i) {         printf( %d-> , a[i]);       }       printf( (0->0)->0 n );       return 0;     }     int x;     for (x = n - 3; x >= 0 && a[x]; --x)       ;     for (int i = 0; i < x; ++i) printf( %d-> , a[i]);     printf( (0->( );     for (int i = x + 1; i < n - 2; ++i) printf( 1-> );     printf( 0))->0 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int jie[2000050], i, ni[2000050], j, g[1000050], su[1000050], m;   bool vis[1000050];   int qmi(int di, int zhi) {     int ret = 1, x = di;     while (zhi) {       if (zhi & 1) ret = 1LL * ret * x % 1000000007;       x = 1LL * x * x % 1000000007;       zhi >>= 1;     }     return ret;   }   int main() {     jie[0] = jie[1] = ni[1] = ni[0] = 1;     for (i = 2; i <= 2000000; i++) jie[i] = 1LL * jie[i - 1] * i % 1000000007;     for (i = 1; i <= 2000000; i++) ni[i] = qmi(jie[i], 1000000007 - 2);     for (i = 2; i <= 1000000; i++) {       if (!vis[i]) {         g[i] = i;         su[++m] = i;       }       for (j = 1; j <= m; j++) {         if (i * su[j] > 1000000) break;         if (i % su[j]) {           g[i * su[j]] = su[j];           vis[i * su[j]] = true;         } else {           g[i * su[j]] = su[j];           vis[i * su[j]] = true;           break;         }       }     }     int t;     scanf( %d , &t);     while (t--) {       int r, x;       scanf( %d%d , &r, &x);       int ans = 1;       while (x != 1) {         int cnt = 0, psz = g[x];         while (x % psz == 0) x /= psz, cnt++;         ans = 1LL * ans *               (0LL +                2LL * (r + cnt >= cnt                           ? ((1LL * ni[r + cnt - cnt] * ni[cnt] % 1000000007) *                              jie[r + cnt] % 1000000007)                           : 0) -                (r + cnt - 1 >= cnt                     ? ((1LL * ni[r + cnt - 1 - cnt] * ni[cnt] % 1000000007) *                        jie[r + cnt - 1] % 1000000007)                     : 0)) %               1000000007;       }       printf( %d n , (ans + 1000000007) % 1000000007);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char a[100000];     int len, i, flag = 0, m;     cin >> a;     len = strlen(a);     for (i = 0; i <= (len / 2); i++) {       m = int(a[i]);       if ((m == 65) || (m == 72) || (m == 73) || (m == 77) || (m == 79) ||           (m == 84) || (m == 85) || (m == 86) || (m == 87) || (m == 88) ||           (m == 89)) {         if (int(a[len - 1 - i]) != m) {           flag = 1;           break;         }       } else {         flag = 1;         break;       }     }     if (flag == 1) {       cout <<  NO ;     } else {       cout <<  YES ;     }   }
#include <bits/stdc++.h>   int main() {     int n, i, j, cnt = 0, sum = 0, cost;     scanf( %d %d , &n, &cost);     int ara[n], ara2[100000];     for (i = 0; i < n; i++) {       scanf( %d , &ara[i]);     }     std::sort(ara, ara + n);     int x = 0, z = 0;     for (i = 1; i <= cost; i++) {       sum += i;       cnt++;       if (i == ara[x] && x < n) {         cnt--;         sum -= ara[x];         x++;         continue;       }       if (sum > cost) {         sum -= i;         cnt--;         i--;         break;       } else if (sum == cost) {         ara2[z] = i;         z++;         break;       } else {         ara2[z] = i;         z++;       }     }     printf( %d n , cnt);     for (j = 0; j < z; j++) printf( %d  , ara2[j]);   }
#include <bits/stdc++.h>   using namespace std;   #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)   #define rep(i,n) REP(i,0,n)   #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)   #define ALLOF(c) (c).begin(), (c).end()   typedef long long ll;   typedef unsigned long long ull;      int getnum(const vector<ll>& v, ll x){     if(x < v[0]) return 0;        int lb = 0, ub = v.size();     while(ub-lb>1){       int mid = (lb+ub)/2;          if(v[mid] <= x) lb = mid;       else ub = mid;     }        return ub;   }         int calc(const vector<ll>& v, const vector<ll>& w){     if(v.size() == 0) return 0;     if(w.size() == 0) return 0;        map<ll,int> memo;     rep(i,w.size()){       memo[w[i]] = i;     }        int ret = 0;          int cnt = 0;     vector<int> match(w.size(), 0);     rep(i,v.size()){       if(memo.count(v[i]) > 0){         cnt++;         match[memo[v[i]]] = 1;       }     }        ret = max(ret, cnt);        rep(i,w.size()){       if(match[i] == 1) cnt--;          int x = getnum(v, w[i]);       int y = getnum(w, w[i]);       int z = getnum(w, w[i]-x);              ret = max(ret, cnt + (y-z));     }          return ret;   }            void solve(){     int n, m;     cin >> n >> m;     vector<ll> v1, v2, w1, w2;     rep(i,n){       ll a;       cin >> a;       if(a < 0) v1.push_back(-a);       else v2.push_back(a);     }     reverse(ALLOF(v1));          rep(i,m){       ll a;       cin >> a;       if(a < 0) w1.push_back(-a);       else w2.push_back(a);     }     reverse(ALLOF(w1));          cout << calc(v1,w1) + calc(v2,w2) << endl;   }      int main(){     cin.tie(nullptr);     ios::sync_with_stdio(false);        int t;     cin >> t;     rep(i,t){       solve();     }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long N, M;   struct MATRIX {     int dim;     long long MAT[100][100];     MATRIX(int N, int x = -1) {       dim = N;       for (int i = 0; i < dim; i++)         for (int j = 0; j < dim; j++) {           if (x != -1 && i == j)             MAT[i][j] = x;           else             MAT[i][j] = 0;         }     }     void operator+=(const MATRIX& a) {       for (int i = 0; i < a.dim; i++) {         for (int j = 0; j < a.dim; j++) {           MAT[i][j] += a.MAT[i][j];         }       }     }     void show() {       for (int i = 0; i < dim; i++) {         for (int j = 0; j < dim; j++) cout << MAT[i][j] <<    ;         cout << endl;       }       cout << endl;     }   };   MATRIX operator*(MATRIX a, MATRIX b) {     MATRIX res(a.dim);     for (int i = 0; i < a.dim; i++) {       for (int j = 0; j < b.dim; j++) {         long long sum = 0;         for (int z = 0; z < a.dim; z++) {           sum += a.MAT[i][z] * b.MAT[z][j];         }         sum %= M;         res.MAT[i][j] = sum;       }     }     return res;   }   MATRIX binpow(MATRIX a, long long n) {     MATRIX res = a;     while (n) {       if (n & 1) res = res * a;       a = a * a;       n >>= 1;     }     return res;   }   int main() {     int X;     cin >> N >> X;     for (int i = 0; i < N; i++) {       int a, b;       cin >> a >> b;       if (a == 7 - X || b == 7 - X || a == X || b == X) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;     return 0;   }