malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T>   ostream& operator<<(ostream& os, vector<T> V) {     for (auto v : V) os << v <<    ;     return cout <<   ;   }   template <class T>   ostream& operator<<(ostream& os, set<T> S) {     for (auto s : S) os << s <<    ;     return cout <<   ;   }   template <class L, class R>   ostream& operator<<(ostream& os, pair<L, R> P) {     return os << P.first <<     << P.second;   }   const long long mod = 1e9 + 7;   long long inv(long long i) {     if (i == 1) return 1;     return (mod - ((mod / i) * inv(mod % i)) % mod) % mod;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long pwr(long long a, long long b) {     a %= mod;     long long res = 1;     while (b > 0) {       if (b & 1) res = res * a % mod;       a = a * a % mod;       b >>= 1;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int T = 1;     cin >> T;     while (T--) {       int n, c0, c1, h, x = 0, y = 0;       cin >> n >> c0 >> c1 >> h;       string s;       cin >> s;       for (int i = 0; i < n; i++) {         if (s[i] ==  0 )           x++;         else           y++;       }       if (c0 >= c1 + h) {         cout << x * h + n * c1 <<   n ;       } else if (c1 >= c0 + h) {         cout << y * h + n * c0 <<   n ;       } else {         cout << x * c0 + y * c1 <<   n ;       }     }   }
#include <bits/stdc++.h>   long long n, m, k, a[11111], kq;   long long min(long long a, long long b) {     if (a < b) return a;     return b;   }   int main() {     scanf( %lld %lld %lld , &n, &m, &k);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     if (n % 2 == 0)       printf( 0 );     else {       kq = a[1];       for (int i = 3; i <= n; i += 2) kq = min(kq, a[i]);       kq = min(kq, (m / ((n + 1) / 2)) * k);       printf( %lld , kq);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000000 + 7;   const int M = 32;   const long long base = 1e18;   const int mod = 999983;   const int inf = 1e9 + 7;   const double pi = acos(-1);   const int maxn = N * 2;   const double PI = acos(-1);   const double ep = 1e-9;   int n, m, s, e;   int a[N], b[N];   int last[N];   map<int, int> st;   vector<int> all[N];   int dp[2][N];   int getPos(int x) {     if (st.count(x))       return st[x];     else       return st[x] = st.size();   }   void solve() {     cin >> n >> m >> s >> e;     for (int i = (0); i < (n); i++) scanf( %d , a + i);     for (int j = (0); j < (m); j++) {       scanf( %d , b + j);       all[getPos(b[j])].push_back(j);     }     last[0] = -1;     for (int i = (1); i < (N); i++) last[i] = inf;     int C = s / e;     int ans = 0;     for (int i = (0); i < (n); i++) {       if (st.count(a[i])) {         int c = st[a[i]];         for (int j = C - 1; j >= 0; j--) {           typeof(all[c].begin()) it =               lower_bound(all[c].begin(), all[c].end(), last[j] + 1);           if (it != all[c].end()) {             if ((j + 1) * e + (i + 1 + (*it) + 1) <= s) {               ans = max(ans, j + 1);             }             last[j + 1] = min(last[j + 1], *it);           }         }       }     }     cout << ans;   }   int main() {     int T = 1;     for (int i = (1); i < (T + 1); i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int tt;     cin >> tt;     unordered_map<string, string> mp;     unordered_set<string> s;     for (int i = 0; i < tt; i++) {       string s1;       string s2;       cin >> s1 >> s2;       if (s.find(s1) == s.end()) {         mp.insert({s1, s2});         s.insert(s2);       } else {         for (auto &it : mp) {           if (s1 == it.second) {             it.second = s2;             s.insert(s2);           }         }       }     }     cout << mp.size() << endl;     for (auto it : mp) {       cout << it.first <<     << it.second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[3], y[3];   bool is_between(int a, int b, int c) {     return min(a, b) <= c && c <= max(a, b);   }   bool check(int i, int j, int k) {     return (x[k] == x[i] || x[k] == x[j]) && is_between(y[i], y[j], y[k]) ||            (y[k] == y[i] || y[k] == y[j]) && is_between(x[i], x[j], x[k]);   }   int main() {     for (int i = 0; i < 3; i++) {       cin >> x[i] >> y[i];     }     if (x[0] == x[1] && x[1] == x[2] || y[0] == y[1] && y[1] == y[2]) {       cout << 1 << endl;     } else if (check(0, 1, 2) || check(0, 2, 1) || check(1, 2, 0)) {       cout << 2 << endl;     } else {       cout << 3 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   int main() {     cin >> n >> k;     cout << k * (6 * n - 1) << endl;     for (int i = 1; i <= n; i++) {       int x = (i - 1) * 6 + 1;       cout << k * x <<     << k * (x + 1) <<     << k * (x + 2) <<                << k * (x + 4) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   inline long long getint() {     long long ssum = 0, ff = 1;     char ch;     for (ch = getchar(); !isdigit(ch) && ch !=  - ; ch = getchar())       ;     if (ch ==  - ) ff = -1, ch = getchar();     for (; isdigit(ch); ch = getchar()) ssum = ssum * 10 + ch -  0 ;     return ssum * ff;   }   const long long M = 1e6 + 5, mod = 1e9 + 7;   long long ans, f[M], g[M];   long long n, t[3];   signed main() {     cin >> n;     for (long long i = 1; i <= n; i++) t[getint()]++;     f[0] = 1;     f[1] = 1;     for (long long i = 2; i <= t[1]; i++)       (f[i] = f[i - 1] + f[i - 2] * (i - 1)) %= mod;     g[0] = f[t[1]];     for (long long i = 1; i <= t[2]; i++) (g[i] = g[i - 1] * (t[1] + i)) %= mod;     cout << g[t[2]] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, t;     cin >> n;     t = 2 * n;     long long a[t], I;     for (I = 0; I < t; I++) cin >> a[I];     sort(a, a + t);     long long ans = (a[0] - a[n - 1]) * (a[n] - a[2 * n - 1]);     for (I = 1; I < n; I++)       ans = min(ans, (a[I] - a[I + n - 1]) * (a[0] - a[2 * n - 1]));     cout << ans;     return 0;   }
#include <bits/stdc++.h>   inline int read() {     int n = 0, ch = getchar();     for (; !isdigit(ch); ch = getchar())       ;     for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + (ch ^ 48);     return n;   }   int main() {     int T = read();     while (T--) {       int ans[3] = {0, 0, 0};       int n = read();       while (n--) ++ans[read() % 3];       int A = ans[0];       if (ans[1] < ans[2])         A += ans[1] + (ans[2] - ans[1]) / 3;       else         A += ans[2] + (ans[1] - ans[2]) / 3;       printf( %d n , A);     }     return 0;   }
#include <bits/stdc++.h>   #include <vector>   #include <set>   #include <string>   #include <map>   #include <cmath>   #include <algorithm>   typedef long long int ll;   #define f first   #define s second   #define vi vector<int>   #define ld long double   #define pb push_back   #define mp make_pair   #define pii pair<int, int>   #define floop(count,a, n) for(int count{a}; count < n; ++count)   #define tr(c, it) for(auto it{c.begin()}; it != c.end(); ++it)   #define lb lower_bound   #define ub upper_bound   #define bs binary_search   #define newl   n             using namespace std;      const int MOD = 1e9+7;   const ld PI = acos(-1);   const ld EPS = 1e-9;   const ll INF = 1e18;             int main(){          ios::sync_with_stdio(0);       cin.tie(0); cout.tie(0);           #ifndef ONLINE_JUDGE                  freopen( input.txt ,  r , stdin);                                                freopen( output.txt ,  w , stdout);                                  #endif           int cas;cin>>cas;           while(cas--){               int n;               cin>>n;               int a = sqrt(n);               if(a*a == n)                   cout<<a<<  n ;               else                   cout<<a + 1<<  n ;                 }       cerr <<  Time :   << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC <<  ms n ;          return 0;    }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int l, r;     cin >> l >> r;     if (r - l < 2) {       printf( -1 );       return 0;     }     if (l & 1) l++;     if (l + 2 > r) {       printf( -1 );       return 0;     }     cout << l <<     << l + 1 <<     << l + 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 18;   const int MOD = 1000000007;   char c[MAX];   int r[MAX], b[MAX];   int dp[1 << 16][125];   int red[1 << 16], blue[1 << 16];   void precalc(int n) {     for (int i = 0; i < (1 << n); i++) {       for (int j = 0; j < n; j++) {         if (!(i & (1 << j))) {           continue;         }         if (c[j] ==  R ) {           red[i]++;         } else {           blue[i]++;         }       }     }   }   int main() {     for (int i = 0; i < 1 << 16; i++) {       for (int j = 0; j < 125; j++) {         dp[i][j] = -MOD;       }     }     dp[0][0] = 0;     long long rt = 0, bt = 0;     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf(  %c %d %d , &c[i], &r[i], &b[i]);       rt += r[i];       bt += b[i];     }     precalc(n);     long long maxi = 1000000000000000000;     for (int i = 0; i < (1 << n); i++) {       for (int j = 0; j < 125; j++) {         for (int k = 0; k < n; k++) {           if (i & (1 << k)) {             continue;           }           int res = i | (1 << k);           int jnew = j + min(red[i], r[k]);           dp[res][jnew] = max(dp[res][jnew], dp[i][j] + min(blue[i], b[k]));         }         maxi = min(maxi, max(rt - j, bt - dp[i][j]));       }     }     printf( %lld n , n + maxi);   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T Bitcnt(T a) {     int sum = 0;     while (a) {       if (a & 1) sum++;       a /= 2;     }     return sum;   }   template <class T>   T Max3(T a, T b, T c) {     return max(a, max(b, c));   }   template <class T>   T Lcm(T a, T b) {     T tmp = __gcd(a, b);     return (a / tmp) * b;   }   template <class T>   T Pow(T a, T b) {     T ans = 1;     T base = a;     while (b) {       if (b & 1) ans = (ans * base);       base = (base * base);       b /= 2;     }     return ans;   }   long long Bigmod(long long a, long long b) {     long long res = 1;     long long pw = a % 1000000007LL;     while (b > 0) {       if (b & 1) res = (res * pw) % 1000000007LL;       pw = (pw * pw) % 1000000007LL;       b /= 2;     }     return res;   }   int a_x[] = {1, -1, 0, 0};   int a_y[] = {0, 0, 1, -1};   long long X, Y;   void extend_euclid(long long a, long long b) {     if (b == 0) {       X = a;       Y = 0;       return;     }     extend_euclid(b, a % b);     long long x, y;     x = Y;     y = X - (a / b) * Y;     X = x;     Y = y;   }   long long inverse_modulo(long long a, long long b) {     extend_euclid(a, b);     return (X + 1000000007LL) % 1000000007LL;   }   int main() {     long long x;     cin >> x;     if (x == 2) {       cout << -1;       return 0;     }     if (x % 2 == 0) {       long long b = (x / 2) * (x / 2) - 1;       long long c = b + 2;       cout << b <<     << c;       return 0;     } else {       long long b = (x * x - 1) / 2;       long long c = (x * x + 1) / 2;       if (b <= 0 || c <= 0) {         cout << -1;         return 0;       }       cout << b <<     << c << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int freq[300];   string s;   const int maxN = 2000;   int primes[maxN];   int equs[maxN];   char result[maxN];   set<pair<int, char> > lets;   int n;   void sieve() {     for (int i = 2; i < maxN; i++) {       primes[i] = 1;     }     for (long long i = 2; i * i < maxN; i++) {       if (primes[i] == 1) {         for (long long j = i * i; j < maxN; j += i) {           primes[j] = 0;         }       }     }   }   int main(int argc, char const *argv[]) {     cin >> s;     sieve();     n = s.length();     for (int i = 0; i < n; i++) {       freq[s[i]]++;     }     int tot = 0;     for (int i = 0; i <= n; i++) {       if (primes[i] == 1 && i * 2 <= n) {         for (int j = i; j <= n; j += i) {           if (equs[j] == 0) {             tot++;           }           equs[j] = 1;         }       }     }     for (int i = 0; i < 300; i++) {       if (freq[i] != 0) {         lets.insert(make_pair(-freq[i], i));       }     }     if (-lets.begin()->first < tot) {       cout <<  NO  << endl;       return 0;     }     for (int i = 1; i <= n; i++) {       if (equs[i] == 1) {         result[i] = lets.begin()->second;       }     }     pair<int, char> tmp = *lets.begin();     tmp.first += tot;     lets.erase(lets.begin());     lets.insert(tmp);     for (int i = 1; i <= n; i++) {       if (equs[i] == 0) {         if (lets.begin()->first == 0) {           lets.erase(lets.begin());           i--;           continue;         }         result[i] = lets.begin()->second;         tmp = *lets.begin();         tmp.first++;         lets.erase(lets.begin());         lets.insert(tmp);       }     }     cout <<  YES  << endl;     for (int i = 1; i <= n; i++) {       cout << result[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Tp>   inline void rd(Tp &x) {     x = 0;     int fh = 1;     char ch = 1;     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) fh = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     x *= fh;   }   template <typename Tp>   inline void bird(Tp &x) {     x = 0;     int fh = 1;     char ch = 1;     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) fh = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 2 + ch -  0 , ch = getchar();     x *= fh;   }   template <typename Tp>   inline void smax(Tp &x, Tp y) {     if (x < y) x = y;   }   const int maxn = 100000 + 7;   const int maxm = 200000 + 7;   const int mod = 1000000007;   int n, m;   int Head[maxn], to[maxm], Next[maxm], w[maxm], tot;   void add(int x, int y, int z) {     to[++tot] = y, Next[tot] = Head[x], Head[x] = tot, w[tot] = z;   }   inline void Init(void) {     rd(n);     rd(m);     for (int i = 1, x, y, z; i <= m; i++) {       rd(x);       rd(y);       rd(z);       add(x, y, z);       add(y, x, z);     }   }   bool vis[maxn];   int c[maxn];   void dfs(int x, int f, int col) {     if (vis[x]) {       if (c[x] != col) {         puts( 0 );         exit(0);       }       return;     }     vis[x] = true;     c[x] = col;     for (int i = Head[x]; i; i = Next[i]) {       int y = to[i];       if (y == f) continue;       if (w[i])         dfs(y, x, col);       else         dfs(y, x, 3 - col);     }   }   int fpow(long long x, int p) {     long long res = 1ll;     while (p) {       if (p & 1) res = res * x % mod;       p >>= 1;       x = x * x % mod;     }     return res;   }   inline void Work(void) {     long long ans = 1ll;     for (int i = 1; i <= n; i++) {       if (vis[i] == false) {         dfs(i, 0, 1);         ans = ans * 2 % mod;       }     }     ans = ans * fpow(2, mod - 2) % mod;     printf( %lld n , ans);   }   signed main(void) {     Init();     Work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, ans[100], i, sum, z = 1;     scanf( %d%d%d , &n, &a, &b);     sum = ans[0] = 1;     for (i = 1; i <= b; i++) {       ans[i] = sum + 1;       if (ans[i] > 50000) z = 0;       sum += ans[i];     }     if (z) {       if (b != 0) {         for (; i <= a + b; i++) {           ans[i] = ans[i - 1] + 1;           if (ans[i] > 50000) z = 0;         }       } else {         sum = ans[0] = ans[1] = 1;         for (i = 2; i <= 1 + a + b; i++) {           ans[i] = ans[i - 1] + 1;           if (ans[i] > 50000) z = 0;         }         if ((n != 1) && (a == n - 1)) z = 0;       }     }     if (z == 0)       printf( -1 );     else {       for (; i < n; i++) {         ans[i] = ans[i - 1];       }       for (i = 0; i < n; i++) printf( %d  , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 20;   inline int read() {     int ans = 0;     char last =    , ch = getchar();     while (ch< 0  | ch>  9 ) last = ch, ch = getchar();     while (ch >=  0  && ch <=  9 ) ans = ans * 10 + ch -  0 , ch = getchar();     if (last ==  - ) ans = -ans;     return ans;   }   int n, k;   vector<int> save[maxn];   int a[maxn], color[maxn], cnt[maxn], ls[maxn];   void solve() {     n = read(), k = read();     for (int i = 0; i <= n; i++) save[i].clear(), color[i] = 0;     for (int i = 0; i <= n - 1; i++) a[i] = read(), save[a[i]].push_back(i);     int kd = 0;     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= min(k, (int)(save[i].size())) - 1; j++) {         color[save[i][j]] = kd + 1;         ls[kd + 1] = save[i][j];         kd++;         kd %= k;       }     }     for (int i = 1; i <= kd; i++) color[ls[i]] = 0;     for (int i = 0; i <= n - 1; i++) cout << color[i] <<    ;     cout <<   n ;   }   int main() {     int _t;     _t = read();     while (_t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 201001;   const int MAXK = 51;   const double inf = 1e100;   const double eps = 1e-10;   int K, N;   int tab[MAXN];   long long sum[MAXN];   double res[MAXN];   double odw[MAXN];   double dp[MAXK][MAXN];   struct Pt {     double x, y;   };   int ccw(const Pt& a, const Pt& b, const Pt& c) {     double w = 0;     w += a.x * (b.y - c.y);     w += b.x * (c.y - a.y);     w += c.x * (a.y - b.y);     return w < -eps ? -1 : w > eps;   }   int main() {     scanf( %d %d , &N, &K);     for (int i = (1); i <= (N); ++i) {       scanf( %d , &tab[i]);       sum[i] = sum[i - 1] + tab[i];       odw[i] = odw[i - 1] + 1. / tab[i];       res[i] = res[i - 1] + (double)sum[i] / tab[i];     }     for (int i = (1); i <= (N); ++i) dp[1][i] = res[i];     for (int k = (2); k <= (K); ++k) {       vector<Pt> v;       for (int i = (k - 1); i <= (N); ++i) {         Pt pt = {-1. * sum[i], dp[k - 1][i] - res[i] + sum[i] * odw[i]};         while (v.size() >= 2 && ccw(v[((int)((v).size())) - 2], v.back(), pt) > 0)           v.pop_back();         v.push_back(pt);       }       int p = 0;       for (int i = (k); i <= (N); ++i) {         while (p + 1 < ((int)((v).size())) &&                v[p].x * odw[i] + v[p].y > v[p + 1].x * odw[i] + v[p + 1].y)           ++p;         dp[k][i] = v[p].x * odw[i] + v[p].y + res[i];       }     }     printf( %.10lf n , dp[K][N]);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105, INF = 1 << 30, MOD = 1e9 + 7;   int n, k;   vector<int> adj[N];   long long cnt[N][N];   long long ans = 0, F[N];   long long sumOfProducts(vector<int>& arr, int n, int k) {     long long dp[n + 1][n + 1];     memset(dp, 0, sizeof(dp));     long long cur_sum = 0;     for (int i = 1; i <= n; i++) {       dp[1][i] = arr[i - 1];       (cur_sum += arr[i - 1]) %= MOD;     }     for (int i = 2; i <= k; ++i) {       long long temp_sum = 0;       for (int j = 1; j <= n; j++) {         (cur_sum -= dp[i - 1][j]) %= MOD;         dp[i][j] = (arr[j - 1] * cur_sum) % MOD;         (temp_sum += dp[i][j]) %= MOD;       }       cur_sum = temp_sum;     }     return (cur_sum + MOD) % MOD;   }   void dfs(int u, int root, int p, int d) {     ++cnt[root][d];     for (int v : adj[u]) {       if (v == p) continue;       dfs(v, root, u, d + 1);     }   }   void solve(int u) {     memset(cnt, 0, sizeof(cnt));     if (adj[u].size() < k) return;     for (int v : adj[u]) {       dfs(v, v, u, 0);     }     for (int i = 0; i < n; ++i) {       int CNT = 0;       for (int v : adj[u])         if (cnt[v][i]) ++CNT;       if (CNT < k) break;       vector<int> C;       for (int v : adj[u])         if (cnt[v][i]) C.push_back(cnt[v][i]);       (ans += sumOfProducts(C, CNT, k)) %= MOD;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     F[0] = 1;     for (int i = 1; i < N; ++i) F[i] = (F[i - 1] * i) % MOD;     int t;     cin >> t;     while (t--) {       ans = 0;       cin >> n >> k;       for (int i = 0; i < n; ++i) adj[i].clear();       for (int i = 0; i < n - 1; ++i) {         int u, v;         cin >> u >> v;         adj[--u].push_back(--v);         adj[v].push_back(u);       }       if (k == 2)         cout << n * (n - 1) / 2 <<   n ;       else {         for (int i = 0; i < n; ++i) solve(i);         cout << ans % MOD <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXn = 1e5 + 10, MAXx = 4 * MAXn;   struct salar {     int l, r, max1, leftchild, rightchild, id;     long long sum;     salar() { sum = id = l = r = max1 = leftchild = rightchild = 0; }     void idit(int v) {       id = v;       leftchild = 2 * v;       rightchild = 2 * v + 1;     }   };   salar seg[MAXx];   int ar[MAXn], n, m;   void build(int v, int l, int r) {     seg[v].l = l, seg[v].r = r;     seg[v].idit(v);     if (r - l == 1) {       seg[v].sum = ar[l];       seg[v].max1 = ar[l];       return;     }     int med = (l + r) / 2;     build(seg[v].leftchild, l, med);     build(seg[v].rightchild, med, r);     seg[v].sum = seg[seg[v].leftchild].sum + seg[seg[v].rightchild].sum;     seg[v].max1 = max(seg[seg[v].leftchild].max1, seg[seg[v].rightchild].max1);   }   long long get(int v, int l, int r) {     if (max(l, seg[v].l) >= min(r, seg[v].r)) return 0;     if (l <= seg[v].l && seg[v].r <= r) {       return seg[v].sum;     }     return get(seg[v].leftchild, l, r) + get(seg[v].rightchild, l, r);   }   void domodule(int v, int l, int r, int x) {     if (seg[v].max1 < x) return;     if (max(l, seg[v].l) >= min(r, seg[v].r)) return;     if (seg[v].r - seg[v].l == 1) {       ar[seg[v].l] %= x;       seg[v].sum = ar[seg[v].l];       seg[v].max1 = ar[seg[v].l];       return;     }     domodule(seg[v].leftchild, l, r, x);     domodule(seg[v].rightchild, l, r, x);     seg[v].sum = seg[seg[v].leftchild].sum + seg[seg[v].rightchild].sum;     seg[v].max1 = max(seg[seg[v].leftchild].max1, seg[seg[v].rightchild].max1);   }   void change(int v, int l, int x) {     if (l < seg[v].l || l >= seg[v].r) return;     if (seg[v].r - seg[v].l == 1) {       ar[seg[v].l] = x;       seg[v].sum = ar[seg[v].l];       seg[v].max1 = ar[seg[v].l];       return;     }     change(seg[v].leftchild, l, x);     change(seg[v].rightchild, l, x);     seg[v].sum = seg[seg[v].leftchild].sum + seg[seg[v].rightchild].sum;     seg[v].max1 = max(seg[seg[v].leftchild].max1, seg[seg[v].rightchild].max1);   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> ar[i];     build(1, 0, n);     for (int i = 0; i < m; i++) {       int type;       cin >> type;       if (type == 1) {         int l, r;         cin >> l >> r;         l--;         cout << get(1, l, r) << endl;       } else if (type == 2) {         int l, r, x;         cin >> l >> r >> x;         l--;         domodule(1, l, r, x);       } else {         int l, x;         cin >> l >> x;         l--;         change(1, l, x);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100005];   long long b[100005], dpMax[100005], dpMin[100005], ans = (1ll << 63);   void setup() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n - 1; i++) b[i] = abs(a[i] - a[i + 1]);     n--;   }   void xuly() {     for (int i = n; i >= 1; i--) {       dpMax[i] = -min(dpMin[i + 1], 0ll) + b[i];       dpMin[i] = -max(dpMax[i + 1], 0ll) + b[i];       ans = max(ans, dpMax[i]);     }     cout << ans;   }   int main() {     iostream::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     setup();     xuly();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       for (int t = 0; t < n - 1; t++) {         if (a[t] > a[t + 1]) {           int j = t + 1;           cout << t + 1 <<     << j + 1 << endl;           int q = a[t];           a[t] = a[j];           a[j] = q;         }       }     }   }