malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 100011;   const long long INF = (1 << 29) + 123;   const long long MOD = 1000000007;   const long double PI = 4 * atan((long double)1);   int fenw[2 * MAX_N];   int n;   void mod(int i, int v) {     while (i <= n) {       fenw[i] += v;       i += i & -i;     }   }   int query(int i) {     int sum = 0;     while (i > 0) {       sum += fenw[i];       i -= i & -i;     }     return sum;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     vector<pair<int, int> > p;     int x[n], v[n];     for (int i = 0; i < n; i++) cin >> x[i];     for (int i = 0; i < n; i++) {       cin >> v[i];       p.push_back(make_pair(v[i], x[i]));     }     unordered_map<int, int> m;     int rev_map[n];     sort(x, x + n);     for (int i = 0; i < n; i++) {       m[x[i]] = i + 1;       rev_map[i] = x[i];     }     for (int i = 0; i < n; i++) {       p[i].second = m[p[i].second];     }     sort(p.begin(), p.end());     long long ans = 0;     for (int i = 0; i < n; i++) {       int q = query(p[i].second);       ans += 1LL * q * rev_map[p[i].second - 1];       ans -=           1LL * ((n - i - 1) - (p[i].second - 1 - q)) * rev_map[p[i].second - 1];       mod(p[i].second, 1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long V[10005], O[10005], F[1005][10005];   int c[1005], cost[1005];   int n, W, B, X;   struct Queue {     int p[1005], q[1005];     long long maxp[1005], maxq[1005];     void clear() {       *p = 0;       *q = 0;       maxp[0] = maxq[0] = -1;     }     void add(int x) {       q[++*q] = x;       maxq[*q] = max(maxq[(*q) - 1], V[x]);     }     void del() {       if (*p)         --*p;       else {         for (; *q; --*q) ++*p, maxp[*p] = max(maxp[(*p) - 1], V[p[*p] = q[*q]]);         --*p;       }     }     long long ask() { return max(maxp[*p], maxq[*q]); }   } G;   int main() {     scanf( %d%d%d%d , &n, &W, &B, &X);     for (int i = 1; i <= n; i++) scanf( %d , &c[i]);     for (int i = 1; i <= n; i++) scanf( %d , &cost[i]);     memset(F, -1, sizeof(F));     F[0][0] = W;     int sum = 0;     for (int i = 1; i <= n; i++) {       sum += c[i];       for (int j = 0; j <= sum; j++) {         for (int k = max(j - c[i], 0); k <= j; k++)           if (F[i - 1][k] >= 1ll * cost[i] * (j - k))             F[i][j] = max(F[i][j], F[i - 1][k] - 1ll * cost[i] * (j - k));         if (F[i][j] != -1) {           F[i][j] += X;           F[i][j] = min(F[i][j], W + 1ll * j * B);         }       }     }     for (int k = sum; k >= 0; k--)       if (F[n][k] >= 0) {         printf( %d n , k);         return 0;       }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, p1 = 0, p2 = 0;     cin >> n;     int mid[1000], index = 0;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       if (a % 2 == 0) {         for (int j = 1; j <= (a / 2); j++) {           int t;           cin >> t;           p1 += t;         }         for (int j = 1; j <= (a / 2); j++) {           int t;           cin >> t;           p2 += t;         }       } else {         for (int j = 1; j <= (a / 2); j++) {           int t;           cin >> t;           p1 += t;         }         cin >> mid[index++];         for (int j = 1; j <= (a / 2); j++) {           int t;           cin >> t;           p2 += t;         }       }     }     sort(mid, mid + index);     for (int i = index - 1; i >= 0; i--) {       if (((index - 1) % 2 == 0 && i % 2 == 0) ||           ((index - 1) % 2 == 1 && i % 2 == 1))         p1 += mid[i];       else         p2 += mid[i];     }     cout << p1 <<     << p2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 6010;   vector<int> a[N];   int L[N], cnt, r[N], n, res = 0;   void Refresh() {     L[0] = cnt = 0;     for (int i = 1; i <= n + 1; i++) L[i] = 10000000;   }   void DFS(int u, int p) {     int Oldval, Oldid, Oldcnt = cnt;     if (cnt == 0 || r[u] > L[cnt])       L[++cnt] = r[u];     else {       Oldid = lower_bound(L, L + n + 1, r[u]) - L;       Oldval = L[Oldid];       L[Oldid] = r[u];     }     res = max(res, cnt);     for (int i = 0; i < a[u].size(); i++) {       int v = a[u][i];       if (v != p) DFS(v, u);     }     if (Oldcnt != cnt)       L[cnt--] = 10000000;     else       L[Oldid] = Oldval;   }   int main() {     ios_base::sync_with_stdio(0);     int u, v;     cin >> n;     for (int i = 1; i <= n; i++) cin >> r[i];     for (int i = 1; i < n; i++) {       cin >> u >> v;       a[u].push_back(v);       a[v].push_back(u);     }     for (int i = 1; i <= n; i++) {       Refresh();       DFS(i, 0);     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long pow1(int a, int b) {     long long res = 1;     for (int i = 1; i <= b; i++) res *= a;     return res;   }   int main() {     int n;     cin >> n;     long long sum = 2 * (pow1(2, n) - 1);     cout << sum <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, m, k;       cin >> n >> m >> k;       int cardsPlayer = n / k;       double maxCard;       int jokerMax = min(m, cardsPlayer);       maxCard = ceil((m - jokerMax) / (k - 1.0));       if (jokerMax - maxCard > 0)         cout << jokerMax - maxCard << endl;       else         cout << 0 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef struct {     long long j, x1, x2;   } inter;   struct comp1 {     bool operator()(const inter& a, const inter& b) const { return a.x1 < b.x1; };   };   struct comp2 {     bool operator()(const inter& a, const inter& b) const {       return (a.x2 == b.x2) ? (a.x1 < b.x1) : (a.x2 < b.x2);     };   };   void solve() {     long long n;     cin >> n;     vector<long long> a(n), b(n), m(n);     unordered_map<long long, vector<long long>> dsize;     for (long long i = 0; i < (n); i++) {       cin >> a[i] >> b[i] >> m[i];       dsize[a[i] + b[i] - m[i]].push_back(i);     }     long long c = 0;     vector<long long> ea(n);     for (auto& x : dsize) {       multiset<inter, comp1> inter1;       multiset<inter, comp2> inter2;       for (auto& i : x.second) {         long long eamax = min(m[i], a[i]);         long long eamin = max(m[i] - b[i], 0LL);         inter1.insert(inter{i, a[i] - eamax, a[i] - eamin});         inter2.insert(inter{i, a[i] - eamax, a[i] - eamin});       }       auto p1 = inter1.begin();       while (!inter2.empty()) {         long long targ = inter2.begin()->x2;         while ((p1 == inter1.end()) ? false : (p1->x1 <= targ)) {           inter2.erase(*p1);           ea[p1->j] = a[p1->j] - targ;           p1++;         }         c++;       }     }     cout << c << endl;     for (long long i = 0; i < (n); i++)       cout << ea[i] <<     << m[i] - ea[i] << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     ifstream ifs;     if (  [0]) cin.rdbuf((ifs = ifstream(  )).rdbuf());     ;     ofstream ofs;     if (  [0]) cout.rdbuf((ofs = ofstream(  )).rdbuf());     ;     ofstream lfs;     if (  [0]) clog.rdbuf((lfs = ofstream(  )).rdbuf());     ;     int t;     cin >> t;     for (int i = 1; i <= t; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long a[2000], dp[2000];   long long qmod(long long y) {     long long res = 1, two = (long long)2;     for (; y; y >>= 1) {       if (y & 1) res = res * two % mod;       two = two * two % mod;     }     return res;   }   int main() {     long long x, y;     int cnt = 0;     scanf( %lld%lld , &x, &y);     if (y % x) return 0 * puts( 0 );     for (long long i = 1; i <= sqrt(y); ++i) {       if (y % i == 0) {         if (i % x == 0) a[++cnt] = i;         if (i * i != y && y / i % x == 0) a[++cnt] = y / i;       }     }     sort(a + 1, a + 1 + cnt);     for (int i = cnt; i > 0; --i) {       dp[i] = qmod(y / a[i] - 1);       for (int j = i + 1; j <= cnt; ++j)         if (a[j] % a[i] == 0) dp[i] = ((dp[i] - dp[j]) % mod + mod) % mod;     }     printf( %lld n , dp[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 200005;   const int inf = 214748364;   int n, m, g[21][1 << 20], f[maxN], v[maxN], s[maxN];   int cost(int a, int b) {     for (int i = m; i >= 0; --i) {       if ((a & ((1 << i) - 1)) == (b >> (m - i))) return m - i;     }   }   void init() {     char c[25];     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %s , c + 1);       m = strlen(c + 1);       for (int j = 1; j <= m; ++j) v[i] = (v[i] << 1) + c[j] - 48;     }     s[1] = m;     for (int i = 2; i <= n; ++i) s[i] = s[i - 1] + cost(v[i - 1], v[i]);   }   void work() {     int ans = inf;     for (int i = 0; i <= m; ++i)       for (int j = 0; j <= (1 << m) - 1; ++j) g[i][j] = inf;     g[0][0] = 0;     f[1] = m;     for (int i = 2; i <= n; ++i) {       f[i] = inf;       for (int j = 0; j <= m; ++j) {         int tmp = s[i - 1] + g[j][v[i] >> (m - j)] + m - j;         f[i] = ((f[i]) < (tmp) ? (f[i]) : (tmp));       }       for (int j = 0; j <= m; ++j)         g[j][v[i - 1] & ((1 << j) - 1)] =             ((g[j][v[i - 1] & ((1 << j) - 1)]) < (f[i] - s[i])                  ? (g[j][v[i - 1] & ((1 << j) - 1)])                  : (f[i] - s[i]));     }     for (int i = 1; i <= n; ++i)       ans = ((ans) < (f[i] + s[n] - s[i]) ? (ans) : (f[i] + s[n] - s[i]));     printf( %d n , ans);   }   int main() {     init();     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool vis[2][100005];   char c[2][100005];   int main() {     queue<pair<int, pair<int, int> > > q;     bool flag = 0;     int n, k;     cin >> n >> k;     scanf( %s%s , c[0], c[1]);     q.push(make_pair(0, make_pair(0, 0)));     while (!q.empty()) {       int x = q.front().first, y = q.front().second.first,           de = q.front().second.second;       q.pop();       if (y >= n) {         flag = 1;         break;       }       if (vis[x][y] || de > y) continue;       vis[x][y] = 1;       if (y - 1 >= 0 && c[x][y - 1] !=  X  && y - 1 >= de + 1 && !vis[x][y - 1]) {         q.push(make_pair(x, make_pair(y - 1, de + 1)));       }       if (y + 1 >= n || (c[x][y + 1] !=  X  && !vis[x][y + 1])) {         q.push(make_pair(x, make_pair(y + 1, de + 1)));       }       if (y + k >= n || (c[x ^ 1][y + k] !=  X  && !vis[x ^ 1][y + k])) {         q.push(make_pair(x ^ 1, make_pair(y + k, de + 1)));       }     }     if (flag)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   int n, k, ans;   long long s[200005], a[200005], b[200005];   void neg() {     for (int i = 0; i <= n; i++) {       a[i] = -a[i];       b[i] = -b[i];     }   }   void trans() {     b[n]--;     b[0] += 2;     for (int i = 1; i < n; i++) b[i]++;     for (int i = 0; i < n; i++) {       b[i + 1] += b[i] / 2;       b[i] %= 2;     }   }   void print(long long x[]) {     for (int i = 0; i <= n; i++) printf( %I64d  , x[i]);     printf(  n );   }   int main() {     scanf( %d %d , &n, &k);     for (int i = 0; i <= n; i++) scanf( %I64d , &a[i]);     for (int i = 0; i < n; i++) {       b[i] += a[i];       b[i + 1] += b[i] / 2;       b[i] %= 2;       if (b[i] < 0) {         b[i + 1]--;         b[i] += 2;       }     }     b[n] += a[n];     if (b[n] < 0) neg();     trans();     for (int i = n; i >= 0; i--) {       if (s[i + 1] == 10ll * k + 1)         s[i] = 10ll * k + 1;       else         s[i] = s[i + 1] * 2 + b[i];       if (s[i] > 10ll * k) s[i] = 10ll * k + 1;     }     for (int i = 0; i <= n; i++) {       if (i == n && llabs(s[i] - a[i]) <= k && s[i] != a[i]) ans++;       if (i != n && llabs(s[i] - a[i]) <= k) ans++;       if (b[i]) break;     }     printf( %d n , ans);     scanf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int n, k, sum = 0;     cin >> n >> k;     long long int a[n];     for (long long int i = 0; i < n; i++) cin >> a[i];     string s;     cin >> s;     vector<long long int> v;     v.push_back(a[0]);     for (long long int i = 1; s[i]; i++) {       if (s[i] == s[i - 1])         v.push_back(a[i]);       else {         sort(v.rbegin(), v.rend());         for (long long int i = 0; i < k && i < v.size(); i++) {           sum += v[i];         }         v.clear();         v.push_back(a[i]);       }     }     sort(v.rbegin(), v.rend());     for (long long int i = 0; i < k && i < v.size(); i++) sum += v[i];     cout << sum;   }
#include<bits/stdc++.h>   using namespace std;   int a[10];   int main() {       int T;scanf( %d ,&T);       while(T--) {           int sum = 0;           for(int i = 1;i <= 3;i++) {               scanf( %d ,&a[i]);               sum += a[i];           }           if(sum % 9 == 0) {               if(a[1] >= sum / 9 && a[2] >= sum / 9 && a[3] >= sum / 9) {                   printf( YES n );               } else {                   printf( NO n );               }           } else {               printf( NO n );           }       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long int;   using ld = long double;   using vi = vector<int>;   using vll = vector<ll>;   using vd = vector<double>;   using vvi = vector<vi>;   int ctoi(char c) { return c -  0 ; }   int slen(string s) { return s.length(); }   int vsize(vi a) { return (int)a.size(); }   int in() {     int x;     cin >> x;     return x;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int N;     cin >> N;     vi d(N);     for (auto& x : d) cin >> x;     int mn = abs(d[N - 1] - d[0]);     int a = N - 1, b = 0;     for (int i = 1; i < N; i++) {       if (abs(d[i] - d[i - 1]) < mn) {         mn = abs(d[i] - d[i - 1]);         a = i;         b = i - 1;       }     }     cout << a + 1 <<     << b + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int result = 0;     for (int i = 0; i < n; i++) {       int k, a;       cin >> k >> a;       long x = k * a;       int c = 0;       if (a % 4 == 0) a--;       while (a) {         a /= 4;         c++;       }       result = (((result) < (k + c)) ? (k + c) : (result));     }     cout << result;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     cin >> n >> m;     long long x;     for (int i = 0; i < m; i++) {       cin >> x;       if (x > n)         cout << 0 << endl;       else {         if (x % 2 == 1)           cout << x / 2 + 1 << endl;         else {           long long a = x, b, c = n;           while (1) {             if (a % 2 == 1) break;             b = a + (c - a / 2);             a = b;           }           cout << a / 2 + 1 << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int maxn = 100010;   int x0[maxn], x1[maxn], d[maxn], c[maxn];   int main() {     int n, m, y0, y1;     scanf( %d %d %d %d , &n, &m, &y0, &y1);     for (int i = 0; i < n; ++i) {       scanf( %d , &x0[i]);     }     memset(d, -1, sizeof(d));     for (int i = 0; i < m; ++i) {       scanf( %d , &x1[i]);     }     int p = 0, k = 0, last = -1;     for (int i = 0; i < n; ++i) {       while (p < m && abs(x0[i] - x1[p]) > abs(x0[i] - x1[p + 1])) ++p;       if (last < p || abs(x0[i - 1] - x1[p]) == abs(x0[i] - x1[p]))         ++k, last = p;       else if (p < m && abs(x0[i] - x1[p]) == abs(x0[i] - x1[p + 1]))         ++k, last = ++p;       else         last = p;     }     printf( %d n , n - k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a;     cin >> a;     long long int x = a.length();     std::vector<long long int> v;     long long int c = 0;     long long int d = 0;     for (long long int i = 0; i < x; i++) {       if (a[i] ==  b ) {         d++;       }       if (a[i] ==  a ) {         if (d > 0 && c > 0) {           v.push_back(c);           d = 0;           c = 0;         }         c++;         d = 0;       }     }     if (c > 0) v.push_back(c);     long long int res = 1;     for (long long int i = 0; i < v.size(); i++) {       res = (res * (v[i] + 1)) % 1000000007;     }     cout << res - 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[16], b[16];   int main() {     double cnt = 0;     ios::sync_with_stdio(false);     cin >> n;     for (register int i = 0; i < n; i++) cin >> a[i];     for (register int i = 0; i < n; i++) cin >> b[i];     for (register int i = 0; i < 1e6; ++i) {       register bool f = false;       for (register int j = 0; !f && j < n; ++j) f |= i % a[j] == b[j];       cnt += f;     }     cout.setf(ios::fixed, ios::floatfield);     return (cout << setprecision(7) << cnt / 1e6 << endl) && 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k1, k2;   long long a[1005];   long long b[1005];   void ReadData() {     cin >> n >> k1 >> k2;     for (long long i = 1; i <= n; i++) cin >> a[i];     for (long long i = 1; i <= n; i++) cin >> b[i];   }   long long c[1005];   void process() {     long long k = k1 + k2;     priority_queue<long long> heap;     for (long long i = 1; i <= n; i++) {       c[i] = abs(a[i] - b[i]);       heap.push(c[i]);     }     while (k--) {       long long tmp = heap.top();       heap.pop();       tmp--;       heap.push(abs(tmp));     }     long long res = 0;     while (!heap.empty()) {       long long tmp = heap.top();       heap.pop();       res += tmp * tmp;     }     cout << res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ReadData();     process();   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1002, M = 10002;   pair<int, long long> dp[N][M];   map<long long, int> di;   bool vis[N][M];   int nxt[N][M];   long long a[N], b[N], k;   int T[M][N];   int n;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     scanf( %d %lld , &n, &k);     for (int i = 0; i < n; ++i) {       scanf( %lld , b + i);       a[i] = gcd(b[i], k);     }     if (k == 1) return printf( %d n%ld n , 1, min_element(b, b + n) - b + 1), 0;     vector<long long> divisor;     for (long long i = 1; i * i <= k; ++i)       if (k % i == 0) {         divisor.push_back(i);         divisor.push_back(k / i);       }     sort(divisor.begin(), divisor.end());     divisor.resize(unique(divisor.begin(), divisor.end()) - divisor.begin());     int m = divisor.size();     for (int i = 0; i < m; ++i) di[divisor[i]] = i;     for (int i = 0; i < m; ++i)       for (int j = 0; j < n; ++j)         T[i][j] = di[divisor[i] / gcd(divisor[i], a[j])];     nxt[n][0] = -1;     dp[n][0] = {0, 0};     for (int i = 1; i < m; ++i) dp[n][i] = {n + 1, 0};     for (int i = 0; i < m; ++i)       for (int j = n - 1; j >= 0; --j) {         pair<int, long long> ans1 = dp[j + 1][i];         pair<int, long long> ans2 = dp[j + 1][T[i][j]];         ans2.first += 1;         ans2.second += b[j];         if (ans1 <= ans2) {           nxt[j][i] = nxt[j + 1][i];           dp[j][i] = ans1;         } else {           nxt[j][i] = j;           dp[j][i] = ans2;         }       }     pair<int, long long> ans = dp[0][m - 1];     if (ans.first > n) return puts( -1 ), 0;     printf( %d n , ans.first);     int pos = 0;     int nx = m - 1;     while (pos != -1) {       if (nxt[pos][nx] != pos)         pos = nxt[pos][nx];       else {         nx = T[nx][pos];         printf( %d  , pos + 1);         pos += 1;       }     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     int a[100005];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     if (n == 1) {       cout << -1 << endl;       return 0;     }     bool flag = true;     for (int i = 1; i < n; i++) flag = flag && (a[0] == a[i]);     if (flag) {       cout << 1 << endl;       cout << a[0] << endl;       return 0;     }     if (n == 2) {       if ((a[0] + a[1]) % 2 == 0)         cout << 3 << endl;       else         cout << 2 << endl;       cout << 2 * a[0] - a[1] <<    ;       if ((a[0] + a[1]) % 2 == 0) cout << (a[1] + a[0]) / 2 <<    ;       cout << 2 * a[1] - a[0] <<    ;       return 0;     }     flag = true;     for (int i = 2; i < n; i++) flag = flag && (a[1] - a[0] == a[i] - a[i - 1]);     if (flag) {       cout << 2 << endl;       cout << 2 * a[0] - a[1] <<    ;       cout << 2 * a[n - 1] - a[n - 2] << endl;       return 0;     }     vector<int> diff;     set<int> di;     for (int i = 1; i < n; i++) {       diff.push_back(a[i] - a[i - 1]);       di.insert(a[i] - a[i - 1]);     }     if (di.size() != 2) {       cout << 0 << endl;       return 0;     }     sort(diff.begin(), diff.end());     int chan = diff[n - 2];     if (chan != 2 * diff[0]) {       cout << 0 << endl;       return 0;     }     for (int i = n - 3; i >= 0; i--) {       if (diff[i] == chan || diff[i] != diff[0]) {         cout << 0 << endl;         return 0;       }     }     for (int i = 1; i < n; i++) {       if (a[i] - a[i - 1] == chan) {         if ((a[i] + a[i - 1]) % 2 == 0) {           cout << 1 << endl;           cout << (a[i] + a[i - 1]) / 2 << endl;           return 0;         } else {           cout << 0 << endl;           return 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long int> fib(46, -1);   int adv_fib(int n) {     if (n == 0 || n == 1) {       return 1;     } else if (fib[n] == -1) {       return fib[n] = adv_fib(n - 1) + adv_fib(n - 2);     } else {       return fib[n];     }   }   int main() {     int n, curr = 1;     cin >> n;     for (int i = 1; i <= n; i++) {       if (adv_fib(curr) == i) {         cout <<  O ;         curr++;       } else {         cout <<  o ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, k, l, m, n, t, a[211111], b[211111], c[111111], d, s;   string p[111111], q[111111];   int main() {     cin >> n;     for (i = 1; i <= n; i++) scanf( %I64d , &a[i]);     for (i = 1; i <= n; i++) scanf( %I64d , &b[i]);     i = 1;     j = 1;     while (i <= n) {       while (a[i] != b[j] && j <= n) j++;       if (j <= n)         i++;       else         break;     }     if (i > n) {       cout << 0;       return 0;     }     cout << n - i + 1;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> v(n);     for (auto &x : v) cin >> x;     int mine = *min_element(v.begin(), v.end());     vector<int> temp;     for (int i = 0; i < n; i++) {       if (v[i] == mine) temp.push_back(i);     }     for (int i = 0; i < temp.size() - 1; i++) temp[i] = temp[i + 1] - temp[i];     cout << *min_element(temp.begin(), temp.end() - 1) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 50;   int n, a[maxn], ans, maxx = 0;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       maxx = max(maxx, a[i]);     }     cout << maxx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) {       long long a, b, c, i, j;       cin >> a >> b >> c;       string f, s, third;       if (a) {         s = string(a + 1,  0 );       }       if (c) {         f = string(c + 1,  1 );       }       if (b) {         bool flag;         if (a == 0 && c) {           flag = true;           for (i = 0; i < b; i++) {             if (flag) {               third +=  0 ;               flag = false;             } else {               third +=  1 ;               flag = true;             }           }           cout << f << third << endl;           continue;         }         if (c) {           b--;         }         flag = true;         for (i = 0; i < b; i++) {           if (flag) {             third +=  1 ;             flag = false;           } else {             third +=  0 ;             flag = true;           }         }         if (a == 0 && c == 0) {           if (b & 1)             third +=  0 ;           else             third +=  1 ;         }       }       cout << f << s << third << endl;     }     return 0;   }