malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool isprime(long long n) {     if (n < 2) return false;     if (n == 2) return true;     if (n % 2 == 0) return false;     for (int i = 3; i * i <= n; i = i + 2) {       if (n % i == 0) return false;     }     return true;   }   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     int temp = -1, cnt = 0;     for (int i = 0; i < n; i++) {       if (temp != a[i] && a[i] != 0) {         cnt++;         temp = a[i];       }     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d, e, f;     cin >> a >> b >> c >> d >> e >> f;     cout << (b * d * f > a * c * e || c == 0 && d > 0 || a == 0 && b > 0 && d > 0                  ?  Ron                   :  Hermione )          <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, n, z, n1, m1;     int a[10000], b[10000];     int g, j, k, p = 0;     int count = 0;     cin >> n >> m >> z;     n1 = n;     m1 = m;     if (z <= 10000 && z > 0 && n >= 1 && m >= 1) {       while (n <= z || m <= z) {         a[j] = n;         n = n + n1;         j++;         b[g] = m;         m = m + m1;         g++;       }       for (k = 0; k < j; k++) {         for (p = 0; p < g; p++) {           if (a[k] == b[p]) {             count++;           }         }       }       cout << count;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     int n;     cin >> n;     int a[n];     int ans = 0, sum = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       ans += a[i];     }     sum = ans;     sort(a, a + n);     for (int j = n - 1; j >= 1; j--) {       for (int x = 2; x < a[j]; x++) {         if (a[j] % x != 0) continue;         ans = min(ans, sum - a[j] - a[0] + a[j] / x + a[0] * x);       }     }     cout << ans << endl;     cerr <<  Time :   << (double)clock() / (double)CLOCKS_PER_SEC <<  s           <<   n ;     return 0;   }
#include <bits/stdc++.h>   int len;   int big;   int Dgt[30];   int N;   int ans;   void tochar(int);   int main() {     while (scanf( %d , &N) != EOF) {       memset(Dgt, 0, sizeof(Dgt));       ans = 0;       while (N) {         big = -1;         tochar(N);         for (int i = 0; i < len; i++) {           if (Dgt[i] > big) big = Dgt[i];         }         N -= big;         ans++;       }       printf( %d n , ans);     }   }   void tochar(int n) {     len = 0;     while (n) {       Dgt[len] = n % 10;       n /= 10;       len++;     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     long long a[3], b[3];     cin >> a[0] >> a[1] >> a[2];     cin >> b[0] >> b[1] >> b[2];     cout << max(0ll, a[0] - b[0] - b[2]) + max(0ll, a[1] - b[1] - b[0]) +                 max(0ll, a[2] - b[2] - b[1])          <<    ;     cout << min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0]) << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int t;     t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool equal(string s) {     int n = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  a ) n++;     }     if (n * 2 != s.length()) return false;     return true;   }   string s, s1, sex;   int n, d, k;   int main() {     cin >> k;     cin >> s;     n = s.length();     sex = s;     for (int i = 2; i <= n; i = i + 2) {       for (int j = 0; j <= n - i; j++) {         s1 = s.substr(j, i);         if (equal(s1)) {           while (s.find(s1) != -1) {             s.erase(s.find(s1), 1);             d++;           }         }       }     }     cout <<  25 ;   }
#include <bits/stdc++.h>   using namespace std;   int a[105][2];   int main() {     int n, sum = 0, b = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i][0]);       sum += a[i][0];     }     n /= 2;     sum = sum / n;     for (int j = 1; j <= n; j++) {       for (int i = 1; i <= 2 * n; i++) {         if (a[i][1] == 0) {           if (b == 0) {             printf( %d  , i);             b = a[i][0];             a[i][1] = 1;           } else {             if (b + a[i][0] == sum) {               printf( %d n , i);               b = 0;               a[i][1] = 1;               break;             }           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long SG[1110000] = {0, 1, 2, 1, 4, 3, 2, 1, 5,  6, 2, 1, 8,  7,  5,  9,                            8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12, 14, 13};   long long n, Ans, vis[1110000];   set<long long> Hehe;   int main() {     scanf( %I64d , &n);     long long Orz = (long long)(floor)(sqrt(1.0 * n));     for (long long i = 2; i * i <= n; ++i) {       long long c = 0;       if (vis[i]) continue;       for (long long j = i; j <= n; j *= i, c++) {         if (j > Orz)           Hehe.insert(j);         else           vis[j] = 1;       }       Ans ^= SG[c];     }     long long tmp = n - Orz - Hehe.size();     if (!(tmp & 1)) Ans ^= 1;     if (Ans)       printf( Vasya );     else       printf( Petya );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, cnt;   bool vis[1000005];   vector<int> G[1000005];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d%d , &u, &v);       G[u].push_back(v);     }     for (int u = 1; u <= n; u++) {       if (vis[u]) continue;       for (int i = 0; i < G[u].size(); i++) {         int v = G[u][i];         if (v > u) vis[v] = true;       }     }     for (int u = n; u > 0; u--) {       if (vis[u]) continue;       for (int i = 0; i < G[u].size(); i++) vis[G[u][i]] = true;     }     for (int i = 1; i <= n; i++)       if (!vis[i]) cnt++;     printf( %d n , cnt);     for (int i = 1; i <= n; i++)       if (!vis[i]) printf( %d  , i);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2013;   char p[1 << 20], s[205];   int k, n, m;   int main() {     gets(p);     gets(s);     cin >> k;     n = strlen(p);     m = strlen(s);     string minLex;     for (int i = 1; i <= k + 1; ++i) minLex +=  1 ;     int rboud = min(m, k), cntIn = n / k, R = n % k;     for (int d = 1; d <= rboud && cntIn * d <= m; ++d) {       string cans;       for (int i = 1; i <= k; ++i) cans +=  0 ;       {         int r = d - 1, i = min(n - 1, k - 1);         for (; i >= 0 && r >= 0; --i) {           int l1 = m / d + (r < m % d);           int l2 = cntIn + (i < R);           if (l1 != l2) continue;           bool diff = false;           for (int e = 0; e < l1 && !diff; ++e)             diff = s[r + e * d] != p[i + e * k];           if (diff) continue;           cans[i] =  1 ;           --r;         }         if (r == -1) minLex = min(minLex, cans);       }     }     if (minLex.size() > k)       cout << 0;     else       cout << minLex;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x, y, z;   } a[10];   int flag;   long long v[5];   long long dist(int i, int j) {     long long x = a[i].x - a[j].x;     long long y = a[i].y - a[j].y;     long long z = a[i].z - a[j].z;     return x * x + y * y + z * z;   }   int ok() {     int cnt = 0;     for (int i = 1; i < 8; i++)       for (int j = 0; j < i; j++) {         long long w = dist(i, j);         if (!cnt)           v[++cnt] = w;         else {           int k = 1;           while (k <= cnt && v[k] != w) k++;           if (k > cnt && cnt == 3) return 0;           if (k > cnt) v[++cnt] = w;         }       }     if (cnt == 3) return 1;     return 0;   }   void dfs(int p) {     if (flag) return;     if (p == 8) {       if (ok()) flag = 1;       return;     }     node tmp = a[p];     dfs(p + 1);     if (!flag) {       a[p].y = tmp.z;       a[p].z = tmp.y;       dfs(p + 1);     }     if (!flag) {       a[p].x = tmp.y;       a[p].y = tmp.x;       a[p].z = tmp.z;       dfs(p + 1);     }     if (!flag) {       a[p].x = tmp.y;       a[p].y = tmp.z;       a[p].z = tmp.x;       dfs(p + 1);     }     if (!flag) {       a[p].x = tmp.z;       a[p].y = tmp.x;       a[p].z = tmp.y;       dfs(p + 1);     }     if (!flag) {       a[p].x = tmp.z;       a[p].y = tmp.y;       a[p].z = tmp.x;       dfs(p + 1);     }   }   int main() {     for (int i = 0; i < 8; i++) cin >> a[i].x >> a[i].y >> a[i].z;     dfs(0);     if (!flag)       puts( NO );     else {       puts( YES );       for (int i = 0; i < 8; i++) printf( %d %d %d n , a[i].x, a[i].y, a[i].z);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1024;   int n, m;   bool b[MAXN][MAXN];   int main() {     cin >> n >> m;     for (register int l = (1); l < (int)(m + 1); ++l) {       int x, y;       cin >> x >> y;       x--;       y--;       b[x][y] = true;       for (register int xx = (x - 2); xx < (int)(x + 1); ++xx)         for (register int yy = (y - 2); yy < (int)(y + 1); ++yy)           if (xx >= 0 && yy >= 0) {             bool ok = true;             for (register int i = (0); i < (int)(3); ++i)               for (register int j = (0); j < (int)(3); ++j)                 if (!b[i + xx][j + yy]) ok = false;             if (ok) {               cout << l << endl;               return 0;             }           }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 1e6 + 66;   vector<int> g[N], f[N];   int used[N];   vector<int> topsort;   void dfs(int v) {     used[v] = 1;     for (int to : g[v])       if (used[to] != 1) dfs(to);     topsort.emplace_back(v);   }   int c[N];   void color(int v) {     if (false) cerr << v <<   color n ;     if (c[v] == 0) c[v] = v;     used[v] = 2;     for (int to : f[v])       if (used[to] != 2) c[to] = c[v], color(to);   }   int S;   vector<int> newg[N];   void fnd(int v) {     if (false) cerr << v <<   fnd n ;     used[v] = 3;     for (int to : newg[v])       if (used[to] != 3) fnd(to);     if (S == -1) S = v;   }   void clr(int v) {     used[v] = 4;     for (int to : g[v])       if (used[to] != 4) clr(to);   }   void solve() {     int n, m;     cin >> n >> m;     topsort.clear();     for (int i = 1; i <= n; ++i) {       used[i] = 0;       g[i].clear();       f[i].clear();       newg[i].clear();       c[i] = 0;     }     for (int i = 1; i <= m; ++i) {       int a, b;       cin >> a >> b;       g[a].emplace_back(b);       f[b].emplace_back(a);     }     for (int i = 1; i <= n; ++i) {       if (!used[i]) {         dfs(i);       }     }     reverse(topsort.begin(), topsort.end());     for (int i : topsort) {       if (used[i] != 2) {         color(i);       }     }     for (int i = 1; i <= n; ++i) {       if (false) cerr << c[i] <<    n [i == n];       for (int j : g[i]) {         newg[c[i]].emplace_back(c[j]);       }     }     S = -1, fnd(c[1]);     clr(S);     if (false) cerr << S <<   S n ;     vector<int> j, p;     for (int i = 1; i <= n; ++i) {       if (used[i] != 4)         p.emplace_back(i);       else         j.emplace_back(i);     }     assert(!j.empty());     if (p.empty()) {       cout <<  No n ;     } else {       cout <<  Yes n  << j.size() <<     << p.size() <<   n ;       for (int i : j) cout << i <<    ;       cout <<   n ;       for (int i : p) cout << i <<    ;       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     int TT;     cin >> TT;     while (TT--) solve();   }
#include <bits/stdc++.h>   using namespace std;   void read_file(bool outToFile = true) {}   int n, K;   const int MAXN = 200000 + 99;   int A[MAXN];   set<int> X;   int vis[MAXN];   bool check() {     memset(vis, 0, sizeof vis);     stack<int> s;     int idx = 0;     int cur = 1;     while (true) {       while (s.empty() || s.top() != cur) {         s.push(A[idx]);         vis[A[idx]] = 1;         idx++;       }       s.pop();       cur++;       if (cur == n + 1) break;       if (vis[cur] && cur != s.top()) return false;     }     return true;   }   int main() {     read_file();     while (scanf( %d%d , &n, &K) != -1) {       X.clear();       memset(vis, 0, sizeof vis);       for (int i = 0; i < K; i++) {         scanf( %d , &A[i]);         if (A[i] != 1) X.insert(A[i] - 1);         vis[A[i]] = 1;       }       for (int i = 0; i < K; i++) {         if (X.count(A[i])) X.erase(A[i]);       }       int idx = K;       while (!X.empty()) {         int x = *X.begin();         X.erase(X.begin());         A[idx++] = x;         vis[x] = 1;         if (x == 1) continue;         if (!vis[x - 1]) X.insert(x - 1);       }       int mx = 0;       for (int i = 0; i < idx; i++) mx = max(mx, A[i]);       for (int i = n; i > mx; i--) A[idx + n - i] = i;       if (!check()) {         printf( -1 n );         continue;       }       for (int i = 0; i < n; i++) printf( %d%c , A[i],    n [i == n - 1]);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, t, tt, i;     long long t1, t2, t3, t4;     while (~scanf( %lld %lld , &a, &b)) {       t = b - a;       t1 = a % 10;       t2 = b % 10;       t3 = (a / 10) % 10;       t4 = (b / 10) % 10;       if (t >= 10 || (t4 != t3)) {         printf( 0 n );       } else {         if (t1 <= 2 && t2 >= 5)           printf( 0 n );         else {           tt = 1;           for (i = t1 + 1; i <= t2; i++) {             tt *= i;           }           printf( %lld n , tt % 10);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 100050, mod = 1000000007;   ;   int n, ans, k;   int fa[maxN], c[maxN];   int getfa(int u) {     if (fa[u] == u) return u;     int t = fa[u];     fa[u] = getfa(fa[u]);     while (c[u] < 0) c[u] += mod;     while (c[t] < 0) c[t] += mod;     c[u] = (c[u] + c[t]) % mod;     return fa[u];   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       fa[i] = i;       c[i] = 0;     }     int v, x;     for (int i = 1; i <= n; i++) {       scanf( %d , &k);       for (int j = 1; j <= k; j++) {         scanf( %d%d , &v, &x);         int t = getfa(v);         fa[t] = i;         while (c[v] < 0) c[v] += mod;         while (x < 0) x += mod;         c[t] = (c[v] + x) % mod;         while (c[t] < 0) c[t] += mod;         while (ans < 0) ans += mod;         ans = (ans + c[t]) % mod;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:5000000000 )   const long long mod = 1000000007;   long long Inf = (long long)2e9;   long long LINF = (long long)1e18 + 1e17;   using namespace std;   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     vector<long long> a(n);     vector<bool> can(n, true);     map<long long, set<int>> pos;     for (int(i) = 0; (i) < n; (i)++) {       cin >> a[i];       pos[a[i]].insert(i);     }     int k = n;     while (pos.size()) {       if (pos.begin()->second.size() < 2) {         pos.erase(pos.begin());         continue;       }       int i1 = *pos.begin()->second.begin();       pos.begin()->second.erase(i1);       int i2 = *pos.begin()->second.begin();       pos.begin()->second.erase(i2);       long long x = pos.begin()->first;       k--;       can[i1] = false;       pos[2 * x].insert(i2);       a[i2] = 2 * x;     }     cout << k << endl;     for (int(i) = 0; (i) < n; (i)++)       if (can[i]) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (1 << 30);   const int N = 100005;   int n, k;   int g[105][105];   int main() {     int i, j, t, cas = 0;     memset(g, 0, sizeof(g));     scanf( %d , &k);     for (n = 3; n <= 100; n++) {       if ((n) * (n - 1) * (n - 2) / 6 > k) break;     }     n--;     k -= (n) * (n - 1) * (n - 2) / 6;     for (i = 1; i <= n; i++) {       for (j = 1; j <= n; j++) {         if (i == j) continue;         g[i][j] = 1;       }     }     while (k) {       for (i = 2;; i++) {         if ((i) * (i - 1) / 2 > k) break;       }       i--;       n++;       for (j = 1; j <= i; j++) g[j][n] = g[n][j] = 1;       k -= (i) * (i - 1) / 2;     }     printf( %d n , n);     for (i = 1; i <= n; i++) {       for (j = 1; j <= n; j++) {         printf( %d , g[i][j]);       }       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   long long int mod = 1e9 + 7;   long long int mod1 = 998244351;   long long int power(long long int a, long long int b) {     if (b == 0)       return 1;     else if (b % 2 == 0)       return power(a * a % mod, b / 2) % mod;     else       return (a % mod * power(a * a % mod, b / 2)) % mod;   }   long long int bit(long long int x) { return __builtin_popcountll(x); }   long long int temp1, temp2, temp3, temp4;   void fi(long long int x3, long long int y3, long long int x4,           long long int y4) {     long long int x5 = max(temp1, x3);     long long int y5 = max(temp2, y3);     long long int x6 = min(temp3, x4);     long long int y6 = min(temp4, y4);     if (x5 > x6 || y5 > y6) {       temp1 = -1000000009, temp2 = -1e9 - 1, temp3 = -1e9 - 1, temp4 = -1e9 - 1;       return;     }     temp1 = x5;     temp2 = y5;     temp3 = x6;     temp4 = y6;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n;     cin >> n;     long long int a[n], b[n], c[n], d[n];     for (int i = 0; i < n; ++i) {       cin >> a[i] >> b[i] >> c[i] >> d[i];     }     temp1 = a[0], temp2 = b[0], temp3 = c[0], temp4 = d[0];     long long int count = 0;     vector<int> index;     for (int i = 1; i < n; ++i) {       long long int p = temp1, p1 = temp2, p3 = temp3, p4 = temp4;       fi(a[i], b[i], c[i], d[i]);       if (temp1 == -1000000009) {         temp1 = p;         temp2 = p1;         temp3 = p3;         temp4 = p4;         count++;       }     }     if (count <= 1) {       cout << temp1 <<     << temp2 <<   n ;       return 0;     }     temp1 = a[n - 1];     temp2 = b[n - 1];     temp3 = c[n - 1];     temp4 = d[n - 1];     count = 0;     for (int i = n - 1; i >= 0; --i) {       long long int p = temp1, p1 = temp2, p3 = temp3, p4 = temp4;       fi(a[i], b[i], c[i], d[i]);       if (temp1 == -1000000009) {         temp1 = p;         temp2 = p1;         temp3 = p3;         temp4 = p4;         count++;       }     }     if (count <= 1) {       cout << temp1 <<     << temp2 <<   n ;       return 0;     }     temp1 = a[1], temp2 = b[1], temp3 = c[1], temp4 = d[1], count = 0;     for (int i = 2; i < n; ++i) {       long long int p = temp1, p1 = temp2, p3 = temp3, p4 = temp4;       fi(a[i], b[i], c[i], d[i]);     }     cout << temp3 <<     << temp4 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, numone, numtwo, sum, tmp;   char nlong;   string nameone, nametwo;   string read;   struct node {     string name;     int goal, moregoal, score;     int q;   } wxy[100];   bool check(int t) {     for (int i = 0; i < tmp; i++)       if (wxy[t].name[i] != nameone[i]) return false;     return true;   }   bool checktwo(int t) {     for (int i = tmp + 1; i < sum; i++)       if (wxy[t].name[i - tmp - 1] != nametwo[i - tmp - 1]) return false;     return true;   }   bool cmpfirst(node a, node b) {     if (a.score > b.score) return 1;     if (a.score < b.score) return 0;     if (a.moregoal > b.moregoal) return 1;     if (a.moregoal < b.moregoal) return 0;     if (a.goal > b.goal) return 1;     return 0;   }   bool cmplast(node a, node b) { return a.name < b.name; }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> wxy[i].name;       wxy[i].q = wxy[i].name.size();     }     for (int j = 1; j <= n * (n - 1) / 2; j++) {       sum = 0;       tmp = 0;       nameone =   , nametwo =   ;       numone = numtwo = 0;       while (1) {         scanf( %c , &nlong);         if (nlong ==  - )           break;         else if ((nlong >=  a  && nlong <=  z ) ||                  (nlong >=  A  && nlong <=  Z )) {           nameone += nlong;           sum++;         }       }       tmp = sum;       sum++;       while (1) {         scanf( %c , &nlong);         if (nlong ==    )           break;         else {           nametwo += nlong;           sum++;         }       }       while (1) {         scanf( %c , &nlong);         if (nlong ==  : )           break;         else if (nlong >=  0  && nlong <=  9 )           numone = numone * 10 + nlong -  0 ;       }       cin >> numtwo;       int one, two;       for (int i = 1; i <= n; i++)         if (wxy[i].q == tmp)           if (check(i)) {             one = i;             break;           }       for (int i = 1; i <= n; i++)         if (wxy[i].q + tmp + 1 == sum)           if (checktwo(i)) {             two = i;             break;           }       wxy[one].goal += numone;       wxy[two].goal += numtwo;       wxy[one].moregoal += numone - numtwo;       wxy[two].moregoal += numtwo - numone;       if (numone > numtwo)         wxy[one].score += 3;       else if (numtwo > numone)         wxy[two].score += 3;       else {         wxy[one].score++;         wxy[two].score++;       }     }     sort(wxy + 1, wxy + n + 1, cmpfirst);     sort(wxy + 1, wxy + (n) / 2 + 1, cmplast);     for (int i = 1; i <= n / 2; i++) cout << wxy[i].name << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[26];   char s[100005];   int dp[100005][26];   int main(void) {     int n;     scanf( %s , s + 1);     scanf( %d , &n);     for (int i = 0; i < 26; i++) f[i] = -1;     for (int i = 0; i < n; i++) {       char x[10];       scanf( %s , x);       f[x[0] -  a ] = x[1] -  a ;       f[x[1] -  a ] = x[0] -  a ;     }     for (int i = 1; s[i]; i++) {       int mins = 1 << 20;       for (int j = 0; j < 26; j++)         if (j != f[s[i] -  a ]) mins = min(dp[i - 1][j], mins);       for (int j = 0; j < 26; j++) {         if (j == s[i] -  a ) {           dp[i][j] = mins;         } else {           dp[i][j] = dp[i - 1][j] + 1;         }       }     }     int m = strlen(s + 1);     printf( %d n , *min_element(dp[m], dp[m] + 26));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     cin >> T;     while (T--) {       int a, b;       cin >> a >> b;       int x = abs(a - b);       int ans = x / 5;       x %= 5;       ans += x / 2;       x %= 2;       ans += x;       cout << ans << endl;     }     return 0;   }