malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   const long long N = 2e5 + 10;   const long long mod = 1e9 + 7;   struct Trie {     Trie *child[2];     long long cnt;   };   Trie *createNode() {     Trie *node = (Trie *)malloc(sizeof(Trie));     memset(node->child, NULL, sizeof node->child);     node->cnt = 0;     return node;   }   void insert(Trie *root, long long x) {     for (long long i = 30; i >= 0; --i) {       long long val = (1LL << i);       long long bit = 0;       if (val & x) bit = 1;       if (!root->child[bit]) root->child[bit] = createNode();       root = root->child[bit];       root->cnt++;     }   }   void erase(Trie *root, long long x) {     for (long long i = 30; i >= 0; --i) {       long long val = (1LL << i);       long long bit = 0;       if (val & x) bit = 1;       if (!root->child[bit]) root->child[bit] = createNode();       root = root->child[bit];       root->cnt--;     }   }   long long query(Trie *root, long long x) {     long long ans = 0;     for (long long i = 30; i >= 0; --i) {       long long val = (1 << i);       long long bit = 0;       if (val & x) bit = 1;       if (root->child[bit] && root->child[bit]->cnt > 0) {         root = root->child[bit];       } else {         assert(root->child[bit ^ 1] && root->child[bit ^ 1]->cnt > 0);         ans += val;         root = root->child[bit ^ 1];       }     }     return ans;   }   void solve() {     long long n;     cin >> n;     long long a[n], b[n];     for (long long i = 0; i < n; ++i) cin >> a[i];     for (long long i = 0; i < n; ++i) cin >> b[i];     Trie *root = createNode();     for (long long i = 0; i < n; ++i) {       insert(root, b[i]);     }     vector<long long> ans;     for (long long i = 0; i < n; ++i) {       long long x = query(root, a[i]);       ans.push_back(x);       erase(root, a[i] ^ x);     }     for (long long i = 0; i < n; ++i) cout << ans[i] <<    ;     cout <<   n ;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ;     long long t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   int b[12][12];   int main() {     int a;     int i, j;     int sum;     scanf( %d , &a);     memset(b, 0, sizeof(b));     for (i = 1; i <= 10; i++)       for (j = 1; j <= 10; j++) {         b[1][j] = b[i][1] = 1;         b[i][j] = b[i - 1][j] + b[i][j - 1];       }     printf( %d , b[a][a]);   }
#include <bits/stdc++.h>   using namespace std;   int n, Cnt = 0, Num = 0;   int l[200000 + 10], r[200000 + 10];   map<int, int> mp;   int Di[200000 + 10];   vector<int> f[200000 + 10], No[200000 + 10];   int cur[200000 + 10];   bool b[200000 + 10];   int Ans[200000 + 10];   int Check() {     int Now = -1, ODD = 0;     for (int i = 1; i <= Cnt; i++)       if (f[i].size() % 2 == 1) {         ODD++;         Now = i;       }     if (ODD == 2) return Now;     if (ODD == 0) return 1;     return -1;   }   void Euler(int x) {     for (int i = cur[x]; i < f[x].size(); i = cur[x]) {       cur[x] = i + 1;       if (b[No[x][i]]) continue;       b[No[x][i]] = true;       Euler(f[x][i]);     }     Ans[++Ans[0]] = x;   }   int main() {     scanf( %d , &n);     n--;     for (int i = 1; i <= n; i++) scanf( %d , &l[i]);     for (int i = 1; i <= n; i++) scanf( %d , &r[i]);     int x, y;     for (int i = 1; i <= n; i++) {       if (l[i] > r[i]) return printf( -1 ), 0;       if (!mp.count(l[i]))         x = mp[l[i]] = ++Cnt, Di[Cnt] = l[i];       else         x = mp[l[i]];       if (!mp.count(r[i]))         y = mp[r[i]] = ++Cnt, Di[Cnt] = r[i];       else         y = mp[r[i]];       Num++;       f[x].push_back(y);       No[x].push_back(Num);       f[y].push_back(x);       No[y].push_back(Num);     }     int Begin = Check();     if (Begin == -1) return printf( -1 ), 0;     Euler(Begin);     if (Ans[0] != n + 1) return printf( -1 ), 0;     for (int i = n + 1; i; i--) printf( %d  , Di[Ans[i]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[100005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     cout.tie();     cin >> n >> k;     if (k < n / 2 || (n == 1 && k)) {       cout << -1;       return 0;     }     if (n == 1 && k == 0) {       cout << 1;       return 0;     }     k = k - (n - 2) / 2;     cout << k <<     << k * 2 <<    ;     k = k * 2 + 1;     for (int i = 0; i <= n - 3; i++) cout << k + i <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void qmax(long long &x, int y) {     if (x < y) x = y;   }   void qmin(long long &x, long long y) {     if (x > y) x = y;   }   inline long long read() {     char s;     long long k = 0, base = 1;     while ((s = getchar()) !=  -  && s != EOF && !(isdigit(s)))       ;     if (s == EOF) exit(0);     if (s ==  - ) base = -1, s = getchar();     while (isdigit(s)) {       k = k * 10 + (s ^  0 );       s = getchar();     }     return k * base;   }   inline void write(int x) {     static char cnt, num[15];     cnt = 0;     if (!x) {       printf( 0 );       return;     }     for (; x; x /= 10) num[++cnt] = x % 10;     for (; cnt; putchar(num[cnt--] + 48))       ;   }   const int maxn = 1e5 + 100;   int n, m, k, s, X, Y;   int a[maxn];   int po[maxn], ne[maxn * 2], to[maxn * 2], id;   void add(int x, int y) {     id++;     to[id] = y;     ne[id] = po[x];     po[x] = id;   }   int dis[maxn], vis[maxn];   queue<int> q;   int c[maxn][101];   void spfa(int x) {     memset(vis, 0, sizeof(vis));     memset(dis, 0x3f3f3f3f, sizeof(dis));     int inf = dis[0];     while (!q.empty()) q.pop();     for (int i = 1; i <= n; i++)       if (a[i] == x) {         dis[i] = 0;         vis[i] = 1;         q.push(i);       }     while (!q.empty()) {       int u = q.front(), v;       q.pop();       vis[u] = 0;       for (int i = po[u]; i; i = ne[i]) {         v = to[i];         if (dis[v] > dis[u] + 1) {           dis[v] = dis[u] + 1;           if (!vis[v]) {             vis[v] = 1;             q.push(v);           }         }       }     }     for (int i = 1; i <= n; i++) c[i][x] = dis[i];   }   int main() {     n = read();     m = read();     k = read();     s = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= m; i++) {       X = read();       Y = read();       add(X, Y);       add(Y, X);     }     for (int i = 1; i <= k; i++) spfa(i);     for (int i = 1; i <= n; i++) {       long long sum = 0;       sort(c[i] + 1, c[i] + k + 1);       for (int j = 1; j <= s; j++) sum += c[i][j];       printf( %lld  , sum);     }   }
#include <bits/stdc++.h>   using namespace std;   string s;   int pos[1000];   int n, a, b;   int main() {     cin >> n;     cin >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  x )         a++;       else         b++;     }     cout << abs(n / 2 - a) << endl;     int t = abs(n / 2 - a);     if (a > b) {       for (int i = 0; i < s.size(); i++)         if (s[i] ==  x  && t) {           s[i] =  X ;           t--;         }     } else if (a < b) {       for (int i = 0; i < s.size(); i++)         if (s[i] ==  X  && t) {           s[i] =  x ;           t--;         }     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void checkDefine();   long long int a, b, c, d;   int main() {     cin >> a >> b >> c >> d;     long long int t1 = max(3 * a / 10, a - (a * c) / 250);     long long int t2 = max(3 * b / 10, b - (b * d) / 250);     if (t1 > t2) {       cout <<  Misha ;     } else if (t1 < t2) {       cout <<  Vasya ;     } else {       cout <<  Tie ;     }     return 0;   }   void checkDefine() {     long long int n, a[200005];     map<long long int, long long int> m;     cin >> n;     for (int i = (0), _b = (n - 1); i <= _b; i++) {       cin >> a[i];       m[a[i]]++;     }     string s;     cin >> s;     {       cout <<  s             <<   =  ;       cout << (s) << endl;     };     {       cout <<  a             <<   =  ;       for (int _ = 0, _a = (n); _ < _a; _++) cout << a[_] <<    ;       cout << endl;     };     {       cout <<   ------------              <<   =  ;       cout << ( ------------ ) << endl;     };     for (__typeof(m.begin()) it = m.begin(); it != m.end(); ++it) {       cout << it->first <<     << it->second << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, cnt[200005], x, y, ans;   vector<long long> v[200005];   void dfs(long long pos, long long pre) {     long long len = v[pos].size();     for (long long i = 0; i < len; i++) {       long long xx = v[pos][i];       if (xx != pre) {         dfs(xx, pos);         cnt[pos] += cnt[xx];         ans += min(cnt[xx], 2 * k - cnt[xx]);       }     }   }   int main() {     scanf( %lld%lld , &n, &k);     for (long long i = 0; i < 2 * k; i++) {       scanf( %lld , &x);       cnt[x] = 1;     }     for (long long i = 0; i < n - 1; i++) {       scanf( %lld%lld , &x, &y);       v[x].push_back(y);       v[y].push_back(x);     }     dfs(1, 0);     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   bool cmp(pair<long long, int> l, pair<long long, int> r) {     return l.first < r.first;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n, A, cf, cm, money;     cin >> n >> A >> cf >> cm >> money;     vector<pair<long long, int> > v(n + 1);     for (int i = 1; i <= n; i++) {       cin >> v[i].first;       v[i].second = i;     }     sort(v.begin(), v.end());     vector<long long> pf(n + 1, 0);     long long c = 0;     for (int i = 1; i <= n; i++) pf[i] = v[i].first + pf[i - 1];     vector<long long> ps(n + 2, 0);     for (int i = n; i >= 1; i--) ps[i] = ps[i + 1] + v[i].first;     long long ans = 0;     long long no = 0;     long long mn = 0;     for (long long i = 0; i <= n; i++) {       long long m = money;       m = m - max((long long)0, (A * i - ps[n - i + 1]));       if (m < 0) continue;       long long pnts = cf * i;       int lo = 0;       int hi = A;       while (lo < hi) {         long long mid = (lo + hi + 1) >> (long long)1;         vector<pair<long long, int> >::iterator it = lower_bound(             v.begin(), v.begin() + (n - i + 1), make_pair(mid, 0), cmp);         if (it == v.begin()) {           lo = mid;           continue;         } else           it--;         long long reqd = ((long long)(it - v.begin())) * mid - pf[it - v.begin()];         if (reqd <= m)           lo = mid;         else           hi = mid - 1;       }       pnts += lo * cm;       if (ans < pnts) {         ans = pnts;         no = i;         mn = lo;       }       ans = max(ans, pnts);     }     cout << ans <<   n ;     ;     vector<long long> re(n + 1, 0);     for (int i = n; i > n - no; i--) re[(int)v[i].second] = A;     for (int i = 1; i <= n - no; i++) re[v[i].second] = max(v[i].first, mn);     for (int i = 1; i <= n; i++) cout << re[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   int nextInt() {     int x;     scanf( %d , &x);     return x;   }   double nextDouble() {     double x;     scanf( %lf , &x);     return x;   }   long long nextLong() {     long long x;     scanf( %I64d , &x);     return x;   }   char nextChar() {     char x;     scanf( %c , &x);     return x;   }   void newLine() { printf(  n ); }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   long long powM(long long a, long long b, long long MOD) {     long long x = 1, y = a;     while (b > 0) {       if (b % 2 == 1) {         x = (x * y);         if (x > MOD) x %= MOD;       }       y = (y * y);       if (y > MOD) y %= MOD;       b /= 2;     }     return x;   }   long long ModExp(long long n, long long k, long long MOD) {     long long ans = 1;     while (k > 0) {       if (k & 1) ans = (ans * n) % MOD;       n = (n * n) % MOD;       k /= 2;     }     return ans;   }   long long Exp(long long n, long long k) {     long long ans = 1;     while (k > 0) {       if (k & 1) ans = (ans * n);       n = (n * n);       k /= 2;     }     return ans;   }   int countSetBits(long long n) {     int ans = 0;     while (n != 0) {       n -= (n & -n);       ++ans;     }     return ans;   }   const int N = 100100;   const int M = 12;   const int INF = 1e6;   const double EPS = 1e-6;   const long double PI = 2 * acos(0);   using namespace std;   const int LOG = 18;   long long mod = 1000000009;   int par[N];   int getPar(int x) { return x == par[x] ? x : par[x] = getPar(par[x]); };   bool same(int x, int y) { return getPar(x) == getPar(y); }   void merge(int x, int y) {     int xx = getPar(x);     int yy = getPar(y);     if (xx != yy) par[xx] = yy;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) par[i] = i;     long long ans = 1;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       x--, y--;       if (same(x, y)) {         ans = (ans * 2ll) % mod;       } else {         merge(x, y);       }       cout << (ans + mod - 1) % mod << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     set<int> co[2];     set<pair<int, int> > delta[2];     int w, h, n;     scanf( %d%d%d , &w, &h, &n);     co[0].insert(0);     co[0].insert(w);     delta[0].insert(make_pair(w, 0));     co[1].insert(0);     co[1].insert(h);     delta[1].insert(make_pair(h, 0));     for (int i = (0), _end_ = (n); i < _end_; ++i) {       static char s[2];       static int first;       scanf( %s%d , s, &first);       int ty = s[0] ==  H ;       co[ty].insert(first);       auto it = co[ty].lower_bound(first);       auto tmp = it;       --tmp;       ++it;       delta[ty].erase(make_pair(*it - *tmp, *tmp));       delta[ty].insert(make_pair(first - *tmp, *tmp));       delta[ty].insert(make_pair(*it - first, first));       printf( %I64d n ,              (long long)delta[0].rbegin()->first * delta[1].rbegin()->first);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int l, r, x, y;   };   vector<node> p[500010];   int a[500010], b[500010], c[500010];   int main() {     int i, j, k, n, m, s;     node e;     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     b[0] = 0;     for (i = 1; i <= n + 1; i++) {       b[i] = b[i - 1];       if (a[i] == m) b[i]++;     }     a[n + 1] = 0;     j = 0;     k = 0;     for (i = 1; i <= n + 1; i++) {       if (a[i] == a[i - 1])         k++;       else {         e.l = j;         e.r = k;         e.x = k - j + 1;         p[a[i - 1]].push_back(e);         j = i;         k = i;       }     }     s = 0;     for (i = 1; i <= 500010 - 10; i++) {       k = p[i].size();       if (k == 0) continue;       e.l = n + 1;       e.r = n + 1;       e.x = 0;       p[i].push_back(e);       p[i][0].y = p[i][0].x + b[n] - b[p[i][0].r] + b[p[i][0].l - 1];       s = max(s, p[i][0].y);       c[p[i][0].l] = b[p[i][0].l - 1] + p[i][0].x;       for (j = 1; j < k; j++) {         p[i][j].y = p[i][j].x + max(c[p[i][j - 1].l], b[p[i][j].l - 1]) + b[n] -                     b[p[i][j].r];         s = max(s, p[i][j].y);         c[p[i][j].l] =             max(c[p[i][j - 1].l] + p[i][j].x, p[i][j].x + b[p[i][j].l - 1]);       }     }     printf( %d n , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void func() {     string s;     cin >> s;     long long n = s.length();     long long i = 1, len = 0, pre[n];     pre[0] = 0;     while (i < n) {       if (s[i] == s[len]) {         len++;         pre[i++] = len;       } else {         if (len == 0) {           pre[i++] = 0;         } else {           len = pre[len - 1];         }       }     }     if (pre[n - 1] == 0) {       cout <<  Just a legend             <<   n ;       return;     }     for (long long i = 0; i < n - 1; ++i) {       if (pre[i] == pre[n - 1]) {         cout << s.substr(0, pre[n - 1]) <<   n ;         return;       }     }     if (pre[pre[n - 1] - 1] == 0) {       cout <<  Just a legend             <<   n ;       return;     }     cout << s.substr(0, pre[pre[n - 1] - 1]) <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       func();     }   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   struct item {     long long t, d, p, idx;   };   item sh[200005];   bool cmp(item x, item y) { return x.d < y.d; }   long long n;   long long dp[105][2005];   long long sol(long long i, long long cur) {     if (i == n) return 0;     if (~dp[i][cur]) return dp[i][cur];     if (sh[i].t + cur >= sh[i].d) return dp[i][cur] = sol(i + 1, cur);     return dp[i][cur] = max(sh[i].p + sol(i + 1, cur + sh[i].t), sol(i + 1, cur));   }   vector<long long> ans;   void print(long long i, long long cur) {     if (i == n) return;     if (sh[i].t + cur >= sh[i].d) {       print(i + 1, cur);     } else if (sh[i].p + sol(i + 1, cur + sh[i].t) > sol(i + 1, cur)) {       ans.push_back(sh[i].idx);       print(i + 1, cur + sh[i].t);     } else       print(i + 1, cur);   }   void solve() {     long long i, j, k, l, r, m, a, b, c, d, x, y, z, t;     cin >> n;     memset(dp, -1, sizeof dp);     for (i = 0; i < n; i++) {       cin >> sh[i].t >> sh[i].d >> sh[i].p;       sh[i].idx = i + 1;     }     sort(sh, sh + n, cmp);     cout << sol(0, 0) << endl;     print(0, 0);     cout << ans.size() << endl;     for (auto &cv : ans) {       cout << cv <<    ;     }     cout << endl;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long INF = 4e18;   const long long MAX = 1e5;   const long long MV = 1e18;   const long double PI = 3.14159265358979323846;   long long MA = -INF, MI = INF;   long long PO(long long x, long long y) {     if (y == 0) return 1;     long long ans = PO(x, y / 2);     ans *= ans, ans %= MOD;     if (y % 2 == 1) ans *= x, ans %= MOD;     return ans % MOD;   }   void RE(long long x) {     x %= MOD;     if (x < 0) x += MOD;   }   long long fib[100], dp1[100], dp2[100], siz = 2;   void cal() {     fib[1] = 1, fib[2] = 2;     while (true) {       long long temp = fib[siz - 1] + fib[siz];       if (temp > MV)         break;       else         fib[++siz] = temp;     }   }   int32_t main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),         cout << fixed << setprecision(10);     cal();     long long t;     cin >> t;     deque<long long> rep;     while (t--) {       long long n;       cin >> n;       for (long long i = siz; i >= 1; i--) {         if (n >= fib[i]) rep.push_back(i), n -= fib[i];       }       reverse(rep.begin(), rep.end());       rep.push_front(0);       long long len = rep.size();       dp1[0] = 1;       dp2[0] = 0;       for (long long i = 1; i < len; i++) {         dp1[i] = dp1[i - 1] + dp2[i - 1];         dp2[i] = (dp1[i - 1] * ((rep[i] - rep[i - 1] - 1) / 2)) +                  (dp2[i - 1] * ((rep[i] - rep[i - 1]) / 2));       }       cout << dp1[len - 1] + dp2[len - 1] <<   n ;       rep.clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static long long mod = 998244353;   long long pow(long long x, long long y) {     x = x % mod;     int res = 1;     while (y > 0) {       if (y & 1) {         res = (res * x) % mod;       }       y = y >> 1;       x = (x * x) % mod;     }     return res;   }   long long modInverse(long long n, long long mod) { return pow(n, mod - 2); }   long long nCrmodFermat(long long n, long long r) {     if (r == 0) return 1;     long long fact[n + 1];     fact[0] = 1;     for (long long i = 1; i <= n; i++) {       fact[i] = ((fact[i - 1] % mod) * (i % mod)) % mod;     }     return (fact[n] * modInverse(fact[r], mod) % mod *             modInverse(fact[n - r], mod) % mod) %            mod;   }   int main() {     long long n;     cin >> n;     vector<long long> v(2 * n);     long long sum = 0;     for (int i = 0; i < 2 * n; i++) {       cin >> v[i];     }     sort(v.begin(), v.end());     int i = 0;     int j = (2 * n) - 1;     while (i < n && j >= n) {       sum = (sum + abs(v[i] - v[j])) % mod;       i++;       j--;     }     cout << ((sum % mod) * (nCrmodFermat((2 * n), n) % mod)) % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100010];   vector<pair<long long, long long> > people;   long long Free[100010];   int main() {     long long ts, tf, t;     cin >> ts >> tf >> t;     int n;     scanf( %d , &n);     if (n == 0) {       cout << ts << endl;       return 0;     }     for (int i = 1; i <= n; i++) {       scanf( %I64d , &a[i]);     }     people.push_back(make_pair(0, 0));     long long cnt = 1;     for (int i = 1; i < n; i++) {       if (a[i] != a[i + 1]) {         people.push_back(make_pair(a[i], cnt));         cnt = 1;       } else         cnt++;     }     people.push_back(make_pair(a[n], cnt));     long long ans, wait;     ans = a[1] - 1;     wait = ts - (a[1] - 1);     if (wait < 0) {       wait = 0;       ans = ts;     }     long long time = max(people[1].first, ts);     for (int i = 1; i + 1 < people.size(); i++) {       if (time + t > tf) break;       time = time + people[i].second * t;       if (time + t > tf) break;       long long come_time = people[i + 1].first - 1;       long long new_wait = time - come_time;       if (new_wait < 0) {         new_wait = 0;         come_time = time;       }       if (new_wait < wait) {         wait = new_wait;         ans = come_time;       }       time = max(time, people[i + 1].first);     }     time = time + people.back().second * t;     if (time + t <= tf) {       ans = time;       wait = 0;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int co = 0, i, n, y, m, j, k, t, x = 0;     cin >> n;     int a[n + 1];     for (i = 1; i <= n; i++) cin >> a[i];     co = 0;     int c = 1;     j = 0;     vector<int> v;     map<int, int> mp;     for (i = 1; i <= n; i++) {       mp[a[i]]++;       co += a[i];       j++;       if (a[i] < 0) {         if (mp[-1 * a[i]] != 1) {           co = -1;           break;         }       }       if (mp[a[i]] > 1) {         c = 0;         break;       }       if (co == 0) {         v.push_back(j);         mp.clear();         j = 0;         co = 0;       }     }     if (!co) {       if (c) {         cout << v.size() <<   n ;         for (int i = 0; i < v.size(); i++) {           cout << v[i] <<    ;         }       } else         cout << -1 <<   n ;     } else       cout << -1 <<   n ;   }