malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include<bits/stdc++.h>   using namespace std;   #define int long long      int n, k;      int mod(int i){return (i%n+n)%n;}      int q(int x){    x = mod(x) + 1;    cout <<  ?   << x << endl;    int ret; cin >> ret;    return ret;   }      int32_t main(){    cin >> n >> k;    int i=0, j=0, x;    int lo, hi;    while(1){     x = q(j);     if(x > k){lo = j-i-i, hi = j; break;}     if(x < k){lo = j, hi = j+i+i; break;}     j += i; ++i;    }    while(lo <= hi){     int mid = (lo+hi)/2;     int x = q(mid);     if(x == k){      cout <<  !   << mod(mid) + 1 << endl;      exit(0);     }     if(x < k) lo = mid+1;     else hi = mid-1;    }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 55;   char arr[N][N] = {};   bool vis[N][N] = {};   int n, m;   inline bool valid(int nx, int ny) {     return (nx >= 1 && nx <= n && ny >= 1 && ny <= m && !vis[nx][ny] &&             arr[nx][ny] ==  # );   }   void dfs(int xx, int yy) {     vis[xx][yy] = true;     for (int i = -1; i <= (int)1; ++i) {       for (int j = -1; j <= (int)1; ++j) {         if (j != i && (!j || !i)) {           int nx = xx + i;           int ny = yy + j;           if (valid(nx, ny)) dfs(nx, ny);         }       }     }   }   int main() {     ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0),         cout.tie(0);     ;     cin >> n >> m;     for (int i = 1; i <= (int)n; ++i)       for (int j = 1; j <= (int)m; ++j) cin >> arr[i][j];     int z = 0;     for (int x = 1; x <= (int)n; ++x) {       for (int y = 1; y <= (int)m; ++y) {         if (arr[x][y] ==  # ) {           z++;           arr[x][y] =  . ;           int cmp = 0;           memset(vis, 0, sizeof(vis));           ;           for (int i = 1; i <= (int)n; ++i) {             for (int j = 1; j <= (int)m; ++j) {               if (!vis[i][j] && arr[i][j] ==  # ) {                 dfs(i, j);                 ++cmp;               }             }           }           if (cmp >= 2) return cout << 1 <<   n , 0;           arr[x][y] =  # ;         }       }     }     if (z <= 2) return cout << -1 <<   n , 0;     return cout << 2 <<   n , 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 10;   int gi() {     int x = 0, o = 1;     char ch = getchar();     while (!isdigit(ch) && ch !=  - ) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   int n, m, f[N], id[N], dfn[N], tim, fa[N], fe[N], u[N], v[N], w[N];   bool in[N];   vector<pair<int, int> > E[N];   void dfs(int u) {     dfn[u] = ++tim;     for (auto e : E[u]) {       int v = e.first;       if (v != fa[u]) {         if (!dfn[v])           fa[v] = u, fe[v] = e.second, dfs(v);         else if (dfn[v] > dfn[u]) {           int x = v;           vector<int> vec = {e.second};           do vec.push_back(fe[x]), x = fa[x];           while (x != u);           rotate(vec.begin(), min_element(vec.begin(), vec.end()), vec.end());           int p = max_element(vec.begin(), vec.end()) - vec.begin();           bool fl = 1;           for (int i = 0; i < p && fl; i++)             if (vec[i] > vec[i + 1]) fl = 0;           for (int i = p; i < int(vec.size()) - 1 && fl; i++)             if (vec[i] < vec[i + 1]) fl = 0;           if (fl) id[vec[0]] = vec[p];         }       }     }   }   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++)       u[i] = gi(), v[i] = gi(), E[u[i]].push_back(make_pair(v[i], i)),       E[v[i]].push_back(make_pair(u[i], i));     dfs(1);     for (int i = 1; i <= n; i++) f[i] = 1;     for (int i = m; i; i--) {       w[i] = f[u[i]] + f[v[i]];       f[u[i]] = f[v[i]] = w[i] - w[id[i]];     }     for (int i = 1; i <= n; i++) cout << f[i] - 1 <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int i, n, k;     cin >> n >> k;     if ((k == 1 && n > 1) || k > n) {       cout <<  -1 ;     } else {       if (n == 1 && k == 1) {         cout <<  a ;         return 0;       }       string str;       for (i = 0; i < n - (k - 2); i++)         if (i % 2 == 0)           str.push_back( a );         else           str.push_back( b );       char ch =  c ;       for (; i < n; i++) str.push_back(ch++);       cout << str;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5, maxh = 3;   int mod[maxh] = {(int)1e9 + 7, (int)1e9 + 9, (int)998244353};   struct data {     int v[maxh];     data(int a = 0, int b = 0, int c = 0) {       v[0] = a;       v[1] = b;       v[2] = c;     }     int& operator[](int w) { return v[w]; }     friend data operator+(data a, data b) {       for (int i = 0; i < maxh; ++i) a[i] = (a[i] + b[i]) % mod[i];       return a;     }     friend data operator+(data a, int b) {       for (int i = 0; i < maxh; ++i) a[i] = (a[i] + b) % mod[i];       return a;     }     friend data operator*(data a, data b) {       for (int i = 0; i < maxh; ++i) a[i] = 1ll * a[i] * b[i] % mod[i];       return a;     }     friend data operator*(data a, int b) {       for (int i = 0; i < maxh; ++i) a[i] = 1ll * a[i] * b % mod[i];       return a;     }     friend bool operator==(data a, data b) {       for (int i = 0; i < maxh; ++i)         if (a[i] != b[i]) return false;       return true;     }     friend data operator-(data a, data b) {       for (int i = 0; i < maxh; ++i)         a[i] = ((a[i] - b[i]) % mod[i] + mod[i]) % mod[i];       return a;     }     void print() { cout << v[0] <<     << v[1] <<     << v[2] <<   n ; }   };   data H[N], Pow[N];   int n;   char s[N];   data geth(int L, int R) { return H[R] - H[L - 1] * Pow[R - L + 1]; }   vector<int> Ans;   int main() {     scanf( %d%s , &n, s + 1);     Pow[0] = data(1, 1, 1);     for (int i = 1; i <= n; ++i) Pow[i] = Pow[i - 1] * 1331;     for (int i = 1; i <= n; ++i) H[i] = (H[i - 1] * 1331) + (int)s[i];     for (int i = (n + 1) / 2, lst = 10000000, cur; i >= 1; --i) {       int st = i, ed = n + 1 - st, mx = min(lst + 2, ed - st);       mx -= (mx % 2 == 0);       cur = -1;       for (int t = mx; t >= 1; t -= 2)         if (geth(st, st + t - 1) == geth(ed - t + 1, ed)) {           cur = t;           break;         }       Ans.push_back(cur);       lst = cur;     }     reverse(Ans.begin(), Ans.end());     for (auto x : Ans) cout << x <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int l, r;       cin >> l >> r;       if (l * 2 <= r) {         cout << l <<     << l * 2 << endl;       } else {         cout << -1 <<     << -1 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int SIZE = 1e6 + 10;   using namespace std;   int main() {     long long m, h1, a1, x1, y1, h2, a2, x2, y2;     cin >> m >> h1 >> a1 >> x1 >> y1 >> h2 >> a2 >> x2 >> y2;     long long res1 = 0, per1 = 0, now = h1, now3 = h1, now4 = h2, p = 0;     for (int i = 0; i < (20000000); ++i) {       now = (now * x1 + y1) % m;       res1++;       if (now == a1)         break;       else if (i == 19999999) {         cout << -1;         return 0;       }     }     for (int i = 0; i < (10000000); ++i) {       now3 = (now3 * x1 + y1) % m;       now4 = (now4 * x2 + y2) % m;       p++;       if (now3 == a1 && now4 == a2) {         cout << p;         return 0;       }     }     for (int i = 0; i < (20000000); ++i) {       now = (now * x1 + y1) % m;       per1++;       if (now == a1) break;     }     long long res2 = 0, per2 = 0, now2 = h2;     for (int i = 0; i < (9999999); ++i) {       now2 = (now2 * x2 + y2) % m;       res2++;       if (now2 == a2)         break;       else if (i == 9999998) {         cout << -1;         return 0;       }     }     for (int i = 0; i < (20000000); ++i) {       now2 = (now2 * x2 + y2) % m;       per2++;       if (now2 == a2) break;     }     for (int i = 0; i < (2000000); ++i) {       if (res1 == res2) {         cout << res1;         return 0;       }       if (res1 > res2)         res2 += per2;       else if (res2 > res1)         res1 += per1;     }     cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, dp[105], a, b;     memset(dp, 0, sizeof dp);     cin >> n;     for (int i = 1; i < n; ++i) {       cin >> dp[i];       dp[i] += dp[i - 1];     }     cin >> a >> b;     cout << dp[b - 1] - dp[a - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double pi = acos(-1);   void OJ() {}   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     cin >> t;     while (t--) {       long long n, x, od = 0, ev = 0;       cin >> n >> x;       for (long long i = 0; i < n; i++) {         long long temp;         cin >> temp;         if (temp & 1)           od++;         else           ev++;       }       if (ev >= x) {         if (od)           cout <<  YES n ;         else           cout <<  NO n ;         continue;       } else {         if (ev > 0) {           if (od % 2 == 0) od--;           if (ev + od >= x) {             cout <<  YES n ;             continue;           }         } else {           if (x & 1)             cout <<  YES n ;           else             cout <<  NO n ;           continue;         }       }       cout <<  NO n ;     }   }
#include <bits/stdc++.h>   using namespace std;   bool sortp(const pair<int, int> a, const pair<int, int> b) {     if (a.first > b.first)       return 0;     else if (a.first < b.first)       return 1;     else       return a.second > b.second;   }   int main() {     int n, m;     cin >> n >> m;     pair<int, int> b;     vector<pair<int, int>> a;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       b.first = x;       b.second = y;       a.push_back(b);     }     sort(a.begin(), a.end(), sortp);     int flag = 0;     for (int i = 0; i < m; i++) {       if (n <= a[i].first) {         cout <<  NO  << endl;         flag = 1;         break;       } else {         n += a[i].second;       }     }     if (flag == 0) {       cout <<  YES  << endl;     }   }
#include<bits/stdc++.h>   #define int long long   #define p pair<int, int>   #define endl   n    const int INF = 1000000001;      using namespace std;      int A(int k, int n, int C){       int ans = 1;       for (int q = n; q > n-k; q--){           ans = ans*q % C;       }       return ans;   }      signed main(){       ios::sync_with_stdio(false);       cin.tie(nullptr);       cout.tie(nullptr);       int n, C;       cin >> n >> C;       int k = n*(n-1)/2;       int num[n+1][k+1], pref[n+1][k+2];       num[1][0] = 1, pref[1][0] = 0;       fill(num[1]+1, num[1]+k+1, 0);       fill(pref[1]+1, pref[1]+k+2, 1);       for (int q = 2; q <= n; q++){           for (int q1 = 0; q1 <= k; q1++){               num[q][q1] = ((pref[q-1][q1+1]-pref[q-1][max(0LL, q1-q+1)]) % C+C) % C;           }           pref[q][0] = 0;           for (int q1 = 1; q1 <= k+1; q1++){               pref[q][q1] = (pref[q][q1-1]+num[q][q1-1]) % C;           }       }       int d[n+1];       fill(d, d+n+1, 0);       for (int q = 2; q <= n; q++){           for (int q1 = 1; q1 < q; q1++){               for (int q3 = 0; q3 <= k; q3++){                   d[q] += num[q-1][q3]*(pref[q-1][k+1]-pref[q-1][min(k+1, q3+q1+1)]) % C*(q-q1) % C;               }           }           d[q] = (d[q] % C+C) % C;       }       int ans = 0;       for (int q = 0; q < n; q++){           ans += d[n-q]*A(q, n, C) % C;       }       cout << ans % C << endl;       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const int INF = 0x3f3f3f3f;   const int MOD = 1e9 + 7;   const double EPS = 1e-9;   int n, k, deg[1000015], ans, vis[1000015];   vector<int> e[1000015];   int dfs(int u) {     if (e[u].size() == 1) return 1;     vis[u] = 1;     vector<int> d;     for (int i = 0; i < e[u].size(); ++i) {       int v = e[u][i];       if (vis[v]) continue;       int x = dfs(v);       if (~x) d.push_back(x);     }     sort(d.begin(), d.end());     if (0 == d.size()) {       return -1;     } else if (1 == d.size()) {       if (d[0] >= k) {         ++ans;         return -1;       } else {         return ~d[0] ? d[0] + 1 : d[0];       }     }     int i = 0;     while (i + 1 < d.size() && d[i] + d[i + 1] <= k) ++i;     ans += d.size() - i - 1;     return ~d[i] ? d[i] + 1 : d[i];   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i < n; ++i) {       int u, v;       scanf( %d%d , &u, &v);       ++deg[u], ++deg[v];       e[u].push_back(v), e[v].push_back(u);     }     for (int i = 1; i <= n; ++i) {       if (1 != deg[i]) {         if (~dfs(i)) ++ans;         break;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 2e18 + 7;   const long long mod = 1e9 + 7;   const double eps = 1e-9;   const double PI = 2 * acos(0.0);   const double E = 2.71828;   int n;   pair<int, int> a[200005];   int main(void) {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       int x, y;       scanf( %d %d , &x, &y);       a[i] = {x + y, x - y};     }     sort(a, a + n);     int mx = -mod;     int res = 0;     for (int i = 0; i < n; ++i) {       if (mx <= a[i].second) {         mx = a[i].first;         ++res;       }     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     int a, b, q;     cin >> q;     for (int i = 0; i < q; i++) {       cin >> n >> a >> b;       if (a * 2 <= b)         cout << n * a << endl;       else {         {           if (n % 2 == 0)             cout << b * n / 2 << endl;           else             cout << b * (n / 2) + a << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int64_t max(int32_t a, int64_t b) { return max((int64_t)a, b); }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     pair<int64_t, int64_t> lc, rc;     cin >> rc.second >> rc.first;     lc.first = lc.second = 1;     int64_t k;     cin >> k;     int64_t cnt = 0;     int64_t ans = 0;     int64_t cur = 1;     while (cnt < k) {       ans += (rc.first - lc.first + 1) * (rc.second - lc.second + 1);       rc.first--;       rc.second--;       lc.second++;       lc.first++;       ans -= (rc.first - lc.first + 1) * (rc.second - lc.second + 1);       cnt++;       rc.first--;       rc.second--;       lc.second++;       lc.first++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     cin >> T;     while (T--) {       long long n, side = 0, ans = 0;       cin >> n;       int i = (n + 1) % 4;       if (i == 0)         ans = n + 1;       else if (i == 1 || i == 3)         ans = 4 * n + 1;       else         ans = 2 * n + 1;       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2, s;     cin >> s1 >> s2 >> s;     string s3 = s1 + s2;     sort(s3.begin(), s3.end());     sort(s.begin(), s.end());     if (s == s3)       cout <<  YES n ;     else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   struct node {     int x, y, next;   } e[100861];   int head[100861], book[100861] = {0}, b[100861];   int main() {     memset(head, -1, sizeof(head));     int n, m, a;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &e[i].x, &e[i].y);       e[i].next = head[e[i].x];       head[e[i].x] = i;       book[e[i].y]++;     }     int sum = 0, flag = 1, maxx = 0, f;     for (int i = 1; i <= n; i++)       if (book[i] == 0) {         b[sum++] = i;       }     if (sum != 1) flag = 0;     for (int i = 0; i < sum; i++) {       int num = 0;       for (int j = head[b[i]]; j != -1; j = e[j].next) {         book[e[j].y]--;         if (book[e[j].y] == 0) {           b[sum++] = e[j].y;           num++;           if (j > maxx) maxx = j;         }       }       if (num > 1) flag = 0;     }     if (flag == 0 || sum < n)       printf( -1 n );     else       printf( %d n , maxx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void reader() {}   const long long MOD = 1e9 + 7;   const long long N = 3e7 + 5;   const long long inf = 1e18;   long long Set(long long qq, long long pos) { return (qq | (1 << pos)); }   long long chk(long long qq, long long pos) { return (qq & (1 << pos)); }   void solve() {     long long n, first, second;     cin >> n >> first >> second;     vector<long long> dp(n + 1);     dp[1] = first;     dp[0] = 0;     for (long long i = 2; i <= n; i++) {       if (i % 2 == 0)         dp[i] = min(dp[i - 1] + first, dp[i / 2] + second);       else         dp[i] = min(dp[(1 + i) / 2] + first + second, dp[i - 1] + first);     }     cout << dp[n];   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     reader();     solve();   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100100;   int ar[MAXN];   int N;   int main() {     int sum = 0;     for (int i = 0; i < 6; ++i) {       scanf( %d , ar + i);       sum ^= ar[i];     }     sort(ar, ar + 6);     if (ar[0] != ar[3] && ar[1] != ar[4] && ar[2] != ar[5]) {       printf( Alien n );     } else if (sum) {       printf( Bear n );     } else {       printf( Elephant n );     }   }
#include <bits/stdc++.h>   using namespace std;   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;   }   int n, a, b;   void solve() {     cin >> n >> a >> b;     string s;     cin >> s;     a--;     b--;     if (s[a] == s[b]) {       cout << 0;     } else {       cout << 1;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   int main() {     int n1, n2, n3, n4, n5, n6 = 0;     std::cin >> n1 >> n2 >> n3 >> n4;     for (int i = 0; i < n4; i++) {       std::cin >> n5;       if (n5 > n2 && n5 < n3 && n1 > n2 && n1 < n3) n6++;     }     std::cout << n6;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const int N = 110031;   long long n, m;   vector<vector<long long> > one(int sz) {     vector<vector<long long> > ret;     ret.resize(sz);     for (int i = 0; i < ret.size(); i++) {       ret[i].resize(sz);       for (int j = 0; j < ret.size(); j++) {         ret[i][j] = (i == j);       }     }     return ret;   }   vector<vector<long long> > mult(vector<vector<long long> > a,                                   vector<vector<long long> > b) {     vector<vector<long long> > ret;     ret.resize(a.size());     for (int i = 0; i < ret.size(); i++) {       ret[i].resize(a.size());       for (int j = 0; j < ret.size(); j++) {         ret[i][j] = 0;       }     }     for (int k = 0; k < ret.size(); k++) {       for (int i = 0; i < a.size(); i++) {         for (int j = 0; j < b.size(); j++) {           ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]);           ret[i][j] %= 1000000007;         }       }     }     return ret;   }   vector<vector<long long> > pw(vector<vector<long long> > a, long long b) {     if (b == 0) return one((int)a.size());     if (b % 2) return mult(a, pw(a, b - 1));     return pw(mult(a, a), b / 2);   }   vector<vector<long long> > dp;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     dp.resize(m);     for (int i = 0; i < m; i++) {       dp[i].resize(m);     }     for (int i = 0; i < dp.size(); i++) {       for (int j = 0; j < dp.size(); j++) {         dp[i][j] = 0;       }     }     for (int i = 0; i < dp.size(); i++) {       dp[i][(i + 1) % m]++;     }     dp[0][0]++;     dp = pw(dp, n);     cout << dp[0][0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();     return x * f;   }   int n, m, f[4005][4005], l[4005], s[4005], c[4005];   int main() {     n = read(), m = read() + n;     for (int i = n; i >= 1; --i) l[i] = read();     for (int i = n; i >= 1; --i) s[i] = read();     for (int i = 1; i <= m; ++i) c[i] = read();     memset(f, -0x3f, sizeof(f));     for (int i = 0; i <= m; ++i) f[i][0] = 0;     for (int i = 1; i <= n; ++i) {       for (int j = n; j >= 1; --j)         f[l[i]][j] = max(f[l[i]][j], f[l[i]][j - 1] + c[l[i]] - s[i]);       for (int j = l[i]; j < m; ++j) {         for (int k = 0; k <= (n >> j - l[i]); ++k) {           f[j + 1][k / 2] = max(f[j + 1][k / 2], f[j][k] + k / 2 * c[j + 1]);         }       }     }     cout << f[m][0];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[10005];   int vis[100005];   void init() {     f[1] = 1;     f[2] = 1;     vis[1] = 1;     for (int i = 3; i <= 20; i++) {       f[i] = f[i - 1] + f[i - 2];       vis[f[i]] = 1;     }   }   int main() {     int n;     scanf( %d , &n);     init();     for (int i = 1; i <= n; i++) {       if (vis[i] == 1)         printf( O );       else         printf( o );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   string s, t;   int pre[maxn][26], pos[26];   int f[maxn];   int g[maxn];   void solve(string &s, string &t, int f[]) {     for (int i = 0; i < 26; i++) pos[i] = -1;     int n = t.size(), m = s.size();     for (int i = 0; i <= n; i++) {       for (int j = 0; j < 26; j++) {         pre[i][j] = pos[j];       }       if (i < n) pos[t[i] -  a ] = i;     }     int len = 0;     for (int i = 0; i < m; i++) {       if (len < n && s[i] == t[len]) {         f[i] = ++len;       } else {         f[i] = pre[len][s[i] -  a ] + 1;       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> s >> t;     solve(s, t, f);     reverse(s.begin(), s.end());     reverse(t.begin(), t.end());     solve(s, t, g);     bool ok = true;     int m = s.size(), n = t.size();     for (int i = 0; i < m; i++) {       if (f[i] + g[m - i - 1] - 1 < n) {         ok = false;         break;       }     }     if (ok)       cout <<  Yes n ;     else       cout <<  No n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long sqr(long long x) { return (x * x); }   inline long long dist(pair<long long, long long> a,                         pair<long long, long long> b) {     return sqr(a.first - b.first) + sqr(a.second - b.second);   }   int main() {     vector<pair<long long, pair<long long, long long> > > a;     int d;     double answer;     int n;     scanf( %d , &n);     long long x, y, r;     for (int i = 0; i < n; i++) {       scanf( %I64d %I64d %I64d , &x, &y, &r);       a.push_back(make_pair(r, make_pair(x, y)));     }     sort(a.begin(), a.end());     for (int i = 0; i < n; i++) {       d = 0;       for (int j = i + 1; j < n; j++)         if (dist(a[i].second, a[j].second) <= sqr(a[j].first)) d++;       answer += (double)acos(-1) * sqr(a[i].first) * ((!d || d & 1) ? 1 : -1);     }     printf( %.10lf n , answer);     return 0;   }
#include <iostream>   #include <cmath>      using namespace std;       const int N=2e3+3;   int a[N];   int b[N];       int main(){    int n;    cin>>n;    n<<=1;    for(int i=1;i<=n;i++) cin>>a[i];        int ans=n;        for(int C=0;C<=1;C++){        for(int j=1;j<=n;j++) b[j]=a[j];        int cnt=0;    for(int i=0;i<n;i++){     int ok=1;     for(int j=1;j<=n;j++) ok&=b[j]==j;     if(ok) ans=min(ans,i);          if(cnt^C) for(int j=1;j<=n;j+=2) swap(b[j],b[j+1]);     else for(int j=1;j<=n>>1;j++) swap(b[j],b[j+n/2]);          cnt^=1;     }       }       if(ans==n) cout<<-1;       else cout<<ans;   }