malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   struct Comp {     double re, im;     Comp(double x = 0.0, double y = 0.0) : re(x), im(y) {}     Comp operator+(const Comp& rhs) const {       return Comp(re + rhs.re, im + rhs.im);     }     Comp operator-(const Comp& rhs) const {       return Comp(re - rhs.re, im - rhs.im);     }     Comp operator*(const Comp& rhs) const {       return Comp(re * rhs.re - im * rhs.im, re * rhs.im + im * rhs.re);     }     Comp operator/(double x) const { return Comp(re / x, im / x); }   };   int fft_len, fft_lg;   vector<int> r;   void ensure_base(int deg) {     fft_len = 2, fft_lg = 1;     while (fft_len <= deg) fft_len <<= 1, fft_lg++;     r = vector<int>(fft_len, 0);     for (int i = 0; i < fft_len; ++i)       r[i] = (r[i >> 1] >> 1) | ((i & 1) << (fft_lg - 1));   }   void fft(vector<Comp>& A, int dft) {     for (int i = 0; i < fft_len; ++i)       if (i < r[i]) swap(A[i], A[r[i]]);     for (int mid = 1; mid < fft_len; mid <<= 1) {       Comp wn = Comp(cos(PI / mid), sin(PI / mid) * dft);       for (int len = mid << 1, s = 0; s < fft_len; s += len) {         Comp w(1, 0);         for (int k = 0; k < mid; ++k, w = w * wn) {           Comp x = A[s + k], y = w * A[s + k + mid];           A[s + k] = x + y;           A[s + k + mid] = x - y;         }       }     }     if (dft == -1)       for (int i = 0; i < fft_len; ++i) A[i] = A[i] / fft_len;   }   void fft_pmul(vector<Comp>& A, int degA, vector<Comp>& B, int degB) {     ensure_base(degA + degB);     A.resize(fft_len, 0), B.resize(fft_len, 0);     fft(A, 1);     fft(B, 1);     for (int i = 0; i < fft_len; ++i) A[i] = A[i] * B[i];     fft(A, -1);   }   int p[26], q[26];   string s, t;   int main() {     ios::sync_with_stdio(false);     for (int i = 0; i < 26; ++i) cin >> q[i], p[q[i] - 1] = i;     cin >> t >> s;     int n = s.length(), m = t.length();     reverse(t.begin(), t.end());     vector<Comp> ps1(n), ps2(n), ps3(n), pt1(m), pt2(m), pt3(m);     vector<double> p0(n);     for (int i = 0; i < n; ++i) {       int v = s[i] -  a ;       ps3[i].re = -(2 * v + 2 * p[v]);       ps2[i].re = v * v + 4 * v * p[v] + p[v] * p[v];       ps1[i].re = -2 * v * p[v] * (v + p[v]);       p0[i] = v * v * p[v] * p[v];       if (i) p0[i] += p0[i - 1];     }     double t4 = 0;     for (int i = 0; i < m; ++i) {       int v = t[i] -  a ;       pt3[i].re = v * v * v;       pt2[i].re = v * v;       pt1[i].re = v;       t4 += v * v * v * v;     }     fft_pmul(ps3, n, pt3, m);     fft_pmul(ps2, n, pt2, m);     fft_pmul(ps1, n, pt1, m);     for (int i = m - 1; i < n; ++i) {       double res = t4 + ps3[i].re + ps2[i].re + ps1[i].re + p0[i] -                    (i - m < 0 ? 0 : p0[i - m]);       putchar( 0  + (fabs(res) < 0.8));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[110], b[110];   int main() {     int n, m, i, j;     cin >> n >> m;     for (i = 1; i <= m; i++) cin >> a[i];     for (i = 1; i <= m; i++)       for (j = a[i]; b[j] == 0; j++) b[j] = a[i];     for (i = 1; i <= n; i++) cout << b[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100100], b[100100];   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long n, m, cl, ce, v, x1, y1, x2, y2, q, mi;     cin >> n >> m >> cl >> ce >> v;     for (long long i = 0; i < cl; i++) cin >> a[i];     for (long long i = 0; i < ce; i++) cin >> b[i];     cin >> q;     while (q--) {       mi = 1e18;       cin >> x1 >> y1 >> x2 >> y2;       swap(x1, y1);       swap(x2, y2);       if (x1 > x2) swap(x1, x2), swap(y1, y2);       long long t = abs(y1 - y2);       if (t == 0) {         cout << abs(x1 - x2) << endl;         continue;       }       long long p = lower_bound(a, a + cl, x1) - a;       if (p != cl) {         if (a[p] <= x2)           mi = min(mi, x2 - x1 + t);         else           mi = min(mi, a[p] - x1 + a[p] - x2 + t);       }       p = upper_bound(a, a + cl, x1) - a;       if (p != 0) mi = min(mi, x2 - a[p - 1] + x1 - a[p - 1] + t);       p = lower_bound(b, b + ce, x1) - b;       if (p != ce) {         if (b[p] <= x2)           mi = min(mi, x2 - x1 + (t % v == 0 ? (t / v) : (t / v + 1)));         else           mi = min(mi,                    b[p] - x2 + b[p] - x1 + (t % v == 0 ? (t / v) : (t / v + 1)));       }       p = upper_bound(b, b + ce, x1) - b;       if (p != 0)         mi = min(mi, x2 - b[p - 1] + x1 - b[p - 1] +                          (t % v == 0 ? (t / v) : (t / v + 1)));       cout << mi << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(NULL);     string com;     cin >> com;     string s[5];     for (int i = 0; i < 5; i++) {       cin >> s[i];       if (s[i][0] == com[0] || s[i][1] == com[1]) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> adj[200001];   bool vis[200001];   int en = -1;   int a[200005], b[200005];   void dfs(int x) {     vis[x] = 1;     for (auto it = adj[x].begin(); it != adj[x].end(); ++it) {       if (!vis[*it]) {         dfs(*it);       }     }     if (en == -1) en = x;   }   int main() {     int n, m, i, k, l = 0, ans = 0;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i];       adj[i].push_back(a[i]);     }     int flag = 0;     for (i = 1; i <= n; i++) {       cin >> b[i];       if (b[i]) flag++;     }     if (!flag)       ans++;     else if (flag % 2 == 0)       ans++;     int temp = -1;     for (i = 1; i <= n; i++) {       if (!vis[i]) {         temp = en;         en = -1;         dfs(i);         adj[en].clear();         if (temp > 0) {           ans++;           adj[temp].push_back(i);         }       }     }     if (temp != -1) {       adj[en].push_back(1);       ans++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, p;   long long fac[250005], ans;   int main() {     scanf( %d%d , &n, &p);     fac[0] = 1;     for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;     for (int i = 1; i <= n; i++)       ans = (ans + fac[n - i + 1] * (n - i + 1) % p * fac[i] % p) % p;     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long s[n];     for (long long c = 0; c < n; c++) cin >> s[c];     long long sum = 0;     long long nextAllowedNum = 10000000000000 + 33;     for (long long c = n - 1; c >= 0; c--) {       if (nextAllowedNum <= 0) break;       long long takeval = 0;       takeval = s[c] <= nextAllowedNum ? s[c] : nextAllowedNum;       nextAllowedNum = takeval - 1;       sum += takeval;     }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void vin(vector<long long int> &v, long long int t) {     for (long long int i = 0; i < t; i++) cin >> v[i];   }   void vout(vector<long long int> &v, long long int t) {     for (long long int i = 0; i < t; i++) cout << v[i] <<    ;     cout << endl;   }   void ingraph(vector<vector<long long int>> &graph, long long int m) {     long long int x, y;     for (long long int i = 0; i < m; i++) {       cin >> x >> y;       x--, y--;       graph[x].push_back(y);       graph[y].push_back(x);     }   }   bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {     return (a.second < b.second);   }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int lcm(long long int a, long long int b) {     return a * b / gcd(a, b);   }   void solve() {     long long int n, m, x, y;     cin >> n >> m >> x >> y;     long long int cost = 0;     y = min(y, 2 * x);     for (long long int i = 0; i < n; i++) {       string s;       cin >> s;       for (long long int j = 0; j < m; j++) {         if (s[j] ==  . ) {           if (j != m - 1 && s[j + 1] ==  . )             cost += y, j++;           else             cost += x;         }       }     }     cout << cost <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int gi() {     char c = getchar();     int x = 0, f = 1;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) f = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) x = (x << 1) + (x << 3) + c -  0 ;     return x * f;   }   const int N = 5e5 + 5, Mod = 1e9 + 7;   int x[N], y[N], n;   long long ara, sx[N], sy[N], ssum[N], ans;   long long sum[N];   long long cross(int i, int j) { return 1ll * x[i] * y[j] - 1ll * x[j] * y[i]; }   long long cross(long long x1, long long y1, long long x2, long long y2,                   bool b = true) {     if (!b) return x1 * y2 - x2 * y1;     x1 %= Mod, y1 %= Mod;     return (x1 * y2 - x2 * y1) % Mod;   }   int main() {     n = gi();     for (int i = 1; i <= n; ++i) x[i] = gi(), y[i] = gi();     for (int i = 3; i <= n; ++i)       ara += cross(x[i] - x[1], y[i] - y[1], x[i - 1] - x[1], y[i - 1] - y[1], 0);     for (int i = 2; i <= n; ++i)       sum[i] = sum[i - 1] + cross(i, i - 1),       ssum[i] = (ssum[i - 1] + sum[i]) % Mod;     for (int i = 1; i <= n; ++i)       sx[i] = sx[i - 1] + x[i], sy[i] = sy[i - 1] + y[i];     for (int i = 1, j = 0; i <= n; ++i) {       for (j = max(j, i + 2); j <= n - (i == 1); ++j)         if (2ull * (sum[j] - sum[i] - cross(j, i)) > ara) break;       const int m = n - (i == 1);       int tmp = 0;       tmp = (ssum[j - 1] - ssum[i + 1] - sum[i] % Mod * (j - i - 2)) % Mod;       tmp = (tmp -              cross(sx[j - 1] - sx[i + 1], sy[j - 1] - sy[i + 1], x[i], y[i])) %             Mod;       ans = (ans + ara % Mod * (j - i - 2) % Mod - 2 * tmp % Mod + Mod) % Mod;       if (j > m) continue;       tmp = (ssum[m] - ssum[j - 1] - sum[i] % Mod * (m - j + 1)) % Mod;       tmp = (tmp - cross(sx[m] - sx[j - 1], sy[m] - sy[j - 1], x[i], y[i])) % Mod;       ans = ((ans + tmp * 2 - ara % Mod * (m - j + 1) % Mod) % Mod + Mod) % Mod;     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 7, inf = 1e9;   long long n, m, cnt, ans;   long long a[N], b[N], c[N], tr[N];   long long lowbit(long long x) { return x & -x; }   long long query(long long x) {     long long sum = 0;     for (; x; x -= lowbit(x)) sum += tr[x];     return sum;   }   void add(long long x) {     for (; x <= cnt; x += lowbit(x)) tr[x]++;   }   long long check(long long x) {     long long sum = 0;     add(lower_bound(b + 1, b + cnt + 1, 0) - b);     for (long long i = 1; i <= n; i++) {       if (a[i] - x < b[1])         sum += i;       else if (a[i] - x > b[cnt])         ;       else {         long long pos = lower_bound(b + 1, b + cnt + 1, a[i] - x) - b;         if (b[pos] > a[i] - x) pos--;         sum += i - query(pos);       }       add(c[i]);     }     return sum;   }   signed main() {     scanf( %lld%lld , &n, &m);     for (long long i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (long long i = 1; i <= n; i++) a[i] = a[i - 1] + a[i], b[i] = a[i];     b[n + 1] = 0;     sort(b + 1, b + n + 2);     cnt = unique(b + 1, b + n + 2) - b - 1;     for (long long i = 1; i <= n; i++)       c[i] = lower_bound(b + 1, b + cnt + 1, a[i]) - b;     printf( %lld n , check(m));   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e6 + 10;   long long n, k, A[maxn];   int32_t main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (long long i = 0; i < n; i++) {       long long a, b, c, d;       cin >> a >> b >> c >> d;       if (a > b * c) {         cout << -1 << endl;         continue;       }       long long e = (a + d * b - 1) / (d * b);       cout << e * a - (e * (e - 1ll) / 2ll * d * b) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   struct Boot {     int _pos;     char _char;   };   struct PairBoots {     Boot _left;     Boot _right;   };   int main() {     int n;     string leftBoots;     string rightBoots;     vector<vector<Boot>> leftBootsBucket(27);     vector<vector<Boot>> rightBootsBucket(27);     vector<PairBoots> ans;     cin >> n;     cin.ignore();     getline(cin, leftBoots);     getline(cin, rightBoots);     for (int i = 0; i < n; i++) {       Boot leftBoot;       leftBoot._pos = i;       leftBoot._char = leftBoots[i];       if (leftBoot._char ==  ? )         leftBootsBucket[26].push_back(leftBoot);       else         leftBootsBucket[leftBoots[i] -  a ].push_back(leftBoot);       Boot rightBoot;       rightBoot._pos = i;       rightBoot._char = rightBoots[i];       if (rightBoot._char ==  ? )         rightBootsBucket[26].push_back(rightBoot);       else         rightBootsBucket[rightBoots[i] -  a ].push_back(rightBoot);     }     for (int i = 0; i < 27; i++) {       for (int j = 0;            j < leftBootsBucket[i].size() || j < rightBootsBucket[i].size(); j++) {         PairBoots temp;         if (j < leftBootsBucket[i].size() && j < rightBootsBucket[i].size()) {           temp._left = leftBootsBucket[i][j];           temp._right = rightBootsBucket[i][j];         } else {           if (j < leftBootsBucket[i].size()) {             if (rightBootsBucket[26].size() != 0) {               temp._left = leftBootsBucket[i][j];               temp._right = rightBootsBucket[26][rightBootsBucket[26].size() - 1];               rightBootsBucket[26].pop_back();               goto here;             }           }           if (j < rightBootsBucket[i].size()) {             if (leftBootsBucket[26].size() != 0) {               temp._left = leftBootsBucket[26][leftBootsBucket[26].size() - 1];               temp._right = rightBootsBucket[i][j];               leftBootsBucket[26].pop_back();               goto here;             }           }           break;         }       here:         ans.push_back(temp);       }     }     cout << ans.size() <<   n ;     for (auto i : ans) {       cout << i._left._pos + 1 <<     << i._right._pos + 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   bool choice_first(std::vector<size_t> a, std::vector<size_t> b) {     uint64_t sum_a, sum_b;     sum_a = sum_b = 0;     for (auto elem : a) {       sum_a += elem;     }     for (auto elem : b) {       sum_b += elem;     }     return sum_a > sum_b || (sum_a == sum_b && a < b);   }   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(0);     std::cout.tie(0);     size_t n, m;     std::cin >> n;     std::vector<std::vector<std::vector<size_t>>> dp(         n + 1, std::vector<std::vector<size_t>>(n + 1));     std::vector<size_t> a(n);     for (size_t i = 0; i < n; i++) {       std::cin >> a[i];     }     std::cin >> m;     for (size_t i = 0; i < n; i++) {       if (i == 0) {         dp[1][i] = {a[0]};         continue;       }       dp[1][i] = std::max(std::vector<size_t>{a[i]}, dp[1][i - 1]);     }     for (size_t i = 2; i <= n; i++) {       for (size_t j = i - 1; j < n; j++) {         if (j == i - 1) {           std::vector<size_t> cur = dp[i - 1][j - 1];           cur.push_back(a[j]);           dp[i][j] = cur;           continue;         }         std::vector<size_t> first, second;         first = dp[i - 1][j - 1];         first.push_back(a[j]);         second = dp[i][j - 1];         if (choice_first(first, second)) {           dp[i][j] = first;         } else {           dp[i][j] = second;         }       }     }     for (size_t i = 0; i < m; i++) {       size_t k, pos;       std::cin >> k >> pos;       std::cout << dp[k][n - 1][pos - 1] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T abs(T zz) {     return zz < 0 ? -zz : zz;   }   template <typename T>   inline T sqr(T zz) {     return zz * zz;   }   const int MAGIC = 1000500;   vector<int> used;   vector<int> primes;   bool is_prime(int n) {     for (int p : primes) {       if (p * p > n) break;       if (n % p == 0) return false;     }     return true;   }   int main() {     used = vector<int>(MAGIC, 0);     for (int i = 2; i < MAGIC; ++i) {       if (!used[i]) {         primes.push_back(i);         for (int j = i; j < MAGIC; j += i) {           used[j] = true;         }       }     }     int n;     cin >> n;     if (is_prime(n) == 1) {       cout << 1 << endl;       return 0;     }     if (n % 2 == 0) {       cout << 2 << endl;       return 0;     }     if (is_prime(n - 2)) {       cout << 2 << endl;       return 0;     }     cout << 3 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int ans = 0, n;     string s;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> s;       int flag = 0;       for (int i = 0; i < s.length(); i++)         if (s[i] ==  + ) flag = 1;       if (flag)         ans += 1;       else         ans -= 1;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   double R, r;   struct Punct {     double x, y;   };   Punct A, B;   inline double Dist(Punct A, Punct B) {     return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));   }   int main() {     double d;     cin >> A.x >> A.y >> R;     cin >> B.x >> B.y >> r;     d = Dist(A, B);     if (R >= r) {       if (d + r <= R) {         d = R - d - r;         d /= 2.0;       } else {         if (d <= R + r)           d = 0.0;         else {           d = d - R - r;           d /= 2.0;         }       }     } else {       if (d + R <= r) {         d = r - d - R;         d /= 2.0;       } else {         if (d <= R + r)           d = 0.0;         else {           d = d - R - r;           d /= 2.0;         }       }     }     printf( %.6lf n , d);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void smain();   int main() {     ios_base::sync_with_stdio(0);     cout.precision(12);     cout << fixed;     smain();     return 0;   }   int n;   int ans[1000001];   int f[1000001];   inline int sum(int r) {     int result = 0;     for (; r >= 0; r = (r & (r + 1)) - 1) result += f[r];     return result;   }   inline void inc(int i, int delta) {     for (; i < n; i = (i | (i + 1))) f[i] += delta;   }   void solve(vector<pair<int, pair<int, int> > > &q) {     vector<int> ts;     ts.reserve(q.size());     for (auto it : q) ts.push_back(it.first);     sort(ts.begin(), ts.end());     ts.resize(unique(ts.begin(), ts.end()) - ts.begin());     int m = ts.size();     memset(f, 0, sizeof(int) * m);     for (auto it : q) {       int tp = it.second.first;       int t = lower_bound(ts.begin(), ts.end(), it.first) - ts.begin();       if (tp == 1) {         inc(t, 1);       } else if (tp == 2) {         inc(t, -1);       } else {         ans[it.second.second] = sum(t);       }     }   }   void smain() {     for (; scanf( %d , &n) != EOF;) {       map<int, vector<pair<int, pair<int, int> > > > q;       for (int i = 0; i < n; i++) {         int a, t, x;         scanf( %d %d %d , &a, &t, &x);         q[x].emplace_back(t, make_pair(a, i));       }       memset(ans, 255, sizeof(int) * n);       for (auto it : q) solve(it.second);       for (int i = 0; i < n; i++)         if (ans[i] != -1) printf( %d n , ans[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, -1, 1};   int dy[] = {-1, 1, 0, 0};   const int N = 1e6 + 5;   long long ans, sum, d[N];   int n, m;   int main() {     int a, b;     while (~scanf( %d%d , &n, &m)) {       memset(d, 0, sizeof(d));       for (int i = 0; i < (m); ++i) {         scanf( %d%d , &a, &b);         d[a]++, d[b]++;       }       if (n < 3) {         puts( 0 );         continue;       }       ans = (long long)n * (n - 1) * (n - 2) / 6;       sum = 0;       for (int i = (1); i <= (n); ++i) sum += d[i] * (n - 1 - d[i]);       sum /= 2;       printf( %lld n , ans - sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[200009], ans = 1, b[200009], sum = 1;   bool vis[200009];   void dfs(long long x) {     if (vis[x]) return;     vis[x] = 1;     dfs(a[x]);   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) cin >> b[i];     dfs(1);     for (int i = 1; i <= n; i++) {       if (vis[i]) continue;       sum++;       dfs(i);     }     bool f = 0, g = 0;     for (int i = 1; i <= n; i++) {       ans += b[i];     }     ans %= 2;     if (sum != 1) ans += sum;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[2][105];   int main() {     int c, w, h, c2;     cin >> c >> w >> h;     c2 = (c + 1) >> 1;     int *src = dp[0], *dst = dp[1];     src[0] = 1;     for (int i = 1; i <= w; i++) src[i] = 0;     while (c2--) {       dst[0] = src[0];       for (int i = 1; i <= w; i++) {         dst[i] = src[i - 1] * h % 1000003;         dst[0] += src[i];       }       dst[0] %= 1000003;       swap(src, dst);     }     int ans = 0, sum = 0;     if ((c & 1) == 0) {       for (int i = 0; i <= w; i++) {         sum += src[i];         ans = (ans + (long long)sum * src[w - i]) % 1000003;       }     } else {       for (int i = 0; i <= w; i++) {         sum += dst[i];         ans = (ans + (long long)sum * src[w - i]) % 1000003;       }     }     cout << ans % 1000003 << endl;     return 0;   }
#include <bits/stdc++.h>   const int N = 1e6 + 10;   const int mod = 1e9 + 7;   const int INF = 0x3f3f3f3f;   using namespace std;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   int n, m;   long long f[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     f[1] = 2, f[2] = 4;     cin >> n >> m;     for (int i = 3; i <= max(n, m); ++i) f[i] = f[i - 1] % mod + f[i - 2] % mod;     cout << (f[n] + f[m] - 2) % mod <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct lhy {     int x, y, l, r, id;   } b[400040];   int n, m, mN, ans;   int cnt[400040], a[400040], Ans[400040], c[2 * 400040], C[2 * 400040],       L[400040], R[400040], x[2 * 400040];   inline void add(int x, int o) {     for (; x <= mN; x += x & -x) c[x] = max(c[x], o);   }   inline int ask(int x) {     int nowans = 0;     for (; x; x -= x & -x) nowans = max(nowans, c[x]);     return nowans;   }   inline void Add(int x, int o) {     for (; x; x -= x & -x) C[x] = max(C[x], o);   }   inline int Ask(int x) {     int nowans = 0;     for (; x <= mN; x += x & -x) nowans = max(nowans, C[x]);     return nowans;   }   inline int cmp(const lhy &a, const lhy &b) { return a.x < b.x; }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), x[++x[0]] = a[i];     for (int i = 1; i <= m; i++)       scanf( %d%d , &b[i].x, &b[i].y), b[i].id = i, x[++x[0]] = b[i].y;     sort(x + 1, x + 1 + x[0]);     mN = unique(x + 1, x + 1 + x[0]) - x - 1;     for (int i = 1; i <= n; i++) a[i] = lower_bound(x + 1, x + 1 + mN, a[i]) - x;     for (int i = 1; i <= m; i++)       b[i].y = lower_bound(x + 1, x + 1 + mN, b[i].y) - x;     sort(b + 1, b + 1 + m, cmp);     int now = 1;     for (int i = 1; i <= n; i++) {       L[i] = ask(a[i] - 1);       while (b[now].x == i) {         b[now].l = ask(b[now].y - 1);         now++;       }       add(a[i], L[i] + 1);     }     now = m;     for (int i = n; i; i--) {       R[i] = Ask(a[i] + 1);       while (b[now].x == i) {         b[now].r = Ask(b[now].y + 1);         now--;       }       Add(a[i], R[i] + 1);     }     for (int i = 1; i <= n; i++) ans = max(ans, L[i] + R[i] + 1);     for (int i = 1; i <= n; i++)       if (L[i] + R[i] + 1 == ans) cnt[L[i]]++;     for (int i = 1; i <= m; i++)       if (L[b[i].x] + R[b[i].x] + 1 < ans || cnt[L[b[i].x]] > 1)         Ans[b[i].id] = max(ans, b[i].l + b[i].r + 1);       else         Ans[b[i].id] = max(ans - 1, b[i].l + b[i].r + 1);     for (int i = 1; i <= m; i++) printf( %d n , Ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[100069], dv;   int main() {     long long i, j, z = 1;     scanf( %lld%lld , &n, &dv);     if (n > dv) {       printf( 0 n );       return 0;     }     for (i = 1; i <= n; i++) {       scanf( %lld , a + i);       for (j = 1; j < i; j++) {         z = z * abs(a[i] - a[j]) % dv;       }     }     printf( %lld n , z);   }