malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     string a;     vector<string> v, b;     bool u = false, l = false;     for (int i = 0; i < 4 * n; i++) {       cin >> a;       int k = 0;       u = false;       for (int j = (int)a.length() - 1; j >= 0; j--) {         if (a[j] ==  a  || a[j] ==  e  || a[j] ==  i  || a[j] ==  o  ||             a[j] ==  u )           k++;         if (k >= m) {           v.push_back(a.substr(j));           u = true;           break;         }       }       if (!u) {         l = true;       }     }     if (l) {       cout <<  NO ;       return 0;     }     for (int i = 0; i < n; i++) {       if (v[i * 4] == v[i * 4 + 1] && v[i * 4 + 1] == v[i * 4 + 2] &&           v[i * 4 + 2] == v[i * 4 + 3]) {         continue;       }       if (v[i * 4] == v[i * 4 + 1] && v[i * 4 + 2] == v[i * 4 + 3]) {         b.push_back( aabb );         continue;       }       if (v[i * 4 + 0] == v[i * 4 + 3] && v[i * 4 + 1] == v[i * 4 + 2]) {         b.push_back( abba );         continue;       }       if (v[i * 4 + 0] == v[i * 4 + 2] && v[i * 4 + 1] == v[i * 4 + 3]) {         b.push_back( abab );         continue;       }       cout <<  NO ;       return 0;     }     if ((int)b.size() == 0) {       cout <<  aaaa ;       return 0;     }     bool h = true;     for (int i = 1; i < (int)b.size(); i++) {       if (b[i] != b[i - 1]) {         h = false;         break;       }     }     if (h)       cout << b[0];     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());   template <typename T>   bool uax(T& a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   template <typename T>   bool uin(T& a, const T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <typename T1, typename T2>   istream& operator>>(istream& in, pair<T1, T2>& p) {     in >> p.first >> p.second;     return in;   }   template <typename T1, typename T2>   ostream& operator<<(ostream& out, pair<T1, T2>& p) {     out << p.first <<     << p.second;     return out;   }   const int N = 200 + 7;   int n;   vector<int> g[N];   vector<int> p[N];   int sz[N];   int ans[N];   vector<int> wr;   int s[N];   bool used[N];   int last_ind = 0;   int arr[N];   void del(int x) {     used[x] = true;     for (int i = 0; i < p[x].size(); i++) {       s[p[x][i]]--;       if (s[p[x][i]] == 1) {         arr[last_ind++] = p[x][i];       }     }   }   bool solve(int x) {     last_ind = 0;     for (int i = 0; i <= n; i++) {       s[i] = sz[i];       used[i] = false;     }     ans[0] = x;     del(x);     for (int i = 1; i < n; i++) {       if (last_ind != 1) {         return false;       }       int ind = arr[0];       int cur = 0;       for (int j = 0; j < g[ind].size(); j++) {         if (!used[g[ind][j]]) cur = g[ind][j];       }       ans[i] = cur;       wr.clear();       for (int j = 0; j < sz[ind]; j++) {         wr.push_back(ans[i - j]);       }       sort(wr.begin(), wr.end());       for (int j = 0; j < g[ind].size(); j++) {         if (g[ind][j] != wr[j]) return false;       }       last_ind = 0;       del(cur);     }     for (int i = 0; i < n; i++) {       cout << ans[i] <<    ;     }     cout <<   n ;     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long T;     cin >> T;     while (T--) {       fill(p, p + n + 1, vector<int>());       cin >> n;       int k;       for (int i = 0; i < n - 1; i++) {         cin >> k;         g[i].resize(k);         sz[i] = k;         for (int j = 0; j < k; j++) {           cin >> g[i][j];           p[g[i][j]].push_back(i);         }       }       for (int i = 1; i <= n; i++) {         if (solve(i)) {           break;         }       }     }   }
#include <bits/stdc++.h>   int query(long long q) {     printf( ? %lld n , q);     fflush(stdout);     int gcd;     scanf( %d , &gcd);     return gcd;   }   void printAnswer(int answer) {     printf( ! %d n , answer);     fflush(stdout);   }   const int MAX_PRIMES = 617;   const int MAX_X = 1000 * 1000 * 1000;   const long long MAX_QUERY = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;   bool isPrime[1 + MAX_PRIMES];   int main() {     for (int i = 2; i <= MAX_PRIMES; i++) {       isPrime[i] = true;     }     std::vector<long long> queries;     queries.push_back(1);     for (int p = 2; p <= MAX_PRIMES; p++) {       if (isPrime[p]) {         for (int m = p * p; m <= MAX_PRIMES; m += p) {           isPrime[m] = false;         }         if (queries.back() <= MAX_QUERY / p) {           long long b = queries.back();           queries.pop_back();           queries.push_back(b * p);         } else {           queries.push_back(p);         }       }     }     int t;     scanf( %d , &t);     for (int _ = 0; _ < t; _++) {       std::vector<int> primeDivs;       for (long long q : queries) {         int gcd = query(q);         for (int p = 2; p <= MAX_PRIMES; p++) {           if (gcd % p == 0) {             primeDivs.push_back(p);             while (gcd % p == 0) {               gcd /= p;             }           }         }       }       for (int &p : primeDivs) {         int copy = p;         while (p <= MAX_X / copy) {           p *= copy;         }       }       if (primeDivs.size() % 2 == 1) {         primeDivs.push_back(1);       }       int sureAnswer = 1;       for (int i = 0; i < (int)primeDivs.size(); i += 2) {         long long q = (long long)primeDivs[i] * primeDivs[i + 1];         int gcd = query(q);         for (int p = 2; p <= MAX_PRIMES; p++) {           int exp = 0;           while (gcd % p == 0) {             gcd /= p;             exp++;           }           sureAnswer *= exp + 1;         }       }       int guessAnswer = std::max(sureAnswer + 7, sureAnswer * 2);       printAnswer(guessAnswer);       primeDivs.clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ar[500005];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %lld , &ar[i]);     }     string s;     cin >> s;     long long gain = 0;     long long loss = 0;     long long bob = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  B ) {         bob += ar[i];       }     }     long long ma = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  A ) {         gain += ar[i];       } else {         loss += ar[i];       }       ma = max(ma, gain - loss);     }     gain = 0;     loss = 0;     for (int i = s.length() - 1; i >= 0; i--) {       if (s[i] ==  A ) {         gain += ar[i];       } else {         loss += ar[i];       }       ma = max(ma, gain - loss);     }     bob += ma;     printf( %lld , bob);   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 100 + 3;   int n, m, k;   bool mat[MX][MX], tmp[MX][MX];   void solve1() {     int q = (1 << m);     int cnt = 0;     int ans = 20;     for (int z = 0; z < q; z++) {       cnt = 0;       memset(tmp, false, sizeof(tmp));       for (int j = 0; j < m; j++) {         if (z & (1 << j)) tmp[0][j] = true;         if (tmp[0][j] != mat[0][j]) cnt++;       }       for (int i = 1; i < n; i++) {         int p = 0;         for (int j = 0; j < m; j++) {           tmp[i][j] = !tmp[i - 1][j];           if (tmp[i][j] != mat[i][j]) p++;         }         p = min(p, m - p);         cnt += p;       }       ans = min(cnt, ans);     }     if (ans > k)       cout << -1 << endl;     else       cout << ans << endl;     exit(0);   }   void swp() {     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) tmp[i][j] = mat[i][j];     for (int i = 0; i < m; i++)       for (int j = 0; j < n; j++) mat[i][j] = tmp[j][i];     swap(n, m);   }   void solve2() {     int ans = 20;     int cnt = 0;     if (n > k) {       for (int i = 0; i < n; i++) {         cnt = 0;         memset(tmp, false, sizeof(tmp));         for (int j = 0; j < m; j++) tmp[i][j] = mat[i][j];         for (int k = 0; k < n; k++) {           if (k != i) {             int p = 0;             for (int j = 0; j < m; j++) {               tmp[k][j] = !tmp[i][j];               if (tmp[k][j] != mat[k][j]) p++;             }             p = min(p, m - p);             cnt += p;           }         }         ans = min(ans, cnt);       }     } else {       swp();       memset(tmp, false, sizeof(tmp));       for (int i = 0; i < n; i++) {         cnt = 0;         for (int j = 0; j < m; j++) tmp[i][j] = mat[i][j];         for (int k = 0; k < n; k++) {           if (k != i) {             int p = 0;             for (int j = 0; j < m; j++) {               tmp[k][j] = !tmp[i][j];               if (tmp[k][j] != mat[k][j]) p++;             }             p = min(p, m - p);             cnt += p;           }         }         ans = min(ans, cnt);       }     }     if (ans <= k)       cout << ans << endl;     else       cout << -1 << endl;     exit(0);   }   int main() {     cin >> n >> m >> k;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> mat[i][j];     if (n <= k && m <= k)       solve1();     else       solve2();     return 0;   }
#include <bits/stdc++.h>   const int Maxn = 500000;   int n;   struct Answer {     int l, r;   } a[Maxn + 5];   int len;   void work(int left, int right) {     if (left == right) {       return;     }     int mid = (left + right) >> 1;     work(left, mid);     work(mid + 1, right);     for (int i = left; i <= mid; i++) {       a[++len].l = i;       a[len].r = mid + (i - left + 1);     }   }   int main() {     scanf( %d , &n);     if (n <= 2) {       puts( 0 );       return 0;     }     int lim = 1;     while (lim <= n) {       lim <<= 1;     }     lim >>= 1;     work(1, lim);     int m = n - lim;     if (m > 0) {       int sz = 1;       while (sz < m) {         sz <<= 1;       }       work(n - sz + 1, n);     }     printf( %d n , len);     for (int i = 1; i <= len; i++) {       printf( %d %d n , a[i].l, a[i].r);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   void solve() {     long long n, m;     cin >> n >> m;     long long ost = m % 10;     set<int> o;     for (int i = 0; i <= 10; ++i) {       o.insert((i * ost) % 10);     }     long long sum = 0;     for (auto x : o) sum += x;     long long d = n / m;     if (n == 0)       cout << 0 <<   n ;     else {       long long res = sum * (d / o.size());       for (int i = 0; i < (d % o.size()); ++i) {         res += ((i + 1) * m) % 10;       }       cout << res <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long t[100005], T[100005], x[100005], c[100005];   long long n, m;   int main() {     while (scanf( %lld%lld , &n, &m) != EOF) {       int i;       int a, b;       long long sum = 0;       for (i = 1; i <= n; i++)         scanf( %lld%lld%lld%lld , &t[i], &T[i], &x[i], &c[i]);       for (i = 1; i <= n; i++) {         if (t[i] >= T[i]) {           sum += (c[i] + x[i] * m);         } else {           if (t[i] + m <= T[i])             sum += c[i];           else {             long long a, b;             long long cha = T[i] - t[i];             long long d = m % (T[i] - t[i]);             long long w = m / (T[i] - t[i]);             if (d)               a = (w + 1) * c[i];             else               a = (w * c[i]);             b = x[i] * m + c[i];             sum += min(a, b);           }         }       }       printf( %I64d n , sum);     }   }
#include <bits/stdc++.h>   using namespace std;   char ss[100050];   char b[12][12];   int len[12];   int n, m;   bool g[100050][11];   bool f[100050][11];   int dp[100050];   struct Node {     int a, b;   };   int main() {     int ll, pos;     bool tmp;     scanf( %s , ss);     n = strlen(ss);     scanf( %d , &m);     for (int i = 0; i < m; i++) {       scanf( %s , b[i]);       len[i] = strlen(b[i]);     }     memset(f, false, sizeof(f));     for (int i = 0; i < n; i++) {       for (int j = 1; j <= 10 && i - j + 1 >= 0; j++) f[i][j] = true;       for (int j = 0; j < m; j++) {         if (i + 1 >= len[j]) {           tmp = true;           for (int k = 0; k < len[j]; k++) {             if (ss[i + k + 1 - len[j]] != b[j][k]) {               tmp = false;               break;             }           }           if (tmp) f[i][len[j]] = false;         }       }       if (!i)         dp[i] = 1;       else         dp[i] = dp[i - 1] + 1;       for (int j = 1; j <= 10 && i + 1 >= j; j++)         if (!f[i][j]) {           dp[i] = j - 1;           break;         }     }     Node ans;     ans.a = ans.b = 0;     pos = 0;     for (int i = 0; i < n; i++) {       pos = max(pos, i - dp[i] + 1);       if (i - pos + 1 > 0 && i - pos + 1 >= ans.b) {         ans.a = pos;         ans.b = i - pos + 1;       }     }     printf( %d %d n , ans.b, ans.a);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       string s1;       cin >> s1;       int p1 = 0, p2 = 0, c1, c2;       set<pair<pair<int, int>, pair<int, int> > > s;       int c = 0;       for (int i = 0; i < s1.size(); i++) {         if (s1[i] ==  N ) {           c2 = p2 + 1;           c1 = p1;         } else if (s1[i] ==  S ) {           c2 = p2 - 1;           c1 = p1;         } else if (s1[i] ==  E ) {           c1 = p1 + 1;           c2 = p2;         } else if (s1[i] ==  W ) {           c1 = p1 - 1;           c2 = p2;         }         if (s.find(make_pair(make_pair(c1, c2), make_pair(p1, p2))) != s.end() ||             s.find(make_pair(make_pair(p1, p2), make_pair(c1, c2))) != s.end()) {           c = c + 1;         } else {           c = c + 5;           s.insert(make_pair(make_pair(p1, p2), make_pair(c1, c2)));         }         p1 = c1;         p2 = c2;       }       cout << c <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long ans;   long long cnt(long long i, long long n, long long count) {     long long c = 0, j = i, k = n;     while (k / i > 0) {       c += k / i;       k /= i;     }     c /= count;     return c;   }   void factorize(long long n, long long p) {     long long count = 0;     while (!(n % 2)) {       n >>= 1;       count++;     }     if (count) {       ans = min(ans, cnt(2, p, count));     }     long long y = n;     for (long long int i = 3; i * i <= y; i++) {       count = 0;       while (n % i == 0) {         count++;         n = n / i;       }       if (count) {         ans = min(ans, cnt(i, p, count));       }     }     if (n > 2) {       ans = min(ans, cnt(n, p, 1));     }     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long n, b;     cin >> n >> b;     ans = LLONG_MAX;     factorize(b, n);     if (ans != LLONG_MAX)       cout << ans << endl;     else       cout << 0 << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long N, K;   long long s1, s2, p1, p2;   long long Get(long long now, long long to) {     if (now <= to << 1) return 0;     long long re = 0;     s1 = 1;     s2 = 0;     p1 = now;     p2 = now - 1;     while (p2 >= to << 1) {       if (p2 == to << 1) return s1 + re;       if (p1 & 1) {         re += s1 + s2;         s1 = (s1 << 1) + s2;       } else {         re += s1 + s2;         s2 = (s2 << 1) + s1;       }       p2 = (p1 >> 1) - 1;       p1 = (p1 >> 1);     }     return re;   }   long long solve(long long l, long long r, long long p, long long k) {     long long mid = (l + r) >> 1;     if (k == 1) return mid;     long long tmp = Get(mid - l, p), Tmp = Get(r - mid, p + 1);     if (k > tmp + Tmp + 1)       return solve(mid + 1, r, p, k - tmp - 1);     else       return solve(l, mid - 1, p, k - Tmp - 1);   }   int main() {     scanf( %lld%lld , &N, &K);     if (K == 1) {       printf( 1 );       return 0;     }     if (K == 2) {       printf( %lld , N);       return 0;     }     N -= 2;     K -= 2;     long long l = 0, r = (N >> 1) + 1;     while (r - l > 1) {       long long mid = (l + r) >> 1;       if (Get(N, mid) < K)         r = mid;       else         l = mid;     }     printf( %lld , solve(1, N, l, K) + 1);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000001;   int N, M, cur, F, a[maxn], del[maxn];   int c[maxn];   inline int lowbit(int x) { return x & -x; }   inline void add(int x, int d) {     for (; x < maxn; x += lowbit(x)) {       c[x] += d;     }   }   inline int seek(int k) {     int ans = 0, sum = 0;     for (int i = 23; i >= 0; i--) {       ans += 1 << i;       if (ans > maxn || sum + c[ans] >= k)         ans -= 1 << i;       else         sum += c[ans];     }     return ans + 1;   }   int main() {     scanf( %d%d , &M, &N);     for (int i = 1; i <= N; ++i) {       scanf( %d , &del[i]);     }     while (M--) {       int d;       scanf( %d , &d);       if (d == -1) {         int x = upper_bound(del + 1, del + N + 1, cur) - del;         for (int i = x - 1; i > 0; --i) {           cur--;           int t = seek(del[i]);           add(t, -1);           a[t] = -1;         }       } else {         cur++;         add(++F, 1);         a[F] = d;       }     }     if (cur == 0) {       printf( Poor stack! n );     } else {       for (int i = 1; i <= cur; ++i) {         printf( %d , a[seek(i)]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {-1, 1, 0, 0};   int dy[] = {0, 0, -1, 1};   long long int sizes[100001];   long long int arr[100001];   bool ok = true;   long long int A[100001];   pair<long long int, long long int> B[100001];   long long int root(long long int i) {     while (i != arr[i]) i = arr[i];     return (i);   }   void Union(long long int i, long long int j) {     long long int root_i = root(i), root_j = root(j);     if (root_i == root_j) return;     if (sizes[root_i] > sizes[root_j]) swap(root_i, root_j);     sizes[root_j] += sizes[root_i];     arr[root_i] = arr[root_j];     return;   }   long long int Arr[100001];   bool solve(long long int n) {     if (n == 1) return (true);     set<long long int> st;     for (long long int i = 0; i < n; i++) {       long long int m = (Arr[i] + i) % n;       if (m < 0) m += n;       if (st.count(m)) return (false);       st.insert(m);     }     return (true);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     cin >> t;     while (t--) {       string s;       cin >> s;       set<pair<pair<long long int, long long int>,                pair<long long int, long long int> > >           st;       long long int ans = 0, x = 0, y = 0;       for (long long int i = 0; i < s.size(); i++) {         long long int a, b, c, d;         if (s[i] ==  N ) {           a = x;           b = y + 1;           c = 0;           d = 1;         } else if (s[i] ==  S ) {           a = x;           b = y - 1;           c = 0;           d = -1;         } else if (s[i] ==  W ) {           a = x + 1;           b = y;           c = 1;           d = 0;         } else if (s[i] ==  E ) {           a = x - 1;           b = y;           c = -1;           d = 0;         }         if (st.count(pair<pair<long long int, long long int>,                           pair<long long int, long long int> >(                 pair<long long int, long long int>(x, y),                 pair<long long int, long long int>(a, b))))           ans++;         else if (st.count(pair<pair<long long int, long long int>,                                pair<long long int, long long int> >(                      pair<long long int, long long int>(a, b),                      pair<long long int, long long int>(x, y))))           ans++;         else           ans += 5;         st.insert(pair<pair<long long int, long long int>,                        pair<long long int, long long int> >(             pair<long long int, long long int>(x, y),             pair<long long int, long long int>(a, b)));         x += c;         y += d;       }       cout << ans <<   n ;     }     return (0);   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll mod = 1e9L + 7;   const int N = 121, M = 1211;   int x[N], y[N];   ll dp[N][M];   ll c[M][M];   int main() {     for (int i = 0; i < M; i++) {       c[i][0] = 1;       for (int j = 1; j <= i; j++)         c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;     }     ios ::sync_with_stdio(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> x[i];     for (int i = 1; i <= n; i++) cin >> y[i];     dp[0][0] = 1;     for (int i = 0; i <= n; i++)       for (int j = 0; j < M; j++)         for (int k = 0; k <= y[i + 1] && j + x[i + 1] - k >= 0; k++) {           dp[i + 1][j + x[i + 1] - k] += dp[i][j] * c[j + x[i + 1]][k];           dp[i + 1][j + x[i + 1] - k] %= mod;         }     ll ans = dp[n + 1][0];     int m = accumulate(x, x + n + 1, 0);     for (int i = 1; i <= n; i++) {       ans *= c[m][x[i]];       ans %= mod;       m -= x[i];     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops )   #pragma GCC optimize( no-stack-protector,fast-math )   using namespace std;   const int N = 5e5 + 100, OO = 724249387, T = 4500 + 100, M = 1e9 + 7, P = 6151,             SQ = 280, lg = 30;   map<int, int> mp;   int dp[N], l[N], r[N], t[N], seg[4][N << 2], lazy[4][N << 2];   vector<pair<int, int> > v[N];   void shift(int c, int id) {     seg[id][c << 1] += lazy[id][c];     seg[id][c << 1 | 1] += lazy[id][c];     lazy[id][c << 1] += lazy[id][c];     lazy[id][c << 1 | 1] += lazy[id][c];     lazy[id][c] = 0;   }   void upd(int id, int c, int b, int e, int l, int r, int t) {     if (e <= l || r <= b) return;     if (l <= b && e <= r) {       seg[id][c] += t;       lazy[id][c] += t;       return;     }     int mid = (b + e) >> 1;     shift(c, id);     upd(id, c << 1, b, mid, l, r, t), upd(id, c << 1 | 1, mid, e, l, r, t);     seg[id][c] = max(seg[id][c << 1 | 1], seg[id][c << 1]);   }   int get(int id, int c, int b, int e, int l, int r) {     if (r <= b || e <= l) return 0;     if (l <= b && e <= r) return seg[id][c];     int mid = (b + e) >> 1;     shift(c, id);     return max(get(id, c << 1, b, mid, l, r), get(id, c << 1 | 1, mid, e, l, r));   }   int32_t main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n;     cin >> n;     set<int> st;     st.insert(0);     for (int i = 0; i < n; i++) {       cin >> l[i] >> r[i] >> t[i];       st.insert(l[i]), st.insert(r[i]);     }     int cnt = 0;     for (auto u : st) mp[u] = cnt++;     for (int i = 0; i < n; i++) {       l[i] = mp[l[i]], r[i] = mp[r[i]];       v[r[i]].push_back({l[i], t[i]});     }     for (int i = 1; i < cnt; i++) {       for (auto u : v[i]) upd(u.second, 1, 0, cnt, 0, u.first, +1);       dp[i] = max(get(1, 1, 0, cnt, 0, i), get(2, 1, 0, cnt, 0, i));       upd(1, 1, 0, cnt, i, i + 1, dp[i]), upd(2, 1, 0, cnt, i, i + 1, dp[i]);     }     cout << dp[cnt - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXL = 1e5;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long int k, p;     long long int ans = 0;     cin >> k >> p;     for (int i = 1; i <= k; i++) {       int x = i;       string str1, str2;       while (x) {         str1 += (x % 10 +  0 );         x /= 10;       }       for (int j = str1.size() - 1; j >= 0; j--) str2 += str1[j];       str2 += str1;       long long int sum = 0;       for (int j = 0; j < str2.size(); j++) sum = sum * 10 + str2[j] -  0 ;       ans = (ans + sum) % p;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   int main() {     int n, i, cnt = 0;     float y;     scanf( %d , &n);     int p[n];     for (i = 1; i <= n; i++) {       scanf( %d , &p[i]);       cnt += p[i];     }     y = (float)cnt / (float)n;     printf( %f , y);     return 0;   }