malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e3 + 5;   bool adj1[MAXN][MAXN], adj2[MAXN][MAXN];   vector<pair<int, int> > ans1, ans2;   int n;   void comp1(int a, int b) {     if (b - a == 1) return;     for (int i = a + 1; i < b; ++i) {       if (adj1[1][i] == 1) {         comp1(a, i);         comp1(i, b);         return;       }     }     assert(adj1[a][b] == 1);     for (int i = a + 1; i < b; ++i) {       if (adj1[i][a] * adj1[i][b] == 1) {         ans1.push_back(make_pair(a, b));         adj1[a][b] = adj1[b][a] = 0;         adj1[1][i] = adj1[i][1] = 1;         comp1(a, i);         comp1(i, b);         return;       }     }   }   void comp2(int a, int b) {     if (b - a == 1) return;     for (int i = a + 1; i < b; ++i) {       if (adj2[1][i] == 1) {         comp2(a, i);         comp2(i, b);         return;       }     }     assert(adj2[a][b] == 1);     for (int i = a + 1; i < b; ++i) {       if (adj2[i][a] * adj2[i][b] == 1) {         ans2.push_back(make_pair(1, i));         adj2[a][b] = adj2[b][a] = 0;         adj2[1][i] = adj2[i][1] = 1;         comp2(a, i);         comp2(i, b);         return;       }     }   }   int main() {     cin >> n;     for (int i = 0; i < n - 3; ++i) {       int u, v;       cin >> u >> v;       adj1[u][v] = adj1[v][u] = 1;     }     for (int i = 0; i < n - 3; ++i) {       int u, v;       cin >> u >> v;       adj2[u][v] = adj2[v][u] = 1;     }     for (int i = 0; i < n; ++i) {       adj1[i + 1][(i + 1) % n + 1] = adj1[(i + 1) % n + 1][i + 1] =           adj2[i + 1][(i + 1) % n + 1] = adj2[(i + 1) % n + 1][i + 1] = 1;     }     comp1(2, n);     comp2(2, n);     cout << ans1.size() + ans2.size() << endl;     for (int i = 0; i < ans1.size(); ++i)       cout << ans1[i].first <<     << ans1[i].second << endl;     for (int i = ans2.size() - 1; i >= 0; --i)       cout << ans2[i].first <<     << ans2[i].second << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long parent[1000001];   long long result[1000005];   map<int, list<int>> g;   long long getPoints(int p, int t) {     return max((3 * p) / 10, (p - (p / 250) * t));   }   struct Score {     int p, t;   };   bool chc(Score a, Score b) {     if (a.p == b.p) {       return a.t < b.t;     } else {       return a.p < b.p;     }   }   void solve() {     int n;     cin >> n;     int tf = 0, fifty = 0;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       int x = a[i];       if (x == 25) {         tf++;       } else if (x == 50) {         if (tf == 0) {           cout <<  NO n ;           return;         } else {           tf--;         }         fifty++;       } else if (x == 100) {         if (fifty > 0 && tf > 0) {           fifty--;           tf--;         } else if (tf > 2) {           tf = tf - 3;         } else {           cout <<  NO n ;           return;         }       }     }     cout <<  YES n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 1e5 + 7;   int n, m;   vector<tuple<int, int, int>> res;   vector<pair<int, int>> g[maxN];   bool blocked[maxN];   bool solve(int v, int pr = -1) {     vector<int> unpaired;     vector<int> adj;     for (auto& to : g[v]) {       if (!blocked[to.second]) {         adj.push_back(to.first);       }       blocked[to.second] = true;     }     for (auto& to : adj) {       if (solve(to, v)) {         unpaired.push_back(to);       }     }     while (unpaired.size() >= 2) {       int first = unpaired.back();       unpaired.pop_back();       int second = unpaired.back();       unpaired.pop_back();       res.push_back(make_tuple(first, v, second));     }     if (unpaired.size() > 0) {       int vertex = unpaired.back();       unpaired.pop_back();       res.push_back(make_tuple(pr, v, vertex));       return false;     }     return true;   }   int main() {     scanf( %d %d , &n, &m);     if (m % 2 == 1) {       printf( No solution n );       return 0;     }     for (int i = 0; i < m; ++i) {       int a, b;       scanf( %d %d , &a, &b);       g[a].push_back({b, i});       g[b].push_back({a, i});     }     solve(1);     for (auto& x : res) {       printf( %d %d %d n , get<0>(x), get<1>(x), get<2>(x));     }     return 0;   }
#include <bits/stdc++.h>   const int mod = 1e9 + 7;   int n, m;   inline long long ksm(register int y, register int p) {     long long x = y, now = 1;     while (p) {       if (p & 1) now = now * x % mod;       x = x * x % mod, p >>= 1;     }     return now;   }   int main() {     scanf( %d%d , &n, &m);     printf( %lld , ksm(2, m) % mod * ksm(n + 1, m - 1) % mod * (n + 1 - m) % mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char** argv) {     int n, x, p, min = 0, max = 1000;     cin >> n >> x;     p = x;     for (int i = 0; i < n; i++) {       int a, b;       cin >> a >> b;       if (a < b) {         if ((p >= a) && (p <= b)) {           if (a > min) min = a;           if (b < max) max = b;         } else if (p < a) {           if (a <= max) {             p = a;             if (a > min) min = a;             if (b < max) max = b;           } else {             cout << -1;             return 0;           }         } else if (p > b) {           if (b >= min) {             p = b;             if (a > min) min = a;             if (b < max) max = b;           } else {             cout << -1;             return 0;           }         }       } else {         if ((p >= b) && (p <= a)) {           if (b > min) min = b;           if (a < max) max = a;         } else if (p < b) {           if (b <= max) {             p = b;             if (b > min) min = b;             if (a < max) max = a;           } else {             cout << -1;             return 0;           }         } else if (p > a) {           if (a >= min) {             p = a;             if (b > min) min = b;             if (a < max) max = a;           } else {             cout << -1;             return 0;           }         }       }     }     if ((p - x) >= 0)       cout << p - x;     else       cout << x - p;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> graph[250];   long long int n, a[250];   long long int visit[250];   long long int sol(long long int pos) {     memset(visit, 0, sizeof(visit));     long long int ans = 0;     long long int c = 0;     while (c <= n) {       long long int f = 0;       for (long long int i = 1; i <= n; i++) {         if (a[i] != pos || visit[i]) {           continue;         }         long long int ff = 1;         for (auto p : graph[i]) {           if (!visit[p]) {             ff = 0;             break;           }         }         if (ff) {           f = 1;           ans++;           c++;           visit[i] = 1;         }       }       if (c == n) {         break;       }       if (!f) {         pos++;         ans++;         if (pos == 4) {           pos = 1;         }       }     }     return ans;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (long long int i = 1; i <= n; i++) {       cin >> a[i];     }     for (long long int i = 1; i <= n; i++) {       long long int k;       cin >> k;       for (long long int j = 1; j <= k; j++) {         long long int tl;         cin >> tl;         graph[i].push_back(tl);       }     }     long long int ans = 1e18;     for (long long int i = 1; i <= 3; i++) {       ans = min(ans, sol(i));     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int mat[505][505];   const int N = 3e5 + 10, C = 26, inf = 1e7;   bool check(int i, int j) {     if ((i - 1 > 0 || i - 1 == 0) && mat[i - 1][j] == 1) {       return 1;     }     if ((j - 1 > 0 || j - 1 == 0) && mat[i][j - 1] == 1) {       return 1;     }     if (mat[i + 1][j] == 1 && i < n) {       return 1;     }     if (mat[i][j + 1] == 1 && j < m) {       return 1;     }     return 0;   }   void FUSE() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         char t;         cin >> t;         if (t ==  S )           mat[i][j] = -1;         else if (t ==  W )           mat[i][j] = 1;         else           mat[i][j] = 0;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (mat[i][j] == -1 && check(i, j)) {           cout <<  No n ;           return;         }       }     }     cout <<  Yes n ;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (mat[i][j] == -1)           cout <<  S ;         else if (mat[i][j] == 1)           cout <<  W ;         else           cout <<  D ;       }       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     while (T--) {       FUSE();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e5 + 100;   int dp[N];   int b[N];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> b[i];     int Max = 0;     vector<int> v;     for (int i = 0; i < n; i++) {       while (!v.empty()) {         int ind = v.back();         if (b[ind] < b[i]) {           dp[i] = max(dp[i], dp[ind] + 1);           v.pop_back();         } else {           dp[i] = max(dp[i], 1);           break;         }       }       if (v.empty()) dp[i] = 0;       Max = max(Max, dp[i]);       v.push_back(i);     }     cout << Max;     cin >> n;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[9] = {0, 1, -1, 0, 0, -1, -1, 1, 1};   const int dy[9] = {0, 0, 0, -1, 1, -1, 1, -1, 1};   const double pi = acos(-1.0);   const int N = 110;   long long n, m, ans;   void input_data() { cin >> n >> m; }   void get_ans() {     if (n <= m) {       ans = n;       return;     }     n -= (m + 1);     if (n <= 0) {       ans = m + 1;       return;     }     long long l = 0, r = 2e9 + 2, t = 0;     ans = m;     while (l <= r) {       long long mid = (l + r) >> 1;       long long temp = (mid + 2) * (mid - 1) / 2;       if (temp >= n) {         t = mid;         r = mid - 1;       } else         l = mid + 1;     }     ans += t;   }   void o() { cout << ans << endl; }   int main() {     input_data();     get_ans();     o();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void solve() {     int n, x;     cin >> n >> x;     vector<int> cs(n);     for (auto& c : cs) {       cin >> c;     }     int c_sum = accumulate(cs.begin(), cs.end(), 0);     vector<vector<T>> mass(n + 1, vector<T>(c_sum + 1, 0));     mass[0][0] = T(1);     for (int c : cs) {       for (int k = n - 1; k >= 0; --k) {         for (int s = c_sum - c; s >= 0; --s) {           mass[k + 1][s + c] += T(k + 1) / T(n - k) * mass[k][s];         }       }     }     T answer(0);     for (int k = 1; k <= n; ++k) {       for (int s = 0; s <= c_sum; ++s) {         answer +=             min(T(s) / T(k), T(x) / T(2) * (T(1) + T(n) / T(k))) * mass[k][s];       }     }     printf( %.17f n , (double)answer);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     solve<double>();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 210;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   long long LCM = 1, limit, X;   int n, a[MAXN];   bool inCir[MAXN];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++) {       int x = i, Len = 0;       for (int j = 1; j <= n; j++) x = a[x];       while (!inCir[x]) inCir[x] = true, x = a[x], Len++;       if (Len) LCM = lcm(LCM, Len);     }     for (int i = 1; i <= n; i++) {       int x = i, Len = 0;       while (!inCir[x]) x = a[x], Len++;       limit = max(limit, (long long)Len);     }     X = LCM;     while (X < limit) X += LCM;     printf( %I64d n , X);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5, aa[8] = {-1, 0, 1, -1, 2, -1, -1, -1},             bb[8] = {-1, -1, -1, 2, -1, 1, 0, -1};   int T, n, i, j;   long long l, r, m, a[N], b[N], c[N], x, y, z, mn[8], u[4], d[4];   inline bool ckk(long long p, long long q, long long r) {     for (x = q + r - 4 >> 1; x <= q + r + 4 >> 1; ++x)       for (y = r + p - 4 >> 1; y <= r + p + 4 >> 1; ++y)         for (z = p + q - 4 >> 1; z <= p + q + 4 >> 1; ++z)           if (d[0] <= -x + y + z && -x + y + z <= u[0] && d[1] <= x - y + z &&               x - y + z <= u[1] && d[2] <= x + y - z && x + y - z <= u[2] &&               d[3] <= x + y + z && x + y + z <= u[3])             return 1;     return 0;   }   inline bool ck(long long D) {     for (i = 0; i < 8; ++i) mn[i] = 8e18;     for (i = 1; i <= n; ++i)       for (j = 0; j < 8; ++j)         mn[j] = min(mn[j], D + (j & 1 ? -a[i] : a[i]) + (j & 2 ? -b[i] : b[i]) +                                (j & 4 ? -c[i] : c[i]));     u[3] = mn[0];     d[3] = -mn[7];     for (i = 1; i < 7; ++i) {       if (aa[i] != -1) u[aa[i]] = mn[i];       if (bb[i] != -1) d[bb[i]] = -mn[i];     }     for (i = 0; i < 4; ++i)       if (u[i] < d[i]) return 0;     x = 27;     y = 26;     z = 59;     if (53 <= D && D < 70) ++D, --D;     for (i = 0; i < 16; ++i) {       long long p, q, r, s;       p = i & 1 ? u[0] : d[0];       q = i & 2 ? u[1] : d[1];       r = i & 4 ? u[2] : d[2];       s = i & 8 ? u[3] : d[3];       s = p + q + r;       if (d[3] <= s && s <= u[3] && ckk(p, q, r)) return 1;       p = i & 1 ? u[0] : d[0];       q = i & 2 ? u[1] : d[1];       r = i & 4 ? u[2] : d[2];       s = i & 8 ? u[3] : d[3];       r = s - p - q;       if (d[2] <= r && r <= u[2] && ckk(p, q, r)) return 1;       if (i == 0) ++i, --i;       p = i & 1 ? u[0] : d[0];       q = i & 2 ? u[1] : d[1];       r = i & 4 ? u[2] : d[2];       s = i & 8 ? u[3] : d[3];       q = s - p - r;       if (d[1] <= q && q <= u[1] && ckk(p, q, r)) return 1;       p = i & 1 ? u[0] : d[0];       q = i & 2 ? u[1] : d[1];       r = i & 4 ? u[2] : d[2];       s = i & 8 ? u[3] : d[3];       p = s - q - r;       if (d[0] <= p && p <= u[0] && ckk(p, q, r)) return 1;     }     return 0;   }   int main() {     scanf( %d , &T);     for (; T--;) {       l = r = 0;       scanf( %d , &n);       for (i = 1; i <= n; ++i)         scanf( %lld%lld%lld , a + i, b + i, c + i),             r = max(r, abs(a[i]) + abs(b[i]) + abs(c[i]));       for (; l < r;) {         m = l + r >> 1;         if (ck(m))           r = m;         else           l = m + 1;       }       ck(l);       printf( %lld %lld %lld n , x, y, z);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct SegmentTree {     int n;     struct node {       long long add, mn;       node() {}       node(long long v) : mn(v), add(0) {}     };     vector<node> tree;     void push(int id, int l, int r) {       if (tree[id].add != 0) {         int m = (l + r) >> 1;         apply(id << 1, l, m, tree[id].add);         apply(id << 1 | 1, m + 1, r, tree[id].add);         tree[id].add = 0;       }     }     void apply(int id, int l, int r, long long add) {       tree[id].mn += add;       tree[id].add += add;     }     void pull(int id) {       tree[id].mn = min(tree[id << 1].mn, tree[id << 1 | 1].mn);     }     SegmentTree(int n) : n(n), tree(4 * n) {}     SegmentTree(const vector<long long> &v) {       n = (int)v.size();       tree.resize(4 * n);       function<void(int, int, int)> build = [&](int id, int l, int r) {         if (l == r) {           tree[id] = v[l];           return;         }         push(id, l, r);         int m = (l + r) >> 1;         build(id << 1, l, m);         build(id << 1 | 1, m + 1, r);         pull(id);       };       build(1, 0, n - 1);     }     void rangeadd(int id, int l, int r, int ql, int qr, long long add) {       if (l > qr || r < ql) {         return;       }       if (ql <= l && r <= qr) {         apply(id, l, r, add);         return;       }       push(id, l, r);       int m = (l + r) >> 1;       rangeadd(id << 1, l, m, ql, qr, add);       rangeadd(id << 1 | 1, m + 1, r, ql, qr, add);       pull(id);     }     void rangeadd(int ql, int qr, long long add) {       rangeadd(1, 0, n - 1, ql, qr, add);     }   };   void solve() {     int N;     cin >> N;     vector<int> P(N), pos(N);     for (int i = 0; i < N; i++) {       cin >> P[i];       P[i]--;       pos[P[i]] = i;     }     vector<int> A(N);     for (int i = 0; i < N; i++) {       cin >> A[i];     }     vector<long long> init(N - 1);     for (int i = 0; i < N - 1; i++) {       init[i] = (i == 0 ? 0 : init[i - 1]) + A[i];     }     SegmentTree st(init);     long long ans = A[0];     for (int i = 0; i < N; i++) {       st.rangeadd(0, pos[i] - 1, A[pos[i]]);       st.rangeadd(pos[i], N - 2, -A[pos[i]]);       ans = min(ans, st.tree[1].mn);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       for (int i = 0; i < n; i++) cin >> arr[i];       if (n < 6) {         cout << 0 <<     << 0 <<     << 0 << endl;         continue;       }       int index = (n / 2) - 1;       while (index >= 0 && arr[index] == arr[index + 1]) index--;       vector<int> count;       int sum = 0;       for (int i = index; i >= 0; i--) {         int temp = 1;         int j = i - 1;         while (j >= 0 && arr[j] == arr[i]) {           j--;           temp++;         }         count.push_back(temp);         sum += temp;         i = j + 1;       }       if (count.size() < 3) {         cout << 0 <<     << 0 <<     << 0 << endl;         continue;       }       sum -= count[count.size() - 1];       int g = count[count.size() - 1], s = 0, b = 0;       bool ans = 0;       for (int i = 0; i < count.size() - 1; i++) {         b += count[i];         s = sum - b;         if (g < b && g < s) {           ans = 1;           break;         }       }       if (ans == 1)         cout << g <<     << s <<     << b << endl;       else         cout << 0 <<     << 0 <<     << 0 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cal(long long x, long long a) {     long long y = a, ans = 0, cnt = 1;     while (x / (long long)(pow(a, cnt)) != 0) {       ans += x / (long long)(pow(a, cnt));       cnt++;     }     return ans;   }   signed main() {     long long n, b, mx = LLONG_MAX;     vector<long long> v, k;     cin >> n >> b;     for (long long i = 2; i * i <= b; i++) {       if (b % i == 0) {         long long cnt = 0;         v.push_back(i);         while (b % i == 0) {           b = b / i;           cnt++;         }         k.push_back(cnt);       }     }     if (b != 1) v.push_back(b), k.push_back(1);     for (long long i = 0; i < v.size(); i++) {       mx = min(cal(n, v[i]) / k[i], mx);     }     cout << mx;   }
#include <bits/stdc++.h>   const double PI = 2.0 * acos(0.0);   const double EPS = 1e-9;   using namespace std;   int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};   int dc[] = {0, 1, 0, -1, -1, 1, -1, 1};   int V, E;   int T;   int N, M, K;   string S;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> N >> K;     int ans[5010];     int i, j;     map<int, vector<int>> m;     for (i = 0; i <= N - 1; i++) cin >> j, m[j].push_back(i);     int col = 0;     for (auto x : m) {       if (x.second.size() > K) {         cout <<  NO  << endl;         return 0;       } else {         for (j = 0; j <= x.second.size() - 1; j++) {           ans[x.second[j]] = col % K + 1;           col++;         }       }     }     cout <<  YES  << endl;     for (i = 0; i <= N - 1; i++) cout << ans[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 50;   const long long MAXN = 1e18 + 10;   const int MAX = 1e5 + 10;   const long long mod = 1e9 + 7;   const int inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const double eps = 1e-7;   inline void solve() {     int n, w;     scanf( %d , &n);     scanf( %d , &w);     int minn = 0, maxn = w;     bool flag = false;     for (int i = 0; i < n; ++i) {       int temp;       scanf( %d , &temp);       if (temp < 0) {         minn += (-temp);         if (minn > w) flag = true;         maxn = min(w, maxn - temp);       } else if (temp > 0) {         maxn -= temp;         if (maxn < 0) flag = true;         minn = max(0, minn - temp);       }       if (maxn < minn) flag = true;     }     if (flag)       printf( 0 n );     else       printf( %d n , maxn - minn + 1);     return;   }   int main() {     int casen = 1;     while (casen--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     cin.get();     string s;     getline(cin, s);     vector<int> pref(n);     for (int i = 0; i < n; ++i) {       if (i != 0) pref[i] = pref[i - 1];       pref[i] += s[i] ==  (  ? +1 : -1;     }     if (pref[n - 1] != 0) {       cout <<  0 n1 1 n ;       return 0;     }     int min_pos = min_element(pref.begin(), pref.end()) - pref.begin() + 1;     if (min_pos == n) min_pos = 0;     rotate(s.begin(), s.begin() + min_pos, s.end());     for (int i = 0; i < n; ++i) {       pref[i] = 0;       if (i != 0) pref[i] = pref[i - 1];       pref[i] += s[i] ==  (  ? +1 : -1;       assert(pref[i] >= 0);     }     vector<int> merged;     vector<vector<int>> pos(2);     vector<vector<int>> cnt(n, vector<int>(3));     pos[0].emplace_back(-1);     merged.emplace_back(-1);     for (int i = 0; i < n; ++i) {       if (i != 0) cnt[i] = cnt[i - 1];       if (pref[i] < 3) {         cnt[i][pref[i]] += 1;         if (pref[i] < 2) {           merged.emplace_back(i);           pos[pref[i]].emplace_back(i);         }       }     }     tuple<int, int, int> ans((int)pos[0].size() - 1, 0, 0);     for (int i = 0; i + 1 < (int)pos[0].size(); ++i) {       int l = pos[0][i], r = pos[0][i + 1];       int cnt_1 = cnt[r][1] - (l >= 0 ? cnt[l][1] : 0);       ans = max(ans, make_tuple(cnt_1, l + 1, r));     }     for (int i = 0; i + 1 < (int)merged.size(); ++i) {       int l = merged[i], r = merged[i + 1];       if (s[l + 1] == s[r]) continue;       int cnt_2 = cnt[r][2] - (l >= 0 ? cnt[l][2] : 0);       ans = max(ans, make_tuple(cnt_2 + (int)pos[0].size() - 1, l + 1, r));     }     int res, l, r;     tie(res, l, r) = ans;     (l += min_pos) %= n;     (r += min_pos) %= n;     cout << res << endl;     cout << 1 + l <<     << 1 + r << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     ;     long long i, j, k, l, r, m, n, o, t;     cin >> n;     cin >> l >> r;     char str[100001];     cin >> str;     long long len = strlen(str);     l--;     r--;     if (str[l] == str[r]) {       cout << 0 << endl;       return 0;     }     cout << 1 << endl;   }