malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 77;   int T, n, L, R, par[N], fa[N][20];   int dep[N], son[N], tid[N], sz[N];   pair<int, int> mx[N][3];   vector<int> G[N];   void dfs1(int v, int fa) {     mx[v][0] = {0, v}, mx[v][1] = mx[v][2] = {-1, 0};     for (int u : G[v])       if (u ^ fa) {         dfs1(u, v);         pair<int, int> p = {mx[u][0].first + 1, u};         if (p > mx[v][0]) swap(p, mx[v][0]);         if (p > mx[v][1]) swap(p, mx[v][1]);         if (p > mx[v][2]) swap(p, mx[v][2]);       }   };   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d %d %d , &n, &L, &R);       for (int i = 1; i <= n; i++) {         G[i].clear();       }       for (int i = 1, u, v; i < n; i++) {         scanf( %d %d , &u, &v);         G[u].push_back(v), G[v].push_back(u);       }       dfs1(1, 0);       function<void(int, int)> dfs2 = [&](int v, int fa) {         for (int u : G[v])           if (u ^ fa) {             par[u] = max(par[v],                          mx[v][0].second == u ? mx[v][1].first : mx[v][0].first) +                      1,             dfs2(u, v);           }       };       memset(par, 0, sizeof(par)), dfs2(1, 0);       auto find = [&](int u, int v) {         static int dist[N];         fill(dist + 1, dist + n + 1, -1);         queue<int> q;         q.push(u), dist[u] = 0;         while (!q.empty()) {           int x = q.front();           q.pop();           for (int y : G[x])             if (!~dist[y]) {               q.push(y), dist[y] = dist[x] + 1;             }         }         return dist[v];       };       int rt = -1, len = find(L, R);       for (int i = 1; i <= n; i++) {         int cnt = 0;         if (mx[i][0].first >= len) cnt++;         if (mx[i][1].first >= len) cnt++;         if (mx[i][2].first >= len) cnt++;         if (par[i] >= len) cnt++;         if (cnt >= 3) {           rt = i;           break;         }       }       if (!~rt) {         printf( NO n );         continue;       }       int tim = 0;       function<void(int)> dfs3 = [&](int v) {         son[v] = v, tid[v] = ++tim, sz[v] = 1;         for (int i = 1; i < 20; i++) {           fa[v][i] = fa[fa[v][i - 1]][i - 1];         }         for (int u : G[v])           if (u ^ fa[v][0]) {             fa[u][0] = v, dep[u] = dep[v] + 1;             dfs3(u), sz[v] += sz[u];             if (dep[son[u]] > dep[son[v]]) son[v] = son[u];           }       };       fa[rt][0] = rt, dep[rt] = 0, dfs3(rt);       bool flag = 0;       for (int t = 1; t <= n; t++) {         auto chk = [&](int u, int v) {           return tid[v] >= tid[u] && tid[v] < tid[u] + sz[u];         };         if (chk(L, R) || chk(R, L)) {           flag = 1;           break;         }         auto get = [&](int v, int k) {           for (int i = 19; ~i; i--) {             if (k >> i & 1) v = fa[v][i];           }           return v;         };         int num = dep[son[L]] - dep[L];         L = son[L], R = get(R, num), swap(L, R);       }       printf( %s n , flag ?  YES  :  NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void maximize(T &a, T b) {     if (a < b) a = b;   }   const int maxN = 305;   int n, a[maxN][maxN], f[2][maxN][maxN];   void solve() {     for (int i = 1; i <= n; ++i) fill(f[0][i] + 1, f[0][i] + n + 1, INT_MIN);     f[0][1][1] = a[1][1];     for (int d = 2; d < n + n; ++d) {       for (int i = 1; i <= n; ++i)         fill(f[(d + 1) & 1][i] + 1, f[(d + 1) & 1][i] + n + 1, INT_MIN);       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= n; ++j)           if (f[d & 1][i][j] > INT_MIN)             for (int ni = i; ni < i + 2; ++ni)               if (ni <= n && d - ni + 1 <= n)                 for (int nj = j; nj < j + 2; ++nj)                   if (nj <= n && d - nj + 1 <= n) {                     int t = f[d & 1][i][j] + a[ni][d - ni + 1];                     if (ni != nj) t += a[nj][d - nj + 1];                     maximize(f[(d + 1) & 1][ni][nj], t);                   }     }   }   int main() {     ios_base::sync_with_stdio(false);     scanf( %d , &n);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j) scanf( %d , &a[i][j]);     solve();     printf( %d n , f[0][n][n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vi = vector<int>;   using pi = pair<int, int>;   void setIO(string name =   ) {     ios_base::sync_with_stdio(0);     cin.tie(0);   }   int main() {     setIO();     int a, b, c, d;     cin >> a >> b >> c >> d;     int pv = max(3 * a / 10, a - a / 250 * c);     int pm = max(3 * b / 10, b - b / 250 * d);     if (pv == pm) {       cout <<  Tie ;     } else if (pv > pm) {       cout <<  Misha ;     } else {       cout <<  Vasya ;     }     return 0;   }
#include <bits/stdc++.h>   double ans, f[10][1000];   int n, k, a, v[10], p[10], g[10], ki[10], l[10];   void calc() {     int b = a;     for (int i = 1; i <= n; ++i) {       l[i] = p[i] + g[i];       if (l[i] > 100) l[i] = 100;     }     f[0][0] = 1;     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= (1 << i - 1) - 1; ++j) {         f[i][j] = f[i - 1][j] * (100 - l[i]) / 100;         f[i][j + (1 << i - 1)] = f[i - 1][j] * l[i] / 100;       }     double res = 0;     for (int i = 0; i <= (1 << n) - 1; ++i) {       int tot = 0, b = a;       for (int j = 1; j <= n; ++j)         if (i & (1 << j - 1))           ++tot;         else           b += v[j];       if (tot * 2 > n)         res += f[n][i];       else         res += f[n][i] * a / b;     }     if (res > ans) ans = res;   }   void dfs(int now, int left) {     if (now == n + 1) {       calc();       return;     }     if (left == 0)       dfs(now + 1, 0);     else {       for (int i = 0; i <= left; ++i) {         if (p[now] + i * 10 >= 110) break;         g[now] = i * 10;         dfs(now + 1, left - i);         g[now] = 0;       }     }   }   int main() {     scanf( %d%d%d , &n, &k, &a);     for (int i = 1; i <= n; ++i) scanf( %d%d , &v[i], &p[i]);     dfs(1, k);     printf( %.6lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > vec;   void update() {     int x;     scanf( %d , &x);     vector<pair<int, int> > a, b;     a.push_back({1000010, 0});     b.push_back({1000010, 0});     a.push_back({0, 0});     b.push_back({0, 0});     int sz = vec.size();     for (int i = 0; i + 1 < sz; i++) {       int p = x - vec[i].first;       if (p > 0) a.push_back({p, vec[i + 1].second});       if (p < 0) b.push_back({-p, vec[i].second});     }     sort(a.begin(), a.end());     sort(b.begin(), b.end());     vec.clear();     int i = 0, j = 0;     int as = a.size(), bs = b.size();     while (i < as || j < bs) {       if (a[i].first == b[j].first) {         vec.push_back({a[i].first, a[i].second + b[j].second});         i++, j++;       } else if (a[i].first < b[j].first) {         vec.push_back({a[i].first, a[i].second + b[j].second});         i++;       } else {         vec.push_back({b[j].first, a[i].second + b[j].second});         j++;       }     }     vec[0].second = 0;     return;   }   void qry() {     int s, e, ans = 0;     scanf( %d %d , &s, &e);     int sz = vec.size();     for (auto cur : vec) {       if (e > cur.first) {         if (cur.first > s) {           ans += cur.second * (cur.first - s);           s = cur.first;         }       } else {         ans += cur.second * (e - s);         break;       }     }     printf( %d n , ans);     return;   }   int main() {     int n, q;     scanf( %d %d , &n, &q);     vec.push_back({0, 0});     vec.push_back({n, 1});     vec.push_back({1000010, 0});     while (q--) {       int type;       scanf( %d , &type);       if (type == 1)         update();       else         qry();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int in, x = 0;     int cnt = 0, p = 1, ans = 0;     cin >> in;     for (int i = in; i > 0; i /= 10) {       if (i % 10 == 7) ans += p;       p *= 2;       cnt++;     }     if (cnt != 0) x = pow(2, cnt) - 2;     cout << ans + x + 1;   }
#include <bits/stdc++.h>   using namespace std;   int a[100 + 5];   int b[100 + 5];   int main() {     int m, n;     int l, r;     while (scanf( %d%d , &m, &n) != EOF) {       int sum = 0;       for (int i = 1; i <= m; i++) cin >> a[i];       for (int i = 1; i <= n; i++) {         cin >> l >> r;         int sum1 = 0;         for (int i = l; i <= r; i++) {           sum1 += a[i];         }         if (sum1 > 0) sum += sum1;       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {1, -1, 0, 0};   int dy[] = {0, 0, 1, -1};   int xx[] = {0, 0, 1, -1, 1, -1, 1, -1};   int yy[] = {1, -1, 0, 0, 1, -1, -1, 1};   double PI = 3.1415926535897932384626433832795;   const long long oo = (long long)1e9 + 1;   const double eps = 1e-9;   const long long mod = 1000000009;   string a, b;   bool good(int l, string s) {     for (int i = 0; i < ((long long)s.size()); i++) {       if (a[i % l] != s[i]) return false;     }     return true;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> a >> b;     int res = 0;     for (int i = 1; i <= min(((long long)a.size()), ((long long)b.size())); i++) {       if (((long long)a.size()) % i == 0 && ((long long)b.size()) % i == 0 &&           good(i, a) && good(i, b))         res++;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string t;   long long cnt1[3000001];   int main() {     ios_base::sync_with_stdio(0);     cin >> t;     cnt1[0] = 0;     int n = (int)t.length();     for (int i = 0; i <= n - 4; ++i) {       if (t.substr(i, 5) ==  heavy ) ++cnt1[i + 1];       cnt1[i + 1] += cnt1[i];     }     long long ans = 0;     for (int i = 0; i <= n - 4; ++i)       if (t.substr(i, 5) ==  metal ) ans += cnt1[i];     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class wwj {    public:     wwj(int x);     int klz();     int pdly(int k);       private:     int x;   };   wwj::wwj(int x) { this->x = x; }   int wwj::klz() {     int i, sum = 0;     double SM = 0;     if (x == 0) return 0;     SM = (-1 + sqrt(1.0 + 8 * abs(x))) / 2;     if (int(SM) == SM)       i = int(SM);     else       i = int(SM + 1);     while (1) {       if (pdly(i))         return i;       else         ++i;     }   }   int wwj::pdly(int k) {     int s;     s = k * (1 + k) / 2;     x = abs(x);     if (x % 2 == s % 2) return 1;     return 0;   }   int main() {     int x;     cin >> x;     wwj LR(x);     cout << LR.klz() << endl;     ;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   long long power(long long x, long long y, long long m) {     if (y == 0) return 1;     long long p = power(x, y / 2, m) % m;     p = (p * p) % m;     return (y % 2 == 0) ? p : (x * p) % m;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long modInverse(long long a, long long m) {     long long g = gcd(a, m);     if (g != 1)       cout <<  Inverse doesn t exist ;     else {       return power(a, m - 2, m);     }   }   long long log_a_b(long long a, long long b) {     return (a > b - 1) ? 1 + log_a_b(a / b, b) : 0;   }   int t;   vector<vector<long long> > graph;   vector<long long> tin, tout;   vector<bool> vis;   vector<vector<long long> > up;   void dfs(int v, int p, int l) {     vis[v] = true;     tin[v] = ++t;     up[v][0] = p;     for (int(i) = (1); (i) < (l + 1); (i)++) {       up[v][i] = up[v][i - 1] < 0 ? -1 : up[up[v][i - 1]][i - 1];     }     for (int x : graph[v])       if (!vis[x]) dfs(x, v, l);     tout[v] = ++t;   }   bool isan(int u, int v) { return tin[u] <= tin[v] && tout[u] >= tout[v]; }   int lca(int u, int v, int l) {     if (isan(u, v)) return u;     if (isan(v, u)) return v;     for (int(i) = (l); (i) >= (0); (i)--) {       if (up[u][i] == -1) continue;       if (!isan(up[u][i], v)) u = up[u][i];     }     return up[u][0];   }   bool sum(long long n, long long i, long long s, long long cnt,            vector<long long> &a) {     if (i >= n && cnt > 0) {       if (s != 0)         return 0;       else         return 1;     }     if (i >= n && cnt == 0) return 0;     bool a1 = sum(n, i + 1, s, cnt, a);     bool b = sum(n, i + 1, s - a[i], cnt + 1, a);     bool c = sum(n, i + 1, s + a[i], cnt + 1, a);     bool d = (a1 | b | c);     return d;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.precision(15);     long long T;     cin >> T;     while (T--) {       long long n, q, k, m, u, v, w, x;       string s, t;       cin >> n >> m;       long long ans = 0;       m++;       vector<long long> a(31), b(31);       for (int(i) = (0); (i) < (31); (i)++) {         a[i] = n % 2;         b[i] = m % 2;         n /= 2;         m /= 2;       }       reverse((a).begin(), (a).end());       reverse((b).begin(), (b).end());       for (int(i) = (0); (i) < (31); (i)++) {         if (a[i] && !b[i]) break;         if (!a[i] && b[i]) ans = ans | (1 << (30 - i));       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int two(int n) { return 1 << n; }   inline void set_bit(int& n, int b) { n |= two(b); }   inline void unset_bit(int& n, int b) { n &= ~two(b); }   inline int last_bit(int n) { return n & (-n); }   template <class T>   T gcd(T a, T b) {     return (b != 0 ? gcd<T>(b, a % b) : a);   }   template <class T>   T lcm(T a, T b) {     return (a / gcd<T>(a, b) * b);   }   int dr[] = {-1, 0, 0, 1}, dc[] = {0, -1, 1, 0};   const int md = 1000000007;   int dcmp(double a, double b) {     return fabs(a - b) <= 1e-9 ? 0 : (a > b) ? 1 : -1;   }   int arr[1009], tmp[1009] = {0};   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, r, sum = 0;     cin >> n >> r;     for (int i = 1; i <= n; ++i) {       cin >> arr[i];       sum += arr[i];       if (arr[i] == 1) {         for (int j = i - r + 1; j <= i + r - 1; ++j) {           if (j >= 1 && j <= n) tmp[j]++;         }       }     }     int cnt = 0;     for (int i = 1; i <= n; ++i) {       if (tmp[i] < 1) return cout << -1, 0;     }     for (int i = 1; i <= n; ++i) {       bool ok = false;       if (arr[i] == 1) {         for (int j = i - r + 1; j <= i + r - 1; ++j) {           if (j >= 1 && j <= n)             if (tmp[j] == 1) {               ok = true;               break;             }         }         if (!ok) {           cnt++;           for (int j = i - r + 1; j <= i + r - 1; ++j) {             if (j >= 1 && j <= n) tmp[j]--;           }         }       }     }     cout << sum - cnt;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(0), cout.tie(0);     ios::sync_with_stdio(false);     string a, b;     while (cin >> a >> b) {       unsigned int len = a.size();       int ans = 0;       bool OK = true;       map<int, int> dic;       for (unsigned int i = 0; i < len; ++i) {         if (a.at(i) != b.at(i)) {           if (!dic.count(a.at(i)) && !dic.count(b.at(i))) {             ++ans;             dic[a.at(i)] = b.at(i);             dic[b.at(i)] = a.at(i);           } else if (dic[a.at(i)] != b.at(i) || dic[b.at(i)] != a.at(i)) {             cout << -1 << endl;             OK = false;             break;           }         } else {           if (!dic.count(a.at(i))) {             dic[a.at(i)] = a.at(i);           } else if (dic[a.at(i)] != a.at(i)) {             cout << -1 << endl;             OK = false;             break;           }         }       }       if (OK) {         cout << ans << endl;         int vis[1000] = {0};         if (ans != 0) {           for (char c =  a ; c <=  z ; ++c) {             if (!vis[(int)c] && dic[c] != 0 && dic[c] != c) {               cout << c <<     << (char)dic[c] << endl;               vis[dic[c]] = c;             }           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 * 100 + 15;   int n, mark[maxn], h[maxn], d[maxn], g[2], cnt, c, w;   vector<int> ad[maxn];   void dfs(int v) {     mark[v] = 1;     for (auto u : ad[v]) {       if (mark[u] == 0) {         h[u] = h[v] + 1;         dfs(u);       }     }   }   int main() {     cin >> n;     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       ad[u].push_back(v);       ad[v].push_back(u);       d[u]++;       d[v]++;     }     dfs(1);     for (int i = 1; i <= n; i++) {       cnt = 0;       if (d[i] <= 1) {         g[h[i] % 2] = 1;       }       for (auto u : ad[i]) {         if (d[u] == 1) cnt++;       }       if (cnt > 1) {         c++;         w += cnt;       }     }     if (g[0] && g[1])       cout << 3;     else       cout << 1;     cout <<    ;     cout << n - 1 + c - w;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned long long n, k;     cin >> n >> k;     unsigned long long lo = 0, hi = min(n / 2, n / k + 1), mid;     while (lo < hi) {       mid = lo + (hi - lo + 1) / 2;       if (mid + mid * k <= n / 2)         lo = mid;       else         hi = mid - 1;     }     cout << lo <<     << lo * k <<     << n - (lo + lo * k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[72] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31,                  30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30,                  31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30,                  31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,                  31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};     int n;     cin >> n;     vector<int> b(n);     for (int i = 0; i < n; i++) {       cin >> b[i];     }     for (int i = 0; i < 72 - n + 1; i++) {       int u = 0;       for (int j = i; j < i + n; j++) {         if (a[j] == b[j - i]) {           u++;         } else           break;       }       if (u == n) {         cout <<  Yes  << endl;         return 0;       }     }     cout <<  No  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> lol1;   vector<long long> lol2;   int main() {     long long n, m;     cin >> n >> m;     for (long long i = 0; i < n; i++) {       long long x;       cin >> x;       lol1.push_back(x);     }     for (long long i = 0; i < m; i++) {       long long x;       cin >> x;       lol2.push_back(x);     }     long long s1 = lol1[0], s2 = lol2[0];     long long x = 1, y = 1;     long long ans = 0;     while (true) {       if (s1 < s2) {         if (x == n) break;         s1 += lol1[x];         x++;       }       if (s2 < s1) {         if (y == m) break;         s2 += lol2[y];         y++;       }       if (s1 == s2) {         ans++;         s1 = lol1[x];         s2 = lol2[y];         x++;         y++;         if (x > n && y > m) break;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1 << 28;   const long long LINF = 1ll << 61;   inline long long getnum() {     register long long r = 0;     register bool ng = 0;     register char c;     c = getchar();     while (c !=  -  && (c <  0  || c >  9 )) c = getchar();     if (c ==  - ) ng = 1, c = getchar();     while (c >=  0  && c <=  9 ) r = r * 10 + c -  0 , c = getchar();     if (ng) r = -r;     return r;   }   template <class T>   inline void putnum(T x) {     if (x < 0) putchar( - ), x = -x;     register short a[20] = {}, sz = 0;     while (x > 0) a[sz++] = x % 10, x /= 10;     if (sz == 0) putchar( 0 );     for (int i = sz - 1; i >= 0; i--) putchar( 0  + a[i]);   }   inline void putsp() { putchar(   ); }   inline void putendl() { putchar(  n ); }   inline char mygetchar() {     register char c = getchar();     while (c ==     || c ==   n ) c = getchar();     return c;   }   int n, c;   int a[200111];   set<pair<int, int> > s;   vector<pair<int, int> > tmps;   bool used[200111];   int cnt[200111];   int main() {     c = getnum(), n = getnum();     s.insert(make_pair(-c, 0));     for (int i = 1; i <= n; i++) {       a[i] = getnum();     }     sort(a + 1, a + n + 1);     for (int i = n; i >= 1; i--) {       tmps.clear();       while (s.size() > 0 && -s.begin()->first > a[i]) {         int x = s.begin()->second, y = -s.begin()->first + x;         s.erase(s.begin());         tmps.push_back(make_pair(-a[i], x));         tmps.push_back(make_pair(-(y - (x + a[i])), x + a[i]));       }       for (int j = 0; j < tmps.size(); j++) {         s.insert(tmps[j]);       }     }     for (auto x : s) {       used[x.second] = 1;     }     int tmp = c;     for (int i = n; i >= 1; i--) {       if (tmp >= a[i]) {         cnt[a[i]]++;         cnt[tmp + 1]--;         tmp -= a[i];       }     }     int sum = 0;     for (int i = 1; i <= c; i++) {       sum += cnt[i];       if (sum > 0 && !used[c - i]) {         cout << i << endl;         return 0;       }     }     puts( Greed is good );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     vector<int> g;     while (cin >> n) {       int xi, xf;       xi = -1;       xf = -1;       bool init = false;       g = vector<int>(n);       for (int i = 0; i < n; i++) {         cin >> g[i];         if (init == false && g[i] == 1) {           xi = i;           xf = i;           init = true;         } else if (init == true && g[i] == 1)           xf = max(xf, i);       }       if (xi == -1 || xf == -1)         cout << 0 << endl;       else {         int ceros = 0;         for (int i = xi; i < xf;) {           if (g[i] == 0 && g[i + 1] == 0) {             i += 2;             ceros += 2;             int b = i;             for (int q = b; q <= xf; q++)               if (g[q] == 0) {                 ceros++;                 b = max(b, q);               } else                 break;             i = b + 1;           } else             i++;         }         cout << (xf - xi + 1) - ceros << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   bool Check(int x, int y) {     if (gcd(x, y) > 1) return false;     if (gcd(x + 1, y) > 1) return false;     if (gcd(x + 2, y) > 1) return false;     return true;   }   vector<int> ans[10010];   int main() {     int n, k;     cin >> n >> k;     int x = 1;     for (int i = 0; i < (n); i++) {       ans[i].push_back(x * k);       ans[i].push_back((x + 1) * k);       ans[i].push_back((x + 2) * k);       int y = x + 4;       while (!Check(x, y)) y += 2;       ans[i].push_back(y * k);       x = y + 2;     }     cout << (x - 2) * k << endl;     for (int i = 0; i < (n); i++)       cout << ans[i][0] <<     << ans[i][1] <<     << ans[i][2] <<                << ans[i][3] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int N = 1e5 + 10, INFI = 1e9 + 10;   int val[12];   unordered_set<int> s;   int main() {     cin.tie(NULL);     cout.tie(NULL);     ios_base::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 0; i < 12; i++) {       s.clear();       for (int a = 0; a <= i + 1; a++) {         for (int b = 0; b <= i + 1 - a; b++) {           for (int c = 0; c <= i + 1 - a - b; c++) {             for (int d = 0; d <= i + 1 - a - b - c; d++) {               if (a + b + c + d == i + 1) {                 s.insert((a * 1) + (b * 5) + (c * 10) + (d * 50));               }             }           }         }       }       val[i] = s.size();     }     if (n <= 12) {       cout << val[n - 1] << endl;     } else {       cout << val[11] + 1LL * 49 * (n - 12) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200010], n, S, T;   vector<int> A;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , a + i), S += a[i];     for (int i = 0; i < n; i++)       if (S - a[i] == (long long)a[i] * (n - 1)) A.push_back(i + 1);     printf( %d n , (int)A.size());     for (int i = 0; i < (int)A.size(); i++)       printf( %d%c , A[i], i == (int)A.size() - 1 ?   n  :    );     return 0;   }