malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int a[10005];   int num[10005];   int main() {     int n;     scanf( %d , &n);     int mm = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       num[a[i]]++;       mm = max(mm, a[i]);     }     int nn = 0;     for (int i = 1; i <= mm; i++) {       if (mm % i == 0) num[i]--;     }     for (int i = 10000; i >= 1; i--) {       if (num[i] > 0) {         nn = i;         break;       }     }     printf( %d %d n , mm, nn);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int m, k;     scanf( %d %d , &m, &k);     vector<int> a(k, 0);     vector<int> t(m - 1), r(m - 1, 0);     vector<int> last(k, 0);     for (int i = 0; i < k; ++i) {       scanf( %d , &a[i]);     }     int free_num = 0;     for (int i = 0; i + 1 < m; ++i) {       scanf( %d %d , &t[i], &r[i]);       if (t[i] > 0) {         last[t[i] - 1] = i;       }     }     int first_upset_id = -1;     int before_upset_num = 0;     for (int i = 0; i + 1 < m; ++i) {       if (r[i] == 1) {         first_upset_id = i;         break;       } else if (t[i] == 0) {         ++before_upset_num;       }     }     for (int i = 0; i + 1 < m; ++i) {       if (t[i] == 0) {         ++free_num;       } else {         --a[t[i] - 1];       }     }     if (first_upset_id >= 0) {       int min_id = -1;       for (int i = 0; i < k; ++i) {         if ((last[i] < first_upset_id) &&             ((min_id == -1) || (a[min_id] > a[i]))) {           min_id = i;         }       }       free_num -= a[min_id];     }     for (int i = 0; i < k; ++i) {       if ((a[i] <= free_num) ||           ((last[i] < first_upset_id) && (a[i] <= before_upset_num))) {         printf( Y );       } else {         printf( N );       }     }     printf(  n );   }   int main() {     int t;     scanf( %d , &t);     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct om_nom {     int t;     int h;     int m;   } a[2005];   int n, x;   bool eaten[2005];   bool have_candy(int type) {     int flag = false;     for (int i = 0; i < n; ++i)       if (a[i].t == (bool)type && !eaten[i]) {         flag = true;         break;       }     return flag;   }   int solve(int cur, int H) {     int cnt = 0;     for (int i = 0; i < n; ++i) {       eaten[i] = false;     }     while (have_candy(cur)) {       int mm = -1, it = -1;       for (int i = 0; i < n; ++i)         if (a[i].t == cur && a[i].m > mm && a[i].h <= H && !eaten[i]) {           it = i;           mm = a[i].m;         }       if (it != -1) {         H += a[it].m;         cur ^= 1;         eaten[it] = true;       } else         break;       cnt++;     }     return cnt;   }   int main() {     cin >> n >> x;     for (int i = 0; i < n; ++i) {       cin >> a[i].t >> a[i].h >> a[i].m;     }     cout << max(solve(0, x), solve(1, x)) << endl;     return 0;   }
#include <bits/stdc++.h>   inline int read() {     int f = 1, x = 0;     char ch = getchar();     while (!(ch >=  0  && ch <=  9 )) {       if (ch ==  - ) f *= -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return f * x;   }   int dx[8] = {1, 1, -1, -1, 2, 2, -2, -2};   int dy[8] = {2, -2, 2, -2, 1, -1, 1, -1};   struct Point {     int x, y, c, fa;     friend bool operator==(Point a, Point b) {       return (a.x == b.x && a.y == b.y);     }   } w[2], b[2], list[4][1000 * 1000 + 1];   int otherx, othery;   void printlist(int k, Point a) {     if (a.fa == -1) return;     if (a.fa != 1) printlist(k, list[k][a.fa]);     printf( %d %d n , a.x, a.y);   }   int n, m, head, tail, v[4][1000 + 1][1000 + 1];   void closer(int k, Point st, Point ed) {     Point a, b;     head = tail = 1;     memset(v[k], 0, sizeof(v[k]));     v[k][st.x][st.y] = head;     list[k][head] = st, list[k][head].c = 0, list[k][head].fa = -1;     if (st == ed) return;     while (head <= tail) {       a = list[k][head];       for (int i = 0; i < 8; i++) {         b = a, b.x += dx[i], b.y += dy[i], b.c++;         if (b.x < 1 || b.y < 1 || b.x > n || b.y > m || v[k][b.x][b.y] != 0)           continue;         tail++;         v[k][b.x][b.y] = tail;         b.fa = head;         list[k][tail] = b;         if (b == ed) return;       }       head++;     }   }   void printlast(int k) {     if (k == 0) {       printf( %d %d n , b[0].x - 1, b[0].y + 2);       printf( %d %d n , b[0].x - 3, b[0].y + 1);       printf( %d %d n , b[0].x - 1, b[0].y);     } else {       printf( %d %d n , w[0].x + 1, w[0].y + 2);       printf( %d %d n , w[0].x + 3, w[0].y + 1);       printf( %d %d n , w[0].x + 1, w[0].y);     }   }   bool choose;   int main() {     n = read(), m = read(), w[1].x = read(), w[1].y = read(), b[1].x = read(),     b[1].y = read();     w[0].x = n / 2, w[0].y = m / 2, b[0].x = n / 2 + 1, b[0].y = m / 2;     closer(0, w[1], w[0]), closer(1, b[1], b[0]);     closer(2, w[1], b[0]);     closer(3, b[1], w[0]);     if ((w[1].x + w[1].y) % 2 != (b[1].x + b[1].y) % 2) {       if (list[0][v[0][w[0].x][w[0].y]].c <= list[1][v[1][b[0].x][b[0].y]].c)         printf( WHITE n ), printlist(0, list[0][v[0][w[0].x][w[0].y]]);       else if (list[2][v[2][b[0].x][b[0].y]].c >=                list[1][v[1][b[0].x][b[0].y]].c + 2)         printf( BLACK n ), printlist(1, list[1][v[1][b[0].x][b[0].y]]);       else         printf( WHITE n ), printlist(2, list[2][v[2][b[0].x][b[0].y]]),             printlast(0);     } else {       if (list[1][v[1][b[0].x][b[0].y]].c < list[0][v[0][w[0].x][w[0].y]].c)         printf( BLACK n ), printlist(1, list[1][v[1][b[0].x][b[0].y]]);       else if (list[3][v[3][w[0].x][w[0].y]].c > list[0][v[0][w[0].x][w[0].y]].c)         printf( WHITE n ), printlist(0, list[0][v[0][w[0].x][w[0].y]]);       else         printf( BLACK n ), printlist(3, list[3][v[3][w[0].x][w[0].y]]),             printlast(1);     }     fflush(stdout);   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4 )   using namespace std;   const int inf = (int)2e9 + 99999, mod = (int)1e9 + 7;   const long long linf = (long long)2e18 + 99999;   int kob(int x, int y) { return ((long long)x * y) % mod; }   int aza(int x, int y) {     x -= y;     if (x < 0) return x + mod;     return x;   }   int kos(int x, int y) {     x += y;     if (x >= mod) return x - mod;     return x;   }   const int maxn = (int)1e5 + 777, maxn2 = (int)1e6 + 55;   int main() {     int a1, a2, a3, a4;     cin >> a1 >> a2 >> a3 >> a4;     int a11 = a1, a22 = a2, a33 = a3, a44 = a4;     a1 -= a3;     a2 -= a3;     bool bad = false;     if (a3 <= a4) bad = 1, --a1;     if (a3 < a4) --a2;     if (abs(a3 - a4) >= 2 || a1 < 0 || a2 < 0) {       if (a33 == a44 && a11 < a22) {         a11 -= a33;         a22 -= a33;         a22--;         if (a11 < 0 || a22 < 0) {           cout << -1;           exit(0);         }         for (int i = 1; i <= a33; ++i) cout <<  74 ;         for (int i = 1; i <= a11; ++i) cout << 4;         cout << 7;         for (int i = 1; i <= a22; ++i) cout << 7;         exit(0);       }       cout <<  -1 , exit(0);     }     if (a3 < a4) cout <<  7 ;     for (int i = 1; i <= a1; ++i) cout <<  4 ;     for (int i = 1; i <= a3; ++i) cout <<  47 ;     for (int i = 1; i <= a2; ++i) cout <<  7 ;     if (bad) cout <<  4 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   const int SQRTN = 320;   const int LOGN = 20;   const double PI = acos(-1);   int n, val;   map<int, int> dp;   int dp2[N];   int range[N];   bool en[N];   int grundy(long long n) {     if (n < 1e6) return dp2[n];     if (dp.find(n) != dp.end()) return dp[n];     int& mex = dp[n];     int st = 0;     double e = sqrt(n);     double s = sqrt(e);     int i = ceil(s), _ = floor(e);     while (i < n && i <= _) {       i = range[i];       st = st | (1 << grundy(i));       i++;     }     while (st & (1 << mex)) mex++;     return mex;   }   int calc(int n) {     int& mex = dp2[n];     int st = 0;     double e = sqrt(n);     double s = sqrt(e);     for (int i = ceil(s), _ = floor(e); i < n && i <= _; i++) {       st = st | (1 << dp2[i]);     }     while (st & (1 << mex)) mex++;     return mex;   }   int main() {     for (int i = 0; i < 1000000; i++) {       calc(i);     }     range[999999] = 999999;     en[999999] = 1;     for (int i = 999998; i > -1; i--) {       if (dp2[i] != dp2[i + 1])         range[i] = i, en[i] = 1;       else         range[i] = range[i + 1];     }     cin >> n;     long long a;     for (int i = 0; i < n; i++) {       scanf( %lld , &a);       val = val ^ grundy(a);     }     cout << (val ?  Furlo  :  Rublo ) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, s, c[10000];     cin >> n >> a >> b;     for (int i = 1; i <= n; i++) {       cin >> c[i];     }     s = 0;     for (int i = 1; i <= n / 2; i++) {       if (c[i] != 2 && c[n - i + 1] != 2 && c[i] != c[n - i + 1]) {         cout << -1 << endl;         return 0;       } else if (c[i] == c[n - i + 1] && c[i] == 2) {         s += 2 * min(a, b);       } else if (c[i] == 2 && c[n - i + 1] != 2) {         if (c[n - i + 1] == 0)           s += a;         else           s += b;       } else if (c[i] != 2 && c[n - i + 1] == 2) {         if (c[i] == 0)           s += a;         else           s += b;       }     }     if (n % 2 == 1 && c[n / 2 + 1] == 2) s += min(a, b);     cout << s << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long cross2(long long x1, long long y1, long long x2, long long y2) {     return x1 * y2 - x2 * y1;   }   long long cross(long long i, long long j, long long k, const long long* xx,                   const long long* yy) {     return cross2(xx[j] - xx[i], yy[j] - yy[i], xx[k] - xx[i], yy[k] - yy[i]);   }   int main() {     int n;     cin >> n;     auto* xx = new long long[n];     auto* yy = new long long[n];     for (int i = 0; i < n; i++) {       cin >> xx[i];       cin >> yy[i];     }     bool flip = xx[0] < xx[1];     long long x = xx[1], y = yy[1];     for (int i = 0; i < n; i++) {       xx[i] -= x;       yy[i] -= y;       if (flip) {         xx[i] = -xx[i];         yy[i] = -yy[i];       }     }     long long left = 0, right = xx[0];     for (int i = 2; i + 1 < n; i++) {       long long cright = cross(i, i + 1, 0, xx, yy);       long long cleft = cross(i, i + 1, 1, xx, yy);       if (cright > 0 && cleft > 0) {         cout << 0;         return 0;       }       long long x0 = xx[i], y0 = yy[i], x1 = xx[i + 1], y1 = yy[i + 1];       if (cright > 0 || cleft > 0) {         long long p = x0 * (y1 - y0) - y0 * (x1 - x0);         long long q = y1 - y0;         if (q < 0) {           p = -p;           q = -q;         }         if (cright > 0)           right = min(right, (p / q));         else           left = max(left, ((p + q - 1) / q));       }     }     cout << (left <= right ? right - left + 1 : 0) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   bitset<N> b;   int p[N];   int cnt[N];   bool was[N];   int main() {     int n, k;     scanf( %d %d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , p + i);       p[i]--;       was[i] = false;     }     for (int i = 1; i <= n; i++) {       cnt[i] = 0;     }     int c1 = 0, c2 = 0;     for (int i = 0; i < n; i++) {       if (was[i]) {         continue;       }       int x = i;       int len = 0;       while (!was[x]) {         was[x] = true;         x = p[x];         len++;       }       c1 += len % 2;       c2 += len / 2;       cnt[len]++;     }     b.set(0);     for (int i = 1; i <= n; i++) {       if (cnt[i] == 0) {         continue;       }       int j = 1;       while (cnt[i] > 0) {         j = min(j, cnt[i]);         int u = i * j;         b |= (b << u);         cnt[i] -= j;         j *= 2;       }     }     int ans_min = k;     if (!b.test(k)) {       ans_min++;     }     int ans_max = 0;     ans_max += 2 * min(k, c2);     k -= min(k, c2);     ans_max += min(k, c1);     printf( %d %d n , ans_min, ans_max);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, h;   int bb[109][109][109];   int a[109], b[109], c[109][109];   int main() {     scanf( %d%d%d , &n, &m, &h);     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= n; j++) {         for (int k = 1; k <= h; k++) {           bb[i][j][k] = 1;         }       }     }     for (int i = 1; i <= m; i++) {       scanf( %d , &a[i]);       for (int j = 1; j <= n; j++) {         for (int k = a[i] + 1; k <= h; k++) {           bb[i][j][k] = 0;         }       }     }     for (int j = 1; j <= n; j++) {       scanf( %d , &b[j]);       for (int i = 1; i <= m; i++) {         for (int k = b[j] + 1; k <= h; k++) {           bb[i][j][k] = 0;         }       }     }     for (int j = 1; j <= n; j++) {       for (int i = 1; i <= m; i++) {         scanf( %d , &c[i][j]);         if (c[i][j] == 0) {           for (int k = 1; k <= h; k++) bb[i][j][k] = 0;         }       }     }     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= n; j++) {         for (int k = 2; k <= h; k++) {           if (bb[i][j][k]) bb[i][j][1]++;         }       }     }     for (int j = 1; j <= n; j++) {       for (int i = 1; i <= m; i++) {         printf( %d  , bb[i][j][1]);       }       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[100001], first, space, op = 1, last;   int main() {     long long k, n, page;     cin >> k >> n >> page;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     if (n == 0) {       cout << 0;       return 0;     }     first = (a[1] - space) / page;     if ((a[1] - space) % page) first++;     for (int i = 1; i <= n; i++) {       long long pg_now = (a[i] - space) / page;       if ((a[i] - space) % page) pg_now++;       if (pg_now == first)         last++;       else {         space = last;         first = (a[i] - space) / page;         if ((a[i] - space) % page) first++;         last++;         op++;       }     }     cout << op;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int md = 1000000007;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int tt{}, T{};     tt = 1;     while (tt--) {       int n{}, m{}, ans{}, k{}, a{}, b{}, c{}, f{};       cin >> n;       if (n == 1) {         cout <<  1 n ;         return 0;       }       if (n == 2) {         cout <<  2 1 n ;         return 0;       }       a = sqrt(n);       b = n - a * a;       for (int j = 0; j < b; ++j) {         for (int i = n + 1 - j * (a + 1) - a - 1; i < n + 1 - j * (a + 1); ++i) {           if (i > 0) cout << i <<    ;         }       }       if (b > 0) n = n - (b) * (a + 1);       for (int i = 0; i < a - b; ++i) {         for (int j = n + 1 - i * a - a; j < n + 1 - i * a; ++j) {           if (j > 0) cout << j <<    ;         }       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   int n;   char a[1000005], b[1000005], dic[130];   int main() {     dic[ W ] =  E ;     dic[ E ] =  W ;     dic[ N ] =  S ;     dic[ S ] =  N ;     scanf( %d%s%s , &n, a, b);     unsigned int ha = 0, hb = 0, rol = 1, mul = 233;     for (int i = n - 2; i >= 0; i--) {       if ((ha = a[i] * rol + ha) == (hb = dic[b[i]] + hb * mul)) {         puts( NO );         return 0;       }       rol *= mul;     }     puts( YES );   }
#include <bits/stdc++.h>   using namespace std;   using T = int;   struct Edge {     int from, to;     T cost, flow, cap;     Edge(int _from = 0, int _to = 0, T _cost = 0, T _cap = 0)         : from(_from), to(_to), cost(_cost), flow(0), cap(_cap) {}   };   const int N = 7010;   const int INF = 0x3f3f3f3f;   int n;   vector<Edge> edges;   vector<int> g[N];   int par[N];   int dist[N];   int pi[N];   void addEdge(int from, int to, T cost, T cap) {     g[from].push_back(edges.size());     edges.emplace_back(from, to, cost, cap);     g[to].push_back(edges.size());     edges.emplace_back(to, from, -cost, 0);   }   bool dijkstra(int s, int t) {     for (int i = 0; i <= t; ++i) {       dist[i] = INF;       par[i] = -1;     }     priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;     dist[s] = 0;     pq.push({0, s});     while (!pq.empty()) {       auto on = pq.top();       pq.pop();       int chosen = on.second;       int d = on.first;       if (d > dist[chosen]) continue;       for (int edge_id : g[chosen]) {         int to = edges[edge_id].to;         int cost = edges[edge_id].cost;         T flowing = edges[edge_id].flow;         T cap = edges[edge_id].cap;         if (cap <= flowing) continue;         if (dist[to] > dist[chosen] + pi[chosen] - pi[to] + cost) {           dist[to] = dist[chosen] + pi[chosen] - pi[to] + cost;           par[to] = edge_id;           pq.push({dist[to], to});         }       }     }     return dist[t] != INF;   }   int mcmf(int s, int t) {     memset(pi, 0, sizeof pi);     int cost = 0, max_flow = 0;     while (dijkstra(s, t)) {       for (int i = 0; i <= t; ++i) {         pi[i] += dist[i];       }       int cur = t, flow = (1 << 30);       for (int cur = t; par[cur] != -1; cur = edges[par[cur]].from) {         flow = min(flow, edges[par[cur]].cap - edges[par[cur]].flow);       }       for (int cur = t; par[cur] != -1; cur = edges[par[cur]].from) {         cost += edges[par[cur]].cost * flow;         edges[par[cur]].flow += flow;         edges[par[cur] ^ 1].flow -= flow;       }       max_flow += flow;     }     return cost;   }   int main() {     scanf( %d , &n);     vector<int> a(n);     addEdge(0, 1, 0, 4);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     for (int i = 0; i < n; ++i) {       addEdge(1, i + 2, 0, 1);       addEdge(i + 2, n + i + 2, -1, 1);       addEdge(n + i + 2, 2 * n + 2, 0, 1);       for (int j = i + 1; j < n; ++j) {         if (abs(a[i] - a[j]) == 1 or a[i] % 7 == a[j] % 7) {           addEdge(n + i + 2, j + 2, 0, 1);         }       }     }     printf( %d n , -1 * mcmf(0, 2 * n + 2));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 200100;   const long long INF = 2000000100;   const long long MOD = 998244353;   long long N, S[MAXN], P[MAXN];   long long B[MAXN];   void update(int ind, long long v) {     for (int i = ind; i <= N; i += (i & -i)) {       B[i] += v;     }   }   long long query(int ind) {     if (ind == 0) return 0;     long long s = 0;     for (int i = ind; i > 0; i -= (i & -i)) {       s += B[i];     }     return s;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> N;     for (int i = 0; i < N; i++) cin >> S[i];     for (int i = 1; i <= N; i++) update(i, i);     for (int i = N - 1; i >= 0; i--) {       long long a = 1, b = N, c;       long long ans = -39;       while (a <= b) {         c = (a + b) / 2;         if (query(c - 1) > S[i]) {           b = c - 1;         } else {           ans = c;           a = c + 1;         }       }       P[i] = ans;       update(ans, -ans);     }     for (int i = 0; i < N; i++) cout << P[i] << (i == N - 1 ?   n  :    );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     cin >> b >> a;     a--;     b -= a;     if (b >= 0 && b % 2 == 0 && a > 0) {       cout <<  Yes  << endl;     } else if (b == 0 && a == 0)       cout <<  Yes  << endl;     else       cout <<  No  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.141592653589793238463;   int a[100009], p[200009];   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     int h;     cin >> h;     for (int i = (0); i <= (h); i++) cin >> a[i];     bool perfect = true;     for (int i = 0; i < (h); i++)       if (a[i] > 1 && a[i + 1] > 1) perfect = false;     if (perfect) {       cout <<  perfect  <<   n ;       return 0;     }     cout <<  ambiguous  <<   n ;     int idx = 1;     p[0] = 0;     for (int i = (0); i <= (h); i++) {       p[i + 1] = idx;       for (int j = (0); j < (a[i]); j++) cout << p[i] <<    ;       idx += a[i];     }     cout <<   n ;     idx = 1;     p[0] = 0;     for (int i = (0); i <= (h); i++) {       p[i + 1] = idx;       if (i > 0 && a[i] > 1 && a[i - 1] > 1) {         cout << p[i] <<    ;         for (int j = (0); j < (a[i] - 1); j++) cout << p[i] + 1 <<    ;       } else         for (int j = (0); j < (a[i]); j++) cout << p[i] <<    ;       idx += a[i];     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f(char c1, char c2) {     if (c1 ==  R  && c2 ==  S ) return 1;     if (c1 ==  S  && c2 ==  P ) return 1;     if (c1 ==  P  && c2 ==  R ) return 1;     if (c2 ==  R  && c1 ==  S ) return -1;     if (c2 ==  S  && c1 ==  P ) return -1;     if (c2 ==  P  && c1 ==  R ) return -1;     return 0;   }   int main() {     int n, j1 = 0, j2 = 0, i, r1 = 0, r2 = 0, t;     char s1[1500], s2[1500];     cin >> n >> s1 >> s2;     for (i = 0; i < n; ++i) {       t = f(s1[j1], s2[j2]);       if (t == 1) ++r2;       if (t == -1) ++r1;       ++j1;       if (!s1[j1]) j1 = 0;       ++j2;       if (!s2[j2]) j2 = 0;       if (j1 == 0 && j2 == 0) {         r1 *= n / (i + 1);         r2 *= n / (i + 1);         n %= (i + 1);         i = -1;       }     }     cout << r1 <<     << r2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 2;   const int M = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     vector<int> pre(n, 1);     for (int i = 1; i < n; i++) {       if (v[i] <= v[i - 1] * 2) pre[i] = pre[i - 1] + 1;     }     cout << *max_element(pre.begin(), pre.end());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     float a, b, c, d;     float mpts;     float vpts;     cin >> a >> b >> c >> d;     mpts = max((3 * a) / 10, a - ((a / 250) * c));     vpts = max((3 * b) / 10, b - ((b / 250) * d));     if (mpts == vpts) {       cout <<  Tie n ;       return 0;     }     mpts > vpts ? cout <<  Misha n  : cout <<  Vasya n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e3 + 10;   const int oo = 1e9;   vector<int> g[N], gt[N];   vector<pair<int, int> > b[N], bt[N];   int cost[N][N];   void bfs(int u, int n, vector<int> adj[], vector<pair<int, int> > &b, bool q) {     queue<int> Q;     vector<int> d(n + 1, oo);     d[u] = 0;     Q.push(u);     while (!Q.empty()) {       int cur = Q.front();       Q.pop();       for (auto v : adj[cur]) {         int dist = d[cur] + 1;         if (dist >= d[v]) continue;         d[v] = dist;         Q.push(v);         if (q) cost[u][v] = dist;       }     }     for (int i = 1; i <= n; i++) b.push_back({d[i], i});     sort(b.begin(), b.end());     while (!b.empty() && b.back().first >= oo) b.pop_back();     reverse(b.begin(), b.end());   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= n; j++) cost[i][j] = oo;       cost[i][i] = 0;     }     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       g[u].push_back(v);       gt[v].push_back(u);     }     for (int i = 1; i <= n; i++) {       bfs(i, n, g, b[i], 1);       bfs(i, n, gt, bt[i], 0);     }     vector<int> ans;     int best = -1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i == j) continue;         for (int k = 0; k < min(3, (int)bt[i].size()); k++) {           for (int l = 0; l < min(3, (int)b[j].size()); l++) {             int u = bt[i][k].second, du = bt[i][k].first;             int v = b[j][l].second, dv = b[j][l].first;             int cur_ans = du + cost[i][j] + dv;             if (cur_ans >= oo || cur_ans <= best) continue;             set<int> S = {u, i, j, v};             if (S.size() < 4) continue;             best = cur_ans;             ans = {u, i, j, v};           }         }       }     }     for (auto x : ans) cout << x <<    ;     cout <<   n ;     return 0;   }