malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> edges[500000];   bool vis[500000];   int order[1000000];   int first[500000], second[500000];   int C;   void dfs(int i) {     vis[i] = 1;     first[i] = C;     order[C++] = i;     for (int j = 0; j < edges[i].size(); j++)       if (!vis[edges[i][j]]) dfs(edges[i][j]);     second[i] = C;     order[C++] = i;   }   int segFill[2 * (1 << 20)], up[2 * (1 << 20)];   int segEmpty[2 * (1 << 20)];   int l[2 * (1 << 20)], r[2 * (1 << 20)];   void init() {     for (int i = (1 << 20); i < 2 * (1 << 20); i++) {       segFill[i] = -1;       up[i] = 0;       segEmpty[i] = 0;       l[i] = r[i] = i - (1 << 20);     }     for (int i = (1 << 20) - 1; i > 0; i--) {       segFill[i] = -1;       up[i] = 0;       segEmpty[i] = 0;       l[i] = l[2 * i];       r[i] = r[2 * i + 1];     }   }   void push(int i) {     if (up[i] > 0) {       if (i < (1 << 20)) {         up[(i << 1)] = up[i];         up[(i << 1) + 1] = up[i];       }       segFill[i] = up[i];       up[i] = 0;     }   }   int getFill(int i, int loc) {     push(i);     if (i >= (1 << 20))       return segFill[i];     else if (r[(i << 1)] >= loc)       return getFill((i << 1), loc);     else       return getFill((i << 1) + 1, loc);   }   int low, high;   void setFill(int i, int v) {     push(i);     if ((l[i] > high) || (r[i] < low)) return;     if ((l[i] >= low) && (r[i] <= high)) {       up[i] = v;       push(i);       return;     }     setFill((i << 1), v);     setFill((i << 1) + 1, v);     segFill[i] = max(segFill[(i << 1)], segFill[(i << 1) + 1]);   }   void setEmpty(int loc, int v) {     loc += (1 << 20);     segEmpty[loc] = v;     for (loc /= 2; loc > 0; loc /= 2)       segEmpty[loc] = max(segEmpty[2 * loc], segEmpty[2 * loc + 1]);   }   int getEmpty(int i) {     if ((l[i] > high) || (r[i] < low)) return 0;     if ((l[i] >= low) && (r[i] <= high)) return segEmpty[i];     return max(getEmpty((i << 1)), getEmpty((i << 1) + 1));   }   int main() {     int N, a, b;     scanf( %d , &N);     for (int i = 1; i < N; i++) {       scanf( %d %d , &a, &b);       a--, b--;       edges[a].push_back(b);       edges[b].push_back(a);     }     C = 0;     dfs(0);     init();     int Q, tp, v;     scanf( %d , &Q);     for (int i = 0; i < Q; i++) {       scanf( %d %d , &tp, &v);       v--;       if (tp == 1) {         low = first[v];         high = second[v];         setFill(1, i + 1);       }       if (tp == 2) setEmpty(first[v], i + 1);       if (tp == 3) {         low = first[v];         high = second[v];         a = getFill(1, first[v]);         b = getEmpty(1);         printf( %d n , a >= b);       }     }   }
#include <bits/stdc++.h>   using namespace std;   template <class C>   void mini(C& a, C b) {     a = min(a, b);   }   template <class C>   void maxi(C& a, C b) {     a = max(a, b);   }   void a() {     int n;     cin >> n;     vector<int> a(n), b(n), c(n);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     for (int i = 0; i < n; i++) cin >> c[i];     vector<int> p(n);     p[0] = a[0];     for (int(i) = 1; i <= n - 2; i++) {       if (a[i] == p[i - 1])         p[i] = b[i];       else         p[i] = a[i];     }     if (a.back() != p[0] and a.back() != p[n - 2])       p[n - 1] = a.back();     else if (b.back() != p[0] and b.back() != p[n - 2])       p[n - 1] = b.back();     else       p[n - 1] = c.back();     for (int i = 0; i < n; i++) cout << p[i] <<    ;     cout <<   n ;   }   void b() {     int n, k;     cin >> n >> k;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     int diferentes = 1;     for (int(i) = 1; i <= n - 1; i++)       if (a[i] != a[i - 1]) diferentes++;     if (k == 1 and diferentes != 1) {       cout <<  -1 n ;       return;     }     int res = 1;     diferentes -= k;     while (diferentes > 0) {       res++;       diferentes -= k - 1;     }     cout << res <<   n ;   }   void c() {     int n;     long long l;     cin >> n >> l;     vector<long long> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     double izq = 0;     double izqVel = 1;     double der = l;     double derVel = 1;     int i = 0;     int j = n - 1;     double time = 0.0;     while (i <= j) {       double ti = (double)(a[i] - izq) / (double)izqVel;       double tj = (double)(der - a[j]) / (double)derVel;       if (ti < tj) {         izq = a[i];         i++;         izqVel++;         der -= ti * derVel;         time += ti;       } else {         der = a[j];         j--;         derVel++;         izq += tj * izqVel;         time += tj;       }     }     time += (der - izq) / (izqVel + derVel);     cout << setprecision(9) << fixed << time <<   n ;   }   void d() {     int n, m;     cin >> n >> m;     vector<int> a(n), b(n), c(m), d(m);     for (int i = 0; i < n; i++) cin >> a[i] >> b[i];     for (int i = 0; i < m; i++) cin >> c[i] >> d[i];     vector<pair<int, int> > delta;     int dx, dy;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         dx = c[j] - a[i];         dy = d[j] - b[i];         if (dx >= 0 and dy >= 0) delta.push_back({dx, dy});       }     sort(delta.begin(), delta.end());     if (delta.empty()) {       cout << 0 <<   n ;       return;     }     int x = delta.back().first + 1;     int maxy = -1;     int res = x;     for (int(i) = delta.size() - 1; i >= 1; i--) {       x = delta[i - 1].first + 1;       maxi(maxy, delta[i].second);       mini(res, x + maxy + 1);     }     maxi(maxy, delta[0].second);     mini(res, maxy + 1);     cout << res <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     d();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, o = 0, z = 0;     cin >> n;     string s;     cin >> s;     for (i = 0; i < n; i++) {       if (s[i] ==  1 )         o++;       else         z++;     }     if (z != o) {       cout << 1 << endl << s;     } else {       cout << 2 << endl;       for (i = 0; i < n - 1; i++) cout << s[i];       cout <<     << s[n - 1];     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a[100], b[100], oa = 0, ob = 0, ore = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i] >> b[i];       if (a[i] % 2 == 1) oa++;       if (b[i] % 2 == 1) ob++;       if (a[i] % 2 == 1 && b[i] % 2 == 1) ore++;     }     if (oa % 2 == 0 && ob % 2 == 0)       cout << 0;     else if (oa % 2 == 1 && ob % 2 == 0 || oa % 2 == 0 && ob % 2 == 1 ||              oa - ore == 0 && ob - ore == 0)       cout << -1;     else       cout << 1;   }
#include <bits/stdc++.h>   using namespace std;   void Solves();   void In(int **a, int n);   int main() {     Solves();     return 0;   }   void Solves() {     long long n, k;     cin >> n >> k;     if (k > n * n) {       cout << -1;       return;     }     int **a = new int *[n + 1];     for (int i = 0; i <= n; i++) {       a[i] = new int[n + 1];     }     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= n; j++) {         a[i][j] = 0;       }     }     if (k == 0) {       In(a, n);       return;     }     if (n == 1 && k == 1) {       cout << 1 << endl;       return;     }     for (int i = 1; i <= n - 1; i++) {       a[i][i] = 1;       k--;       for (int j = i + 1; j <= n; j++) {         if (k >= 2) {           a[i][j] = 1;           a[j][i] = 1;           k -= 2;         }         if (k == 1) {           a[i + 1][i + 1] = 1;           k--;         }         if (k == 0) {           In(a, n);           return;         }       }     }   }   void In(int **a, int n) {     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         cout << a[i][j] <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[1000000], l[1000000], r[1000000];   int main() {     int n;     cin >> n;     int minn = 10000000;     int kol = 0;     int ans = 0;     int m = 2 * n - 1;     for (int i = 0; i < m; i++) {       cin >> a[i];       if (a[i] < 0) {         kol++;         a[i] = -a[i];       }       ans += a[i];       if (a[i] < minn) minn = a[i];     }     if (n % 2 == 1)       cout << ans << endl;     else {       if (kol % 2 == 0)         cout << ans << endl;       else         cout << ans - 2 * minn << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1000000001;   void run_case() {     long long n;     cin >> n;     vector<pair<long long, long long>> v;     for (long long i = 0; i < n; i++) {       long long x;       cin >> x;       v.push_back({x, i});     }     sort(v.begin(), v.end());     vector<long long> curr_max(n), maxi(n), ans(n);     curr_max[0] = v[0].second;     maxi[0] = v[0].second;     ans[v[0].second] = -1;     for (long long i = 1; i < n; i++) {       curr_max[i] = max(curr_max[i - 1], v[i].second);       if (v[i].first == v[i - 1].first)         maxi[i] = maxi[i - 1];       else         maxi[i] = curr_max[i];       ans[v[i].second] = maxi[i] - v[i].second - 1;     }     for (long long i = 0; i < n; i++) {       cout << max(ans[i], -1ll) <<    ;     }     cout << endl;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long tc = 1;     while (tc--) run_case();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, K;   int A, B;   signed long long from[505];   signed long long to[505];   void solve() {     int i, j, k, l, r, x, y;     string s;     cin >> N >> K;     for (x = 0; x < (505); x++)       for (y = 0; y < (505); y++) from[x] = -1LL << 60;     from[0] = 0;     int sum = 0;     for (i = 0; i < (N); i++) {       cin >> A >> B;       for (x = 0; x < (505); x++) to[x] = -1LL << 60;       for (x = 0; x < (K); x++) {         y = (sum - x) % K;         if (y < 0) y += K;         for (j = 0; j < (K); j++) {           if (j > A) continue;           k = (A + B - j) % K;           if (k > B) continue;           int add = (A + B - j - k) / K;           to[(x + j) % K] = max(to[(x + j) % K],                                 from[x] + add + ((x + j) >= K) + ((y + k) >= K));         }       }       (sum += A + B) %= K;       swap(from, to);     }     signed long long ma = 0;     for (i = 0; i < (K); i++) ma = max(ma, from[i]);     cout << ma << endl;   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);     for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     multiset<long long> x, y;     long long n, closing = 0, count = 0, i, j, pair = 0;     cin >> n;     string ss;     for (i = 0; i < n; i++) {       stack<char> s;       closing = 0;       cin >> ss;       for (j = 0; j < ss.length(); j++) {         if (ss[j] ==  )  && s.size() == 0) closing++;         if (ss[j] ==  ( ) s.push(ss[j]);         if (ss[j] ==  )  && s.size() != 0) s.pop();       }       if (closing == 0 && s.size() > 0) x.insert(s.size());       if (closing > 0 && s.size() == 0) y.insert(closing);       if (closing == 0 && s.size() == 0) count++;     }     for (auto i : x) {       if (y.find(i) != y.end()) {         pair++;         y.erase(y.find(i));       }     }     cout << pair + count / 2;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   int n, m, i, j, a, b;   long long check(long long x, long long y) {     if (x == i && y == j) return 0;     if (abs(x - i) % a != 0 || abs(y - j) % b != 0) return inf;     if (abs(abs(x - i) / a - abs(y - j) / b) & 1) return inf;     if ((i - a < 1 && i + a > n) || (j - b < 1 && j + b > m))       return inf;     else       return max(abs(x - i) / a, abs(y - j) / b);   }   int main() {     scanf( %d%d%d%d%d%d , &n, &m, &i, &j, &a, &b);     long long ret = inf;     ret = min(check(1, m), check(n, 1));     ret = min(ret, check(n, m));     ret = min(ret, check(1, 1));     if (ret == inf)       printf( Poor Inna and pony! n );     else       printf( %d n , ret);   }
#include <bits/stdc++.h>   using namespace std;   long long C[20][20];   long long dp[20];   int cnt[16];   int k, t;   long long solve(int l) {     memset(dp, 0, sizeof(dp));     dp[0] = 1;     for (int j = 0; j < 16; j++) {       for (int i = l; i >= 0; i--) {         for (int k = 1; k <= min(l - i, t - cnt[j]); k++) {           dp[i + k] = (dp[i + k] + C[l - i][k] * dp[i]);         }       }     }     return dp[l];   }   int main() {     C[0][0] = 1;     for (int i = 1; i < 20; i++) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; j++) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];     }     scanf( %d%d , &k, &t);     for (int i = 1; i < 20; i++) {       long long ways = 0;       for (int j = 1; j < 16; j++) {         cnt[j]++;         ways += solve(i - 1);         cnt[j]--;       }       if (ways < k) {         k -= ways;       } else {         int l = i;         for (int i = 1; i <= l; i++) {           if (i == 1) {             for (int j = 1; j < 16; j++) {               cnt[j]++;               long long ways = solve(l - i);               if (ways < k) {                 k -= ways;                 cnt[j]--;               } else {                 if (j < 10)                   printf( %d , j);                 else                   printf( %c ,  a  + (j - 10));                 break;               }             }           } else {             for (int j = 0; j < 16; j++) {               if (cnt[j] == t) continue;               cnt[j]++;               long long ways = solve(l - i);               if (ways < k) {                 k -= ways;                 cnt[j]--;               } else {                 if (j < 10)                   printf( %d , j);                 else                   printf( %c ,  a  + (j - 10));                 break;               }             }           }         }         break;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int a[1000010];   int solution[1000010] = {0};   int main() {     ios::sync_with_stdio(0);     int n;     long long int sum = 0;     long long int part;     long long partSum = 0;     long long int result = 0;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];       sum += a[i];     }     if (sum % 3)       cout <<  0 ;     else {       part = sum / 3;       for (int i = 0; i < n; ++i) {         partSum += a[i];         if (partSum == part) solution[i] = 1;       }       for (int i = 0; i < n - 2; i++) solution[i + 1] += solution[i];       partSum = 0;       for (int i = n - 1; i - 2 >= 0; --i) {         partSum += a[i];         if (partSum == part) result += solution[i - 2];       }       cout << result;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mx = 1e5 + 1, Mod = 1e9 + 7;   int n, a[mx];   long long int dpl[mx][2], dpr[mx][2];   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n - 1; i++) cin >> a[i];     dpl[0][0] = dpl[0][1] = 0;     for (int i = 1; i < n; i++) {       dpl[i][0] = (a[i - 1] > 1 ? dpl[i - 1][0] + a[i - 1] - (a[i - 1] & 1) : 0);       dpl[i][1] = (a[i - 1] ? max(dpl[i - 1][0] + a[i - 1],                                   dpl[i - 1][1] + a[i - 1] - !(a[i - 1] & 1))                             : 0);     }     dpr[n - 1][0] = dpr[n - 1][1] = 0;     for (int i = n - 2; i >= 0; i--) {       dpr[i][0] = (a[i] > 1 ? dpr[i + 1][0] + a[i] - (a[i] & 1) : 0);       dpr[i][1] =           (a[i] ? max(dpr[i + 1][0] + a[i], dpr[i + 1][1] + a[i] - !(a[i] & 1))                 : 0);     }     long long int ans = 0;     for (int i = 0; i < n; i++)       ans = max({ans, dpl[i][0] + dpr[i][1], dpr[i][0] + dpl[i][1],                  dpl[i][1] + dpr[i][1]});     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1500 + 5, INF = 2000 * 1000 * 1000;   vector<pair<int, int> > li[N];   vector<int> adj[N];   pair<pair<int, int>, int> po[N];   pair<int, int> J;   int d[N], out[N];   void dfs(const int &v, const int &pa) {     d[v] = 1;     for (int i = 0; i < (int)(adj[v]).size(); ++i) {       if (adj[v][i] != pa) {         dfs(adj[v][i], v);         d[v] += d[adj[v][i]];         li[v].push_back(make_pair(d[adj[v][i]], adj[v][i]));       }     }   }   bool cmp(const pair<pair<int, int>, int> &R,            const pair<pair<int, int>, int> &T) {     long long a1 = J.first - R.first.first, a2 = J.first - T.first.first;     long long b1 = J.second - R.first.second, b2 = J.second - T.first.second;     return a1 * b2 > a2 * b1;   }   void ass(int f, int s, int x) {     pair<int, int> ans = make_pair(-INF, -INF);     int no;     for (int i = f; i <= s; ++i) {       if (po[i].first.second > ans.second)         ans = make_pair(po[i].first.first, po[i].first.second), no = i;       else if (po[i].first.second == ans.second && po[i].first.first < ans.first)         ans = make_pair(po[i].first.first, po[i].first.second), no = i;     }     J = ans;     out[po[no].second] = x;     swap(po[no], po[s]);     sort(po + f, po + s, cmp);     for (int i = 0; i < (int)(li[x]).size(); ++i) {       ass(f, f + li[x][i].first - 1, li[x][i].second);       f += li[x][i].first;     }   }   int main() {     ios::sync_with_stdio(false);     srand(time(0));     int n, a, b, root;     int zero = 0;     scanf( %d , &n);     if (n >= 1300)       root = 750;     else       root = rand() % n + 1;     for (int i = 0; i < n - 1; ++i) {       adj[i].reserve(N);       li[i].reserve(N);       scanf( %d%d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     dfs(root, zero);     for (int i = 1; i <= n; ++i)       scanf( %d%d , &po[i].first.first, &po[i].first.second), po[i].second = i;     ass(1, n, root);     for (int i = 1; i <= n; ++i) printf( %d  , out[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     long long int a[n + 2];     for (int i = 1; i <= n; i++) {       scanf( %lld , &a[i]);     }     long long int mx = 1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i != j) {           mx = max(mx, a[i] | a[j]);         }         for (int k = 1; k <= n; k++) {           if (i != j && i != k && j != k) {             mx = max(mx, a[i] | a[j] | a[k]);           }         }       }     }     printf( %lld , mx);     return 0;   }
#include<bits/stdc++.h>   #define pb push_back   #define F first   #define S second   using namespace std;   typedef long long ll;   typedef pair<int,int>pi;   typedef vector<int>vi;   const int maxn=1e6+10;   const int M=998244353;   ll t[1<<14][105];   ll d[105][105],d2[105][14],d22[14][14];   ll mind[1<<14][105],mind2[1<<14][14];   ll xa[105],ya[105],xb[105],yb[105],T[105],ans;   struct node{       ll x,y,t;   }A[205];   bool cmp(node u,node v){return u.t<v.t;}   void Min(ll &x,ll y){if (y<x)x=y;}   int n,m,f[1<<14][105];   const ll inf=1e14;   int main(){       cin >> m >> n;       for (int i=0;i<m;i++) cin >> xb[i] >> yb[i];       for (int i=0;i<n;i++) cin >> A[i].x >> A[i].y >> A[i].t;       sort(A,A+n,cmp);       for (int i=0;i<n;i++) xa[i]=A[i].x,ya[i]=A[i].y,T[i]=A[i].t;       for (int i=0;i<n;i++)           for (int j=0;j<n;j++)               d[i][j]=abs(xa[i]-xa[j])+abs(ya[i]-ya[j]);       for (int i=0;i<n;i++)           for (int j=0;j<m;j++)               d2[i][j]=abs(xa[i]-xb[j])+abs(ya[i]-yb[j]);       for (int i=0;i<m;i++)           for (int j=0;j<m;j++)               d22[i][j]=abs(xb[i]-xb[j])+abs(yb[i]-yb[j]);       for (int i=0;i<n;i++)       for (int j=0;j<(1<<m);j++){           mind[j][i]=inf;           for (int k=0;k<m;k++) if ((j>>k)&1) Min(mind[j][i],d2[i][k]);       }       for (int i=0;i<m;i++)       for (int j=0;j<(1<<m);j++){           mind2[j][i]=inf;           for (int k=0;k<m;k++) if ((j>>k)&1) Min(mind2[j][i],d22[i][k]);       }       memset(f,-1,sizeof(f));       for (int i=0;i<n;i++) f[0][i]=1;       for (int i=0;i<=n;i++)           for (int j=0;j<(1<<m);j++)               t[j][i]=inf;       for (int i=0;i<m;i++) t[1<<i][0]=0;       int ans=0;       for (int mask=0;mask<(1<<m);mask++){           for (int j=0;j<=n;j++) if (t[mask][j]<inf){               for (int i=0;i<m;i++) if (!((mask>>i)&1)){                   Min(t[mask|1<<i][j],t[mask][j]+mind2[mask][i]);               }               for (int i=0;i<n;i++) if (t[mask][j]+mind[mask][i]<=T[i]){                   f[mask][i]=max(f[mask][i],j+1);               }           }           for (int i=0;i<n;i++) if (f[mask][i]!=-1){               int k=f[mask][i];               ans=max(ans,k);               for (int j=0;j<m;j++) if (!((mask>>j)&1)){                   Min(t[mask|1<<j][k],T[i]+min(d2[i][j],mind2[mask][j]));               }               for (int j=i+1;j<n;j++) if (min(d[i][j],mind[mask][j])+T[i]<=T[j]){                   f[mask][j]=max(f[mask][j],k+1);               }           }       }       cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[200005];   long long k;   int main() {     scanf( %d%I64d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]);     int p;     for (p = 1; p <= n && a[p] == 0; p++)       ;     p = n - p + 1;     long long mx = 0;     for (int i = 1; i <= n; i++) mx = max(mx, a[i]);     if (p == 2)       printf( %I64d n , (k - a[n] - 1) / a[n - 1] + 1);     else if (p == 3) {       long long l = 0, r = 1.5e9;       while (l < r) {         long long md = (l + r) / 2;         long long res = md * (md + 1) / 2;         if (res < 0 || res >= k)           r = md;         else {           res *= a[n - 2];           if (res < 0 || res >= k)             r = md;           else {             res += md * a[n - 1];             if (res < 0 || res >= k)               r = md;             else if (res + a[n] >= k)               r = md;             else               l = md + 1;           }         }       }       printf( %I64d n , r);     } else {       p = n - p + 2;       int ans = 0, i;       while (mx < k) {         for (i = p; i <= n; i++) a[i] += a[i - 1], mx = max(mx, a[i]);         ans++;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2;     cin >> s1 >> s2;     int h1 = stoi(s1.substr(0, 2));     int m1 = stoi(s1.substr(3, 2));     int h2 = stoi(s2.substr(0, 2));     int m2 = stoi(s2.substr(3, 2));     int m3 = (m1 + m2) / 2;     int h3 = h1 + h2;     if (h3 % 2 != 0) m3 += 30;     h3 = h3 / 2;     if (m3 >= 60) {       h3++;       m3 -= 60;     }     if (h3 < 10) cout <<  0 ;     cout << h3 <<  : ;     if (m3 < 10) cout <<  0 ;     cout << m3;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ans = 0, sch = 0, nm = -100000, pnm = 10000;     vector<int> v;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int t;       scanf( %d , &t);       if ((t % 2 == 1) && (t > 0)) {         pnm = ((pnm) < (t)) ? (pnm) : (t);         ans += t;       } else if (t % 2 == -1) {         nm = ((nm) > (t)) ? (nm) : (t);       } else if (t > 0) {         sch += t;       }     }     if (ans == 0) ans += nm;     ans += sch;     if (ans % 2 == 0) ans = ((ans - pnm) > (ans + nm)) ? (ans - pnm) : (ans + nm);     printf( %d , ans);     return 0;   }