malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   struct edge {     int u, v;     int adj(int x) { return u + v - x; }   };   int n, c[N];   vector<int> adj[N];   vector<edge> e;   int lvl[N], pre[N], root;   vector<int> cycle;   void dfs1(int u) {     for (auto ind : adj[u])       if (ind != pre[u]) {         auto ei = e[ind];         int v = ei.adj(u);         if (lvl[v]) {           if ((lvl[u] + lvl[v]) % 2 == 0 && cycle.empty()) {             for (int w = u; w != v; w = e[pre[w]].adj(w)) cycle.push_back(pre[w]);             reverse((cycle).begin(), (cycle).end());             cycle.push_back(ind);             root = v;           }         } else {           lvl[v] = lvl[u] + 1;           pre[v] = ind;           dfs1(v);         }       }   }   long long int ans[N];   bool vis[N];   long long int dfs2(int u, int pre) {     if (vis[u]) return 0;     vis[u] = 1;     long long int sum = 0;     for (auto ind : adj[u])       if (ind != pre) {         int v = e[ind].adj(u);         sum += dfs2(v, ind);       }     if (pre != -1) ans[pre] = c[u] - sum;     return c[u] - sum;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int m;     cin >> n >> m;     for (int i = 0; i < (int)(n); i++) cin >> c[i];     e.resize(m);     for (int i = 0; i < (int)(m); i++) {       cin >> e[i].u >> e[i].v;       e[i].u--;       e[i].v--;       adj[e[i].u].push_back(i);       adj[e[i].v].push_back(i);     }     bool ok = 1;     for (int u = 0; u < (int)(n); u++)       if (!lvl[u]) {         cycle.clear();         lvl[u] = 1;         pre[u] = -1;         dfs1(u);         if (cycle.empty()) {           ok &= dfs2(u, -1) == 0;         } else {           auto delta = dfs2(root, -1) / 2;           for (auto ind : cycle) {             ans[ind] += delta;             delta = -delta;           }         }       }     if (ok) {       cout <<  YES n ;       for (int i = 0; i < (int)(m); i++) cout << ans[i] <<   n ;     } else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cout << setprecision(10);     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       if (x == 1) {         cout <<  HARD n ;         return 0;       }     }     cout <<  EASY n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 41, K = 11;   bitset<40> a[N];   vector<int> steps[K];   int n, k;   bool ok = true;   void go(int pos, bitset<40> is_one, bitset<40> is_question) {     if (pos == k) {       if (is_question != 0) {         ok = false;         return;       }       int ones = is_one.count();       if (is_one != a[ones]) {         ok = false;         return;       }       return;     }     int ones = 0, zeros = 0, questions = 0;     for (int i : steps[pos]) {       if (is_question[i]) {         questions++;       } else if (is_one[i]) {         ones++;       } else {         zeros++;       }       is_question[i] = 0;       is_one[i] = 1;     }     for (int i = 0; i < zeros; i++) {       is_one[steps[pos][i]] = 0;     }     go(pos + 1, is_one, is_question);     for (int i = zeros; i < questions + zeros; i++) {       is_one[steps[pos][i]] = 0;       go(pos + 1, is_one, is_question);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int _ = 1;     while (_--) {       cin >> n >> k;       for (int i = 0; i <= n; i++) {         a[i] = 0;         for (int j = 0; j < i; j++) {           a[i][n - j - 1] = 1;         }       }       for (int i = 0; i < k; i++) {         int q;         cin >> q;         while (q--) {           int x;           cin >> x;           steps[i].push_back(--x);         }       }       bitset<40> is_one = 0;       bitset<40> is_question = (1ll << n) - 1;       go(0, is_one, is_question);       cout << (n == 1 || ok ?  ACCEPTED  :  REJECTED ) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long xmax, ymax, sx, sy, i, j;     cin >> xmax >> ymax >> sx >> sy;     cout << sx <<     << sy << endl;     for (i = sx - 1; i >= 1; i--) cout << i <<     << sy << endl;     i++;     for (j = sy + 1; j <= ymax; j++) cout << i <<     << j << endl;     j--;     for (j = sy - 1; j >= 1; j--) cout << i <<     << j << endl;     j++;     for (i = 2; i <= xmax; i++) {       if (i % 2 == 0) {         for (j = 1; j <= ymax; j++) {           if (i <= sx && j == sy)             continue;           else             cout << i <<     << j << endl;         }         j--;       } else {         for (j = ymax; j >= 1; j--) {           if (i <= sx && j == sy)             continue;           else             cout << i <<     << j << endl;         }         j++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, m, n, x, y;   set<long long> a, b;   int main() {     cin >> n >> m;     for (i = 0; i < m; i++) {       cin >> x >> y;       a.insert(x);       b.insert(y);       cout << (n - a.size()) * (n - b.size()) <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   const int MAX = 1000007;   int n;   long long a, b;   vector<int> primes(int x) {     vector<int> p;     for (int i = 2; i * i <= x; ++i)       if (x % i == 0) {         p.push_back(i);         while (x % i == 0) {           x /= i;         }       }     if (x != 1) p.push_back(x);     return p;   }   long long dp[MAX][3];   long long solve(vector<int> c) {     vector<int> p = primes(c[0]);     vector<int> p1 = primes(c[0] - 1);     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     p1 = primes(c[0] + 1);     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     p1 = primes(c.back());     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     p1 = primes(c.back() + 1);     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     p1 = primes(c.back() - 1);     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     sort(p.begin(), p.end());     p.resize(unique(p.begin(), p.end()) - p.begin());     long long res = 1LL * INF * INF;     for (int t = (0); t < (p.size()); t++) {       int pr = p[t];       dp[0][0] = dp[0][1] = dp[0][2] = 0;       for (int i = (0); i < (n); i++) {         int val = min(c[i] % pr, pr - c[i] % pr);         dp[i + 1][0] = dp[i + 1][1] = dp[i + 1][2] = 1LL * INF * INF;         if (val <= 1) {           dp[i + 1][2] = min(dp[i][2] + a * val,                              min(dp[i][1] + a * val, dp[i][0] + a * val));         }         dp[i + 1][1] = min(dp[i][0], dp[i][1]) + b;         if (val <= 1) {           dp[i + 1][0] = dp[i][0] + a * val;         }       }       long long r = min(dp[n][2], min(dp[n][1], dp[n][0]));       res = min(res, r);     }     return res;   }   int main() {     cin >> n >> a >> b;     swap(a, b);     vector<int> c(n);     for (int i = (0); i < (n); i++) {       scanf( %d , &c[i]);     }     long long res = solve(c);     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[55][55];   int query(int xa, int ya, int xb, int yb) {     if (xa > xb || ya > yb) swap(xa, xb), swap(ya, yb);     cout <<  ?   << xa + 1 <<     << ya + 1 <<     << xb + 1 <<     << yb + 1          << endl;     int p;     cin >> p;     return p;   }   int h[2];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     a[0][0] = 1, a[n - 1][n - 1] = 0;     for (int i = 0; i < n; i++) {       for (int j = i + 2; j < n; j += 2) {         int p = query(i, j - 2, i, j);         p ^= 1;         a[i][j] = p ^ a[i][j - 2];         p = query(j - 2, i, j, i);         p ^= 1;         a[j][i] = p ^ a[j - 2][i];       }       if (i < n - 1) {         int p = query(i, i, i + 1, i + 1);         p ^= 1;         a[i + 1][i + 1] = p ^ a[i][i];       }     }     a[0][1] = 0;     for (int i = 0; i < n; i++) {       if (i & 1) {         int p = query(i - 1, n - 2, i, n - 1);         p ^= 1;         a[i][n - 1] = a[i - 1][n - 2] ^ p;         for (int j = n - 3; j >= 0; j -= 2) {           int p = query(i, j, i, j + 2);           p ^= 1;           a[i][j] = a[i][j + 2] ^ p;         }       } else {         if (i) {           int p = query(i - 2, 1, i, 1);           p ^= 1;           a[i][1] = a[i - 2][1] ^ p;         }         for (int j = 3; j < n; j += 2) {           int p = query(i, j - 2, i, j);           p ^= 1;           a[i][j] = a[i][j - 2] ^ p;         }       }     }     int ind;     for (int i = 0; i < n - 2; i++) {       if (i % 2 == 0 && a[i + 2][i + 2] == 0 && a[i][i] == 1) {         ind = i;         break;       }     }     if (!(a[ind][ind] == a[ind][ind + 2]) ^         (a[ind][ind + 1] == a[ind + 1][ind + 2])) {       int p = query(ind, ind, ind + 1, ind + 2);       if (p) {         h[a[ind + 1][ind + 2]] = 1;         h[1 - a[ind + 1][ind + 2]] = 0;       } else {         h[a[ind + 1][ind + 2]] = 0;         h[1 - a[ind + 1][ind + 2]] = 1;       }     } else {       int p = query(ind, ind + 1, ind + 2, ind + 2);       if (p) {         h[a[ind][ind + 1]] = 0;         h[1 - a[ind][ind + 1]] = 1;       } else {         h[a[ind][ind + 1]] = 1;         h[1 - a[ind][ind + 1]] = 0;       }     }     cout <<  !  << endl;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if ((i + j) % 2) {           cout << h[a[i][j]];         } else {           cout << a[i][j];         }       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[100][40];   char b[100][40];   int at[1445], use[100], ok[100], idx[100], pos[100], sum[100], cnt;   int dp[43205], ans_dd, ans_hh, ans_mm;   int pt[43205][100];   void run_to(int t) {     while (1) {       int next_dd = ans_dd;       int next_hh = ans_hh;       int next_mm = ans_mm;       if (++next_mm == 60) {         next_mm = 0;         if (++next_hh == 24) {           next_hh = 0;           next_dd++;         }       }       if ((next_dd - 1) * cnt + at[next_hh * 60 + next_mm] >= t) break;       ans_dd = next_dd;       ans_hh = next_hh;       ans_mm = next_mm;     }   }   void output(int t, int i, int cnt) {     if (~i) {       int x = pt[t][i];       if (~x) {         output(t - use[idx[x]], i - 1, cnt + 1);         run_to(t - use[idx[x]] + 1);         printf( %d %d %02d:%02d , x + 1, ans_dd, ans_hh, ans_mm);         run_to(t);         printf(  %d %02d:%02d n , ans_dd, ans_hh, ans_mm);       } else {         output(t, i - 1, cnt);       }     } else {       printf( %d n , cnt);     }   }   int main() {     int m, n, all, hh, mm;     scanf( %d%d%d , &m, &n, &all);     for (int i = 0; i < m; i++) scanf( %s , a[i]);     for (int i = 0; i < m; i++) scanf( %d , use + i);     for (int i = 0; i < 4; i++) {       scanf( %d:%d- , &hh, &mm);       int st = hh * 60 + mm;       scanf( %d:%d , &hh, &mm);       int ed = hh * 60 + mm;       for (int x = st; x <= ed; x++) at[x] = -1;     }     for (int x = 0; x < 1440; x++)       if (~at[x]) at[x] = cnt++;     all *= at[1440] = cnt;     for (int x = 1439; ~x; x--)       if (at[x] < 0) at[x] = at[x + 1];     for (int i = 0; i < n; i++) {       scanf( %s , b[i]);       for (idx[i] = 0; idx[i] < m; idx[i]++)         if (!strcmp(b[i], a[idx[i]])) break;       if (idx[i] != m) ok[i] = 1;       scanf( %d%d:%d%d , pos + i, &hh, &mm, sum + i);       pos[i] = (pos[i] - 1) * cnt + at[hh * 60 + mm];     }     for (int i = 0; i < n; i++) {       int k = -1;       for (int j = 0; j < n; j++)         if (ok[j] && (k < 0 || pos[j] < pos[k])) k = j;       for (int x = all; ~x; x--) pt[x][i] = -1;       for (int x = all; ~x; x--) {         int t = x + use[idx[k]];         if (t <= pos[k] && sum[k] + dp[x] > dp[t]) {           dp[t] = sum[k] + dp[x];           pt[t][i] = k;         }       }       ok[k] = 0;     }     int x = max_element(dp, dp + all + 1) - dp;     printf( %d n , dp[x]);     output(x, n - 1, 0);   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const long long INF = 2e18;   const int N = 11234;   int n, m;   set<string> st;   char s[N];   int dp[N][4];   void dfs(int pos, string pre, int len) {     if (pos - 1 < 5) return;     if (dp[pos][len]) return;     dp[pos][len] = 1;     string str =   ;     for (int i = 1; i >= 0; --i) str += s[pos - i];     if (str != pre) {       st.insert(str);       dfs(pos - 2, str, 2);     }     if (pos - 2 >= 5) {       str =   ;       for (int i = 2; i >= 0; --i) str += s[pos - i];       if (str != pre) {         st.insert(str);         dfs(pos - 3, str, 3);       }     }   }   int main() {     while (scanf( %s , s) != EOF) {       int i, j;       memset(dp, 0, sizeof(dp));       st.clear();       n = strlen(s);       if (n < 5)         puts( 0 );       else {         dfs(n - 1,   , 0);         printf( %d n , st.size());         set<string>::iterator it = st.begin();         for (; it != st.end(); ++it) {           cout << *it << endl;         }       }     }   }
#include <bits/stdc++.h>   template <class C, class E>   inline bool contains(const C &container, const E &element) {     return container.find(element) != container.end();   }   template <class T>   inline void checkmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   inline void checkmax(T &a, T b) {     if (b > a) a = b;   }   using namespace std;   class UnionFind {    public:     UnionFind(int elements) : _subsets(elements), _setCount(elements) {       for (int i = 0; i < elements; ++i) {         _subsets[i].parent = i;         _subsets[i].rank = 0;       }     }     int Find(int i) {       if (_subsets[i].parent != i) _subsets[i].parent = Find(_subsets[i].parent);       return _subsets[i].parent;     }     void Union(int x, int y) {       int xroot = Find(x);       int yroot = Find(y);       if (xroot == yroot) return;       --_setCount;       if (_subsets[xroot].rank < _subsets[yroot].rank)         _subsets[xroot].parent = yroot;       else if (_subsets[xroot].rank > _subsets[yroot].rank)         _subsets[yroot].parent = xroot;       else {         _subsets[yroot].parent = xroot;         _subsets[xroot].rank++;       }     }     struct subset {       int parent;       int rank;     };     void Trace() {       for (int i = (0), _b = ((_subsets.size()) - 1); i <= _b; i++)         cout << i <<  :  << Find(i) <<   | ;       cout << endl;     }     vector<subset> _subsets;     int _setCount;   };   vector<int> res;   struct Node {     Node(int v) {       l = r = NULL;       val = v;     }     Node(Node *_l, Node *_r) {       l = _l;       r = _r;     }     Node *l, *r;     int val;     void Solve() {       if (l == NULL) {         cout << val <<    ;       } else {         l->Solve();         r->Solve();       }     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cout << std::setprecision(15);     cout << std::fixed;     int n;     cin >> n;     res.reserve(n);     UnionFind uf(n + 1);     vector<Node *> d(n + 1);     for (int i = (1), _b = (n); i <= _b; i++) {       d[i] = new Node(i);     }     for (int i = (0), _b = ((n - 1) - 1); i <= _b; i++) {       int a, b;       cin >> a >> b;       int ra = uf.Find(a);       int rb = uf.Find(b);       Node *na = d[ra];       Node *nb = d[rb];       assert(na != NULL);       assert(nb != NULL);       d[ra] = NULL;       d[rb] = NULL;       uf.Union(ra, rb);       int nr = uf.Find(ra);       Node *nn = new Node(na, nb);       d[nr] = nn;     }     int rootR = uf.Find(1);     d[rootR]->Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long tc, n, m, a, b, k;   string str;   char c;   set<long long> s;   map<long long, long long> mp;   int main() {     int k2, k3, k5, k6, ans = 0;     cin >> k2 >> k3 >> k5 >> k6;     int x = min(k2, k5);     x = min(x, k6);     ans += 256 * x;     k2 -= x;     x = min(k2, k3);     ans += 32 * x;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   string inp[100005];   int num[100005];   int tl;   int ch[1200005][27];   int fail[1200005], len[1200005], elen[1200005];   long long cost[1200005];   int rt = 1, tot = 1, last = 1;   void add(int x, int c, int _elen) {     int p = last;     int np = ++tot;     len[np] = len[p] + 1;     cost[np] = c;     elen[np] = _elen;     last = np;     while (p && !ch[p][x]) {       ch[p][x] = np;       p = fail[p];     }     if (!p) {       fail[np] = rt;     } else {       int q = ch[p][x];       if (len[q] == len[p] + 1) {         fail[np] = q;       } else {         int nq = ++tot;         memcpy(ch[nq], ch[q], sizeof(ch[q]));         len[nq] = len[p] + 1;         fail[nq] = fail[q];         fail[np] = fail[q] = nq;         while (p && ch[p][x] == q) {           ch[p][x] = nq;           p = fail[p];         }       }     }   }   int freq[600005], tpsort[1200005];   void TopoSort() {     for (int i = (1); i <= (tot); i += (1)) freq[len[i]]++;     for (int i = (1); i <= (tl); i += (1)) freq[i] += freq[i - 1];     for (int i = (tot); i >= (1); i -= (1)) tpsort[--freq[len[i]]] = i;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     for (int i = (1); i <= (n); i += (1)) cin >> inp[i];     for (int i = (1); i <= (n); i += (1)) cin >> num[i];     for (int i = (0); i <= (1200005 - 1); i += (1)) elen[i] = 1000000000;     tl = 0;     for (int i = (1); i <= (n); i += (1)) {       int t = inp[i].length();       for (int j = (0); j <= (t - 1); j += (1)) {         add(inp[i][j] -  a , num[i], j + 1);       }       add(26, 0, 0);       tl += t + 1;     }     TopoSort();     long long mx = 0;     for (int i = (tot); i >= (1); i -= (1)) {       int u = tpsort[i];       cost[fail[u]] += cost[u];       elen[fail[u]] = min(elen[fail[u]], elen[u]);       if (elen[u] > len[fail[u]]) {         mx = max(mx, cost[u] * min(elen[u], len[u]));       }     }     printf( %lld n , mx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 10;   int col[N], par[N], to[N];   int num = 0;   void dfs(int u, int from) {     if (col[u] == 2) return;     if (col[u] == 1) {       ++num;       return;     }     col[u] = 1;     par[u] = from;     dfs(to[u], u);     col[u] = 2;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n, cnt = 0;     cin >> n;     for (int i = 1; i <= n; ++i) cin >> to[i];     int b[N];     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       if (x) ++cnt;     }     for (int i = 1; i <= n; ++i)       if (!col[i]) dfs(i, -1);     if (num == 1) num = 0;     cout << num + ((cnt % 2) ? 0 : 1);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k, q;     long long int i, j;     cin >> n >> k >> q;     long long int arr[n][2];     for (i = 0; i < n; i++) {       cin >> arr[i][0] >> arr[i][1];     }     long long int temp[200010];     for (i = 0; i < 200001; i++) {       temp[i] = 0;     }     for (i = 0; i < n; i++) {       temp[arr[i][0]] = temp[arr[i][0]] + 1;       temp[arr[i][1] + 1] = temp[arr[i][1] + 1] - 1;     }     for (i = 1; i < 200001; i++) {       temp[i] = temp[i - 1] + temp[i];     }     long long int ans[200010];     ans[0] = 0;     for (i = 1; i < 200001; i++) {       if (temp[i] >= k)         ans[i] = ans[i - 1] + 1;       else         ans[i] = ans[i - 1];     }     int s, e;     while (q--) {       cin >> s >> e;       cout << ans[e] - ans[s - 1] << endl;     }     return (0);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int i, j;     int arr1[n], arr2[n], p[n];     for (i = 1; i <= n; i++) cin >> arr1[i];     for (i = 1; i <= n; i++) cin >> arr2[i];     for (i = 1; i <= n; i++) p[arr1[i]] = arr2[i];     for (i = 1; i <= n; i++) cout << p[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c, Count = 1;   int main() {     cin >> a >> b >> c;     if ((a + b > c) && (a + c > b) && (b + c > a)) {       cout << 0 << endl;       return 0;     }     while ((a + b < c) || (a + c < b) || (b + c < a)) {       ++Count;       if (a + b < c) {         if (a < b)           a++;         else           b++;       } else if (a + c < b) {         if (a < c)           a++;         else           c++;       } else if (b + c < a) {         if (b < c)           b++;         else           c++;       }     }     cout << Count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     long long x = __builtin_popcount(n);     if (k > n || k < x) {       cout <<  NO  << endl;     } else {       cout <<  YES n ;       k = k - x;       long long count[30] = {0};       int i = 0;       int a = n;       n = 0;       while (a > 0) {         count[i] = a % 2;         n++;         a = a / 2;         i++;       }       long long cur = 29;       while (k--) {         if (count[cur]) {           count[cur - 1] += 2;           count[cur]--;         } else if (count[cur] == 0) {           cur = cur - 1;           k++;         }       }       cur = 1;       for (int i = 0; i < 30; i++) {         for (int j = 0; j < count[i]; j++) {           cout << cur <<    ;         }         cur *= 2;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     vector<vector<long long>> adj(n + 1, vector<long long>(n + 1, 0));     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= n; j++) {         cin >> adj[i][j];       }     }     vector<long long> del(n + 1), v, ans;     for (long long i = 1; i <= n; i++) cin >> del[i];     for (long long k = n; k >= 1; k--) {       v.push_back(del[k]);       for (long long i = 1; i <= n; i++) {         for (long long j = 1; j <= n; j++) {           adj[i][j] = min(adj[i][j], adj[i][del[k]] + adj[del[k]][j]);         }       }       long long sum = 0;       for (long long i = 0; i < v.size(); i++) {         for (long long j = 0; j < v.size(); j++) {           sum += adj[v[i]][v[j]];         }       }       ans.push_back(sum);     }     for (long long i = ans.size() - 1; i >= 0; i--) {       cout << ans[i] <<    ;     }     cout << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long qu = 1;     for (long long cas = 1; cas <= qu; cas++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     cin >> a >> b;     if (b - a >= 5l)       printf( 0 );     else {       long long p = 1l, t = b;       while (t > a && t > 0) {         p *= t;         p %= 10;         t--;       }       printf( %I64d , p);     }   }
#include <bits/stdc++.h>   int n;   int p[512];   int c[512][512];   int a[512];   int main() {     int i, j, k;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       for (j = 1; j <= n; j++) {         scanf( %d , &c[i][j]);       }     }     for (i = 1; i <= n; i++) {       scanf( %d , &p[i]);     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= n; j++) {         if (c[i][j] == i) continue;         for (k = 1; k <= n; k++) {           if (p[k] == c[i][j]) break;           if ((p[k] < c[i][j]) && (p[k] != i)) break;         }         if (p[k] == c[i][j]) {           a[i] = c[i][j];           break;         }       }     }     for (i = 1; i < n; i++) printf( %d  , a[i]);     printf( %d n , a[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long int m = 1000000007;   int prsb(long long int n) {     int pos = 0;     long long int m = 1;     while (!(n & m)) {       m = m << 1;       pos++;     }     return pos;   }   int main() {     int t;     cin >> t;     while (t--) {       long long int a, b;       cin >> a >> b;       long long int x, y, z;       int n, c = 0;       x = min(a, b);       y = max(a, b);       z = y / x;       if (y % x != 0) {         c = -1;       } else if (z == 1) {         c = 0;       } else if (z && (!(z & (z - 1)))) {         n = prsb(z);         c += n / 3;         n = n % 3;         c += n / 2;         n = n % 2;         c += n / 1;       } else {         c = -1;       }       cout << c << endl;     }   }