malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 50;   const int maxm = 1e6 + 50;   const double eps = 1e-10;   const int max_index = 62;   const int inf = 0x3f3f3f3f;   const int MOD = 1e9 + 7;   inline int read() {     char c = getchar();     while (!isdigit(c)) c = getchar();     int x = 0;     while (isdigit(c)) {       x = x * 10 + c -  0 ;       c = getchar();     }     return x;   }   const int offset = 2000;   struct Point {     int x, y;     Point(int x = 0, int y = 0) : x(x), y(y) {}     bool operator<(const Point &rhs) const {       if (x == rhs.x) return y < rhs.y;       return x < rhs.x;     }   } P[205];   std::vector<int> G[maxm];   int n, m;   int dis[maxm], vis[maxm];   int get(int x, int y) { return x * m + y; }   int ans = 0;   void dfs(int u) {     vis[u] = 1;     int res = 0;     for (int i = 0; i < G[u].size(); i++) {       int v = G[u][i];       if (vis[v]) {         puts( Poor Inna! );         exit(0);       }       if (!dis[v]) dfs(v);       res = max(res, dis[v]);     }     dis[u] = res + 1;     vis[u] = 0;   }   int dir[4][2] = {0, -1, -1, 0, 0, 1, 0, -1};   char mp[1005][1005];   bool judge(char x, char y) {     bool ok = 0;     ok |= (x ==  D  && y ==  I );     ok |= (x ==  I  && y ==  M );     ok |= (x ==  M  && y ==  A );     ok |= (x ==  A  && y ==  D );     return ok;   }   int main() {     n = read(), m = read();     for (int i = 0; i < n; i++) scanf( %s , mp[i]);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         int u = get(i, j);         for (int k = 0; k < 2; k++) {           int dx = i + dir[k][0], dy = j + dir[k][1];           if (dx < 0 || dy < 0) continue;           int v = get(dx, dy);           if (judge(mp[dx][dy], mp[i][j])) {             G[v].push_back(u);           } else if (judge(mp[i][j], mp[dx][dy])) {             G[u].push_back(v);           }         }       }     }     for (int i = 0; i < m * n; i++) {       int x = i / m, y = i % m;       if (mp[x][y] !=  D ) continue;       dfs(i);       ans = max(ans, dis[i]);     }     if (ans < 4)       puts( Poor Dima! );     else       printf( %d n , ans / 4);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   int add(int a, int b) {     a += b;     return a >= mod ? a - mod : a;   }   const int MN = 1000011;   int f[MN][2], n;   inline void Main() {     f[0][0] = f[0][1] = 1;     scanf( %d , &n);     for (register int i = (1), _c = (n); i <= _c; i++)       for (register int j = (0), _c = (1); j <= _c; j++)         if (f[i - 1][j]) {           (f[i][j] = add(f[i][j], f[i - 1][j]));           if (j != i % 2) (f[i][i % 2] = add(f[i][i % 2], f[i - 1][j]));         }     register int ans = add(add(f[n][0], f[n][1]), mod - 2);     printf( %d n , ans);   }   int main() {     Main();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     if (((n * m) % 2 != 0) || (n == 1 && m > 2) || (m == 1 && n > 2)) {       cout << 1 << endl;       cout << n <<     << m <<   1 1  << endl;       for (int i = 1; i <= m; i++) {         for (int j = 1; j <= n; j++) {           if (i % 2 == 1)             cout << j <<     << i << endl;           else             cout << n + 1 - j <<     << i << endl;         }       }       cout <<  1 1 ;       return 0;     }     cout << 0 << endl;     if (n % 2 == 0) {       for (int i = 1; i <= n; i++) cout << i <<     << 1 << endl;       for (int i = n; i >= 1; i--) {         for (int j = 2; j <= m; j++) {           if (i % 2 == 0)             cout << i <<     << j << endl;           else             cout << i <<     << m + 2 - j << endl;         }       }       cout <<  1 1 ;       return 0;     }     if (m % 2 == 0) {       for (int i = 1; i <= m; i++) cout << 1 <<     << i << endl;       for (int i = m; i >= 1; i--) {         for (int j = 2; j <= n; j++) {           if (i % 2 == 0)             cout << j <<     << i << endl;           else             cout << n + 2 - j <<     << i << endl;         }       }       cout <<  1 1 ;       return 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int pri[200050];   int que[200050];   int ans[200050];   int l[200050];   int r[200050];   int main() {     int n;     while (scanf( %d , &n) != EOF) {       for (int i = 1; i <= n; i++) {         scanf( %d , &pri[i]);         ans[i] = 0;         l[i] = r[i] = 1;       }       int s = 1, e = 0;       for (int i = 1; i <= n; i++) {         while (s <= e && pri[que[e]] >= pri[i]) {           l[i] = i - que[e] + l[que[e]];           e--;         }         que[++e] = i;       }       s = 1, e = 0;       for (int i = n; i >= 1; i--) {         while (s <= e && pri[que[e]] >= pri[i]) {           r[i] = r[que[e]] + que[e] - i;           e--;         }         que[++e] = i;       }       for (int i = 1; i <= n; i++) {         ans[l[i]] = max(ans[l[i]], pri[i]);         ans[r[i]] = max(ans[r[i]], pri[i]);         ans[r[i] + l[i] - 1] = max(ans[r[i] + l[i] - 1], pri[i]);       }       for (int i = n - 1; i >= 1; i--) {         ans[i] = max(ans[i], ans[i + 1]);       }       for (int i = 1; i <= n; i++)         if (i == 1)           printf( %d , ans[i]);         else           printf(  %d , ans[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 37;   long long int c[1037][1037];   int main() {     for (int i = 0; i < 1037; i++) {       c[i][0] = 1;       for (int j = 1; j < i + 1; j++) {         c[i][j] = c[i - 1][j - 1] + c[i - 1][j];       }     }     int n, k;     cin >> n >> k;     int pole[5] = {0, 0, 1, 2, 9};     long long int vys = 1;     for (int i = 2; i < k + 1; i++) {       vys += c[n][i] * pole[i];     }     cout << vys << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   using lim = numeric_limits<T>;   const int maxn = 2e5;   int table[maxn * 2 + 2];   int find(int i) {     if (table[i] == i)       return i;     else       return table[i] = find(table[i]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     for (int i = 0; i < 2 * maxn + 2; i++) table[i] = i;     int n, m, q;     cin >> n >> m >> q;     int ans = n + m - 1;     while (q--) {       int x, y;       cin >> x >> y;       x = find(x);       y = find(y + n);       if (x == y) continue;       ans--;       table[x] = y;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   struct trio {     int64_t first, second, trd;     friend ostream &operator<<(ostream &o, trio &a) {       o <<  (  << a.first <<  ,  << a.second <<  ,  << a.trd <<  ) ;       return o;     }   };   template <typename T>   inline T max() {     return numeric_limits<T>::max();   }   template <typename T>   inline T gcd(T a, T b) {     return b == 0 ? a : gcd(b, a % b);   }   template <typename T>   inline void get(T &&v) {     cin >> v;   }   template <typename T, typename... Args>   inline void get(T &&v, Args &&...args) {     cin >> v;     get(args...);   }   template <typename T>   inline void put(T &&v) {     cout << v <<   n ;   }   template <typename T, typename... Args>   inline void put(T &&v, Args &&...args) {     cout << v <<    ;     put(args...);   }   template <typename T>   inline void putc(T &&a, const string s =    ) {     {       for (auto &v : a) cout << v << s;     }     cout <<   n ;   }   ostream &operator<<(ostream &out, pair<int32_t, int32_t> &a) {     out <<  (  << a.first <<  ,  << a.second <<  ) ;     return out;   }   ostream &operator<<(ostream &out, pair<int64_t, int64_t> &a) {     out <<  (  << a.first <<  ,  << a.second <<  ) ;     return out;   }   vector<int32_t> primes;   inline void calc_primes(int32_t lmt) {     vector<char> s(lmt);     primes.push_back(2);     for (int32_t i = 3; i < lmt; i += 2) {       if (s[i]) continue;       primes.push_back(i);       for (int32_t j = i + (i << 1); j < lmt; j += (i << 1)) s[j] = 1;     }   }   inline vector<pair<int32_t, int32_t> > factorize(int32_t n) {     vector<pair<int32_t, int32_t> > a;     int32_t cnt = __builtin_ctzl(n);     a.push_back({2, cnt});     n >>= cnt;     for (auto &d : primes) {       cnt = 0;       while (n % d == 0) n /= d, cnt++;       a.push_back({d, cnt});       if (n == 1) break;     }     if (n != 1) a.push_back({n, 1});     return a;   }   int64_t mod = 1e9 + 9;   inline int64_t mmul(int64_t a, int64_t n) {     if (a < 0) a += mod;     if (n < 0) n += mod;     int64_t r = 0;     while (n) {       if (n & 1) r = (r + a) % mod;       a = (a + a) % mod;       n >>= 1;     }     return r;   }   inline int64_t mpow(int64_t a, int64_t n) {     if (a < 0) a += mod;     if (n < 0) n += mod;     int64_t r = 1;     while (n) {       if (n & 1) r = mmul(r, a);       a = mmul(a, a);       n >>= 1;     }     return r;   }   int main() {     {       ios_base::sync_with_stdio(false);       cin.tie(nullptr);       cout << setprecision(20);     };     int64_t n, a, b, k;     get(n, a, b, k);     int64_t inv_a = mpow(a, mod - 2);     int64_t aa = mpow(a, n);     int64_t bb = 1;     int64_t z = 0;     for (int64_t i = 0; i < k; ++i) {       char c;       cin >> c;       int64_t sgn = (c ==  +  ? 1 : -1);       z = (z + sgn * mmul(aa, bb)) % mod;       aa = mmul(aa, inv_a);       bb = mmul(bb, b);     }     int64_t q = mmul(bb, mpow(inv_a, k));     int64_t s = 0, t = (n + 1) / k;     if (q == 1)       s = t;     else       s = mmul((mod + 1 - mpow(q, t)), mpow(mod + 1 - q, mod - 2));     z = mmul(z, s);     if (z < 0) z += mod;     put(z);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   const int N = 101000;   int n, val[N];   pair<int, int> p[N];   long long A, cf, cm, m, s[N];   int main() {     scanf( %d%lld%lld%lld%lld , &n, &A, &cf, &cm, &m);     for (int i = 1; i < n + 1; i++) {       scanf( %d , &p[i].first);       p[i].second = i;     }     sort(p + 1, p + n + 1);     p[n + 1].first = A;     for (int i = 1; i < n + 1; i++) s[i] = s[i - 1] + p[i].first;     long long ans = 0;     int ansp = 0, ansl = 0, ansv = 0;     if (n * A - s[n] <= m) {       ans = A * cm + n * cf;       ansp = 0;       ansl = 0;       ansv = 0;     }     for (int i = 1; i < n + 1; i++) {       long long c = (n - i) * A - (s[n] - s[i]);       if (c > m) continue;       long long rm = m - c;       int l = 1, r = i + 1;       while (l + 1 < r) {         int md = (l + r) >> 1;         long long sm = (long long)p[md].first * md - s[md];         if (sm <= rm)           l = md;         else           r = md;       }       rm -= ((long long)p[l].first * l - s[l]);       long long nv = p[l + 1].first;       if (l == i) nv = A;       long long mm = min(p[l].first + rm / l, nv);       long long ret = mm * cm + (n - i) * cf;       if (ret >= ans) {         ans = ret;         ansp = i;         ansl = l;         ansv = mm;       }     }     printf( %lld n , ans);     for (int i = ansp + 1; i < n + 1; i++) p[i].first = A;     for (int i = 1; i < ansl + 1; i++) p[i].first = ansv;     for (int i = 1; i < n + 1; i++) val[p[i].second] = p[i].first;     for (int i = 1; i < n + 1; i++) printf( %d  , val[i]);     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   int n;   int x_search(const int &down, const int &up, const int &c) {     int l = down, r = up, key = 0;     while (l <= r) {       int mid = (l + r) / 2, cnt;       cout <<  ?   << mid <<     << 1 <<     << n <<     << n <<   n ;       cin >> cnt;       if (cnt >= c) {         key = mid;         l = mid + 1;       } else         r = mid - 1;     }     return key;   }   int u_search(const int &left, const int &right, const int &c) {     int l = left, r = right, key = right + 1;     while (l <= r) {       int mid = (l + r) / 2, cnt;       cout <<  ?   << 1 <<     << 1 <<     << mid <<     << n <<   n ;       cin >> cnt;       if (cnt >= c) {         key = mid;         r = mid - 1;       } else         l = mid + 1;     }     return key;   }   int y_search(const int &left, const int &right, const int &c) {     int l = left, r = right, key = 0;     while (l <= r) {       int mid = (l + r) / 2, cnt;       cout <<  ?   << 1 <<     << mid <<     << n <<     << n <<   n ;       cin >> cnt;       if (cnt >= c) {         key = mid;         l = mid + 1;       } else         r = mid - 1;     }     return key;   }   int v_search(const int &left, const int &right, const int &c) {     int l = left, r = right, key = right + 1;     while (l <= r) {       int mid = (l + r) / 2, cnt;       cout <<  ?   << 1 <<     << 1 <<     << n <<     << mid <<   n ;       cin >> cnt;       if (cnt >= c) {         key = mid;         r = mid - 1;       } else         l = mid + 1;     }     return key;   }   void check(int x_1, int y_1, int u_1, int v_1, int x_2, int y_2, int u_2,              int v_2) {     if (x_1 > u_1 || y_1 > v_1 || x_2 > u_2 || y_2 > v_2) return;     int c1, c2;     cout <<  ?   << x_1 <<     << y_1 <<     << u_1 <<     << v_1 <<   n ;     cin >> c1;     cout <<  ?   << x_2 <<     << y_2 <<     << u_2 <<     << v_2 <<   n ;     cin >> c2;     if (c1 == 1 && c2 == 1)       cout <<  !   << x_1 <<     << y_1 <<     << u_1 <<     << v_1 <<     << x_2            <<     << y_2 <<     << u_2 <<     << v_2 <<   n ;   }   int main() {     cin >> n;     int x_1 = x_search(1, n, 2), x_2 = x_search(x_1, n, 1),         u_2 = u_search(1, n, 2), u_1 = u_search(1, u_2, 1),         y_1 = y_search(1, n, 2), y_2 = y_search(y_1, n, 1),         v_2 = v_search(1, n, 2), v_1 = v_search(1, v_2, 1);     int c;     check(x_1, y_1, u_1, v_1, x_2, y_2, u_2, v_2);     check(x_1, y_1, u_2, v_1, x_2, y_2, u_1, v_2);     check(x_1, y_1, u_1, v_2, x_2, y_2, u_2, v_1);     check(x_1, y_1, u_2, v_2, x_2, y_2, u_1, v_1);     check(x_1, y_2, u_1, v_1, x_2, y_1, u_2, v_2);     check(x_1, y_2, u_2, v_1, x_2, y_1, u_1, v_2);     check(x_1, y_2, u_1, v_2, x_2, y_1, u_2, v_1);     check(x_1, y_2, u_2, v_2, x_2, y_1, u_1, v_1);   }
#include <bits/stdc++.h>   using namespace std;   constexpr long long int mod = 1e9 + 7;   constexpr long long int MAXN = 1e6 + 3;   constexpr long long int inf = 1ll << 32;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> vx(n + 2);     int med = 0;     for (int c = 1; c <= n; c++) {       cin >> vx[c];       vx[c] += vx[c - 1];     }     if (vx[n] % 2 == 0)       med = vx[n] / 2;     else       med = vx[n] / 2 + 1;     for (int c = 1; c <= n; c++)       if (vx[c] >= med) {         cout << c;         return 0;       }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int pos[11][1111];   int gra[1111][1111];   int main() {     int n, m;     cin >> n >> m;     int x;     for (int i = 0; i < m; i++) {       for (int j = 0; j < n; j++) {         cin >> x;         pos[i][x - 1] = j;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         int flag = 1;         for (int k = 0; k < m; k++) {           flag &= (pos[k][i] < pos[k][j]);         }         if (flag == true)           gra[i][j] = 1;         else           gra[i][j] = -INF;       }     }     for (int k = 0; k < n; k++) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           gra[i][j] = max(gra[i][j], gra[i][k] + gra[k][j]);         }       }     }     int ans = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         ans = max(ans, gra[i][j]);       }     }     cout << ans + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   using ll = long long;   using ii = pair<int, int>;   using uint = unsigned int;   const int N = 1e5 + 5, MOD = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     vector<int> deg(n + 1);     for (int i = 1, u, v; i < n; i++) {       cin >> u >> v;       deg[u]++;       deg[v]++;     }     if (find(deg.begin(), deg.end(), 2) == deg.end())       cout <<  YES n ;     else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, y;   set<pair<int, int> > S, T;   int solve(set<pair<int, int> >& s, set<pair<int, int> >& t) {     set<pair<int, int> >::iterator it1, it2, it3, it4;     it1 = s.begin();     it2 = s.end();     it2--;     it3 = t.begin();     it4 = t.end();     it4--;     while (it1->first < it2->first || it3->first < it4->first) {       int x = it1->first;       int xx = (++it1)->first;       if (xx > x + 1) {         set<pair<int, int> > res_s;         set<pair<int, int> > res_t;         while (1) {           it1 = s.begin();           if (it1->first == xx) break;           res_s.insert(make_pair(it1->first, it1->second));           res_t.insert(make_pair(it1->second, it1->first));           s.erase(make_pair(it1->first, it1->second));           t.erase(make_pair(it1->second, it1->first));         }         return solve(s, t) + solve(res_s, res_t);       }       x = it2->first;       xx = (--it2)->first;       if (xx < x - 1) {         set<pair<int, int> > res_s;         set<pair<int, int> > res_t;         while (1) {           it2 = s.end();           it2--;           if (it2->first == xx) break;           res_s.insert(make_pair(it2->first, it2->second));           res_t.insert(make_pair(it2->second, it2->first));           s.erase(make_pair(it2->first, it2->second));           t.erase(make_pair(it2->second, it2->first));         }         return solve(s, t) + solve(res_s, res_t);       }       int y = it3->first;       int yy = (++it3)->first;       if (yy > y + 1) {         set<pair<int, int> > res_s;         set<pair<int, int> > res_t;         while (1) {           it3 = t.begin();           if (it3->first == yy) break;           res_s.insert(make_pair(it3->second, it3->first));           res_t.insert(make_pair(it3->first, it3->second));           s.erase(make_pair(it3->second, it3->first));           t.erase(make_pair(it3->first, it3->second));         }         return solve(s, t) + solve(res_s, res_t);       }       y = it4->first;       yy = (--it4)->first;       if (yy < y - 1) {         set<pair<int, int> > res_s;         set<pair<int, int> > res_t;         while (1) {           it4 = t.end();           it4--;           if (it4->first == yy) break;           res_s.insert(make_pair(it4->second, it4->first));           res_t.insert(make_pair(it4->first, it4->second));           s.erase(make_pair(it4->second, it4->first));           t.erase(make_pair(it4->first, it4->second));         }         return solve(s, t) + solve(res_s, res_t);       }     }     return 1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &x, &y);       S.insert(make_pair(x, y));       T.insert(make_pair(y, x));     }     printf( %d n , solve(S, T));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, sn, i, j, sum, temp, nl;   map<int, int> myMap;   vector<int> t[105];   int main() {     cin >> n;     j = 0;     sn = n * n;     for (i = sn; i > sn / 2; i--) {       t[j % n].push_back(i);       t[j % n].push_back(sn - i + 1);       j++;     }     for (i = 0; i < n; i++) {       nl = t[i].size();       for (j = 0; j < nl; j++) cout << t[i][j] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Number[12][12];   int Next[110];   double dp[110];   int main() {     for (int i = 1; i <= 10; i++)       for (int j = 1; j <= 10; j++)         Number[i][j] = (10 - i) * 10 + (i % 2 == 0 ? j : 11 - j);     for (int i = 1; i <= 10; i++) {       for (int j = 1; j <= 10; j++) {         int x;         scanf( %d , &x);         if (x == 0)           Next[Number[i][j]] = Number[i][j];         else           Next[Number[i][j]] = Number[i - x][j];       }     }     dp[100] = 0;     double c = 1;     for (int i = 99; i >= 94; i--) {       dp[i] = (c + 6 - (100 - i)) / (100 - i);       c += dp[i] + 1;     }     for (int i = 93; i >= 1; i--) {       double temp = 0;       for (int j = 1; j <= 6; j++) temp += min(dp[i + j], dp[Next[i + j]]);       dp[i] = temp / 6 + 1;     }     printf( %.10f n , dp[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a, b, c, d;       cin >> a >> b >> c >> d;       if (a < b) swap(a, b);       if (c < d) swap(c, d);       cout << ((a == c && b + d == a) ?  Yes n  :  No n );     }   }
#include <bits/stdc++.h>   int main() {     int64_t d1, d2, d3;     std::cin >> d1 >> d2 >> d3;     int64_t dist = d1 + d2 + d3;     dist = std::min(dist, 2 * d1 + 2 * d2);     dist = std::min(dist, 2 * d1 + 2 * d3);     dist = std::min(dist, 2 * d2 + 2 * d3);     std::cout << dist << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2e9;   long long gcd(long long a, long long b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   int main() {     long long l, r, x, y;     cin >> l >> r >> x >> y;     long long d = 1;     long long res = 0;     map<int, int> m;     while (d * d <= y) {       if (y % d == 0) {         if (!m[min(y / d, d * x)] && d * x >= l && d * x <= r && y / d >= l &&             y / d <= r && gcd(d * x, y / d) == x) {           res++;           if (d * x != y / d) res++;           m[min(y / d, d * x)]++;         }       }       d++;     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 50010;   const int mod = 998244353;   int n;   const int a[16] = {0,   4,  8,   -1, 16,  -10, 4,  -12,                      -48, 26, -44, 15, -16, -4,  -4, -1};   int f[N] = {0,    0,    0,     24,    4,      240,    204,     1316,               2988, 6720, 26200, 50248, 174280, 436904, 1140888, 3436404};   int main() {     for (int i = 16; i <= 50000; i++)       for (int j = 0; j <= 15; j++)         f[i] = ((f[i] + 1ll * a[j] * f[i - j - 1]) % mod + mod) % mod;     scanf( %d , &n);     printf( %d n , f[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e2;   pair<pair<int, int>, bool> pr[maxn][maxn][2];   queue<pair<pair<int, int>, bool> > q;   vector<int> neighbor[maxn];   void bfs(int s, int t) {     for (int i = 0; i < maxn; i++)       for (int j = 0; j < maxn; j++)         for (int k = 0; k < 2; k++)           pr[i][j][k] = make_pair(make_pair(-1, -1), false);     q.push(make_pair(make_pair(s, t), 0));     while (!q.empty()) {       int v = q.front().first.second, u = q.front().first.first;       bool b = q.front().second;       q.pop();       if (!b) {         for (int i = 0; i < neighbor[u].size(); i++)           if (pr[neighbor[u][i]][v][!b].first.first == -1) {             pr[neighbor[u][i]][v][!b] = make_pair(make_pair(u, v), b);             q.push(make_pair(make_pair(neighbor[u][i], v), !b));           }       } else {         for (int i = 0; i < neighbor[v].size(); i++)           if (pr[u][neighbor[v][i]][!b].first.first == -1 &&               neighbor[v][i] != u && (u != s || neighbor[v][i] != t)) {             pr[u][neighbor[v][i]][!b] = make_pair(make_pair(u, v), b);             q.push(make_pair(make_pair(u, neighbor[v][i]), !b));           }       }     }   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       neighbor[u - 1].push_back(v - 1);       neighbor[v - 1].push_back(u - 1);     }     bfs(0, n - 1);     if (pr[n - 1][0][0].first.first == -1)       cout << -1;     else {       vector<int> fi, se;       pair<pair<int, int>, bool> kl = make_pair(make_pair(n - 1, 0), 0);       while (kl.first.first != -1) {         if (kl.second)           se.push_back(kl.first.second);         else           fi.push_back(kl.first.first);         kl = pr[kl.first.first][kl.first.second][kl.second];       }       cout << fi.size() - 1 << endl;       for (int i = fi.size() - 1; i > -1; i--) cout << fi[i] + 1 <<    ;       cout << endl;       for (int i = se.size() - 1; i > -1; i--) cout << se[i] + 1 <<    ;       cout << 1;     }   }