malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char ch = getchar();     int x = 0, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) -  0  + ch;       ch = getchar();     }     return x * f;   }   int main() {     priority_queue<int> q;     int n = read(), T = read();     int ans = 0;     for (int i = 1; i <= n; i++) {       int x = read();       x = max(x, i);       while (!q.empty() && q.top() >= T - i) {         q.pop();       }       if (x < T) q.push(x - i);       ans = max(ans, (int)q.size());     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int a[1005];   int b[1005];   int h;   bool cmp(int x, int y) { return x > y; }   bool check(int x) {     for (int i = 1; i <= x; i++) {       b[i] = a[i];     }     sort(b + 1, b + x + 1, cmp);     long long sum = 0;     for (int i = 1; i <= x; i += 2) {       sum += (long long)(b[i]);     }     if (sum <= h) {       return 1;     } else {       return 0;     }   }   int main() {     int n;     cin >> n >> h;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     int l = 1, r = n, mid;     while (l < r) {       mid = (l + r + 1) / 2;       if (check(mid)) {         l = mid;       } else {         r = mid - 1;       }     }     cout << l;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int in() {     int x;     scanf( %d , &x);     return x;   }   template <typename T>   inline istream& operator>>(istream& i, vector<T>& v) {     for (int j = 0; j < ((int)(v).size()); ++j) i >> v[j];     return i;   }   template <typename T>   string join(const vector<T>& v) {     stringstream s;     for (int i = 0; i < ((int)(v).size()); ++i) s <<     << v[i];     return s.str().substr(1);   }   template <typename T>   inline ostream& operator<<(ostream& o, const vector<T>& v) {     if ((int)(v).size()) o << join(v);     return o;   }   template <typename T1, typename T2>   inline istream& operator>>(istream& i, pair<T1, T2>& v) {     return i >> v.first >> v.second;   }   template <typename T1, typename T2>   inline ostream& operator<<(ostream& o, const pair<T1, T2>& v) {     return o << v.first <<  ,  << v.second;   }   template <typename T>   inline long long int suma(const vector<T>& a) {     long long int res(0);     for (auto&& x : a) res += x;     return res;   }   const double eps = 1e-10;   const long long int LINF = 1001002003004005006ll;   const int INF = 1001001001;   const int MX = 200005;   int n, m;   int dp[55][55][55];   struct Q {     int l, r, x, c;     int cost(int i, int h) {       if (l <= i && i < r && h > x) return c;       return 0;     }   };   vector<Q> q;   int dfs(int l, int r, int h) {     if (l == r) return 0;     int& now = dp[l][r][h];     if (now != -1) return now;     now = 0;     if (h) now = dfs(l, r, h - 1);     for (int i = l; i < r; ++i) {       int c = h * h;       for (int k = 0; k < (m); ++k) {         if (l <= q[k].l && q[k].r <= r) c -= q[k].cost(i, h);       }       c += dfs(l, i, h) + dfs(i + 1, r, h);       (now = max(now, c));     }     return now;   }   int main() {     int h;     cin >> n >> h >> m;     q = vector<Q>(m);     for (int i = 0; i < (m); ++i) {       int l, r, x, c;       scanf( %d%d%d%d , &l, &r, &x, &c);       --l;       q[i] = (Q){l, r, x, c};     }     for (int i = 0; i < (n); ++i)       for (int j = 0; j < (n + 1); ++j)         for (int k = 0; k < (h + 1); ++k) dp[i][j][k] = -1;     int ans = dfs(0, n, h);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x, y;   } p[8];   int cmp(node a, node b) {     if (a.x == b.x) return (a.y < b.y);     return a.x < b.x;   }   int main() {     while (scanf( %d %d , &p[0].x, &p[0].y) != EOF) {       int cnt1 = 0;       int cnt2 = 0;       int cnt3 = 0;       int cnt4 = 0;       for (int i = 1; i < 8; i++) {         scanf( %d %d , &p[i].x, &p[i].y);       }       sort(p, p + 8, cmp);       node zuoshang = p[0];       node youxia = p[7];       for (int i = 1; i < 7; i++) {         if (p[i].x == zuoshang.x) cnt1++;         if (p[i].y == zuoshang.y) cnt2++;         if (p[i].x == youxia.x) cnt3++;         if (p[i].y == youxia.y) cnt4++;       }       if (cnt1 == 2 && cnt2 == 2 && cnt3 == 2 && cnt4 == 2 && p[1].y == p[6].y &&           p[4].x == p[3].x)         puts( respectable );       else         puts( ugly );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       double x, y, z, a, b, c, sq;       cin >> x;       a = 1.0, b = x, c = x;       z = (b * b) - (4 * a * c);       if (z < 0) {         cout <<  N  << endl;         continue;       }       y = ((-b + (sqrt((b * b) - (4 * a * c)))) / 2 * a);       if (y != 0) y = -1 * y;       cout << fixed << setprecision(9) <<  Y   << (x - y) <<     << y << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int r1, r2;   int c1, c2;   int b, e, k;   int main() {     ios_base::sync_with_stdio(0);     b = e = k = 0;     cin >> r1 >> c1;     cin >> r2 >> c2;     if (r1 > r2) {       swap(r1, r2);       swap(c1, c2);     }     b = (r1 == r2 || c1 == c2) ? 1 : 2;     e = ((((r1 & 1) == (c1 & 1)) && ((r2 & 1) == (c2 & 1))) ||          (((r1 & 1) != (c1 & 1)) && ((r2 & 1) != (c2 & 1))))             ? 2             : 0;     e = (abs(r1 - r2) == abs(c1 - c2) && e != 0) ? 1 : e;     k = min(abs(r1 - r2), abs(c1 - c2)) + max(abs(r1 - r2), abs(c1 - c2)) -         min(abs(r1 - r2), abs(c1 - c2));     cout << b <<     << e <<     << k << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e3 + 789;   const int M = 2e5 + 5;   const int NN = 1e5 + 55;   const long long mod = 1e9 + 7;   const long long inf = 0x3f3f3f3f;   const long long INF = 1LL << 62;   bitset<2000> P[N], S[N], T;   char ms[N][N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     P[0].reset();     for (int i = 0; i < n; i++) {       cin >> ms[i];       if (i) P[i] = P[i - 1];       for (int j = 0; j < m; j++) {         if (ms[i][j] ==  1 ) P[i][j] = 1;       }     }     for (int i = n - 1; i >= 0; i--) {       if (i != n - 1) S[i] = S[i + 1];       for (int j = 0; j < m; j++) {         if (ms[i][j] ==  1 ) S[i][j] = 1;       }     }     bool f = 0;     for (int i = 0; i < n; i++) {       T.reset();       if (i - 1 >= 0) T |= P[i - 1];       if (i + 1 < n) T |= S[i + 1];       if (T.count() == m) f = 1;     }     if (f)       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline void Boost() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   const int NMax = 1e6 + 50;   string convert(const string &s) {     string ret =  @ ;     for (int i = 0; i < (int)s.size(); ++i) {       ret +=  #  + s.substr(i, 1);     }     ret +=  #$ ;     return ret;   }   int P[NMax * 2];   void Solve() {     string s;     cin >> s;     int n = (int)s.size();     int a = 0;     int b = n - 1;     while (a <= b) {       if (a == b) {         cout << s <<   n ;         return;       }       if (s[a] == s[b]) {         ++a;         --b;         if (a > b) {           cout << s <<   n ;           return;         }       } else {         string nw = convert(s);         int cen = 0, r = 0;         for (int i = 0; i < (int)nw.size(); ++i) P[i] = 0;         for (int i = 1; i < (int)nw.size() - 1; ++i) {           int mir = cen - (i - cen);           if (r > i) {             P[i] = min(r - i, P[mir]);           }           while (nw[i + 1 + P[i]] == nw[i - 1 - P[i]]) {             P[i]++;           }           if (i + P[i] > r) {             cen = i;             r = i + P[i];           }         }         int best = 0;         int pos = 0;         for (int i = 1; i < (int)nw.size() - 1; i++) {           int start = (i - 1 - P[i]) / 2;           int fin = start + P[i] - 1;           if (start < a) {             int mv = a - start;             start += mv;             fin -= mv;           }           if (fin > b) {             int mv = fin - b;             start += mv;             fin -= mv;           }           if (start != a && fin != b) continue;           if (start <= fin && (fin - start + 1) > best) {             best = fin - start + 1;             pos = start;           }         }         for (int i = 0; i < a; ++i) cout << s[i];         for (int i = pos; i < pos + best; ++i) cout << s[i];         for (int i = a - 1; i >= 0; --i) cout << s[i];         cout <<   n ;         return;       }     }   }   int main() {     Boost();     int t;     cin >> t;     while (t--) {       Solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool is_prefix(string s, string comp) {     bool res = false;     int sz = s.size();     int comp_sz = comp.size();     if (sz > comp_sz)       return res;     else {       res = true;       for (int i = 0; i < sz; i++) {         if (s[i] != comp[i]) {           res = false;           break;         }       }     }     return res;   }   int main(int argc, char* argv[]) {     int n;     string s;     vector<string> res;     cin >> s;     cin >> n;     for (int i = 0; i < n; i++) {       string t;       cin >> t;       if (is_prefix(s, t)) res.push_back(t);     }     if (res.size() == 0) {       cout << s;     } else {       sort(res.begin(), res.end());       cout << res[0];     }     return 0;   }
#include <bits/stdc++.h>   int du[100010], fa[100010], s1[100010], s2[100010];   int find(int x) {     if (x != fa[x]) fa[x] = find(fa[x]);     return fa[x];   }   int main() {     int n, m, x, y, i, j, k, sum;     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) fa[i] = i;     memset(du, 0, sizeof(du));     memset(s1, 0, sizeof(s1));     memset(s2, 0, sizeof(s2));     for (i = 1; i <= m; i++) {       scanf( %d%d , &x, &y);       j = find(x);       k = find(y);       du[x]++;       du[y]++;       if (j != k) {         if (j < k)           fa[k] = j;         else           fa[j] = k;       }     }     for (i = 1; i <= n; i++) {       j = find(i);       s1[j] = s1[j] + du[i];       s2[j]++;     }     sum = 0;     for (i = 1; i <= n; i++)       if (s2[i] != 0) {         j = s1[i] / 2;         if (j < s2[i]) sum = sum + s2[i] - j;       }     printf( %d n , sum);   }
#include <bits/stdc++.h>   const int maxn = 100001;   int n, val[maxn], cL[maxn], cR[maxn], ord[maxn], tot, in[maxn], out[maxn],       bit[maxn], ans;   bool vis[maxn];   void dfs(int u) {     if (u == -1) return;     in[u] = ++tot;     dfs(cL[u]);     dfs(cR[u]);     out[u] = tot;   }   void bit_add(int x, int v) {     for (; x <= n; x += x & -x) bit[x] += v;   }   int bit_sum(int x) {     int ret = 0;     for (; x > 0; x -= x & -x) ret += bit[x];     return ret;   }   bool cmp(int const &x, int const &y) { return val[x] < val[y]; }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d%d%d , val + i, cL + i, cR + i);       if (cL[i] != -1) vis[cL[i]] = 1;       if (cR[i] != -1) vis[cR[i]] = 1;       ord[i] = i;     }     std::sort(ord + 1, ord + n + 1, cmp);     for (int i = 1; i <= n; ++i)       if (!vis[i]) dfs(i);     for (int i = 1; i <= n; ++i)       if (cR[i] != -1) {         bit_add(in[cR[i]], 1);         bit_add(out[cR[i]] + 1, -1);       }     for (int i = 1, j = 1; i <= n;) {       for (; j <= n && val[ord[j]] <= val[ord[i]]; ++j) {         int u = ord[j];         if (cL[u] != -1) {           bit_add(in[cL[u]], 1);           bit_add(out[cL[u]] + 1, -1);         }         if (cR[u] != -1) {           bit_add(in[cR[u]], -1);           bit_add(out[cR[u]] + 1, 1);         }       }       int cnt = 0, flg = 0;       for (int v = val[ord[i]]; i <= n && val[ord[i]] == v; ++i, ++cnt)         flg |= !bit_sum(in[ord[i]]);       if (!flg) ans += cnt;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 210;   int n, m, x;   long long dp[maxn][maxn], v[maxn], ans = -1;   void read_and_parse() {     scanf( %d%d%d , &n, &m, &x);     for (int i = 1; i <= n; i++) scanf( %d , &v[i]);   }   void solve() {     memset(dp, 0xcf, sizeof(dp));     dp[0][0] = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= x; j++)         for (int k = max(0, i - m); k < i; k++)           dp[i][j] = max(dp[i][j], dp[k][j - 1] + v[i]);     for (int i = n - m + 1; i <= n; i++) ans = max(ans, dp[i][x]);     printf( %lld n , ans);   }   int main() {     read_and_parse();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void checkDefine();   string x;   string y;   string z;   int main() {     cin >> x >> y;     long long int n = x.size();     for (int i = (0), _b = (n - 1); i <= _b; i++) {       if (x[i] < y[i]) {         cout << -1;         return 0;       }     }     cout << y;     return 0;   }   void checkDefine() {     long long int n, a[200005];     map<long long int, long long int> m;     cin >> n;     for (int i = (0), _b = (n - 1); i <= _b; i++) {       cin >> a[i];       m[a[i]]++;     }     string s;     cin >> s;     {       cout <<  s             <<   =  ;       cout << (s) << endl;     };     {       cout <<  a             <<   =  ;       for (int _ = 0, _a = (n); _ < _a; _++) cout << a[_] <<    ;       cout << endl;     };     {       cout <<   ------------              <<   =  ;       cout << ( ------------ ) << endl;     };     for (__typeof(m.begin()) it = m.begin(); it != m.end(); ++it) {       cout << it->first <<     << it->second << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class L, class R>   ostream &operator<<(ostream &os, map<L, R> P) {     for (auto const &vv : P) os <<  (  << vv.first <<  ,  << vv.second <<  ) ;     return os;   }   template <class T>   ostream &operator<<(ostream &os, set<T> V) {     os <<  [ ;     for (auto const &vv : V) os << vv <<  , ;     os <<  ] ;     return os;   }   template <class T>   ostream &operator<<(ostream &os, vector<T> V) {     os <<  [ ;     for (auto const &vv : V) os << vv <<  , ;     os <<  ] ;     return os;   }   template <class L, class R>   ostream &operator<<(ostream &os, pair<L, R> P) {     os <<  (  << P.first <<  ,  << P.second <<  ) ;     return os;   }   inline int fstoi(const string &str) {     auto it = str.begin();     bool neg = 0;     int num = 0;     if (*it ==  - )       neg = 1;     else       num = *it -  0 ;     ++it;     while (it < str.end()) num = num * 10 + (*it++ -  0 );     if (neg) num *= -1;     return num;   }   inline void getch(char &x) {     while (x = getchar_unlocked(), x < 33) {       ;     }   }   inline void getstr(string &str) {     str.clear();     char cur;     while (cur = getchar_unlocked(), cur < 33) {       ;     }     while (cur > 32) {       str += cur;       cur = getchar_unlocked();     }   }   template <typename T>   inline bool sc(T &num) {     bool neg = 0;     int c;     num = 0;     while (c = getchar_unlocked(), c < 33) {       if (c == EOF) return false;     }     if (c ==  - ) {       neg = 1;       c = getchar_unlocked();     }     for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48;     if (neg) num *= -1;     return true;   }   template <typename T, typename... Args>   inline void sc(T &num, Args &...args) {     bool neg = 0;     int c;     num = 0;     while (c = getchar_unlocked(), c < 33) {       ;     }     if (c ==  - ) {       neg = 1;       c = getchar_unlocked();     }     for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48;     if (neg) num *= -1;     sc(args...);   }   int getsum(int a, int b) {     int oor, oand;     cout <<  and   << a <<     << b << endl;     cin >> oand;     cout <<  or   << a <<     << b << endl;     cin >> oor;     return oor + oand;   }   int main() {     int n, k;     cin >> n >> k;     int cr;     int x, y, z;     x = getsum(1, 2);     y = getsum(1, 3);     z = getsum(2, 3);     int a[n + 1];     a[3] = (y + z - x) / 2;     a[2] = (-y + z + x) / 2;     a[1] = (y - z + x) / 2;     for (auto i = (4); i <= (n); ++i) {       int wh = getsum(1, i);       a[i] = wh - a[1];     }     sort(a + 1, a + n + 1);     cout <<  finish   << a[k] << endl;     cout << a[k] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   bool operator<(pair<int, int> lhs, pair<int, int> rhs) {     return (lhs.first != rhs.first) ? (lhs.first < rhs.first)                                     : (lhs.second < rhs.second);   }   set<pair<int, int> > inqUp, inqDown, pendUp, pendDown;   int N, M, prsis, rci;   long long T, Ans[MAXN];   struct User {     int id, ar, f, t;   };   bool cmp_Useraraz(User lhs, User rhs) { return lhs.ar < rhs.ar; }   User u[MAXN], ru[MAXN];   int Where;   void Unload() {     while ((inqUp.size()) && (inqUp.begin()->first == Where)) {       Ans[inqUp.begin()->second] = T;       inqUp.erase(inqUp.begin());       rci++;     }     while (((inqDown.size()) && (--inqDown.end())->first == Where)) {       Ans[(--inqDown.end())->second] = T;       inqDown.erase(--inqDown.end());       rci++;     }   }   void Request() {     while ((prsis != N) && (u[prsis + 1].ar == T)) {       prsis++;       if (u[prsis].f >= Where)         pendUp.insert(make_pair(u[prsis].f, u[prsis].id));       else         pendDown.insert(make_pair(u[prsis].f, u[prsis].id));     }   }   void Load(int id) {     if (ru[id].t >= Where)       inqUp.insert(make_pair(ru[id].t, id));     else       inqDown.insert(make_pair(ru[id].t, id));   }   void Load() {     while ((pendUp.size()) && (pendUp.begin()->first == Where)) {       Load(pendUp.begin()->second);       pendUp.erase(pendUp.begin());     }     while ((pendDown.size()) && ((--pendDown.end())->first == Where)) {       Load((--pendDown.end())->second);       pendDown.erase(--pendDown.end());     }   }   int main() {     scanf( %d%d , &N, &M);     int i;     for (i = 1; i <= N; i++) {       scanf( %d%d%d , &u[i].ar, &u[i].f, &u[i].t);       u[i].id = i;       ru[i] = u[i];     }     sort(u + 1, u + N + 1, cmp_Useraraz);     inqUp.clear();     inqDown.clear();     pendUp.clear();     pendDown.clear();     Where = 1;     T = 0;     prsis = rci = 0;     while (rci < N) {       Unload();       Request();       Load();       int pUp = inqUp.size() + pendUp.size();       int pDown = inqDown.size() + pendDown.size();       int Action = (pUp + pDown) ? ((pUp >= pDown) ? 1 : -1) : 0;       int timePass = (prsis == N) ? M : (u[prsis + 1].ar - T);       if (Action == 1) {         if (pendUp.size())           timePass = min(timePass, pendUp.begin()->first - Where);         if (inqUp.size()) timePass = min(timePass, inqUp.begin()->first - Where);       }       if (Action == -1) {         if (pendDown.size())           timePass = min(timePass, Where - (--pendDown.end())->first);         if (inqDown.size())           timePass = min(timePass, Where - (--inqDown.end())->first);       }       T += timePass;       Where += timePass * Action;     }     for (i = 1; i <= N; i++) printf( %I64d n , Ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   map<char, char> mp;   string check(string s) {     for (int i = 0; i <= s.size() / 2; i++)       if (s[i] != mp[s[s.size() - 1 - i]]) return  NIE ;     return  TAK ;   }   int main() {     mp[ A ] =  A ;     mp[ b ] =  d ;     mp[ d ] =  b ;     mp[ H ] =  H ;     mp[ I ] =  I ;     mp[ M ] =  M ;     mp[ O ] =  O ;     mp[ o ] =  o ;     mp[ p ] =  q ;     mp[ q ] =  p ;     mp[ T ] =  T ;     mp[ U ] =  U ;     mp[ V ] =  V ;     mp[ v ] =  v ;     mp[ W ] =  W ;     mp[ w ] =  w ;     mp[ X ] =  X ;     mp[ x ] =  x ;     mp[ Y ] =  Y ;     string s;     cin >> s;     cout << check(s) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[3][3], b[3][3];     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         cin >> a[i][j];         a[i][j] %= 2;         b[i][j] = 0;       }     }     pair<int, int> f[] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {0, 0}};     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         for (auto m : f) {           if (i + m.first < 3 && i + m.first > -1) {             if (j + m.second < 3 && j + m.second > -1) {               if (a[i + m.first][j + m.second] % 2) {                 b[i][j]++;                 b[i][j] %= 2;               }             }           }         }       }     }     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         cout << (b[i][j] ^ 1);       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200000;   const long long mod = 1e9 + 7;   long long fac[maxn + 5], inv[maxn + 5];   long long f[2005];   struct node {     long long x, y;   } data[2005];   long long qmod(long long a, long long b) {     long long ans = 1;     a = a % mod;     while (b) {       if (b & 1) {         ans = (ans * a) % mod;       }       b = b / 2;       a = (a * a) % mod;     }     return ans;   }   void init() {     fac[0] = 1;     for (long long i = 1; i <= maxn; i++) {       fac[i] = (fac[i - 1] * i) % mod;     }   }   long long com(long long n, long long m) {     if (n < m)       return 0;     else if (n == m)       return 1;     else       return (fac[n] * qmod(fac[m] * fac[n - m], mod - 2)) % mod;   }   long long Lucas(long long n, long long m) {     if (m == 0)       return 1;     else       return (com(n % mod, m % mod) * Lucas(n / mod, m / mod)) % mod;   }   bool cmp(node a, node b) {     if (a.x < b.x)       return true;     else if (a.x == b.x) {       if (a.y < b.y)         return true;       else         return false;     } else       return false;   }   int main(int argc, char const *argv[]) {     long long h, w, n;     init();     scanf( %lld %lld %lld , &h, &w, &n);     for (int i = 1; i <= n; i++) {       scanf( %lld %lld , &data[i].x, &data[i].y);     }     sort(data + 1, data + 1 + n, cmp);     memset(f, 0, sizeof(f));     n++;     data[n].x = h;     data[n].y = w;     for (int i = 1; i <= n; i++) {       long long dx, dy;       dx = data[i].x - 1;       dy = data[i].y - 1;       f[i] = Lucas(dx + dy, dx);       for (int j = 1; j < i; j++) {         if (data[i].x >= data[j].x && data[i].y >= data[j].y) {           dx = data[i].x - data[j].x;           dy = data[i].y - data[j].y;           f[i] = f[i] - (f[j] * Lucas(dx + dy, dx)) % mod;           f[i] = (f[i] + mod) % mod;         }       }     }     cout << (f[n] + mod) % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x[100], s[100];   struct par {     int v, id;     bool operator<(const par &r) const { return v < r.v; }   };   vector<par> v;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &x[i]);       v.push_back({x[i], i});     }     sort(v.begin(), v.end());     vector<par> v1 = v;     rotate(v1.begin(), v1.begin() + 1, v1.end());     for (int i = 0; i < (int)v.size(); i++) s[v[i].id] = v1[i].v;     for (int i = 0; i < n; i++) {       printf( %d , s[i]);       i == n - 1 ? printf(  n ) : printf(   );     }     return 0;   }