malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool cmp(pair<int, int> a, pair<int, int> b) {     return abs(a.first) + abs(a.second) < abs(b.first) + abs(b.second);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<pair<int, int>> q1;     vector<pair<int, int>> q2;     vector<pair<int, int>> q3;     vector<pair<int, int>> q4;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       if (x > 0 && y >= 0) {         q1.push_back(make_pair(x, y));       }       if (x <= 0 && y > 0) {         q2.push_back(make_pair(x, y));       }       if (x < 0 && y <= 0) {         q3.push_back(make_pair(x, y));       }       if (x >= 0 && y < 0) {         q4.push_back(make_pair(x, y));       }     }     sort(q1.begin(), q1.end(), cmp);     sort(q2.begin(), q2.end(), cmp);     sort(q3.begin(), q3.end(), cmp);     sort(q4.begin(), q4.end(), cmp);     int ans = 0;     for (int i = 0; i < q1.size(); i++) {       ans += 4;       if (q1[i].second != 0) {         ans += 2;       }     }     for (int i = 0; i < q2.size(); i++) {       ans += 4;       if (q2[i].first != 0) {         ans += 2;       }     }     for (int i = 0; i < q3.size(); i++) {       ans += 4;       if (q3[i].second != 0) {         ans += 2;       }     }     for (int i = 0; i < q4.size(); i++) {       ans += 4;       if (q4[i].first != 0) {         ans += 2;       }     }     cout << ans << endl;     for (int i = 0; i < q1.size(); i++) {       cout <<  1   << abs(q1[i].first) <<   R n ;       if (q1[i].second != 0) {         cout <<  1   << abs(q1[i].second) <<   U n ;       }       cout << 2 << endl;       if (q1[i].second != 0) {         cout <<  1   << abs(q1[i].second) <<   D n ;       }       cout <<  1   << abs(q1[i].first) <<   L n ;       cout << 3 << endl;     }     for (int i = 0; i < q2.size(); i++) {       cout <<  1   << abs(q2[i].second) <<   U n ;       if (q2[i].first != 0) {         cout <<  1   << abs(q2[i].first) <<   L n ;       }       cout << 2 << endl;       if (q2[i].first != 0) {         cout <<  1   << abs(q2[i].first) <<   R n ;       }       cout <<  1   << abs(q2[i].second) <<   D n ;       cout << 3 << endl;     }     for (int i = 0; i < q3.size(); i++) {       cout <<  1   << abs(q3[i].first) <<   L n ;       if (q3[i].second != 0) {         cout <<  1   << abs(q3[i].second) <<   D n ;       }       cout << 2 << endl;       if (q3[i].second != 0) {         cout <<  1   << abs(q3[i].second) <<   U n ;       }       cout <<  1   << abs(q3[i].first) <<   R n ;       cout << 3 << endl;     }     for (int i = 0; i < q4.size(); i++) {       cout <<  1   << abs(q4[i].second) <<   D n ;       if (q4[i].first != 0) {         cout <<  1   << abs(q4[i].first) <<   R n ;       }       cout << 2 << endl;       if (q4[i].first != 0) {         cout <<  1   << abs(q4[i].first) <<   L n ;       }       cout <<  1   << abs(q4[i].second) <<   U n ;       cout << 3 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2007;   set<pair<int, int> > E[N];   struct edge {     int x, y;   } e[N];   int n, rk[N], mxrk, mxid;   void adde(int x, int y, int i) {     E[x].insert(make_pair(y, i)), E[y].insert(make_pair(x, i));   }   void dele(int i) {     int x = e[i].x, y = e[i].y;     E[x].erase(make_pair(y, i)), E[y].erase(make_pair(x, i));     printf( ? %d %d n , x, y), fflush(stdout);   }   bool check(vector<pair<__int128, int> > &ve, __int128 x) {     priority_queue<pair<__int128, int> > q;     for (auto u : ve) q.push(u);     for (int i = n - 1; i >= 0; i--)       if (x >> i & 1) {         pair<__int128, int> v = q.top();         q.pop();         v.first -= __int128(1) << i, rk[v.second] = i;         q.push(v);       }     return q.top().first < 0;   }   __int128 produce(vector<pair<__int128, int> > &ve) {     if (!ve.size()) return 0;     __int128 z = (__int128(1) << n) - 1;     for (int i = n - 1; i >= 0; i--)       if (check(ve, z - (__int128(1) << i))) z -= __int128(1) << i;     check(ve, z);     return z;   }   __int128 dfs(int v, int fa) {     vector<pair<__int128, int> > ve;     for (auto x : E[v]) {       int u = x.first;       if (u == fa) continue;       ve.push_back(make_pair(dfs(u, v), x.second));     }     return produce(ve);   }   void find(int v, int fa) {     for (auto x : E[v]) {       int u = x.first, i = x.second;       if (u == fa) continue;       if (rk[i] > mxrk) mxrk = rk[i], mxid = i;       find(u, v);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       adde(x, y, i), adde(y, x, i);       e[i] = {x, y};     }     dfs(1, 0);     int rt = 1;     while (1) {       mxrk = -1, mxid = 0;       find(rt, 0);       if (mxrk == -1) break;       dele(mxid);       scanf( %d , &rt);     }     printf( ! %d n , rt), fflush(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long bin_pow(long long a, long long b) {     if (b == 0) return 1;     if (b % 2 == 0) {       long long t = bin_pow(a, b / 2);       return t * t % 1000000007;     } else       return a * bin_pow(a, b - 1) % 1000000007;   }   vector<long long> a;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long t = 1, n, m, k = 0, x = 0, y = 0, z = 0, sum = 0, l = 0, r = 0,               ans = 0, mn = LLONG_MAX, mx = LLONG_MIN;     cin >> n;     a.resize(n);     vector<pair<long long, long long> > d;     stack<long long> s;     for (int i = 0; i < n; i++) cin >> a[i];     t = 0;     for (int i = 0; i < n; i++) {       if (a[i] < t) {         while (a[i] != t) {           x = s.top();           s.pop();           d.push_back({x, i});           t--;         }       } else {         while (a[i] != t) {           s.push(i + 1);           t++;         }       }     }     while (!s.empty()) {       x = s.top();       d.push_back({x, n});       s.pop();     }     cout << d.size() <<   n ;     for (auto u : d) cout << u.first <<     << u.second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> graph[5001];   bool subset[5001][5001];   set<pair<int, int>> ans_pairs;   vector<int> child_nodes(5001, -1);   int total_nodes;   void insert_into_answer(int network1, int network2) {     if (network1 != 0 && network2 != 0) {       ans_pairs.insert({network1, network2});       ans_pairs.insert({network2, network1});     }     return;   }   bool isSubsetSum(vector<int> &set, int n, int sum) {     for (int i = 0; i <= set.size(); i++) subset[i][0] = true;     for (int j = 1; j <= sum; j++) subset[0][j] = false;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= sum; j++) {         if (j < set[i - 1]) subset[i][j] = subset[i - 1][j];         if (j >= set[i - 1])           subset[i][j] = subset[i - 1][j] || subset[i - 1][j - set[i - 1]];       }     }     return subset[n][sum];   }   int dfs(int id, int parent) {     if (child_nodes[id] != -1) {       return child_nodes[id];     }     if (graph[id].size() == 0) {       return child_nodes[id] = 1;     }     int temp = 0;     for (long long i = 0; i < graph[id].size(); i++) {       if (graph[id][i] != parent) {         temp += dfs(graph[id][i], id);       }     }     return child_nodes[id] = temp + 1;   }   void solve(int id, int parent) {     insert_into_answer(child_nodes[id] - 1, total_nodes - child_nodes[id]);     vector<int> childs_to_adjacent;     for (long long i = 0; i < graph[id].size(); i++) {       if (graph[id][i] != parent) {         childs_to_adjacent.push_back(child_nodes[graph[id][i]]);       }     }     isSubsetSum(childs_to_adjacent, childs_to_adjacent.size(), child_nodes[id]);     int child_length = childs_to_adjacent.size();     for (long long i = 1; i < child_nodes[id]; i++) {       if (subset[child_length][i]) {         insert_into_answer(i, total_nodes - i - 1);       }     }     for (long long i = 0; i < graph[id].size(); i++) {       if (graph[id][i] != parent) {         solve(graph[id][i], id);       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> total_nodes;     int x, y;     for (long long i = 1; i < total_nodes; i++) {       cin >> x >> y;       graph[x - 1].push_back(y - 1);       graph[y - 1].push_back(x - 1);     }     int a = dfs(0, -1);     solve(0, -1);     cout << ans_pairs.size() << endl;     for (auto it : ans_pairs) {       cout << it.first <<     << it.second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     int e = max(c, d);     if (e > 2 * c || e > 2 * d || e >= b) {       cout << -1;       return 0;     }     cout << 2 * a << endl << 2 * b << endl << e;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       string str;       int n;       cin >> n;       cin.ignore();       getline(cin, str);       int l = 0, r = n - 1;       while (l < n && str[l] ==  0 ) {         l++;       }       while (r >= 0 && str[r] ==  1 ) {         r--;       }       if (l >= r) {         cout << str << endl;       } else {         cout << str.substr(0, l) <<  0  << str.substr(r + 1, n) << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k, l;       cin >> n >> k;       vector<int> barrel;       for (int i = 0; i < n; i++) {         cin >> l;         barrel.push_back(l);       }       sort(barrel.begin(), barrel.end());       long long int resp = 0;       k++;       while (k--) {         resp += barrel.back();         barrel.pop_back();       }       cout << resp << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   char buf[100000];   vector<pair<int, string> > vp;   int b[maxn], n, m;   pair<int, string> me;   int getL() {     int tx = 0, ret = 1;     if (m == n) {       me.first -= b[0];       tx = 1;     }     for (int i = 0; i < (int)vp.size(); i++) {       if (vp[i] < me) {         ret++;         continue;       }       while (tx < m) {         pair<int, string> tmp = vp[i];         tmp.first -= b[tx];         tx++;         if (tmp < me) {           ret++;           break;         }       }     }     if (m == n) me.first += b[0];     return ret;   }   int getH() {     me.first -= b[m - 1];     int tx = m - 2, ret = 1;     vector<pair<int, string> > vp2;     for (int i = 0; i < (int)vp.size(); i++) {       if (vp[i] < me) {         if (tx >= 0) tx--;         ret++;       } else         vp2.push_back(vp[i]);     }     for (int i = (int)vp2.size() - 1; i >= 0; i--) {       while (tx >= 0) {         pair<int, string> tmp = vp2[i];         tmp.first -= b[tx];         tx--;         if (tmp < me) {           ret++;         } else           break;       }     }     while (tx >= 0) {       ret++;       tx--;     }     me.first += b[m - 1];     return ret;   }   int main() {     while (scanf( %d , &n) != EOF) {       vp.clear();       for (int i = 0; i < n; i++) {         int tmp;         scanf( %s%d , buf, &tmp);         vp.push_back(make_pair(-tmp, string(buf)));       }       scanf( %d , &m);       for (int i = 0; i < m; i++) {         scanf( %d , &b[i]);       }       sort(b, b + m);       scanf( %s , buf);       string s(buf);       for (int i = 0; i < (int)vp.size(); i++) {         if (vp[i].second == s) {           me = vp[i];           swap(vp[i], vp[vp.size() - 1]);           vp.pop_back();           break;         }       }       sort(vp.begin(), vp.end());       printf( %d %d n , getH(), getL());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct edge {     int x, y, d, r;     bool operator<(edge const &T) const { return d < T.d; }   };   int n, t, ed, x, y;   int v[100005], b[100005], p[100005], s[100005], l[100005], qd[100005 + 100005],       qn[100005 + 100005], qr[100005 + 100005];   long long int sum, mx, sz[100005], res[100005];   edge a[100005];   void bd(int x, int y, int r) {     qd[++ed] = y, qn[ed] = l[x], qr[ed] = r, l[x] = ed;   }   void precal(int x) {     sum += s[x];     v[x] = 1;     for (int i = l[x]; i; i = qn[i])       if (!v[qd[i]]) precal(qd[i]);   }   void dfs(int x, int y) {     sz[x] = s[x];     for (int i = l[x]; i; i = qn[i]) {       if (qd[i] == y) continue;       dfs(qd[i], x);       res[qr[i]] = (sum - sz[qd[i]]) * sz[qd[i]];       sz[x] += sz[qd[i]];     }   }   int find(int x) { return x == p[x] ? x : p[x] = find(p[x]); }   int main() {     scanf( %d , &n);     for (int i = (0); i < (n - 1); i++)       scanf( %d%d%d , &a[i].x, &a[i].y, &a[i].d), a[i].r = i + 1;     for (int i = (1); i <= (n); i++) p[i] = i, s[i] = 1;     sort(a, a + n - 1);     for (int i = 0, j = 0; i < n - 1; i = j) {       ed = t = 0;       while (j < n - 1 && a[i].d == a[j].d) {         b[t++] = x = find(a[j].x);         b[t++] = y = find(a[j].y);         bd(x, y, a[j].r), bd(y, x, a[j].r);         j++;       }       sort(b, b + t);       t = unique(b, b + t) - b;       for (int k = (0); k < (t); k++) v[b[k]] = 0;       for (int k = (0); k < (t); k++) {         if (v[b[k]]) continue;         sum = 0;         precal(b[k]);         dfs(b[k], -1);       }       for (int k = (0); k < (t); k++) l[b[k]] = 0;       for (int k = i; k < j; k++) {         x = find(a[k].x), y = find(a[k].y);         p[x] = y;         s[y] += s[x];       }     }     mx = 0;     for (int i = (1); i <= (n - 1); i++) mx = max(mx, res[i]);     sum = 0;     for (int i = (1); i <= (n - 1); i++) sum += res[i] == mx;     printf( %I64d %I64d n , mx << 1, sum);     for (int i = (1); i <= (n - 1); i++)       if (res[i] == mx) printf( %d  , i);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > v;   int promena[3002];   long long d[3001], s[3002][3002], pom;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int j, n, i, x, p;     cin >> n;     for (i = 0; i < n; i++) {       cin >> x >> p;       v.push_back(make_pair(x, p));     }     sort(v.begin(), v.end());     d[n - 1] = v[n - 1].second;     for (i = 0; i < n - 1; i++)       for (j = i + 1; j < n; j++)         s[i][j] = s[i][j - 1] + (long long)v[j].first - v[i].first;     for (i = n - 2; i >= 0; i--) {       for (j = i; j < n; j++) {         pom = d[j + 1] + s[i][j] + (long long)v[i].second;         if (promena[i] == 0) {           d[i] = pom;           promena[i] = 1;         } else {           if (d[i] > pom) d[i] = pom;         }       }     }     cout << d[0];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long int n;     cin >> n;     long long int a[n];     map<long long int, long long int> mp;     for (long long int i = 0; i < n; i++) {       cin >> a[i];       mp[a[i]] = i;     }     long long int prev = mp[1];     long long int mx = 1;     for (long long int i = 2; i <= n; i++) {       if (mp[i] > mp[i - 1]) {         long long int j = i;         long long int cnt = 1;         while (mp[j] > mp[j - 1]) {           cnt++;           j++;         }         mx = max(mx, cnt);         i = j - 1;       }     }     long long int ans = n - mx;     cout << ans <<   n ;     cerr <<   nTime elapsed:   << 1000 * clock() / CLOCKS_PER_SEC <<  ms n ;   }
#include <bits/stdc++.h>   using namespace std;   inline int setBit(int N, int pos) { return N = N | (1 << pos); }   inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); }   inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); }   int A[400000 + 10];   vector<int> nxt[400000 + 10];   int idx[400000 + 10];   struct data {     int id, p;   };   bool operator<(data a, data b) { return a.p < b.p; }   priority_queue<data> Q;   int holding[400000 + 10];   void validate(int i) {     while (Q.size() && Q.top().p <= i) Q.pop();   }   int main() {     int n, k;     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &A[i]), nxt[A[i]].push_back(i);     for (int i = 1; i <= n; i++) nxt[i].push_back(n + 1), idx[i] = 1;     int ans = 0;     int have = 0;     for (int i = 1; i <= n; i++) {       if (holding[A[i]] == true) {         Q.push({A[i], nxt[A[i]][idx[A[i]]]});         idx[A[i]]++;       } else {         if (have < k) {           have++;           ans++;           Q.push({A[i], nxt[A[i]][idx[A[i]]]});           idx[A[i]]++;           holding[A[i]] = true;         } else {           validate(i);           ans++;           holding[Q.top().id] = false;           Q.pop();           Q.push({A[i], nxt[A[i]][idx[A[i]]]});           holding[A[i]] = true;           idx[A[i]]++;         }       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 100 + 3;   int n, m, k, ns[MAX];   long long dp[MAX][MAX][MAX], cs[MAX][MAX];   long long solve(int cur = 0, int pre = 0, int rem = k) {     if (cur == n && rem == 0) return 0;     if (rem < 0 || (cur == n && rem != 0)) return 1e18;     long long &ret = dp[cur][pre][rem];     if (ret != -1) return ret;     if (ns[cur] == 0) {       ret = 1e18;       for (int i = 1; i <= m; i++)         ret = min(ret, solve(cur + 1, i, rem - (pre != i)) + cs[cur][i - 1]);     } else {       if (ns[cur] == pre)         ret = solve(cur + 1, pre, rem);       else         ret = solve(cur + 1, ns[cur], rem - 1);     }     return ret;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     memset(dp, -1, sizeof(dp));     for (int i = 0; i < n; i++) {       scanf( %d , &ns[i]);     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         scanf( %d , &cs[i][j]);       }     }     long long ans = solve();     if (ans == 1e18)       printf( -1 );     else       printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n, i, count = 0;     vector<long long int> v;     string s1, s2, s3, reverses1, reverses2, reverses3;     cin >> s1 >> s2 >> s3;     reverses1 = s1;     reverses2 = s2;     reverses3 = s3;     reverse(s1.begin(), s1.end());     reverse(s2.begin(), s2.end());     reverse(s3.begin(), s3.end());     if (reverses1 == s3 && reverses2 == s2 && reverses3 == s1)       cout <<  YES             <<   n ;     else       cout <<  NO             <<   n ;   }   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   int main() {     fast();     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 3e18 + 100;   const int MOD = 1e9 + 7;   const int N = 100;   int32_t main() {     cin.sync_with_stdio(0);     cin.tie(0);     cin.exceptions(cin.failbit);     int n;     cin >> n;     set<int> s, tot;     vector<int> a(n + 5, 0), cnt(n + 5, 0), last(n + 5);     vector<bool> ok(n + 4, true);     for (int i = 1; i <= n; ++i) {       s.insert(i);     }     for (int i = 1; i <= n; ++i) {       cin >> a[i];       cnt[a[i]]++;       tot.insert(a[i]);       if (s.find(a[i]) != s.end()) {         s.erase(a[i]);       }     }     cout << n - tot.size() << endl;     for (int i = 1; i <= n; ++i) {       if (cnt[a[i]] == 1) continue;       if (ok[a[i]] and *s.begin() > a[i]) {         ok[a[i]] = false;       } else {         cnt[a[i]]--;         a[i] = *s.begin();         s.erase(s.begin());       }     }     for (int i = 1; i <= n; ++i) {       cout << a[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, cnt;     string s;     map<int, pair<int, int> > mapp;     cin >> n;     cin >> s;     cnt = 0;     int maxm = 0;     for (i = 0; i < n; i++) {       if (s[i] ==  0 )         cnt--;       else         cnt++;       if (mapp.find(cnt) == mapp.end()) {         mapp[cnt].first = i;         mapp[cnt].second = i;       } else {         mapp[cnt].second = i;         int len = mapp[cnt].second - mapp[cnt].first;         if (len > maxm) maxm = len;       }     }     if (mapp.find(0) != mapp.end()) maxm = max(maxm, mapp[0].second + 1);     cout << maxm << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const vector<int> mods = {998244353, 1000000007, 1000000009};   const long long inf = 3e18;   const double pi = acos(-1.0);   const double eps = 0.0000001;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   template <class... K>   using umap = unordered_map<K...>;   template <class... K>   using uset = unordered_set<K...>;   const int N = 1000100;   int n, l[N];   vector<vector<int> > a, ord;   string s;   umap<int, long long> dp;   long long res;   void build(int x) {     vector<int> cur = {};     vector<int> bk;     auto ad = [&](vector<int>& to) {       while (((int)(cur).size())) {         to.push_back(cur.back());         cur.pop_back();       }     };     for (long long i = (0); i < (l[x] - 1); ++i) {       cur.push_back(i);       if (a[x][i] < a[x][i + 1]) ad(ord[x]);       if (a[x][i] > a[x][i + 1]) ad(bk);     }     cur.push_back(l[x] - 1);     ad(ord[x]);     for (int i = ((int)(bk).size()) - 1; i >= 0; i--) ord[x].push_back(bk[i]);   }   int p(int i, int si) { return i + (i >= si); }   bool gt(int i, int si, int j, int sj) {     int pp = 0;     while (p(pp, si) < l[i] && p(pp, sj) < l[j]) {       int ppi = p(pp, si), ppj = p(pp, sj);       if (a[i][ppi] < a[j][ppj]) return 0;       if (a[i][ppi] > a[j][ppj]) return 1;       pp++;     }     long long il = l[i] - (si != l[i] - 1);     long long jl = l[j] - (sj != l[j] - 1);     if (il > jl)       return 1;     else       return 0;   }   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cout.precision(13);     cin >> n;     a.resize(n + 1);     ord.resize(n + 1);     for (long long i = (0); i < (n); ++i) {       cin >> s;       l[i] = s.length() + 1;       for (long long j = (0); j < (l[i] - 1); ++j) a[i].push_back(s[j] -  a );       a[i].push_back(-1);     }     a[n] = {27, -1};     l[n] = 2;     for (long long i = (0); i < (n + 1); ++i) build(i);     dp[0] = 1;     dp[1] = 0;     for (int i = n; i >= 1; i--) {       umap<int, long long> nxdp;       int j = i - 1;       int pi = 0, pj = 0;       long long pre = 0;       while (pi < l[i] || pj < l[j]) {         if (pi >= l[i] || pj < l[j] && gt(j, ord[j][pj], i, ord[i][pi]))           nxdp[pj++] = pre;         else           pre = (pre + dp[pi++]) % mod;       }       dp = move(nxdp);     }     for (auto& d_ : dp) res = (res + d_.second) % mod;     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2200000;   int chk[N];   int main() {     ios_base::sync_with_stdio(0);     int cnt = 0, n, m;     cin >> n >> m;     for (int i = 0; i < n; i++)       if (!chk[i]) {         for (int j = i;              (j < n && chk[j] < 2) || (j >= n && chk[n + n - 2 - j] < 2);              j = (j + m + m - 2) % (n + n - 2)) {           if (j < n)             chk[j]++;           else             chk[n + n - 2 - j]++;         }         cnt++;       }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, i, b;     while (scanf( %d , &n) != EOF) {       int j = 0, str[10001] = {0}, total = 0;       for (i = 0; i < n; i++) {         scanf( %d , &b);         if (str[b] == 0) ++total;         ++str[b];         if (str[b] > j) j = str[b];       }       printf( %d %d n , j, total);     }     return 0;   }