malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> magic(string t, string s, int sk) {     int tl = t.length();     string x = t +  @  + s;     int n = x.length();     vector<int> pi(n), r(sk + 1, -1);     r[0] = sk - 1;     for (int i = 1, k = 0; i < n; ++i) {       while (k && x[i] != x[k]) k = pi[k - 1];       k += x[i] == x[k];       pi[i] = k;       if (i >= tl + sk) {         while (k > sk) k = pi[k - 1];         for (int j = k; r[j] == -1; j = pi[j - 1]) r[j] = i - tl - 1;       }     }     return r;   }   vector<int> pi_function(const string &s) {     int n = s.length();     vector<int> pi(n);     for (int i = 1, k = 0; i < n; ++i) {       while (k && s[i] != s[k]) k = pi[k - 1];       k += s[i] == s[k];       pi[i] = k;     }     return pi;   }   vector<int> kmp(const string &text, const string &patt) {     int n = text.length(), m = patt.length();     vector<int> ans, pi = pi_function(patt);     for (int i = 0, k = 0; i < n; ++i) {       while (k && text[i] != patt[k]) k = pi[k - 1];       k += text[i] == patt[k];       if (k == m) {         ans.push_back(i - k + 1);         k = pi[k - 1];       }     }     return ans;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     int n, m, k;     string s, t;     cin >> n >> m >> k >> s >> t;     if (m <= k) {       auto p = kmp(s, t);       for (auto i : p) {         int l = max(k, i + m);         if (l + k <= n) {           cout <<  Yes n  << l - k + 1 <<     << l + 1 <<   n ;           return 0;         }         int r = min(i + 1, n - k + 1);         if (r - 1 >= k) {           cout <<  Yes n  << r - k <<     << r <<   n ;           return 0;         }       }     }     auto l = magic(t, s, k);     reverse(t.begin(), t.end());     reverse(s.begin(), s.end());     auto r = magic(t, s, k);     for (auto &i : r)       if (i != -1) i = n - 1 - i;     for (int i = 0; i <= m; ++i)       if (i <= k && m - i <= k && l[i] != -1 && r[m - i] != -1 &&           l[i] < r[m - i]) {         cout <<  Yes n  << l[i] - k + 2 <<     << r[m - i] + 1 <<   n ;         return 0;       }     cout <<  No n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:102400000,102400000 )   inline void read(int &x) {     x = 0;     char ch = getchar();     while (ch <  0 ) ch = getchar();     while (ch >=  0 ) {       x = x * 10 + ch - 48;       ch = getchar();     }   }   int a[100010], ans;   bool f[100010];   int main() {     int n;     scanf( %d , &n);     if (n == 1)       puts( 1 );     else if (n == 2)       puts( -1 );     else if (n % 4 > 1)       puts( -1 );     else {       if (n & 1) a[n / 2 + 1] = n / 2 + 1;       for (int i = 1; i <= n / 2; ++i) {         if (!a[i]) {           a[i] = i + 1;           a[i + 1] = n + 1 - i;           a[n + 1 - i] = n - i;           a[n - i] = i;         }       }       for (int i = 1; i <= n; ++i) printf( %d%c , a[i], (i == n) ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   vector<pair<int, int>> ans, packs;   void sp2(int st, int n) {     if (n < 2) return;     sp2(st, n / 2);     sp2(st + n / 2, n / 2);     for (int i = 0; i < n / 2; ++i) {       ans.push_back({st + i, st + n / 2 + i});     }   }   void getp0(int st, int now, int need) {     while (now < need) {       for (int i = 0; i < now; ++i) {         ans.push_back({st + i, st + now + i});       }       now *= 2;     }   }   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     N = n;     for (int t = 16384, u = 0; t > 0; t /= 2) {       if (n & t) {         sp2(u, t);         packs.push_back({u, t});         u += t;       }     }     int p0 = 0;     while (packs.size() > 2) {       int psz = packs.size();       getp0(packs.back().first, packs.back().second, packs[psz - 2].second);       packs.pop_back();       int nsz = packs.back().second, nst = packs.back().first;       packs.back().second *= 2;       for (int i = 0; i < nsz; ++i) {         ans.push_back({nst + i, nst + nsz + i});       }     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); ++i) {       cout << (ans[i].first % n) + 1 <<     << (ans[i].second % n) + 1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int BIG = 1e9 + 555;   const int maxN = 100 * 1000 + 9;   long long n, m;   pair<long long, long long> a[maxN];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= m; i++) {       long long q, w;       cin >> q >> w;       a[i] = make_pair(w, q);     }     sort(a + 1, a + m + 1);     long long res = 0;     for (long long i = m; i > 0; i--) {       long long j = m - i;       long long foo = 0;       if (j & 1) {         foo = (j * (j + 1)) / 2 + j / 2 + 1;       } else {         foo = (j * (j + 1)) / 2 + 1;       }       if (foo > n) {         break;       }       res += a[i].first;     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   int mod = 1e9 + 7;   long long qpow(long long a, long long b) {     long long ans = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) ans = ans * a % mod;       a = a * a % mod;     }     return ans;   }   long long gcd(long long a, long long b) { return b > 0 ? gcd(b, a % b) : a; }   int n, m, T;   int a[maxn];   int fac[maxn];   void init() {     fac[0] = 1;     for (int i = 1; i <= n; i++) {       fac[i] = 1ll * fac[i - 1] * i % mod;     }   }   int main() {     cin >> n >> mod;     init();     long long ans = 0;     for (int i = 1; i <= n; i++) {       ans = (ans + 1ll * (n - i + 1) * fac[n - i + 1] % mod * fac[i] % mod) % mod;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   struct Edge {     long long to, dis, next;   } edge[100100];   long long n, num_edge;   long long first1[100100];   long long a[100100], b[100100];   double tem;   void dfs(long long x, long long fa, long long p) {     long long k = first1[x];     while (k != 0) {       dfs(edge[k].to, x, edge[k].dis);       k = edge[k].next;     }     if (a[x] < b[x])       b[fa] += b[x] - a[x];     else if (a[x] > b[x]) {       tem = (double)(b[x] - a[x]) * p;       if (tem < -110000000000000000) {         printf( NO );         exit(0);       }       b[fa] -= p * (a[x] - b[x]);       if (b[fa] < -110000000000000000) {         printf( NO );         exit(0);       }     }   }   int main() {     long long i, x, k;     scanf( %lld , &n);     for (i = 1; i <= n; i++) scanf( %lld , &b[i]);     for (i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (i = 2; i <= n; i++) {       scanf( %lld%lld , &x, &k);       edge[++num_edge].to = i;       edge[num_edge].dis = k;       edge[num_edge].next = first1[x];       first1[x] = num_edge;     }     k = first1[1];     while (k != 0) {       dfs(edge[k].to, 1, edge[k].dis);       k = edge[k].next;     }     if (b[1] < a[1])       printf( NO );     else       printf( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int A, B, q;   long long l, t, m;   bool check(long long len) {     long long ind_left = l;     long long ind_righ = ind_left + len - 1;     long long num_left = A + (ind_left - 1) * B;     long long num_righ = A + (ind_righ - 1) * B;     long long need_time;     if (len > m)       need_time = ((num_left + num_righ) * len / 2 + m - 1) / m;     else       need_time = num_righ;     return need_time <= t && num_righ <= t;   }   void work() {     scanf( %d %d %d , &A, &B, &q);     while (q--) {       scanf( %lld %lld %lld , &l, &t, &m);       long long lpt = 0, rpt = 1e6;       while (lpt < rpt) {         long long mid = (lpt + rpt + 1) >> 1;         if (check(mid)) {           lpt = mid;         } else {           rpt = mid - 1;         }       }       if (lpt == 0) {         puts( -1 );       } else {         printf( %lld n , l + rpt - 1);       }     }   }   int main() {     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int gi() {     int data = 0, fu = 1;     char ch = 0;     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) fu = -1, ch = getchar();     while ( 0  <= ch && ch <=  9 )       data = (data << 1) + (data << 3) + (ch ^ 48), ch = getchar();     return data * fu;   }   int f[100005][205][2];   int n, A[100005];   inline void Merge(int i) {     for (int j = 1; j <= 200; ++j) {       f[i][j][0] = (f[i][j - 1][0] + f[i][j][0]) % 998244353;       f[i][j][1] = (f[i][j - 1][1] + f[i][j][1]) % 998244353;     }     return;   }   int main() {     n = gi();     for (int i = 1; i <= n; ++i) A[i] = gi();     if (A[1] != -1)       f[1][A[1]][0] = 1;     else       for (int i = 1; i <= 200; ++i) f[1][i][0] = 1;     Merge(1);     for (int i = 2; i <= n; ++i) {       for (int j = 1; j <= 200; ++j)         if (A[i] == -1 || A[i] == j) {           f[i][j][1] =               (f[i - 1][j][0] - f[i - 1][j - 1][0] + 998244353) % 998244353;           f[i][j][1] =               (f[i][j][1] +                (f[i - 1][200][1] - f[i - 1][j - 1][1] + 998244353) % 998244353) %               998244353;           f[i][j][0] = (f[i - 1][j - 1][0] + f[i - 1][j - 1][1]) % 998244353;         }       Merge(i);     }     cout << f[n][200][1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 1123456;   template <typename T>   T sqr(T x) {     return x * x;   }   template <typename T>   void vout(T s) {     cout << s <<   n ;     exit(0);   }   long long bp(long long a, long long n) {     long long res = 1;     while (n) {       if (n % 2) res *= a;       a *= a;       n >>= 1;     }     return res;   }   char akel_sosat[1001][1001];   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     string a;     cin >> a;     long long kol = 0, mx = 0;     for (int i = 0; i < n; i++) {       if (a[i] ==  [ )         kol++;       else         kol--;       mx = max(mx, kol);     }     long long m = mx * 2 + 3;     long long l = 1, len = mx;     for (int i = 1; i <= 1000; i++)       for (int j = 0; j < 1001; j++) akel_sosat[i][j] =    ;     long long st = 0;     for (int i = 0; i < n; i++, st++) {       if (a[i] ==  [ ) {         akel_sosat[l][st] =  + ;         akel_sosat[l][st + 1] =  - ;         long long l1 = len * 2 - 1;         for (int j = l + 1; j <= l + l1; j++) akel_sosat[j][st] =  | ;         akel_sosat[l + l1 + 1][st] =  + ;         akel_sosat[l + l1 + 1][st + 1] =  - ;         len--;         l++;       } else {         if (a[i] != a[i - 1]) st += 3;         l--;         len++;         akel_sosat[l][st] =  + ;         akel_sosat[l][st - 1] =  - ;         long long l1 = len * 2 - 1;         for (int j = l + 1; j <= l + l1; j++) akel_sosat[j][st] =  | ;         akel_sosat[l + l1 + 1][st] =  + ;         akel_sosat[l + l1 + 1][st - 1] =  - ;       }     }     for (int i = 1; i <= m; i++) {       for (int j = 0; j < st; j++) cout << akel_sosat[i][j];       cout <<   n ;     }     cerr <<  Time execute:   << clock() / (double)CLOCKS_PER_SEC <<   sec           <<   n ;     return 0;   }
#include <bits/stdc++.h>   long long sum(long long val) {     if (val % 2) return (val + 1) / 2 * val;     return val / 2 * (val + 1);   }   int main() {     long long n, x, d[200005], i, xx, l, ans = 0, now, tmp;     scanf( %lld%lld , &n, &x);     for (i = 0; i < n; i++) scanf( %lld , &d[i]);     l = n - 1;     xx = x;     now = 0;     for (i = n - 1; i >= 0; i--) {       while (xx >= d[l]) {         xx -= d[l];         now += sum(d[l]);         l--;         if (l < 0) l += n;       }       tmp = now - sum(d[l] - xx) + sum(d[l]);       if (tmp > ans) ans = tmp;       xx += d[i];       now -= sum(d[i]);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void umax(T &a, T b) {     if (a < b) a = b;   }   template <class T>   inline void umin(T &a, T b) {     if (a > b) a = b;   }   template <class T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   template <class T>   inline T gcd(T a, T b) {     return __gcd(a, b);   }   template <class T>   inline T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   long long modpow(long long a, long long n, long long temp) {     long long res = 1, y = a;     while (n > 0) {       if (n & 1) res = (res * y) % temp;       y = (y * y) % temp;       n /= 2;     }     return res % temp;   }   long long ison(long long mask, long long pos) { return (mask & (1 << pos)); }   long long cbit(long long n) {     long long k = 0;     while (n) n &= (n - 1), k++;     return k;   }   long long nbit(long long n) {     long long k = 0;     while (n) n /= 2, k++;     return k;   }   long long mod = 1e9 + 7;   int sgn(long long x) { return x < 0 ? -1 : !!x; }   long long xo(long long i) {     if ((i & 3) == 0) return i;     if ((i & 3) == 1) return 1;     if ((i & 3) == 2) return i + 1;     return 0;   }   long long a[200005];   int main() {     long long n, i, j, k, l, m, ans = 0;     long long pr = 0;     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= n; i++) {       if (a[i] != pr) {         ans += abs(a[i] - pr);         pr = a[i];       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     bool t = true;     int n;     cin >> n;     int a[200001] = {0};     vector<int> voz;     vector<int> yb;     for (int i = 0; i < n; i++) {       int c;       cin >> c;       a[c]++;       if (a[c] > 2) {         cout <<  NO ;         t = false;         break;       } else if (a[c] == 1) {         yb.push_back(c);       } else if (a[c] == 2) {         voz.push_back(c);       }     }     if (t) {       sort(voz.begin(), voz.end());       sort(yb.begin(), yb.end());       cout <<  YES  <<   n ;       cout << voz.size() <<   n ;       for (int i = 0; i < voz.size(); i++) {         cout << voz[i] <<    ;       }       cout <<   n ;       cout << yb.size() <<   n ;       reverse(yb.begin(), yb.end());       for (int i = 0; i < yb.size(); i++) {         cout << yb[i] <<    ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a;   vector<vector<int>> graph;   vector<vector<int>> residual;   set<int> primes;   map<pair<int, int>, int> factors;   void sieve(int SQRTN) {     vector<int> isPrime(SQRTN, 1);     for (int i = 2; i < SQRTN; i++) {       if (!isPrime[i]) continue;       primes.insert(i);       for (int j = i * i; j < SQRTN; j += i) {         isPrime[j] = 0;       }     }     for (int i = 0; i < a.size(); i++) {       int num = a[i];       for (int p : primes) {         int acc = 0;         while (num % p == 0) {           acc++;           num /= p;         }         factors[{a[i], p}] = acc;       }       if (num != 1) {         primes.insert(num);         factors[{i, num}] = 1;       }     }   }   int bfs(int source, int sink) {     queue<int> q;     vector<int> anc(graph.size(), -1);     q.push(source);     bool reached = false;     while (!q.empty()) {       int curr = q.front();       q.pop();       if (curr == sink) {         reached = true;         break;       }       for (int neighbor : graph[curr]) {         if (anc[neighbor] == -1 and residual[curr][neighbor] > 0) {           q.push(neighbor);           anc[neighbor] = curr;         }       }     }     if (!reached) {       return 0;     }     int node = sink;     int augment = 12312312;     while (node != source) {       int prev = anc[node];       augment = min(augment, residual[prev][node]);       node = prev;     }     node = sink;     while (node != source) {       int prev = anc[node];       residual[prev][node] -= augment;       residual[node][prev] += augment;       node = prev;     }     return augment;   }   int edmondkarp(int source, int sink) {     int res = 0;     while (true) {       int delta = bfs(source, sink);       if (delta == 0) {         break;       }       res += delta;     }     return res;   }   int main() {     int n, m;     cin >> n >> m;     a.resize(n);     int MAXN = -1;     for (int i = 0; i < n; i++) {       cin >> a[i];       MAXN = max(MAXN, a[i]);     }     sieve(sqrt(MAXN));     int s = n;     int t = n + 1;     graph.resize(n + 2);     residual.resize(n + 2, vector<int>(n + 2));     for (int i = 0; i < m; i++) {       int n1, n2;       cin >> n1 >> n2;       --n1;       --n2;       if (!(n1 & 1)) {         swap(n1, n2);       }       graph[n1].push_back(n2);       graph[n2].push_back(n1);       residual[n1][n2] = 12312312;       residual[n2][n1] = 0;     }     for (int i = 0; i < n; i++) {       if (i & 1) {         graph[s].push_back(i);       } else {         graph[i].push_back(t);       }     }     vector<vector<int>> residualCopy(residual);     int sol = 0;     for (int p : primes) {       residual = residualCopy;       for (int i = 0; i < n; i++) {         int capacity = factors.count({a[i], p}) ? factors[{a[i], p}] : 0;         if (i & 1) {           residual[s][i] = capacity;         } else {           residual[i][t] = capacity;         }       }       sol += edmondkarp(s, t);     }     cout << sol <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace io {   char ibuf[(1 << 18)], *iS, *iT, obuf[(1 << 18)],       *oS = obuf, *oT = oS + (1 << 18) - 1, c, qu[55];   int f, qr;   inline void flush(void) {     fwrite(obuf, 1, oS - obuf, stdout);     oS = obuf;     return;   }   inline char getch(void) {     return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, (1 << 18), stdin),                         (iS == iT ? EOF : *iS++))                      : *iS++);   }   inline void putch(char x) {     *oS++ = x;     if (oS == oT) flush();     return;   }   void putstr(string str, int begin = 0, int end = -1) {     if (end == -1) end = str.size();     for (register int i = begin; i < end; i++) putch(str[i]);     return;   }   template <typename T>   inline T read() {     register T x = 0;     for (f = 1, c = getch(); c <  0  || c >  9 ; c = getch())       if (c ==  - ) f = -1;     for (x = 0; c <=  9  && c >=  0 ; c = getch()) x = x * 10 + (c & 15);     x *= f;     return x;   }   template <typename T>   inline void write(const T& t) {     register T x = t;     if (!x) putch( 0 );     if (x < 0) putch( - ), x = -x;     while (x) qu[++qr] = x % 10 +  0 , x /= 10;     while (qr) putch(qu[qr--]);     return;   }   struct Flusher_ {     ~Flusher_() { flush(); }   } io_flusher_;   }  // namespace io   using io::getch;   using io::putch;   using io::putstr;   using io::read;   using io::write;   pair<int, int> a[100005];   int f[100005];   int main() {     int n = read<int>();     for (register int i = 1; i <= n; i++)       a[i].first = read<int>(), a[i].second = read<int>();     sort(a + 1, a + n + 1);     int answer = f[1] = 1;     for (register int i = 2; i <= n; i++) {       f[i] = 1 + f[lower_bound(a + 1, a + i,                                (pair<int, int>){a[i].first - a[i].second, 0}) -                    a - 1];       answer = max(answer, f[i]);     }     write(n - answer), putch(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long N, Q, S[(int)1e5 + 5], i, L, R, p1, p2;   long long Putere(long long p1, long long ex) {     long long i, sol = 1;     for (i = 0; (1 << i) <= ex; i++) {       if (((1 << i) & ex) > 0) sol = (sol * p1) % 1000000007;       p1 = (p1 * p1) % 1000000007;     }     return sol;   }   string str;   int main() {     cin >> N >> Q;     cin >> str;     for (i = 0; i < str.length(); i++) {       if (str[i] ==  1 )         S[i + 1] = S[i] + 1;       else         S[i + 1] = S[i];     }     while (Q--) {       cin >> L >> R;       p1 = S[R] - S[L - 1];       p2 = R - L + 1 - p1;       cout << ((Putere(2, p1) - 1 + (Putere(2, p1) - 1) * (Putere(2, p2) - 1))) %                   1000000007            <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct trip {     int l;     int len;     int t;     int id;   };   const int INF = 1e9;   int main() {     int n, p;     scanf( %d%d , &n, &p);     vector<trip> trips(n);     for (int i = 0; i < n; i++) {       scanf( %d%d%d , &trips[i].l, &trips[i].len, &trips[i].t);       trips[i].id = i;     }     vector<trip> lorder = trips, torder = trips;     sort(lorder.begin(), lorder.end(),          [](const trip& a, const trip& b) { return a.l < b.l; });     sort(torder.begin(), torder.end(),          [](const trip& a, const trip& b) { return a.t < b.t; });     vector<int> dp(1 << n, INF);     vector<int> pj(1 << n, -1);     vector<int> pt(1 << n, -1);     dp[0] = 1;     for (int i = 0; i < (1 << n); i++) {       if (dp[i] == INF) continue;       int c = dp[i];       auto ptr = lorder.begin();       auto ptr_same = lorder.begin();       for (auto j : torder) {         int to = i | (1 << j.id);         if (to == i) continue;         while (true) {           while (ptr != lorder.end() && ptr->l + ptr->len <= c) ptr++;           while (ptr_same != lorder.end() &&                  (ptr_same->l < c || ((i & (1 << ptr_same->id)) == 0)))             ptr_same++;           if (ptr != lorder.end() && ptr->l <= c) {             c = ptr->l + ptr->len;             continue;           }           if (ptr_same != lorder.end() && c + j.t >= ptr_same->l) {             c = ptr_same->l + ptr->len;             continue;           }           break;         }         if (c + j.t < j.l) {           if (dp[to] > c + j.t) {             dp[to] = c + j.t;             pj[to] = j.id;             pt[to] = c;           }         }       }     }     vector<int> anst(n, -1);     vector<int> ansp(n, -1);     auto restore = [&](int mask, int p) {       while (mask) {         int last = pj[mask];         assert(last != -1 && (mask & (1 << last)));         anst[last] = pt[mask];         ansp[last] = p;         mask ^= (1 << last);       }     };     if (p == 1) {       if (dp[(1 << n) - 1] != INF) {         restore((1 << n) - 1, 1);       }     } else {       for (int i = 0; i < (1 << n) - 1; i++) {         if (dp[i] != INF && dp[(1 << n) - 1 - i] != INF) {           restore(i, 1);           restore((1 << n) - 1 - i, 2);           break;         }       }     }     if (anst[0] == -1) {       printf( NO n );     } else {       printf( YES n );       for (int i = 0; i < n; i++) {         printf( %d %d n , ansp[i], anst[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 10;   struct node {     int t;     int x;     int y;   } tt[maxn];   int main() {     int n, m, s, f;     while (~scanf( %d%d%d%d , &n, &m, &s, &f)) {       memset(tt, 0, sizeof tt);       for (int i = 0; i < m; i++) {         scanf( %d%d%d , &tt[i].t, &tt[i].x, &tt[i].y);       }       int cnt = 0;       int time = 1;       int peo = s;       int jj;       if (f > s)         jj = 1;       else         jj = -1;       while (peo != f) {         if (tt[cnt].t != time) {           peo += jj;           if (jj == 1) {             printf( R );           } else             printf( L );         } else if ((peo < tt[cnt].x || peo > tt[cnt].y) &&                    ((peo + jj) < tt[cnt].x || (peo + jj) > tt[cnt].y)) {           peo += jj;           if (jj == 1) {             printf( R );           } else             printf( L );           cnt++;         } else {           printf( X );           cnt++;         }         time++;       }       printf(  n );     }     return 0;   }