malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long LIM = 1e5;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cout.precision(10);     cout << fixed;     long long n, r;     cin >> n >> r;     vector<long long> L(n);     vector<long long> T(n);     for (long long i = 0; i < n; i++) cin >> L[i];     for (long long i = 0; i < n; i++) cin >> T[i];     long long cnt = 0;     vector<long long> ans;     long long curTime = 0;     long long timePotion = 0;     for (long long i = 0; i < n; i++) {       long long l = L[i];       long long t = T[i];       if (timePotion < l) {         t -= timePotion;         l -= timePotion;         curTime += timePotion;         if (t < 0) {           cout << -1 <<   n ;           return 0;         }         if (2 * l > t) {           long long szz = ans.size();           long long timeNeedPotion = 2 * l - t;           if (t - timeNeedPotion < 0) {             cout << -1 <<   n ;             return 0;           }           long long cntMoments = (timeNeedPotion / r) + (timeNeedPotion % r != 0);           curTime = curTime + t - timeNeedPotion;           cnt += cntMoments;           for (long long i = 0; i < cntMoments; i++) {             if (ans.size() < LIM) {               ans.push_back(curTime + i * r);             } else {               break;             }           }           curTime += timeNeedPotion;           timePotion = r - (timeNeedPotion % r);           if (timePotion == r) timePotion -= r;         } else {           curTime += l * 2;           timePotion = 0;         }       } else {         if (l > t) {           cout << -1 <<   n ;           return 0;         } else {           timePotion -= l;           curTime += l;         }       }     }     cout << cnt <<   n ;     if (cnt <= LIM) {       for (long long xx : ans) cout << xx <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long Length, X, Y;   long long Dp[10000001];   int main(void) {     register long long i;     cin >> Length >> X >> Y;     Dp[1] = X;     for (i = 2; i <= Length; i++) {       Dp[i] = Dp[i - 1] + X;       if (i & 1) {         Dp[i] = min(Dp[i], Dp[(i >> 1) + 1] + X + Y);       } else {         Dp[i] = min(Dp[i], Dp[i >> 1] + Y);       }     }     cout << Dp[Length] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int i1, i2, a1, a2;     cout <<  ?  ;     for (int i = 1; i <= k; ++i) cout << i <<    ;     cout <<   n ;     cout.flush();     cin >> i1 >> a1;     cout <<  ?  ;     for (int i = 1; i <= k + 1; ++i) {       if (i == i1) ++i;       cout << i <<    ;     }     cout <<   n ;     cout.flush();     cin >> i2 >> a2;     if (a1 < a2) {       swap(i1, i2);       swap(a1, a2);     }     int count = 0, c1 = 0, c2;     for (int ch = 1; ch <= k + 10; ++ch) {       if (ch == i1 || ch == i2) ++ch;       if (ch == i1 || ch == i2) ++ch;       ++c1;       if (c1 > k - 1) break;       cout <<  ?  ;       c2 = 0;       for (int i = 1; i <= k + 10; ++i) {         ++c2;         if (c2 > k) break;         if (i == i2) ++i;         if (i == ch)           cout << i2 <<    ;         else           cout << i <<    ;       }       cout <<   n ;       cout.flush();       int ich, ach;       cin >> ich >> ach;       if (ich == i1) ++count;     }     cout <<  !   << count + 1;     cout.flush();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[110];   map<int, bool> mp[3];   bool Check(int x) {     if (x < 10) {       if (mp[0][x] || mp[1][x] || mp[2][x]) return true;     } else if (x < 100) {       int a = x / 10, b = x % 10;       if (mp[0][a] && mp[1][b]) return true;       if (mp[0][a] && mp[2][b]) return true;       if ((mp[1][a] && mp[2][b]) || (mp[1][a] && mp[0][b])) return true;       if ((mp[2][a] && mp[0][b]) || (mp[2][a] && mp[1][b])) return true;     }     return false;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       for (int x, j = 0; j < 6; ++j) {         scanf( %d , &x);         mp[i][x] = true;       }     }     int i;     for (i = 1; i < 1000; ++i) {       if (!Check(i)) break;     }     printf( %d n , i - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int a, b;     int s[4010];     cin >> n;     memset(s, 0, sizeof(s));     for (int i = 0; i < n; i++) {       cin >> a >> b;       s[a + b]++;       s[a - b + 3000]++;     }     long long sum = 0;     for (int i = 0; i <= 4000; i++) {       if (s[i] > 1) sum += (s[i] * (s[i] - 1) / 2);     }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long x, y, z;     cin >> x >> y >> z;     long long xx = x, yy = y;     long long g1 = x % z, p1;     if ((y + g1) / z > y / z) {       y += g1;       if (g1 - (y) % z > 0) g1 -= (y) % z;     } else       g1 = 0;     p1 = (x / z) + (y / z);     long long g2 = yy % z, p2;     if ((xx + g2) / z > xx / z) {       xx += g2;       if (g2 - (xx) % z > 0) g2 -= (xx) % z;     } else       g2 = 0;     p2 = (xx / z) + (yy / z);     if (p1 > p2)       cout << p1 <<     << g1;     else if (p2 > p1)       cout << p2 <<     << g2;     else {       cout << p1 <<    ;       if (g1 < g2)         cout << g1;       else         cout << g2;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1e6 + 5;   const long long mod = 1e9 + 7;   void solve() {     long long n;     cin >> n;     long long a = n / 10;     long long b = n % 10;     long long ans = a + (b == 9);     cout << ans;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long T = 1;     cin >> T;     while (T-- > 0) {       solve();       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename TP>   inline bool rd(TP& r) {     r = 0;     char tmp = getchar();     while (tmp <  0  || tmp >  9 ) {       if (tmp == EOF) return 0;       tmp = getchar();     }     while ( 0  <= tmp && tmp <=  9 ) {       r = (r << 3) + (r << 1) + tmp -  0 ;       tmp = getchar();     }     return 1;   }   long long a[110], b[110], n;   long long dt[110 * 110];   bool vis[1000100];   long long ab(long long num) {     if (num >= 0) return num;     return -num;   }   int main() {     int t;     rd(t);     int tot;     int nb;     while (t--) {       rd(n);       for (int i = 1; i <= n; i++) rd(a[i]);       tot = 0;       for (int i = 1; i <= n; i++)         for (int j = 1; j < i; j++) dt[++tot] = ab(a[i] - a[j]);       sort(dt + 1, dt + tot + 1);       tot = unique(dt + 1, dt + tot + 1) - (dt + 1);       memset(vis, 0, sizeof(vis));       nb = 0;       for (int i = 1; i <= 1000000 && nb != n; i++)         if (!vis[i]) {           b[++nb] = i;           for (int j = 1; j <= tot && i + dt[j] < 1000100; j++)             vis[i + dt[j]] = 1;         }       if (nb != n)         printf( NO n );       else {         printf( YES n );         for (int i = 1; i <= n; i++) printf( %I64d  , b[i]);         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   #pragma comment(linker,  /STACK:336777216 )   using namespace std;   int IT_MAX = 1 << 17;   const long long MOD = 1000000007;   const int INF = 0x1f3f3f3f;   const long long LL_INF = 1034567890123456789ll;   const double PI = acos(-1);   const double ERR = 1E-11;   multiset<int> Sx;   int in[100050];   int main() {     int N, K, i, j;     scanf( %d %d , &N, &K);     for (i = 1; i <= N; i++) scanf( %d , &in[i]);     int ans = -1;     vector<int> Va;     for (i = 1, j = 1; i <= N; i++) {       while (j <= N) {         if (Sx.empty()) {           Sx.insert(in[j++]);           continue;         }         auto it1 = Sx.begin();         auto it2 = Sx.end();         it2--;         if (abs(in[j] - *it1) > K || abs(in[j] - *it2) > K) break;         Sx.insert(in[j++]);       }       if (ans < j - i) {         ans = j - i;         Va.clear();       }       if (ans == j - i) Va.push_back(i);       Sx.erase(Sx.lower_bound(in[i]));     }     printf( %d %d n , ans, (int)Va.size());     for (auto it : Va) printf( %d %d n , it, it + ans - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct info {     int l, r, need, onemore, take;   };   vector<string> solve(vector<int> a, int n) {     vector<string> ans(n + 1, string(n,  0 ));     vector<info> state = {{0, n, (n + 1) / 2, ((n + 1) & 1), 0}};     int pos = 0;     for (auto i : a) {       for (auto &j : state)         while (j.need && i) {           --i;           --j.need;           ++j.take;         }       for (auto &j : state)         if (j.onemore && i) {           --i;           --j.onemore;           ++j.take;         }       int j = 0;       while (i > 0) {         if (state[j].take != state[j].r - state[j].l + 1) {           --i;           ++state[j].take;         }         j = (j + 1) % state.size();       }       vector<info> nstate;       for (auto &k : state) {         for (int p = k.l; p < k.l + k.take; ++p) ans[p][pos] =  1 ;         if (k.take) nstate.push_back({k.l, k.l + k.take - 1, 0, 0, 0});         if (k.take < k.r - k.l + 1)           nstate.push_back({k.l + k.take, k.r, 0, 0, 0});       }       state = nstate;       for (auto &k : state) {         k.need = (k.r - k.l + 1) / 2;         k.onemore = (k.r - k.l + 1) & 1;         k.take = 0;       }       ++pos;     }     sort(ans.begin(), ans.end());     reverse(ans.begin(), ans.end());     while (!ans.empty() && ans.back() == string(n,  0 )) ans.pop_back();     return ans;   }   void validate(vector<int> a, int n, vector<string> ans) {     for (auto &j : ans)       for (int i = 0; i < n; ++i)         if (j[i] ==  1 ) --a[i];     assert(count(a.begin(), a.end(), 0) == n);     for (int i = 1; i < ans.size(); ++i) assert(ans[i - 1] != ans[i]);   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     int n;     cin >> n;     vector<int> a(n);     for (auto &i : a) cin >> i;     auto ans = solve(a, n);     validate(a, n, ans);     cout << ans.size() <<   n ;     for (auto i : ans) cout << i <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[ T  + 1];   string p =  AGTC ;   int main() {     int n;     cin >> n;     string s;     cin >> s;     for (int i = 0, __l = s.size(); i < __l; ++i) cnt[s[i]]++;     int maxi = 0;     for (int i = 0, __l = p.size(); i < __l; ++i) maxi = max(maxi, cnt[p[i]]);     int x = 0;     for (int i = 0, __l = p.size(); i < __l; ++i) x += cnt[p[i]] == maxi;     long long ans = 1;     for (int i = 0, __l = n; i < __l; ++i) (ans *= x) %= 1000000007;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double ESP = 1E-8;   long double cal(long double x, long double y, long double z) {     return log(x) * pow(y, z);   }   long double ca(long double x, long double y, long double z) {     return y * z * log(x);   }   int main() {     const char* result[12] = { x^y^z ,  x^z^y ,  (x^y)^z ,  (x^z)^y ,                                y^x^z ,  y^z^x ,  (y^x)^z ,  (y^z)^x ,                                z^x^y ,  z^y^x ,  (z^x)^y ,  (z^y)^x };     long double a[20];     long double x, y, z;     cin >> x >> y >> z;     a[0] = cal(x, y, z);     a[1] = cal(x, z, y);     a[2] = ca(x, y, z);     a[3] = ca(x, z, y);     a[4] = cal(y, x, z);     a[5] = cal(y, z, x);     a[6] = ca(y, x, z);     a[7] = ca(y, z, x);     a[8] = cal(z, x, y);     a[9] = cal(z, y, x);     a[10] = ca(z, x, y);     a[11] = ca(z, y, x);     long double maxn = a[0];     int res = 0;     for (int i = 1; i < 12; ++i) {       if (maxn < a[i] - ESP) {         maxn = a[i];         res = i;       }     }     printf( %s , result[res]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll MOD = (int)1e9 + 7;   ll modAdd(ll a, ll b) {     if (a + b >= MOD)       return a + b - MOD;     else       return a + b;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<int> sweetness(n);     for (int& v : sweetness) cin >> v;     vector<vector<pair<int, int>>> offs(n);     for (int i = 0; i < m; ++i) {       int s, h;       cin >> s >> h;       int a = 0;       for (int need = h; a < n; ++a) {         if (sweetness[a] == s) --need;         if (need == 0) break;       }       int b = n - 1;       for (int need = h; b >= 0; --b) {         if (sweetness[b] == s) --need;         if (need == 0) break;       }       offs[s - 1].push_back({a, b});     }     vector<pair<int, ll>> res;     for (int a = -1; a < n; ++a) {       int cou = 0;       ll v0 = (a != -1);       ll v1 = (a == -1);       for (auto& vec : offs) {         ll dp[2][2][2];         for (int i = 0; i < 2; ++i) {           for (int j = 0; j < 2; ++j) {             for (int t = 0; t < 2; ++t) {               dp[i][j][t] = 0;             }           }         }         dp[0][0][0] = v0;         dp[0][0][1] = v1;         for (auto pr : vec) {           int le = (pr.first <= a) + (pr.first == a);           int ri = (pr.second >= a + 1);           for (int i = 1; i >= 0; --i) {             for (int j = 1; j >= 0; --j) {               for (int t = 1; t >= 0; --t) {                 if (le && i) {                   if (le == 2 && t == 1) {                     dp[i][j][t] =                         modAdd(dp[i][j][t], modAdd(dp[0][j][0], dp[0][j][1]));                   } else if (le == 1) {                     dp[i][j][t] = modAdd(dp[i][j][t], dp[0][j][t]);                   }                 }                 if (ri && j) {                   dp[i][j][t] = modAdd(dp[i][j][t], dp[i][0][t]);                 }               }             }           }         }         if (dp[1][1][0] || dp[1][1][1]) {           cou += 2;           v0 = dp[1][1][0];           v1 = dp[1][1][1];         } else if (dp[1][0][0] || dp[1][0][1] || dp[0][1][0] || dp[0][1][1]) {           ++cou;           v0 = modAdd(dp[1][0][0], dp[0][1][0]);           v1 = modAdd(dp[1][0][1], dp[0][1][1]);         }       }       res.push_back({cou, v1});     }     sort(res.begin(), res.end());     ll ans = 0;     int mc = res.back().first;     while (!res.empty() && res.back().first == mc) {       ans = modAdd(ans, res.back().second);       res.pop_back();     }     cout << mc <<     << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 21;   long long int tot[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     long long int i, j, a[n], b, c, ans = 0;     for (i = 0; i < n; i++) {       cin >> a[i];       for (j = 0; j < N; j++) {         if (a[i] & (1LL << j)) {           tot[j]++;         }       }     }     for (i = 0; i < n; i++) {       long long int cur = 0;       for (j = 0; j < N; j++) {         if (tot[j]) {           cur += (1LL << j);           tot[j]--;         }       }       ans += (cur * cur);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool test_cases_exist = false;   void solve() {     long long int i, j, n, m, k, x, y, ans;     cin >> n;     vector<long long int> v(n);     for (auto &z : v) cin >> z;     long long int bit = 23;     long long int oneall = (1 << 23) - 1;     vector<long long int> dp((1 << 23), -1);     for (auto z : v) dp[z] = z;     for (i = 0; i < (1 << bit); i++) {       for (j = 0; j < bit; j++) {         if (dp[i] != -1) break;         if (i >> j & 1) dp[i] = dp[i ^ 1 << j];       }     }     for (auto z : v) cout << dp[oneall ^ z] <<    ;     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t = 1;     if (test_cases_exist) cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     cin >> n >> m;     long long a = 1;     long long b = 1;     long long c = 1000000007;     for (int i = 0; i < n; i++) {       b = b * (2 * m - 1);       b = b + a;       b = b % c;       a = a * m;       a = a % c;     }     cout << b;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dfn[2100], low[2100], tim, dis[2100], n, i, x, y, M, be[2100], m, j, ans,       du[2100];   vector<int> E[2100], e[2100], q;   void tarjan(int x, int ff) {     dfn[x] = low[x] = ++tim;     q.push_back(x);     for (int i = 0; i < e[x].size(); ++i)       if (e[x][i] != ff) {         if (!dfn[e[x][i]]) {           tarjan(e[x][i], x);           low[x] = min(low[x], low[e[x][i]]);         } else           low[x] = min(low[x], dfn[e[x][i]]);       }     if (low[x] == dfn[x]) {       ++M;       for (;;) {         int t = q.back();         q.pop_back();         be[t] = M;         if (t == x) break;       }     }   }   void dfs(int p, int ff, int dis) {     dfn[p] = 1;     if (dis > y) y = dis, x = p;     for (int i = 0; i < E[p].size(); ++i)       if (E[p][i] != ff) dfs(E[p][i], p, dis + 1);   }   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= m; ++i) {       scanf( %d%d , &x, &y);       e[x].push_back(y);       e[y].push_back(x);     }     for (i = 1; i <= n; ++i)       if (!dfn[i]) tarjan(i, 0);     for (i = 1; i <= n; ++i)       for (j = 0; j < e[i].size(); ++j)         if (be[i] != be[e[i][j]]) E[be[i]].push_back(be[e[i][j]]), du[be[i]]++;     memset(dfn, 0, sizeof(dfn));     for (i = 1; i <= M; ++i) {       if (!dfn[i]) {         y = 0;         dfs(i, 0, 1);         y = 0;         dfs(x, 0, 1);         if (y == 1)           ans--;         else           ans += y - 2 - 1;       }       if (du[i] <= 1) ans++;     }     printf( %d n , n - ans - 1);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   const int INF = 1e9;   struct dot {     int l, r;   };   typedef int node;   const int neutro = 0;   struct RMQ {     int sz;     node t[4 * MAXN];     node &operator[](int p) { return t[sz + p]; }     void init(int n) {       sz = 1 << (32 - __builtin_clz(n));       for (int i = (0); i < (int)(2 * sz); i++) t[i] = neutro;     }     void updall() {       for (int i = sz - 1; i >= 0; i--) {         t[i] = (t[2 * i] ^ t[2 * i + 1]);       }     }     node get(int i, int j) { return get(i, j, 1, 0, sz); }     node get(int i, int j, int n, int a, int b) {       if (j <= a || i >= b) return neutro;       if (i <= a && b <= j) return t[n];       int c = (a + b) / 2;       return (get(i, j, 2 * n, a, c) ^ get(i, j, 2 * n + 1, c, b));     }     void set(int p, node val) {       for (p += sz; p > 0 && t[p] != val;) {         t[p] = val;         p /= 2;         val = (t[p * 2] ^ t[p * 2 + 1]);       }     }   } rmq;   int n, grundy[MAXN], ans[MAXN];   vector<dot> events[MAXN];   int main() {     rmq.init(MAXN);     rmq.updall();     for (int i = (1); i < (int)(MAXN); i++) {       int s = i;       for (int j = i; s < MAXN; j++, s += j) {         if (j == i) continue;         events[s].push_back({i, j});       }     }     grundy[1] = grundy[2] = 0;     rmq.set(1, 0);     rmq.set(2, 0);     for (int i = (3); i < (int)(MAXN); i++) {       ans[i] = INF;       long long bm = 0;       for (auto ev : events[i]) {         long long v = rmq.get(ev.l, ev.r + 1);         if (v < 0) {           printf( %d %d %d : %d %d n , i, ev.l, ev.r, grundy[ev.l], grundy[ev.r]);           exit(-1);         }         bm |= (1ll << v);         if (v == 0) {           if (ev.r - ev.l + 1 < ans[i]) {             ans[i] = ev.r - ev.l + 1;           }         }       }       for (long long j = 0; j < 60; j++) {         if ((bm & (1ll << j)) == 0) {           grundy[i] = j;           break;         }       }       rmq.set(i, grundy[i]);     }     while (scanf( %d , &n) == 1) {       printf( %d n , grundy[n] == 0 ? -1 : ans[n]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, int> m;   int dis(string s1, string s2) { return (m[s2] - m[s1] + 12) % 12; }   int main() {     string s1, s2, s3;     m[ C ] = 0;     m[ C# ] = 1;     m[ D ] = 2;     m[ D# ] = 3;     m[ E ] = 4;     m[ F ] = 5;     m[ F# ] = 6;     m[ G ] = 7;     m[ G# ] = 8;     m[ A ] = 9;     m[ B ] = 10;     m[ H ] = 11;     cin >> s1 >> s2 >> s3;     if ((dis(s1, s2) == 4 && dis(s2, s3) == 3) ||         (dis(s1, s3) == 4 && dis(s3, s2) == 3) ||         (dis(s2, s1) == 4 && dis(s1, s3) == 3) ||         (dis(s2, s3) == 4 && dis(s3, s1) == 3) ||         (dis(s3, s1) == 4 && dis(s1, s2) == 3) ||         (dis(s3, s2) == 4 && dis(s2, s1) == 3))       cout <<  major n ;     else if ((dis(s1, s2) == 3 && dis(s2, s3) == 4) ||              (dis(s1, s3) == 3 && dis(s3, s2) == 4) ||              (dis(s2, s1) == 3 && dis(s1, s3) == 4) ||              (dis(s2, s3) == 3 && dis(s3, s1) == 4) ||              (dis(s3, s1) == 3 && dis(s1, s2) == 4) ||              (dis(s3, s2) == 3 && dis(s2, s1) == 4))       cout <<  minor n ;     else       cout <<  strange n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int n, v[N], id[N], now[N], p[N];   bool is_lucky(int x) {     while (x) {       if (x % 10 != 7 && x % 10 != 4) return false;       x /= 10;     }     return true;   }   void change(int pos1, int pos2) {     swap(now[p[pos1]], now[p[pos2]]);     swap(p[pos1], p[pos2]);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , v + i), p[i] = id[i] = now[i] = i;     if (is_sorted(v, v + n)) return printf( 0 n ), 0;     sort(id, id + n, [](int a, int b) { return v[a] < v[b]; });     int c = -1;     for (int i = 0; i < n; i++)       if (is_lucky(v[i])) {         c = i;         break;       }     if (c == -1) return printf( -1 n ), 0;     vector<pair<int, int>> ans;     for (int i = 0; i < n; i++) {       if (is_lucky(v[i])) {         c = i;         break;       }     }     for (int i = 0; i < n; i++)       if (p[i] != id[i]) {         if (now[c] != i) {           ans.emplace_back(now[c], i);           change(now[c], i);         }         if (now[c] != now[id[i]]) {           ans.emplace_back(now[c], now[id[i]]);           change(now[c], now[id[i]]);         }       }     printf( %d n , (int)ans.size());     for (auto x : ans) printf( %d %d n , x.first + 1, x.second + 1);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       if (a == b) {         cout << 0 <<   n ;         continue;       }       if (a - b > 5) {         int answ = 0;         int cant = (a - b) / 5;         answ = answ + cant;         a = a - cant * 5;         if (a - b == 1 or a - b == 2)           answ = answ + 1;         else {           if (a != b) answ = answ + 2;         }         cout << answ <<   n ;         continue;       }       if (b - a > 5) {         int answ = 0;         int cant = (b - a) / 5;         a = a + cant * 5;         answ = answ + cant;         if (b - a == 1 or b - a == 2)           answ = answ + 1;         else {           if (a != b) answ = answ + 2;         }         cout << answ <<   n ;         continue;       }       if (abs(a - b) == 1 or abs(a - b) == 2 or abs(a - b) == 5)         cout << 1 <<   n ;       else         cout << 2 <<   n ;     }     return 0;   }