malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int const nmax = 200000;   struct Person {     int cost;     int number;     bool operator<(Person const &a) const { return number < a.number; }   };   Person v[1 + nmax];   void solve() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> v[i].number >> v[i].cost;     sort(v + 1, v + n + 1);     ll result = 0;     int votes = 0;     priority_queue<int, vector<int>, greater<int>> pq;     for (int i = n; 1 <= i; i--) {       pq.push(v[i].cost);       if (v[i].number <= i - 1 + votes)         continue;       else {         result += pq.top();         votes++;         pq.pop();       }     }     cout << result <<   n ;   }   int main() {     int t;     cin >> t;     for (int testcase = 1; testcase <= t; testcase++) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int times[50] = {0};   int graph[50][50] = {0};   void findMissing(int n, int &temp1, int &temp2) {     bool condition = false;     for (int i = 0; i < n; i++) {       if (times[i] != (n - 1)) {         if (condition)           temp2 = i;         else {           temp1 = i;           condition = true;         }       }     }   }   void swap(int &n1, int &n2) {     n1 += n2;     n2 = n1 - n2;     n1 -= n2;   }   void findOrder(int n, int &temp1, int &temp2) {     for (int i = 0; i < n; i++) {       bool condition = false;       if (i == temp1 || i == temp2)         continue;       else {         if (graph[temp1][i] == 1 && graph[i][temp2] == 1)           return;         else if (graph[i][temp1] == 1 && graph[temp2][i] == 1) {           swap(temp1, temp2);           return;         }       }     }   }   int main() {     int n, temp1, temp2;     cin >> n;     for (int i = 0; i < (((n * (n - 1)) / 2) - 1); i++) {       cin >> temp1 >> temp2;       times[temp1 - 1]++;       times[temp2 - 1]++;       graph[temp1 - 1][temp2 - 1] = 1;     }     findMissing(n, temp1, temp2);     findOrder(n, temp1, temp2);     cout << temp1 + 1 <<     << temp2 + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int mp[500][500];   int rSum[500][500], cSum[500][500];   int dSumF[500][500], dSumB[500][500];   int blacks(int r1, int c1, int r2, int c2) {     int ans = 1;     if (r1 == r2 && c1 == c2) {       ans = 1;     } else if (r1 == r2) {       if (c2 > c1) {         ans = rSum[r1][c2] - rSum[r1][c1 - 1];       } else {         ans = rSum[r1][c1] - rSum[r1][c2 - 1];       }     } else if (c1 == c2) {       if (r2 > r1) {         ans = cSum[r2][c1] - cSum[r1 - 1][c1];       } else {         ans = cSum[r1][c1] - cSum[r2 - 1][c1];       }     } else if (abs(r1 - r2) == abs(c1 - c2)) {       if (r1 < r2) {         if (c1 < c2) {           ans = dSumB[r2][c2] - dSumB[r1 - 1][c1 - 1];         } else {           ans = dSumF[r2][c2] - dSumF[r1 - 1][c1 + 1];         }       } else {         if (c2 < c1) {           ans = dSumB[r1][c1] - dSumB[r2 - 1][c2 - 1];         } else {           ans = dSumF[r1][c1] - dSumF[r2 - 1][c2 + 1];         }       }     } else       ans = 1;     return ans;   }   int valid(int r1, int c1, int r2, int c2, int r3, int c3) {     return !(blacks(r1, c1, r2, c2) || blacks(r1, c1, r3, c3) ||              blacks(r2, c2, r3, c3));   }   int main() {     scanf( %d %d n , &n, &m);     int i, j, k;     char c;     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         scanf( %c , &c);         mp[i][j] = c -  0 ;       }       scanf(  n );     }     for (i = 0; i <= n + 1; i++) {       for (j = 0; j <= m + 1; j++) {         rSum[i][j] = 0;         cSum[i][j] = 0;         dSumB[i][j] = 0;         dSumF[i][j] = 0;       }     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         rSum[i][j] = rSum[i][j - 1] + mp[i][j];         cSum[i][j] = cSum[i - 1][j] + mp[i][j];         dSumF[i][j] = dSumF[i - 1][j + 1] + mp[i][j];         dSumB[i][j] = dSumB[i - 1][j - 1] + mp[i][j];       }     }     int ans = 0;     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         for (k = 1; j + k <= m && i - k > 0; k++) {           ans += valid(i, j, i, j + k, i - k, j);         }         for (k = 1; j - k > 0 && i - k > 0; k++) {           ans += valid(i, j, i, j - k, i - k, j);         }         for (k = 1; j + k <= m && i + k <= n; k++) {           ans += valid(i, j, i, j + k, i + k, j);         }         for (k = 1; j - k > 0 && i + k <= n; k++) {           ans += valid(i, j, i, j - k, i + k, j);         }         k = 1;         while (i - k > 0 && j + k <= m && j - k > 0) {           ans += valid(i, j, i - k, j + k, i - k, j - k);           k++;         }         k = 1;         while (i + k <= n && j + k <= m && j - k > 0) {           ans += valid(i, j, i + k, j + k, i + k, j - k);           k++;         }         k = 1;         while (j - k > 0 && i + k <= n && i - k > 0) {           ans += valid(i, j, i + k, j - k, i - k, j - k);           k++;         }         k = 1;         while (j + k <= m && i + k <= n && i - k > 0) {           ans += valid(i, j, i + k, j + k, i - k, j + k);           k++;         }       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const string FILENAME =  input ;   vector<pair<int, int> > best;   vector<int> a;   int main() {     int n, m;     cin >> n >> m;     vector<int> has(2 * n, 0);     vector<int> pr(2 * n, -1);     vector<pair<int, int> > next(2 * n, {0, 0});     for (int i = 0; i < 2 * n; i++) {       int t;       cin >> t;       a.push_back(t);       next[i] = {-a[i], i};     }     sort((next).begin(), (next).end());     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       x--;       y--;       pr[x] = y;       pr[y] = x;       if (a[x] > a[y]) {         swap(x, y);       }       best.push_back({y, x});     }     int ans;     int cnt = 0;     int t;     cin >> t;     if (t == 1) {       for (int i = 0; i < m; i++) {         cout << best[i].first + 1 << endl;         cin >> ans;         if (ans == -1) return 0;         has[best[i].first] = 1;         has[ans - 1] = 1;       }       for (int i = 0; i < 2 * n; i++) {         if (has[next[i].second] == 0) {           cout << next[i].second + 1 << endl;           cin >> ans;           if (ans == -1) return 0;           has[ans - 1] = 1;           has[next[i].second] = 1;         }       }       return 0;     }     cin >> ans;     ans--;     has[ans] = 1;     cnt++;     while (pr[ans] != -1) {       cout << pr[ans] + 1 << endl;       cnt++;       if (cnt == 2 * n) return 0;       has[pr[ans]] = 1;       cin >> ans;       cnt++;       if (ans == -1) return 0;       ans--;       has[ans] = 1;     }     for (int i = 0; i < m; i++) {       if (has[best[i].first] == 0) {         has[best[i].first] = 1;         cout << best[i].first + 1 << endl;         cnt++;         if (cnt == 2 * n) return 0;         cin >> ans;         cnt++;         if (ans == -1) return 0;         ans--;         has[ans] = 1;       }     }     for (int i = 0; i < 2 * n; i++) {       if (has[next[i].second] == 0) {         cout << next[i].second + 1 << endl;         cnt++;         if (cnt == 2 * n) return 0;         cin >> ans;         cnt++;         if (ans == -1) return 0;         ans--;         has[ans] = 1;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, k, i, j;     bool flag, flag1, final_flag;     string p, q;     cin >> t;     for (i = 0; i < t; i++) {       map<char, int> m;       final_flag = false;       cin >> p >> q;       for (j = 0; j < p.size(); j++) {         if (m.find(p[j]) == m.end())           m[p[j]] = 1;         else           m[p[j]] += 1;       }       for (j = 0; j < q.size(); j++) {         map<char, int> m1;         flag1 = true;         flag = true;         if (m.find(q[j]) != m.end()) {           k = j;           for (k = j; k < p.size() + j; k++) {             if (m.find(q[k]) == m.end()) {               flag = false;               break;             } else {               if (m1.find(q[k]) == m1.end())                 m1[q[k]] = 1;               else                 m1[q[k]] += 1;             }           }           if (flag) {             map<char, int>::iterator it;             for (it = m.begin(); it != m.end(); it++) {               if (m1.find(it->first) == m1.end()) {                 flag1 = false;                 break;               }               if (m1[it->first] != m[it->first]) {                 flag1 = false;                 break;               }             }             if (flag1) final_flag = true;           }         }         if (final_flag) break;       }       if (final_flag)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const long long oo = 1e18;   const long long mod = 1e9 + 7;   const int INF = 1 << 30;   vector<pair<pair<int, long long>, int>> adj[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     ios_base::sync_with_stdio(0);     int n, m, k;     cin >> n >> m >> k;     map<pair<int, int>, long long> edges;     for (int i = 0; i < m; i++) {       int u, v;       long long w;       cin >> u >> v >> w;       edges[{u, v}] = w;       adj[u].push_back({{v, w}, 0});       adj[v].push_back({{u, w}, 0});     }     int ans = 0;     for (int i = 0; i < k; i++) {       int s;       long long y;       cin >> s >> y;       adj[1].push_back({{s, y}, 1});     }     priority_queue<pair<pair<int, long long>, int>,                    vector<pair<pair<int, long long>, int>>,                    greater<pair<pair<int, long long>, int>>>         q;     long long dis[N];     bool anagetHenaBeTrain[N];     for (int i = 0; i < N; i++) dis[i] = INF;     memset(anagetHenaBeTrain, false, sizeof(anagetHenaBeTrain));     dis[1] = 0;     q.push({{dis[1], 1}, 0});     while (q.size()) {       auto top = q.top();       q.pop();       long long cost = top.first.first;       int node = top.first.second;       int type = top.second;       if (cost > dis[node]) continue;       for (auto v : adj[node]) {         if (v.first.second + cost < dis[v.first.first]) {           dis[v.first.first] = v.first.second + cost;           anagetHenaBeTrain[v.first.first] = v.second;           q.push({{dis[v.first.first], v.first.first}, v.second});         } else if (v.first.second + cost == dis[v.first.first]) {           if (anagetHenaBeTrain[v.first.first] == 1 && v.second == 0) {             anagetHenaBeTrain[v.first.first] = 0;           }         }       }     }     for (int i = 1; i <= n; i++)       if (anagetHenaBeTrain[i] == 1) ans++;     cout << k - ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double EPS = 1E-9;   const int INF = (int)1E9;   const long long INF64 = (long long)1E18;   const long double PI = 2 * acos(.0);   int n, k;   string number;   int repla2[11];   string construct(int ind) {     string resp =   ;     bool used[10005];     memset(used, false, sizeof(used));     for (int i = 0; i < (int)((number).size()); i++) {       bool cent2 = 1;       if (repla2[abs((number[i] -  0 ) - ind)] > 0 && ind <= (number[i] -  0 )) {         repla2[abs((number[i] -  0 ) - ind)]--;         char a =  0  + ind;         used[i] = true;         resp += a;         cent2 = 0;       }       if (cent2) resp += number[i];     }     for (int i = n - 1; i >= 0; i--) {       bool cent2 = 1;       if (!used[i] && repla2[abs((number[i] -  0 ) - ind)] > 0 &&           ind >= (number[i] -  0 )) {         repla2[abs((number[i] -  0 ) - ind)]--;         char a =  0  + ind;         resp[i] = a;         cent2 = 0;       }     }     return resp;   }   int main() {     cin >> n >> k >> number;     string winner;     int mini = INF;     int ind = -1;     int conts[11];     fill(conts, conts + 11, 0);     for (int i = 0; i < (int)((number).size()); i++) {       conts[number[i] -  0 ]++;     }     bool cent = 0;     string resp2;     for (int i = 0; i < (int)(10); i++) {       int kk = k - conts[i];       if (kk <= 0) {         cent = 1;         cout << 0 << endl;         cout << number << endl;         break;       }       int temp = 0;       fill(repla2, repla2 + 11, 0);       for (int j = 1; j < (int)(10); j++) {         int cont1 = i - j;         int cont2 = i + j;         if (cont2 < 10) {           if (kk <= conts[cont2]) {             temp += (kk * j);             repla2[j] += kk;             if (temp < mini) {               ind = i;               mini = temp;               resp2 = construct(i);             } else if (temp == mini) {               string temp = construct(i);               if (temp < resp2) resp2 = temp;             }             break;           } else {             temp += (conts[cont2] * j);             kk -= conts[cont2];             repla2[j] += conts[cont2];           }         }         if (cont1 >= 0) {           if (kk <= conts[cont1]) {             temp += (kk * j);             repla2[j] += kk;             if (temp < mini) {               mini = temp;               resp2 = construct(i);             } else if (temp == mini) {               string temp = construct(i);               if (temp < resp2) resp2 = temp;             }             break;           } else {             temp += (conts[cont1] * j);             kk -= conts[cont1];             repla2[j] += conts[cont1];           }         }       }     }     bool used[10005];     memset(used, false, sizeof(used));     if (!cent) {       cout << mini << endl;       cout << resp2;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int MOD = 998244353;   int n, c, a[3005], cnt[3005], pw[3005], ipw1[3005], ans[3005];   inline int mval(int x) { return x >= MOD ? x - MOD : x; }   inline void inc(int &x, int a) { (x += a) >= MOD && (x -= MOD); }   inline void dec(int &x, int a) { x = mval(MOD + x - a); }   inline int qpow(int x, int p) {     int ret = 1;     while (p) {       if (p & 1) ret = 1ll * ret * x % MOD;       p >>= 1, x = 1ll * x * x % MOD;     }     return ret;   }   namespace sub1 {   int f[3005][1 << 10], g[3005];   inline void solve(void) {     int u = (1 << c) - 1;     g[0] = 1;     ans[0] = pw[n] - 1;     for (int t = 1; t * c <= n + 1; ++t) {       for (int i = 1; i <= n; ++i) std::fill(f[i], f[i] + (1 << c), 0);       for (int i = 1; i <= n; ++i) {         inc(f[i][0], g[i - 1]);         inc(f[i][1 << a[i]], g[i - 1]);         for (int s = 0; s < u; ++s)           inc(f[i][s], f[i - 1][s]), inc(f[i][s | (1 << a[i])], f[i - 1][s]);       }       for (int i = 0; i <= n; ++i) g[i] = f[i][u ^ (1 << a[i])];       for (int i = 0; i <= n; ++i) inc(ans[t], 1ll * g[i] * pw[n - i] % MOD);     }     for (int i = 0; i <= n; ++i) dec(ans[i], ans[i + 1]);   }   }  // namespace sub1   namespace sub2 {   long long *f, *g, dp[2][3005], tr[3005][3005];   inline void solve(void) {     for (int i = 1; i <= n; ++i) {       std::fill(cnt, cnt + c + 1, 0);       int cur = 1, cc = 0;       tr[i][i] = (c == 1);       for (int j = i - 1; j; --j) {         if (a[j] != a[i]) {           cur = 1ll * ipw1[cnt[a[j]]] * cur % MOD;           if (!cnt[a[j]]) ++cc;           ++cnt[a[j]];           cur = 1ll * (pw[cnt[a[j]]] - 1) * cur % MOD;         }         tr[j][i] = (cc == c - 1 ? cur : 0);       }     }     f = dp[0], g = dp[1];     f[0] = 1;     ans[0] = pw[n] - 1;     for (int t = 1; t * c <= n; ++t) {       std::swap(f, g);       std::fill(f, f + n + 1, 0);       for (int j = 1; j <= n; ++j)         if (g[j - 1])           for (int i = j; i <= n; ++i) f[i] += g[j - 1] * tr[j][i] % MOD;       for (int i = 1; i <= n; ++i) f[i] %= MOD;       for (int i = 0; i <= n; ++i) inc(ans[t], f[i] * pw[n - i] % MOD);     }     for (int i = 0; i <= n; ++i) dec(ans[i], ans[i + 1]);   }   }  // namespace sub2   int main() {     scanf( %d%d , &n, &c);     pw[0] = 1;     ipw1[0] = 1;     for (int i = 1; i <= n; ++i)       pw[i] = 2ll * pw[i - 1] % MOD, ipw1[i] = qpow(pw[i] - 1, MOD - 2);     for (int i = 1; i <= n; ++i) scanf( %d , a + i), --a[i];     if (c <= 10)       sub1::solve();     else       sub2::solve();     for (int i = 0; i <= n; ++i) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   const int N = 1e5 + 7;   const int xinc[] = {0, 0, 1, -1};   const int yinc[] = {1, -1, 0, 0};   const long double PI = acos(-1.0);   const double EPS = 1e-9;   string s;   long long a, n, sum[4007], ans;   map<long long, long long> m;   void solve() {     cin >> a >> s;     n = s.size();     for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + s[i - 1] -  0 ;     long long t = 0;     for (int i = 1; i <= n; i++)       for (int j = i; j <= n; j++) {         long long psum = sum[j] - sum[i - 1];         m[psum]++;         t++;       }     for (auto i : m) {       long long psum = i.first;       if (psum != 0 && a != 0 && a % psum == 0) {         long long cur = m[a / psum] * i.second;         ans += cur;       }       if (a == 0) {         if (psum == 0)           ans += m[psum] * t;         else           ans += m[psum] * m[0];       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int num[100008];   int cnt1[100008];   int cnt2[100008];   int cnt;   struct node {     int s, t;   } ans[100008];   bool cmp(node a, node b) {     if (a.s == b.s) return a.t < b.t;     return a.s < b.s;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &num[i]);       if (num[i] == 1) {         cnt1[i] = cnt1[i - 1] + 1;         cnt2[i] = cnt2[i - 1];       } else if (num[i] == 2) {         cnt1[i] = cnt1[i - 1];         cnt2[i] = cnt2[i - 1] + 1;       }     }     int acnt = 0;     int bcnt = 0;     int pre;     int atmp;     int btmp;     for (int i = 1; i <= n; i++) {       pre = 1;       acnt = 0;       bcnt = 0;       while (true) {         atmp = lower_bound(cnt1 + pre, cnt1 + 1 + n, i + cnt1[pre - 1]) - cnt1;         btmp = lower_bound(cnt2 + pre, cnt2 + 1 + n, i + cnt2[pre - 1]) - cnt2;         if (atmp < btmp) {           acnt++;           pre = atmp + 1;           if (atmp == n) {             if (num[n] != 2 && acnt > bcnt) {               cnt++;               ans[cnt].s = acnt;               ans[cnt].t = i;             }             break;           }         } else if (atmp > btmp) {           bcnt++;           pre = btmp + 1;           if (btmp == n) {             if (num[n] != 1 && acnt < bcnt) {               cnt++;               ans[cnt].s = bcnt;               ans[cnt].t = i;             }             break;           }         } else {           break;         }       }     }     sort(ans + 1, ans + 1 + cnt, cmp);     printf( %d n , cnt);     for (int i = 1; i <= cnt; i++) {       printf( %d %d n , ans[i].s, ans[i].t);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     string s;     cin >> s;     bool ans = false;     for (int i = 1; i <= n; ++i)       for (int start = 0; start < n; ++start) {         int jump = 0;         int cur = start;         while (cur < n && s[cur] ==  * ) {           jump += 1;           cur += i;         }         if (jump >= 5) ans = true;       }     if (ans)       cout <<  yes  << endl;     else       cout <<  no  << endl;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(time(0));   const double eps = 1e-10;   const long long inf = 0x3f3f3f3f3f3f3f3fLL;   const long long N = 2e5 + 5;   const long long MOD = 1e9 + 7;   long long pw(long long b, long long p) {     long long res = 1;     while (p > 0) {       if (p & 1) res = res * b % MOD;       b = b * b % MOD;       p >>= 1;     }     return res;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n;     cin >> n;     vector<long long> h(n);     long long sum = 0;     for (long long i = 0; i < n; i++) {       cin >> h[i];       sum += h[i];     }     sum -= (n * (n - 1)) / 2;     long long rem = sum % n;     long long cnt = sum / n;     for (long long i = 0; i < n; i++) {       cout << i + cnt + (rem >= i + 1) <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   long long n, m, a, d;   long long t[N];   int main() {     cin >> n >> m >> a >> d;     for (int j = 1; j <= m; j++) {       scanf( %lld , &t[j]);     }     t[m + 1] = 8e18;     long long i = 1, ans = 0, last = -1;     for (int j = 1; j <= m + 1; j++) {       if (i > n) {         if (j <= m && last < t[j]) {           ans++;           last = t[j] + d;         }         continue;       }       if (t[j] > last) {         if (t[j] <= i * a) {           ans++;           last = t[j] + d;           i = last / a + 1;           continue;         }         long long u = d / a + 1;         long long togo = min(n, t[j] / a);         long long dis = ((togo - i) / u);         ans += dis + 1;         i += dis * u;         last = i * a + d;         if (j <= m && last < t[j]) {           ans++;           last = t[j] + d;         }         i = last / a + 1;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double esp = 1e-8;   const int msz = 10000;   const int mod = 1e9 + 7;   struct Tr {     char s[26];     int len, l;   };   Tr s[111];   bool vis[26];   int main() {     char str[1111];     int n, ans;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %s , str);       s[i].len = strlen(str);       s[i].l = 0;       memset(vis, 0, sizeof(vis));       for (int j = 0; j < s[i].len; ++j) {         if (!vis[str[j] -  a ]) {           vis[str[j] -  a ] = 1;           s[i].s[s[i].l++] = str[j];         }       }     }     int mx = 0;     for (int i =  a ; i <=  z ; ++i) {       for (int j = i; j <=  z ; ++j) {         ans = 0;         for (int k = 0; k < n; ++k) {           if (s[k].l == 1 && (s[k].s[0] == i || s[k].s[0] == j))             ans += s[k].len;           else if (s[k].l == 2 && ((s[k].s[0] == i && s[k].s[1] == j) ||                                    (s[k].s[1] == i && s[k].s[0] == j)))             ans += s[k].len;         }         mx = max(mx, ans);       }     }     printf( %d n , mx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e1 + 5;   int a[N][N], pos[N][N], last[N * N];   double ev[N * N], reg[N * N];   int main() {     for (int i = 0; i < 10; i++) {       for (int j = 0; j < 10; j++) {         scanf( %d , &a[i][j]);         if (i % 2 == 0) {           pos[i][j] = 10 * i + j;         } else {           pos[i][j] = 10 * i + 9 - j;         }         last[pos[i][j]] = pos[i - a[i][j]][j];       }     }     ev[0] = 0;     for (int i = 1; i < 100; i++) {       double sum = 0;       int cnt = 0;       for (int j = i - 1; j >= max(i - 6, 0); j--) {         sum += ev[j];         cnt++;       }       ev[i] = 1 + (1.0 * sum / 6);       ev[i] *= 6.0 / cnt;       reg[i] = ev[i];       ev[i] = min(ev[i], reg[last[i]]);     }     printf( %.7f n , ev[99]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, m, cnt = 0, k, cntt = 0, cnts = 0;   long long int v[100001];   bool vis[100001], ans[100001];   long long int cnte[100001];   int main() {     cin >> n >> m;     memset(vis, false, sizeof(vis));     memset(cnte, 0, sizeof(cnte));     for (int i = 1; i <= m; i++) {       cin >> v[i];       cnte[v[i]]++;       if (vis[v[i]] == false) {         vis[v[i]] = true;         cnt++;       }       if (cnt == n) {         ans[i] = 1;         for (int j = 1; j <= n; j++) {           if (cnte[j] > 1) {             cnte[j]--;           } else {             cnt--;             cnte[j]--;             vis[j] = false;           }         }       } else {         ans[i] = 0;       }     }     for (int i = 1; i <= m; i++) {       cout << ans[i];     }   }