malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long const M = 2000 + 10, M2 = 1e7 + 10, mod = 1e9 + 7, inf = 1e9 + 10,                   sq = 450;   long long a[M][M], ro[M], col[M], all[M];   int32_t main() {     long long n, ans = 0;     cin >> n;     for (long long i = 1; i <= n; i++) {       string x;       cin >> x;       for (long long j = 0; j < x.size(); j++) {         a[i][j + 1] = x[j] -  0 ;       }     }     for (long long i = 1; i <= n; i++) {       for (long long j = n; j > i; j--) {         long long good = col[j] xor ro[i];         long long need = good xor a[i][j];         ro[i] = ro[i] xor need;         all[i] = all[i] xor need;         col[j] = col[j] xor need;         all[j] = all[j] xor need;         ans += need;       }     }     for (long long i = 1; i <= n; i++) col[i] = 0, ro[i] = 0;     for (long long i = n; i >= 1; i--) {       for (long long j = 1; j < i; j++) {         long long good = col[j] xor ro[i];         long long need = good xor a[i][j];         ro[i] = ro[i] xor need;         all[i] = all[i] = all[i] xor need;         col[j] = col[j] xor need;         all[j] = all[j] xor need;         ans += need;       }     }     for (long long i = 1; i <= n; i++) {       ans += all[i] xor a[i][i];     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     long long a[n], b[m];     for (long long i = 0; i < n; ++i) {       cin >> a[i];     }     for (long long i = 0; i < m; ++i) {       cin >> b[i];     }     long long ans = INF;     for (long long i = 0; i < n; ++i) {       long long res = -INF;       for (long long j = 0; j < n; ++j) {         if (i != j) {           for (long long k = 0; k < m; ++k) {             res = max(res, a[j] * b[k]);           }         }       }       ans = min(ans, res);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n, x[maxn], y[maxn];   int solve(set<pair<int, int> >& a, set<pair<int, int> >& b) {     set<pair<int, int> >::iterator itl = a.begin(), itd = b.begin(), it1;     set<pair<int, int> >::reverse_iterator itr = a.rbegin(), itu = b.rbegin(),                                            it2;     set<pair<int, int> > f, s;     bool chk = false;     for (int i = 0; i < a.size() - 1; ++i) {       if (next(itl)->first > itl->first + 1) {         chk = true;         for (it1 = a.begin(); it1 != next(itl); ++it1) {           f.insert({x[it1->second], it1->second});         }       } else if (next(itd)->first > itd->first + 1) {         chk = true;         for (it1 = b.begin(); it1 != next(itd); ++it1) {           f.insert({x[it1->second], it1->second});         }       } else if (next(itr)->first + 1 < itr->first) {         chk = true;         for (it2 = a.rbegin(); it2 != next(itr); ++it2) {           f.insert({x[it2->second], it2->second});         }       } else if (next(itu)->first + 1 < itu->first) {         chk = true;         for (it2 = b.rbegin(); it2 != next(itu); it2++) {           f.insert({x[it2->second], it2->second});         }       }       if (chk) {         for (auto u : f) {           s.insert({y[u.second], u.second});           b.erase({y[u.second], u.second});           a.erase(u);         }         return solve(a, b) + solve(f, s);       }       itl++;       itr++;       itd++;       itu++;     }     return 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     set<pair<int, int> > xs, ys;     for (int i = 0; i < n; ++i) {       cin >> x[i] >> y[i];       xs.insert({x[i], i});       ys.insert({y[i], i});     }     cout << solve(xs, ys);     return 0;   }
#include <bits/stdc++.h>   int main() {     int t = 1, i, j, n;     long long int p, q, temp, arr[90];     for (j = 0; j < t; j++) {       scanf( %lld %lld , &p, &q);       scanf( %d , &n);       for (i = 0; i < n; i++) scanf( %lld , &arr[i]);       for (i = 0; i < n; i++) {         if (p / q < arr[i]) {           printf( NO n );           break;         }         p = p - (q * arr[i]);         if (p == 0 && i != n - 1) {           printf( NO n );           break;         }         if (i != n - 1) {           temp = p;           p = q;           q = temp;         }       }       if (p == 0 && i == n)         printf( YES n );       else if (i == n)         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   struct seg {     vector<int> t;     int n;     seg(int n = 0) : t(2 * n), n(n) {}     int query(int l, int r) {       int ans = 0;       for (l += n, r += n; l < r; l >>= 1, r >>= 1) {         if (l & 1) ans += t[l++];         if (r & 1) ans += t[--r];       }       return ans;     }     void update(int p, int v) {       for (t[p += n] += v; p > 1; p >>= 1) {         t[p >> 1] = t[p] + t[p ^ 1];       }     }   };   seg s[4][11][10];   void modify(int p, int c, int m) {     for (int i = 1; i <= 10; i++) {       s[c][i][p % i].update(p, m);     }   }   void convert(string& s) {     for (char& c : s) {       switch (c) {         case  A :           c = 0;           break;         case  T :           c = 1;           break;         case  C :           c = 2;           break;         case  G :           c = 3;           break;       }     }   }   int main() {     string k;     cin >> k;     convert(k);     for (int i = 0; i < 4; i++) {       for (int j = 1; j <= 10; j++) {         for (int l = 0; l < j; l++) {           s[i][j][l] = seg(k.size());         }       }     }     for (int i = 0; i < k.size(); i++) {       modify(i, k[i], 1);     }     int q;     cin >> q;     while (q--) {       int op;       cin >> op;       if (op == 1) {         int x;         string c;         cin >> x >> c;         convert(c);         x--;         modify(x, k[x], -1);         k[x] = c[0];         modify(x, k[x], 1);       } else {         int l, r;         cin >> l >> r;         l--;         string e;         cin >> e;         convert(e);         int a = 0;         for (int i = l; i < l + e.size(); i++) {           a += s[e[i - l]][e.size()][i % e.size()].query(l, r);         }         cout << a <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};   const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1},             d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};   void DBG() { cout <<  ]  << endl; }   template <class H, class... T>   void DBG(H h, T... t) {     cout << to_string(h);     if (sizeof...(t)) cout <<  ,  ;     DBG(t...);   }   template <class T>   bool umin(T& a, const T& b) {     return b < a ? a = b, 1 : 0;   }   template <class T>   bool umax(T& a, const T& b) {     return a < b ? a = b, 1 : 0;   }   int n;   vector<pair<long long, long long>> cards[(long long)(200002)],       need[(long long)(200002)];   vector<array<long long, 3>> valid[(long long)(200002)];   void prepare() {     for (int i = (1), _c = (n); i <= _c; ++i) {       vector<int> cnt(4, 0);       sort((cards[i]).begin(), (cards[i]).end(),            [](pair<long long, long long> a, pair<long long, long long> b) {              return a.first < b.first ||                     (a.first == b.first && a.second > b.second);            });       for (auto j : cards[i]) {         if (j.first == 1 && cnt[j.first] >= 3) continue;         if (j.first == 2 && cnt[j.first] >= 1) continue;         if (j.first == 3 && cnt[j.first] >= 1) continue;         need[i].push_back(j);         ++cnt[j.first];       }     }     for (int i = (1), _c = (n); i <= _c; ++i) {       for (int j = (0), _c = ((1ll << (((int)((need[i]).size())))) - 1); j <= _c;            ++j) {         long long cost = 0, ma = 0, dame = 0;         for (int k = (0), _c = (((int)((need[i]).size())) - 1); k <= _c; ++k) {           if ((((j) >> (k)) & 1ll)) {             cost += need[i][k].first;             dame += need[i][k].second;             umax(ma, need[i][k].second);           }         }         if (cost <= 3) {           int bonus = __builtin_popcountll(j);           valid[i].push_back({bonus, dame, ma});         }       }     }   }   long long dp[(long long)(200002)][11];   void test_case() {     cin >> n;     for (int i = (1), _c = (n); i <= _c; ++i) {       int k;       cin >> k;       cards[i].assign(k, {0, 0});       for (int j = (0), _c = (k - 1); j <= _c; ++j)         cin >> cards[i][j].first >> cards[i][j].second;     }     prepare();     for (auto i : valid[1]) umax(dp[1][i[0]], i[1]);     for (int i = (1), _c = (n - 1); i <= _c; ++i)       for (int j = (0), _c = (10); j <= _c; ++j)         if (dp[i][j] || j == 0) {           for (auto k : valid[i + 1]) {             int nxtNum = j + k[0];             if (nxtNum < 10)               umax(dp[i + 1][nxtNum], dp[i][j] + k[1]);             else               umax(dp[i + 1][nxtNum % 10], dp[i][j] + k[1] + k[2]);           }         }     long long ans = 0;     for (int i = (0), _c = (10); i <= _c; ++i) umax(ans, dp[n][i]);     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     auto time = clock();     int test = 1;     while (test--) {       test_case();     }     cerr <<  [It took   << fixed << setprecision(3)          << double(clock() - time) / CLOCKS_PER_SEC <<  s]           <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Get(int &T) {     char C;     bool F = 0;     for (; C = getchar(), C <  0  || C >  9 ;)       if (C ==  - ) F = 1;     for (T = C -  0 ; C = getchar(), C >=  0  && C <=  9 ; T = T * 10 + C -  0 )       ;     F && (T = -T);   }   int N;   void Init() { Get(N); }   int T[55][55];   void Mul(int A[][55], int B[][55], int N, int K, int M) {     for (int i = 1; i <= N; i++)       for (int j = 1; j <= M; j++) {         T[i][j] = 0;         for (int k = 1; k <= K; k++) (T[i][j] ^= (A[i][k] & B[k][j]));       }     for (int i = 1; i <= N; i++)       for (int j = 1; j <= M; j++) A[i][j] = T[i][j];   }   int A[55][55];   int B[55][55];   int T2[55][55];   void Pow(int X[][55], long long P) {     for (int i = 1; i <= N; i++)       for (int j = 1; j <= N; j++) T2[i][j] = (i == j);     for (; P; P >>= 1) {       if (P & 1) Mul(T2, X, N, N, N);       Mul(X, X, N, N, N);     }     for (int i = 1; i <= N; i++)       for (int j = 1; j <= N; j++) X[i][j] = T2[i][j];   }   long long Factor[100005];   int FactorTop;   bool I() {     for (int i = 1; i <= N; i++)       for (int j = 1; j <= N; j++)         if (B[i][j] != (i == j)) return 0;     return 1;   }   bool Check() {     for (int i = 1; i <= N; i++)       for (int j = 1; j <= N; j++) B[i][j] = A[i][j];     Pow(B, (1ll << N) - 1);     int Ans = I();     if (Ans == 0) return 0;     for (int k = 1; k <= FactorTop; k++) {       for (int i = 1; i <= N; i++)         for (int j = 1; j <= N; j++) B[i][j] = A[i][j];       Pow(B, ((1ll << N) - 1) / Factor[k]);       int Ans = I();       if (Ans == 1) return 0;     }     return 1;   }   void Debug() {     FactorTop = 0;     long long X = 1ll << N;     X--;     Factor[0] = 1;     for (long long i = 2; i * i <= X; i++) {       for (;; X /= i) {         if (X % i != 0) break;         Factor[++FactorTop] = i;       }     }     if (X > 1) Factor[++FactorTop] = X;     for (int i = 1; i < N; i++) A[i + 1][i] = 1;     for (;;) {       for (int i = 1; i <= N; i++) A[i][N] = rand() & 1;       int Ans = Check();       if (Ans) break;     }   }   void Work() { Debug(); }   void Output() {     for (int i = N; i >= 1; i--) printf( %d  , A[i][N]);     puts(  );     for (int i = N; i >= 1; i--) printf( %d  , 1);     puts(  );   }   int main() {     srand(time(0));     Init();     Work();     Output();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t;   long long n;   long long tmp;   long long gcd(long long a, long long b) {     long long temp;     if (a < b) {       temp = a;       a = b;       b = temp;     }     while (b != 0) {       temp = a % b;       a = b;       b = temp;     }     return a;   }   long long lcm(long long a, long long b) {     long long temp_lcm;     temp_lcm = a * b / gcd(a, b);     return temp_lcm;   }   int main() {     cin >> t;     while (t--) {       cin >> n;       if (n % 2 == 0) {         long long a, b;         tmp = n / 2;         while (tmp--) {           cin >> a >> b;           cout << b <<     << -a <<    ;         }         cout << endl;       } else {         long long a, b, c;         tmp = (n - 2) / 2;         while (tmp--) {           cin >> a >> b;           cout << b <<     << -a <<    ;         }         cin >> a >> b >> c;         tmp = lcm(a, b);         tmp = lcm(tmp, c);         cout << tmp / a <<     << tmp / b <<     << -2 * tmp / c;         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int max = 0, min = 0;     int a[m], b[m];     for (int i = 0; i < m; i++) {       cin >> a[i];       b[i] = a[i];     }     sort(a, a + m, greater<int>());     for (int i = 0; i < n; i++) {       if (a[0] != 0) {         max = max + a[0];         a[0] = a[0] - 1;         sort(a, a + m, greater<int>());       } else {         break;       }     }     sort(b, b + m);     int i = 0, k = 0;     while (i != n) {       if (b[k] != 0) {         min = min + b[k];         b[k] = b[k] - 1;       } else {         k++;         min = min + b[k];         b[k] = b[k] - 1;       }       i++;     }     cout << max <<     << min;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isPrime[1000005] = {false};   vector<long long int> SPF(1000005);   long long int fastPower(long long int a, long long int b) {     if (b == 0) return 1;     long long int prod = 1;     while (b > 0) {       if (b & 1) prod = prod * a;       b = b >> 1;       a = a * a;     }     return prod;   }   void sieve() {     int i;     for (i = 2; i < 1000005; ++i) isPrime[i] = 1;     for (i = 2; i * i < 1000005; ++i) {       if (isPrime[i]) {         for (int j = i * i; j < 1000005; j += i) isPrime[j] = 0;       }     }   }   void printa(bool f) {     if (f)       cout <<  YES ;     else       cout <<  NO ;     cout <<   n ;   }   bool flip(bool f) {     if (f) return 0;     return 1;   }   void solve() {     long long int i, n;     cin >> n;     vector<long long int> a(n);     for (i = 0; i < n; ++i) cin >> a[i];     sort(a.begin(), a.end());     long long int s = 0, m = a[n - 1];     for (i = 0; i < n - 1; ++i) s += a[i];     cout << abs(m - s) + 1 <<   n ;   }   int main() {     int tc = 1;     while (tc--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int m, n, p, count = 0;     cin >> m >> n;     if (m % n == 0)       cout << m / n;     else {       count = count + (m / n);       m = m % n;       for (;;) {         if (m > n) {           if (m % n == 0) {             count += m / n;             break;           }           m = m - n;           count++;         } else if (n > m) {           if (n % m == 0) {             count += n / m;             break;           }           n = n - m;           count++;         }       }       cout << count;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5;   const int MAXM = 20;   int n, m;   int a[MAXN], b[MAXM];   int num[MAXM];   char ans[MAXN][MAXM];   set<int> states[MAXM];   int getState(int mask, int num[MAXM]) {     int res = mask;     for (int i = 0; i < n; ++i) {       res = res * MAXN + num[i];     }     return res;   }   bool dfs(int j, int lastState = 0) {     if (j == m) {       for (int i = 0; i < n; ++i) {         if (num[i] != a[i]) {           return false;         }       }       return true;     }     if (j) {       if (states[j].find(lastState) != states[j].end()) {         return false;       }       states[j].insert(lastState);     }     int origin[MAXM];     memcpy(origin, num, sizeof(num));     for (int k = 0; k < (1 << n); ++k) {       int cnt = 0;       for (int i = 0; i < n; ++i) {         if (k & (1 << i)) {           ans[i][j] =  * ;           if (i == 0 || ans[i - 1][j] ==  . ) {             ++cnt;           }         } else {           ans[i][j] =  . ;         }       }       if (cnt != b[j]) {         continue;       }       for (int i = 0; i < n; ++i) {         if (ans[i][j] ==  * ) {           if (j == 0 || ans[i][j - 1] ==  . ) {             ++num[i];           }         }       }       bool valid = true;       for (int i = 0; i < n; ++i) {         if (num[i] > a[i]) {           valid = false;           break;         }         if (ans[i][j] ==  * ) {           if (a[i] - num[i] > (m - j - 1) / 2) {             valid = false;             break;           }         } else {           if (a[i] - num[i] > (m - j) / 2) {             valid = false;             break;           }         }       }       if (valid) {         if (dfs(j + 1, getState(k, num))) {           return true;         }       }       memcpy(num, origin, sizeof(origin));     }     return false;   }   int main() {     while (cin >> n >> m) {       for (int i = 0; i < n; ++i) {         cin >> a[i];       }       for (int i = 0; i < m; ++i) {         cin >> b[i];       }       for (int i = 0; i < n; ++i) {         states[i].clear();       }       memset(num, 0, sizeof(num));       dfs(0);       for (int i = 0; i < n; ++i) {         for (int j = 0; j < m; ++j) {           cout << ans[i][j];         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100500;   const int INF = 2 * (1e9);   int n, m;   vector<pair<int, int> > edge[N];   vector<pair<int, int> > delay[N];   int dist[N];   int main() {     cin.sync_with_stdio(false);     cin >> n >> m;     for (int i = 0; i < m; i++) {       int from, to, len;       cin >> from >> to >> len;       from--;       to--;       edge[from].push_back(make_pair(to, len));       edge[to].push_back(make_pair(from, len));     }     for (int i = 0; i < n; i++) {       int num;       cin >> num;       int cur;       for (int j = 0; j < num; j++) {         cin >> cur;         if (j == 0 or delay[i].back().second != cur)           delay[i].push_back(make_pair(cur, cur + 1));         else           delay[i].back().second++;       }     }     for (int i = 0; i < n; i++) dist[i] = INF;     dist[0] = 0;     if (delay[0].size() >= 1 and delay[0][0].first == 0)       dist[0] = delay[0][0].second;     set<pair<int, int> > dijkstra;     dijkstra.insert(make_pair(dist[0], 0));     for (int i = 0; i < n; i++) {       if (dijkstra.empty()) break;       pair<int, int> now = *dijkstra.begin();       dijkstra.erase(now);       for (const pair<int, int> &next : edge[now.second]) {         int arrival = next.first;         int tm = next.second + now.first;         int idx = lower_bound(delay[arrival].begin(), delay[arrival].end(),                               make_pair(tm, INF)) -                   delay[arrival].begin();         if (idx > 0 and arrival != n - 1) {           idx--;           if (delay[arrival][idx].first <= tm and tm < delay[arrival][idx].second)             tm = delay[arrival][idx].second;         }         if (dist[arrival] > tm) {           dijkstra.erase(make_pair(dist[arrival], arrival));           dist[arrival] = tm;           dijkstra.insert(make_pair(dist[arrival], arrival));         }       }     }     if (dist[n - 1] == INF) dist[n - 1] = -1;     cout << dist[n - 1] << endl;     return 0;   }
#include <cstdio>   #include <vector>   #include <cstring>   #include <algorithm>   const int Maxn=200000;   const int Inf=0x3f3f3f3f;   int n;   int a[Maxn+5];   std::vector<int> v_lis[Maxn+5];   struct Segment_Tree{    struct Segment_Node{     int minn,maxn;     int lazy;    }seg[Maxn<<2|5];    void update_tag(int root,int a){     seg[root].lazy+=a;     seg[root].minn+=a,seg[root].maxn+=a;    }    void push_up(int root){     seg[root].minn=std::min(seg[root<<1].minn,seg[root<<1|1].minn);     seg[root].maxn=std::max(seg[root<<1].maxn,seg[root<<1|1].maxn);    }    void push_down(int root){     if(seg[root].lazy==0){      return;     }     update_tag(root<<1,seg[root].lazy);     update_tag(root<<1|1,seg[root].lazy);     seg[root].lazy=0;    }    void update(int l,int r,int v,int root=1,int left=0,int right=n){     if(l>right||r<left){      return;     }     if(l<=left&&r>=right){      update_tag(root,v);      return;     }     push_down(root);     int mid=(left+right)>>1;     update(l,r,v,root<<1,left,mid);     update(l,r,v,root<<1|1,mid+1,right);     push_up(root);    }    int query_min(int l,int r,int root=1,int left=0,int right=n){     if(l>right||r<left){      return Inf;     }     if(l<=left&&r>=right){      return seg[root].minn;     }     push_down(root);     int mid=(left+right)>>1;     return std::min(query_min(l,r,root<<1,left,mid),query_min(l,r,root<<1|1,mid+1,right));    }    int query_max(int l,int r,int root=1,int left=0,int right=n){     if(l>right||r<left){      return -Inf;     }     if(l<=left&&r>=right){      return seg[root].maxn;     }     push_down(root);     int mid=(left+right)>>1;     return std::max(query_max(l,r,root<<1,left,mid),query_max(l,r,root<<1|1,mid+1,right));    }   }seg_1,seg_2;   int ans[Maxn+5];   int main(){    scanf( %d ,&n);    for(int i=1;i<=n;i++){     scanf( %d ,&a[i]);     v_lis[a[i]].push_back(i);    }    for(int i=1;i<=n;i++){     seg_1.update(i>>1,(n-1)>>1,1);     seg_2.update((i+1)>>1,n>>1,1);    }    for(int i=1;i<=n;i++){     for(int j=0;j<(int)v_lis[i].size();j++){      int pos=v_lis[i][j];      int pos_1_max=seg_1.query_max(pos>>1,(n-1)>>1);      int pos_1_min=seg_1.query_min(0,(pos>>1)-1);      int pos_2_max=seg_2.query_max((pos+1)>>1,n>>1);      int pos_2_min=seg_2.query_min(0,(pos-1)>>1);      ans[pos]=std::max(std::max((pos_2_max-pos_2_min)>>1,(pos_1_max-pos_1_min)>>1),      std::max((pos_2_max-pos_1_min-1)>>1,(pos_1_max-pos_2_min-1)>>1));     }     for(int j=0;j<(int)v_lis[i].size();j++){      seg_1.update(v_lis[i][j]>>1,(n-1)>>1,-2);      seg_2.update((v_lis[i][j]+1)>>1,n>>1,-2);     }     for(int j=0;j<(int)v_lis[i].size();j++){      int pos=v_lis[i][j];      int pos_1_min=seg_1.query_min(pos>>1,(n-1)>>1);      int pos_1_max=seg_1.query_max(0,(pos>>1)-1);      int pos_2_min=seg_2.query_min((pos+1)>>1,n>>1);      int pos_2_max=seg_2.query_max(0,(pos-1)>>1);      ans[pos]=std::max(ans[pos],std::max(      std::max((pos_2_max-pos_2_min)>>1,(pos_1_max-pos_1_min)>>1)-1,      std::max((pos_2_max-pos_1_min-1)>>1,(pos_1_max-pos_2_min-1)>>1)));     }    }    for(int i=1;i<=n;i++){     printf( %d  ,ans[i]);    }    puts(  );;    return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> V[100005];   int main() {     int N, M, K, ans = 1;     scanf( %d%d%d , &N, &M, &K);     for (int i = 1; i <= N; ++i) {       int c;       scanf( %d , &c);       V[c].push_back(i);     }     for (int c = 1; c <= M; ++c) {       int L = V[c].size(), rem = 0, st = 0;       for (int j = 1; j < L; ++j) {         rem += V[c][j] - V[c][j - 1] - 1;         while (rem > K) {           rem -= V[c][st + 1] - V[c][st] - 1;           ++st;         }         ans = max(ans, j - st + 1);       }     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     string s;     cin >> s;     string h = s.substr(0, 2);     int hour = atoi(h.c_str());     string m = s.substr(3, 2);     int minute = atoi(m.c_str());     long long time = 60 * hour + minute;     long long add;     cin >> add;     long long sum = time + add;     long long n = sum % (24 * 60);     cout << setfill( 0 ) << setw(2) << right << (n / 60);     cout <<  : ;     cout << setfill( 0 ) << setw(2) << right << (n % 60) << endl;     ;     return 0;   }