malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3f;   const double eps = 1e-12;   const double PI = acos(-1.0);   const int mod = 998244353;   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   int ar[100050];   void solve() {     int n, k;     cin >> n >> k;     bool exi = false, gp = false;     for (int i = 1; i <= n; i++) {       cin >> ar[i];       if (ar[i] == k) exi = true;     }     for (int i = 1; i < n; i++) {       if (ar[i] >= k && (ar[i + 1] >= k || i < n - 1 && ar[i + 2] >= k)) {         gp = true;         break;       }     }     if (n == 1 && ar[1] == k || exi && gp)       cout <<  yes n ;     else       cout <<  no n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T;     cin >> T;     for (int t = 1; t <= T; t++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 5255;   long long n, m;   long long a[N], b[N];   long long ans[N], rec[N];   inline long long gt(long long u) {     long long flg = u < 0 ? -1 : 1;     u = u * flg;     for (long long i = 2; i * i <= u; ++i) {       while (u % (i * i) == 0) u = u / (i * i);     }     return u * flg;   }   signed main() {     cin >> n;     for (long long i = 1; i <= n; ++i) {       scanf( %lld , &a[i]);       a[i] = b[i] = gt(a[i]);     }     sort(b + 1, b + n + 1);     m = unique(b + 1, b + n + 1) - b - 1;     for (long long i = 1; i <= n; ++i) {       if (a[i] != 0) a[i] = lower_bound(b + 1, b + m + 1, a[i]) - b + 1;     }     for (long long i = 1; i <= n; ++i) {       long long cnt = 0;       bool flag = 1;       memset(rec, 0, sizeof(rec));       for (long long j = i; j <= n; ++j) {         if (flag == 0) {           if (a[j] == 0)             ;           else {             if (rec[a[j]] == 0) cnt++;           }         } else {           if (i == j) {             if (a[j] != 0)               flag = 0, cnt++;             else               cnt++;           } else {             if (a[j] != 0)               flag = 0;             else               ;           }         }         rec[a[j]] = 1;         ans[cnt]++;       }     }     for (long long i = 1; i <= n; ++i) {       printf( %lld  , ans[i]);     }     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, d;     cin >> n >> d;     int m;     cin >> m;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       if (x + y - d >= 0 && x - y - d <= 0 && x - y + d >= 0 &&           x + y - 2 * n + d <= 0) {         cout <<  YES n ;       } else {         cout <<  NO n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int T = 1;     while (T--) {       long long a, b, s;       cin >> a >> b >> s;       s = s - abs(a) - abs(b);       if (s % 2 == 0 && s >= 0)         cout <<  Yes ;       else         cout <<  No ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   long long quickpow(long long x, long long y) {     long long res = 1;     for (; y; y >>= 1, x *= x, x %= 1000003)       if (y & 1) res *= x, res %= 1000003;     return res;   }   int main() {     scanf( %I64d %I64d , &n, &k);     if (n < 62 && k > (1LL << n))       printf(  1 1 n );     else {       long long A = 1, t = quickpow(2, n), cnt = n;       for (int y = 1; y < 62; y++) cnt += (k - 1) / (1LL << y);       if (k < 1000003) {         for (long long i = 1; i <= k; i++)           A = A * (t - i + 1000003 + 1) % 1000003;         A = A * quickpow(quickpow(2, 1000003 - 2), cnt) % 1000003;       } else         A = 0;       long long B = quickpow(quickpow(2, n), k) *                     quickpow(quickpow(2, 1000003 - 2), cnt) % 1000003;       printf( %I64d %I64d n , (B - A + 1000003) % 1000003, B);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   int x[100005], y[100005], num_, num;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x[i] >> y[i];       if (x[i] > 0) {         num++;       } else {         num_++;       }     }     if (num == 1 || num_ == 1 || num == 0 || num_ == 0) {       cout <<  Yes  << endl;       return 0;     } else {       cout <<  No  << endl;       return 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long b, long long e, long long m) {     if (e == 0) return 1;     if (e & 1) return b * power(b * b % m, e / 2, m) % m;     return power(b * b % m, e / 2, m);   }   long long power(long long b, long long e) {     if (e == 0) return 1;     if (e & 1) return b * power(b * b, e / 2);     return power(b * b, e / 2);   }   int _runtimeTerror_() {     long long n;     cin >> n;     long long i, a[n], b[n];     for (i = 0; i < n; ++i) cin >> a[i];     for (i = 0; i < n; ++i) cin >> b[i];     long long ans = 0;     long long arr[n];     for (i = 0; i < n; ++i) {       arr[i] = a[i] * (i + 1) * (n - i);     }     sort(arr, arr + n, greater<long long>());     sort(b, b + n);     for (i = 0; i < n; ++i) {       ans += (b[i] * (arr[i] % 998244353)) % 998244353;       ans %= 998244353;     }     cout << ans <<   n ;     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) _runtimeTerror_();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long f(long long n) {     long long t = n;     for (long long i = 2; i * i <= n; i++)       if (n % i == 0) {         t = t / i * (i - 1);         while (n % i == 0) n /= i;       }     if (n > 1) t = t / n * (n - 1);     return t;   }   int main() {     long long n, k;     cin >> n >> k;     for (long long i = 1; i <= k && n > 1; i += 2) n = f(n);     printf( %I64d n , n % 1000000007);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string parse(string str) {     string returnme;     for (int i = 0; i < str.length(); i++) {       if (str[i] ==  _  || str[i] ==  ;  || str[i] ==  - ) {       } else {         returnme.push_back(tolower(str[i]));       }     }     return returnme;   }   int main() {     string con1, con2, con3;     cin >> con1 >> con2 >> con3;     con1 = parse(con1);     con2 = parse(con2);     con3 = parse(con3);     int n;     cin >> n;     vector<string> con;     con.push_back(con1 + con2 + con3);     con.push_back(con1 + con3 + con2);     con.push_back(con3 + con2 + con1);     con.push_back(con2 + con3 + con1);     con.push_back(con2 + con1 + con3);     con.push_back(con3 + con1 + con2);     for (int i = 0; i < n; i++) {       string str;       cin >> str;       str = parse(str);       bool acc = false;       for (int j = 0; j < 6; j++) {         if (str == con[j]) {           cout <<  ACC  << endl;           acc = true;           break;         }       }       if (acc == false) {         cout <<  WA  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int foot = 0;     int inch = 0;     int q, o;     if (n < 35) {       if (n == 2) {         inch++;       } else         for (int e = 1; e < n; e = e + 3) {           inch++;         }     } else if (n == 35 || n == 36) {       foot++;     } else if (n > 36) {       if (n == 37) {         inch = 0;       } else if (n == 38) {         inch++;       } else if (n > 38) {         for (int z = 36; z <= n; z = z + 36) {           foot++;           if (z - n == 2 || z - n == 1) {             ;           }           q = z;           o = n - q;         }         for (int i = 3; i <= o; i = i + 3) {           inch++;           if (o - i == 2) {             inch++;           }         }       }     }     if (inch == 12) {       inch = 0;       foot++;     }     cout << foot <<     << inch;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = (int)1e9 + 7;   const int FFTMOD = 1007681537;   const int INF = (int)1e9;   const long long LINF = (long long)1e18;   const long double PI = acos((long double)-1);   const long double EPS = 1e-9;   inline long long gcd(long long a, long long b) {     long long r;     while (b) {       r = a % b;       a = b;       b = r;     }     return a;   }   inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   inline long long fpow(long long n, long long k, int p = MOD) {     long long r = 1;     for (; k; k >>= 1) {       if (k & 1) r = r * n % p;       n = n * n % p;     }     return r;   }   template <class T>   inline int chkmin(T& a, const T& val) {     return val < a ? a = val, 1 : 0;   }   template <class T>   inline int chkmax(T& a, const T& val) {     return a < val ? a = val, 1 : 0;   }   inline long long isqrt(long long k) {     long long r = sqrt(k) + 1;     while (r * r > k) r--;     return r;   }   inline long long icbrt(long long k) {     long long r = cbrt(k) + 1;     while (r * r * r > k) r--;     return r;   }   inline void addmod(int& a, int val, int p = MOD) {     if ((a = (a + val)) >= p) a -= p;   }   inline void submod(int& a, int val, int p = MOD) {     if ((a = (a - val)) < 0) a += p;   }   inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }   inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }   inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }   inline int sign(long double x, long double y) { return sign(x - y); }   const int maxn = 50 + 5;   int n, p;   int c[maxn];   int f[maxn][maxn];   int p2[maxn];   int dp[maxn][maxn][maxn][2];   int calc(int pos, int u, int v, int fa) {     if (pos == n) return fa == p;     int& res = dp[pos][u][v][fa];     if (~res) return res;     res = 0;     for (int i = (0); i < (2); ++i) {       int num = c[pos] == -1 || c[pos] == i;       if (!num) continue;       int ar[] = {u, v};       for (int j = (0); j < (ar[i ^ 1] + 1); ++j) {         int add = j + 1 & 1;         ar[i] += add;         int nfa = fa + j + 1 & 1;         addmod(res,                mult(p2[pos - ar[i ^ 1]],                     mult(f[j][ar[i ^ 1]], calc(pos + 1, ar[0], ar[1], nfa))));         ar[i] -= add;       }     }     return res;   }   void chemthan() {     for (int i = (0); i < (maxn); ++i) f[0][i] = 1;     for (int i = (1); i < (maxn); ++i)       for (int j = (1); j < (maxn); ++j)         f[i][j] = (f[i][j - 1] + f[i - 1][j - 1]) % MOD;     for (int i = (0); i < (maxn); ++i) p2[i] = fpow(2, i);     cin >> n >> p;     for (int i = (0); i < (n); ++i) cin >> c[i];     memset(dp, -1, sizeof(dp));     cout << calc(0, 0, 0, 0) <<   n ;   }   int main(int argc, char* argv[]) {     ios_base::sync_with_stdio(0), cin.tie(0);     if (argc > 1) {       assert(freopen(argv[1],  r , stdin));     }     if (argc > 2) {       assert(freopen(argv[2],  wb , stdout));     }     chemthan();     cerr <<   nTime elapsed:   << 1000 * clock() / CLOCKS_PER_SEC <<  ms n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mx = 3e5 + 66;   const long long mod = 1e9 + 7;   const long long inf = 8e18 + 66;   const int llg = 25;   const long long mxk = 31700000;   long long power(long long a, long long b, long long md) {     if (b == 0) return 1;     long long c = power(a, b / 2, md);     if (b % 2)       return c * c % md * a % md;     else       return c * c % md;   }   int n, a[mx], la[mx], ra[mx], rmq[2][llg][mx], val[2][mx], lga[mx], l[llg][mx],       r[llg][mx];   int cmx(int x, int y, int b) {     if (val[b][x] < val[b][y]) return y;     return x;   }   void build(int b) {     for (int i = 1; i < 3 * n + 1; i++) {       rmq[b][0][i] = i;       if (b == 0)         val[b][i] = -la[i];       else         val[b][i] = ra[i];     }     for (int i = 1; i < lga[3 * n] + 1; i++)       for (int j = 1; j + (1 << i) - 1 <= 3 * n; j++) {         rmq[b][i][j] =             cmx(rmq[b][i - 1][j], rmq[b][i - 1][j + (1 << (i - 1))], b);       }   }   int maxq(int x, int y, int b) {     int k = lga[y - x + 1];     return cmx(rmq[b][k][x], rmq[b][k][y - (1 << k) + 1], b);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     for (int i = 2; i < mx; i++) {       lga[i] = lga[i / 2] + 1;     }     cin >> n;     if (n == 1) {       cout << 0;       return 0;     }     for (int i = 1; i < n + 1; i++) {       cin >> a[i];       a[i + n * 2] = a[i + n] = a[i];     }     for (int i = 1; i < 3 * n + 1; i++) {       la[i] = max(1, i - a[i]);       ra[i] = min(3 * n, a[i] + i);     }     for (int i = 0; i < lga[3 * n] + 1; i++) {       l[i][1] = 1;       r[i][3 * n] = 3 * n;     }     for (int i = 1; i < 3 * n + 1; i++) {       l[0][i] = la[i];       r[0][i] = ra[i];     }     build(0);     build(1);     for (int i = 1; i < lga[n * 3] + 1; i++) {       for (int j = 1; j < 3 * n + 1; j++) {         int al = maxq(l[i - 1][j], r[i - 1][j], 0);         int ar = maxq(l[i - 1][j], r[i - 1][j], 1);         l[i][j] = min(l[i - 1][al], l[i - 1][ar]);         r[i][j] = max(r[i - 1][al], r[i - 1][ar]);       }     }     for (int i = n + 1; i < 2 * n + 1; i++) {       int ans = 1, u = i, v = i;       for (int j = lga[3 * n]; j >= 0; j--) {         if (max(r[j][u], r[j][v]) - min(l[j][u], l[j][v]) < n - 1) {           int al = maxq(l[j][u], r[j][v], 0);           int ar = maxq(l[j][u], r[j][v], 1);           u = al, v = ar, ans += (1 << j);         }       }       cout << ans <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int sizes = 200001;   int main() {     long long int i, j, k, l, m, n, o, p, q, r, s, t, a[sizes], b[sizes],         booked[1001];     cin >> n;     o = 0;     for (i = 0; i < n; i++) {       cin >> a[i];       o = max(o, a[i]);     }     sort(a, a + n);     memset(b, -1, sizeof(b));     for (i = 0; i < n; i++) {       b[a[i]] = i;     }     long long int ans = 1;     for (i = 2 * 1; i <= 2 * o; i++) {       memset(booked, 0, sizeof(booked));       p = 0;       for (j = 0; j < n; j++) {         if (booked[j] == 0) {           if ((i - a[j] > 0) && b[i - a[j]] != -1) {             if (booked[b[i - a[j]]] == 0 && j != b[i - a[j]]) {               booked[j] = 1;               booked[b[i - a[j]]] = 1;               p++;             }           }         }       }       ans = max(ans, p);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e3 + 10;   long long inf = 1e18;   set<pair<long long, pair<int, int> > > s;   vector<pair<pair<int, int>, long long> > vec;   long long dp[2][maxn][maxn], arr[maxn][maxn];   long long ps[maxn][maxn];   int n, m, a, b;   bool mark[maxn][maxn];   void input() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n >> m >> a >> b;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> arr[i][j];   }   void cal_ps() {     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         ps[i + 1][j + 1] = ps[i][j + 1] + ps[i + 1][j] - ps[i][j] + arr[i][j];   }   void cal_dp() {     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) dp[0][i][j] = dp[1][i][j] = inf;     for (int j = 0; j < m; j++) {       deque<int> dq;       for (int i = 0; i < a; i++) {         while (!dq.empty() && arr[dq.back()][j] >= arr[i][j]) dq.pop_back();         dq.push_back(i);       }       dp[0][a - 1][j] = arr[dq.front()][j];       for (int i = a; i < n; i++) {         while (!dq.empty() && arr[dq.back()][j] >= arr[i][j]) dq.pop_back();         dq.push_back(i);         if (dq.front() == i - a) dq.pop_front();         dp[0][i][j] = arr[dq.front()][j];       }     }     for (int i = 0; i < n; i++) {       deque<int> dq;       for (int j = 0; j < b; j++) {         while (!dq.empty() && dp[0][i][dq.back()] >= dp[0][i][j]) dq.pop_back();         dq.push_back(j);       }       dp[1][i][b - 1] = dp[0][i][dq.front()];       for (int j = b; j < m; j++) {         while (!dq.empty() && dp[0][i][dq.back()] >= dp[0][i][j]) dq.pop_back();         dq.push_back(j);         if (dq.front() == j - b) dq.pop_front();         dp[1][i][j] = dp[0][i][dq.front()];       }     }   }   void init() {     for (int i = a - 1; i < n; i++)       for (int j = b - 1; j < m; j++) {         long long sum = ps[i + 1][j + 1] - ps[i + 1][j + 1 - b] -                         ps[i + 1 - a][j + 1] + ps[i + 1 - a][j + 1 - b] -                         a * b * dp[1][i][j];         s.insert({sum, {i - a + 1, j - b + 1}});       }   }   bool valid(int x, int y) {     if (mark[x][y]) return false;     int xx = max(0, x - a + 1), yy = max(0, y - b + 1);     for (int i = x + a - 1; i >= xx; i--)       for (int j = y + b - 1; j >= yy; j--) mark[i][j] = true;     return true;   }   int main() {     input();     cal_ps();     cal_dp();     init();     while (!s.empty()) {       auto tmp = *s.begin();       int x = tmp.second.first, y = tmp.second.second;       long long p = tmp.first;       if (valid(x, y)) vec.push_back({{x, y}, p});       s.erase(tmp);     }     cout << vec.size() <<   n ;     for (auto tmp : vec) {       cout << tmp.first.first + 1 <<     << tmp.first.second + 1 <<                << tmp.second <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200010, X = 2000010, P = 1000000007;   int n, pc, ind;   bool vis[X], chose[N];   int a[N], l[X], pr[N], fc[X];   int tag[X];   void apply(int x) {     int lst = 0, cnt = 0;     while (x != 1) {       int pp = fc[x];       x /= pp;       if (pp == lst) {         ++cnt;       } else {         if (cnt >= l[lst]) {           l[lst] = cnt;           tag[lst] = ind;         }         cnt = 1;         lst = pp;       }     }     if (cnt >= l[lst]) {       l[lst] = cnt;       tag[lst] = ind;     }   }   int main() {     for (int x = 2; x < X; ++x) {       if (!vis[x]) {         fc[x] = x;         pr[++pc] = x;       }       for (int i = 1; x * pr[i] < X; ++i) {         vis[x * pr[i]] = true;         fc[x * pr[i]] = pr[i];         if (x % pr[i] == 0) break;       }     }     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     sort(a + 1, a + n + 1, greater<int>());     for (int i = 1; i <= n; ++i) {       ind = i;       if (!l[a[i]])         apply(a[i]);       else         apply(a[i] - 1);     }     int ans = 1;     for (int i = 1; i <= pc; ++i)       while (l[pr[i]]--) ans = ans * (long long)pr[i] % P;     for (int x = 1; x < X; ++x) chose[tag[x]] = true;     ans = (ans + (count(chose + 1, chose + n + 1, true) != n)) % P;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int T = 1;     while (T--) {       long long int m, n, k, t, i;       cin >> m >> n >> k >> t;       vector<long long int> sol(m);       for (i = 0; i < m; i++) cin >> sol[i];       sort((sol).begin(), (sol).end());       vector<pair<long long int, pair<long long int, long long int>>> traps(k);       for (i = 0; i < k; i++) {         cin >> traps[i].first >> traps[i].second.first >> traps[i].second.second;       }       sort((traps).begin(), (traps).end());       long long int l, r, mid;       l = 0;       r = 200005;       long long int ans = r;       while (l <= r) {         mid = (l + r) / 2;         long long int tm = n + 1;         long long int donest = -1;         long long int doneend = -1;         for (auto x : traps) {           if (x.second.second > mid) {             if (donest == -1) {               donest = x.first;               doneend = x.second.first;             } else if (x.first <= doneend) {               doneend = max(doneend, x.second.first);             } else {               tm += 2 * (doneend - donest + 1);               donest = x.first;               doneend = x.second.first;             }           }         }         if (donest != -1) {           tm += 2 * (doneend - donest + 1);         }         if (tm <= t) {           r = mid - 1;           ans = min(ans, mid);         } else           l = mid + 1;       }       ans = lower_bound((sol).begin(), (sol).end(), ans) - sol.begin();       cout << m - ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, c, d, a, b, i;     cin >> n >> a >> b;     c = b, d = c;     for (i = 2; i <= n; i++) {       cin >> a >> b;       c = max(c, d - a + b);       d = d - a + b;     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000, MD = 1000000007;   char aa[N + 1], bb[N + 1], cc[N * 3];   int zz[N * 3];   void mult(int aa[][2], int bb[][2], int cc[][2]) {     for (int i = 0; i < 2; i++)       for (int j = 0; j < 2; j++) {         long long c = 0;         for (int k = 0; k < 2; k++) c += (long long)aa[i][k] * bb[k][j];         cc[i][j] = c % MD;       }   }   void power(int aa[][2], int pp[][2], int tt[][2], int k) {     if (k == 0) {       pp[0][0] = 1, pp[0][1] = 0;       pp[1][0] = 0, pp[1][1] = 1;       return;     }     if (k & 1) {       power(aa, pp, tt, k >> 1);       mult(pp, pp, tt);       mult(tt, aa, pp);     } else {       power(aa, tt, pp, k >> 1);       mult(tt, tt, pp);     }   }   int main() {     int k;     cin >> aa >> bb >> k;     int n = strlen(aa);     for (int i = 0; i < n; i++) {       cc[i] = bb[i];       cc[n + i] = cc[n + n + i] = aa[i];     }     for (int l = 0, r = 0, i = 1; i < n * 3; i++)       if (i + zz[i - l] < r)         zz[i] = zz[i - l];       else {         l = i;         if (r < l) r = l;         while (r < n * 3 && cc[r] == cc[r - l]) r++;         zz[i] = r - l;       }     int a = 0;     for (int i = n; i < n + n; i++)       if (zz[i] >= n) a++;     int b = n - a;     int aa[2][2], pp[2][2], tt[2][2];     aa[0][0] = a - 1, aa[0][1] = a;     aa[1][0] = b, aa[1][1] = b - 1;     power(aa, pp, tt, k);     int ans = zz[n] >= n ? pp[0][0] : pp[0][1];     if (ans < 0) ans += MD;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e5 + 5;   const int inf = 1e9 + 5;   const int mod = 1e9 + 7;   vector<int> v[M];   int hx2[2 * M];   int hx[M];   int nxt[M];   int n, m;   int KMP() {     memset(nxt, 0, sizeof(nxt));     int la, lb;     la = n;     lb = m;     int j, k;     j = 0;     k = -1;     nxt[0] = -1;     while (j < la) {       if (k == -1 || hx[j] == hx[k]) {         j++;         k++;         nxt[j] = k;       } else {         k = nxt[k];       }     }     int ans = 0;     j = 0;     k = 0;     while (k < lb) {       if (j == -1 || hx[j] == hx2[k]) {         j++;         k++;       } else {         j = nxt[j];       }       if (j == la) {         j = nxt[j];         ans++;       }     }     return ans;   }   int main() {     int k;     scanf( %d%d , &n, &k);     m = 2 * n;     for (int i = 0; i < k; i++) {       int a, b;       scanf( %d%d , &a, &b);       if (a > b) swap(a, b);       v[a].push_back(min(b - a, n - b + a));       v[b].push_back(min(b - a, n - b + a));     }     for (int i = 0; i < n; i++) {       sort(v[i + 1].begin(), v[i + 1].end());       for (int j = 0; j < v[i + 1].size(); j++) {         hx[i] = hx[i] * n + v[i + 1][j];       }     }     for (int i = 0; i < n; i++) {       hx2[i] = hx[i];       hx2[i + n] = hx[i];     }     if (KMP() <= 2) {       printf( No n );     } else {       printf( Yes n );     }     return 0;   }