malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX;   const int N = 2 * 1e3 + 10;   const long double eps = 1e-9;   const int mod = 998244353;   char a[N][N];   int d[N][N], v[N][N], n, m;   bool used[N][N];   void nxt(char c, int &x, int &y) {     if (c ==  U )       --x;     else if (c ==  D )       ++x;     else if (c ==  R )       ++y;     else       --y;     return;   }   int cx, cy;   void fillcycle() {     int x = cx, y = cy, cnt = 1;     nxt(a[x][y], x, y);     while (!(x == cx && y == cy)) {       ++cnt;       nxt(a[x][y], x, y);     }     x = cx, y = cy;     d[x][y] = cnt;     v[x][y] = 2;     nxt(a[x][y], x, y);     while (!(x == cx && y == cy)) {       v[x][y] = 2;       d[x][y] = cnt;       nxt(a[x][y], x, y);     }     return;   }   void cycle(int x, int y) {     while (!(x <= 0 || y <= 0 || x > n || y > m) && !used[x][y]) {       v[x][y] = 0;       used[x][y] = true;       nxt(a[x][y], x, y);     }     if (x <= 0 || y <= 0 || x > n || y > m) return;     if (v[x][y] != 0) return;     cx = x;     cy = y;     fillcycle();     return;   }   void gg(int x, int y) {     while (x > 0 && y > 0 && x <= n && y <= m && v[x][y] == 0) {       v[x][y] = 1;       nxt(a[x][y], x, y);     }     return;   }   void dfs(int x, int y) {     int tx = x, ty = y;     nxt(a[x][y], tx, ty);     stack<pair<int, int> > vc;     vc.push({x, y});     int c = 1;     while (!(tx <= 0 || ty <= 0 || x > n || y > m) && d[tx][ty] == -1) {       vc.push({tx, ty});       nxt(a[tx][ty], tx, ty);     }     if (tx <= 0 || ty <= 0 || x > n || y > m)       c = 1;     else       c = d[tx][ty] + 1;     while (!vc.empty()) {       tx = vc.top().first;       ty = vc.top().second;       vc.pop();       d[tx][ty] = c;       ++c;     }     return;   }   void solve() {     cin >> n >> m;     for (int i = 0; i <= n + 1; ++i) {       fill(d[i], d[i] + m + 1, -1);       fill(used[i], used[i] + m + 1, false);       fill(v[i], v[i] + m + 1, -1);       if (i > 0 && i <= n) {         for (int j = 1; j <= m; ++j) cin >> a[i][j];       }     }     for (int i = 0; i <= n + 1; ++i) d[i][0] = d[i][m + 1] = 0;     for (int i = 0; i <= m + 1; ++i) d[0][i] = d[n + 1][i] = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (!used[i][j]) {           cycle(i, j);           gg(i, j);         }       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (d[i][j] == -1) dfs(i, j);       }     }     int x = 1, y = 1, ans = -2;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (ans < d[i][j]) ans = d[i][j], x = i, y = j;       }     }     cout << x <<     << y <<     << ans <<   n ;     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[300005];   string s, p;   vector<long long> v;   int main() {     ios_base::sync_with_stdio(false);     long long i, j, k, l, m, x, y, r, n, t;     cin >> n >> m;     for (i = 1; i <= n; i++) {       cin >> x;       if (x < 300005) a[x] = 1;     }     long long msd = 0;     long long cnt = 0;     for (i = 1; i <= 300000; i++) {       if (msd >= m) {         break;       }       if (a[i] == 0) {         if ((msd + i) <= m) {           cnt++;           v.push_back(i);           msd += i;         }       }     }     cout << cnt << endl;     for (i = 0; i < v.size(); i++) {       cout << v[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long m = 100000, n = 0, a[1005], b[1005], u, i, j, k = 0, c, d, s = 0,               r = 0;     char str1[1005], str2[1005];     cin >> c >> d;     scanf( %s , str1);     scanf( %s , str2);     for (i = 0, j = 0;; i++, j++) {       if (str1[i] != str2[j]) {         k++;         a[n] = i + 1;         n++;       }       if (i == c - 1) {         i = -1;         s++;         j = -1;         j += s;         if (k < m) {           m = k;           for (r = 0; r < k; r++) {             b[r] = a[r];           }         }         r = 0;         k = 0;         n = 0;         if (s == (d - c + 1)) break;       }     }     cout << m << endl;     for (u = 0; u < m; u++) cout << b[u] <<    ;   }
#include <bits/stdc++.h>   int ab(int x) {     if (x < 0) {       x = x * -1;     }     return x;   }   int main() {     int x, y, z, x1, x2, y1, y2;     scanf( %d %d , &x, &y);     z = ab(x) + ab(y);     if (x < 0) {       x1 = -1 * z;       x2 = 0;       if (y < 0) {         y1 = 0;         y2 = -1 * z;       } else {         y1 = 0;         y2 = z;       }     } else {       x1 = 0;       x2 = z;       if (y < 0) {         y2 = 0;         y1 = -1 * z;       } else {         y2 = 0;         y1 = z;       }     }     printf( %d %d %d %d , x1, y1, x2, y2);   }
#include <bits/stdc++.h>   using namespace std;   char a[310][310];   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     int t = min(m, n);     for (int d = 1; d < t; d++) {       for (int i = d; i < n - d; i++) {         for (int j = d; j < m - d; j++) {           if (a[i][j] ==  *  && a[i][j - d] ==  *  && a[i][j + d] ==  *  &&               a[i - d][j] ==  *  && a[i + d][j] ==  * )             k--;           if (k == 0) {             cout << i + 1 <<     << j + 1 << endl;             cout << i + 1 - d <<     << j + 1 << endl;             cout << i + 1 + d <<     << j + 1 << endl;             cout << i + 1 <<     << j - d + 1 << endl;             cout << i + 1 <<     << j + d + 1 << endl;             return 0;           }         }       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0;     char ch = getchar();     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x;   }   const int maxn = 100005;   int n;   long long zero = 0, one = 0, z1 = 0, o1 = 0;   char s[maxn], t[maxn];   int main() {     n = read();     scanf( %s%s , s, t);     for (int i = 0; i < n; ++i) {       if (s[i] ==  0 ) {         zero++;         if (t[i] ==  0 ) z1++;       } else {         one++;         if (t[i] ==  0 ) o1++;       }     }     printf( %lld n , z1 * one + o1 * zero - z1 * o1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   char ch[] = { N ,  S ,  E ,  W };   template <class T>   inline T biton(T n, T pos) {     return n | ((T)1 << pos);   }   template <class T>   inline T bitoff(T n, T pos) {     return n & ~((T)1 << pos);   }   template <class T>   inline T ison(T n, T pos) {     return (bool)(n & ((T)1 << pos));   }   template <class T>   inline T gcd(T a, T b) {     while (b) {       a = a % b;       swap(a, b);     }     return a;   }   template <class T>   inline T bigmod(T p, T e, T m) {     T ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % m;       p = (p * p) % m;     }     return (T)ret;   };   vector<int> primes;   void sieve(int n) {     vector<int> vec(n + 1);     vec[0] = vec[1] = 1;     for (int i = 2; i <= n; i++) {       if (vec[i] == 0) {         for (int j = i * 2; j <= n; j = j + i) {           vec[j] = 1;         }       }     }     for (int i = 0; i <= n; i++) {       if (vec[i] == 0) {         primes.push_back(i);       }     }   }   void solve() {     int n;     cin >> n;     vector<int> items(n);     for (int i = 0; i < n; i++) {       cin >> items[i];     }     map<int, vector<int>> mp;     for (int i = 0; i < n; i++) {       int it = items[i];       for (int j = 0; j < primes.size() && primes[j] * primes[j] <= it; j++) {         int cnt = 0;         while (it % primes[j] == 0) {           cnt++;           it = it / primes[j];         }         if (cnt > 0) {           mp[primes[j]].push_back(cnt);         }       }       if (it > 1) {         mp[it].push_back(1);       }     }     long long res = 1;     for (auto m : mp) {       sort(m.second.begin(), m.second.end());       if (m.second.size() == n - 1) {         res = res * pow(m.first, m.second[0]);       } else if (m.second.size() == n) {         res = res * pow(m.first, m.second[1]);       }     }     cout << res <<   n ;     ;   }   int main() {     ios_base::sync_with_stdio(false);     cout.setf(ios::fixed);     cout.precision(10);     cout.tie(nullptr);     cin.tie(nullptr);     sieve(2e5);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 105;   vector<long long> a, b, v;   string s;   long long n, m, x;   long long killAll() {     vector<long long> hlp;     long long i = 0;     for (long long x : b) {       while (i < v.size() and v[i] <= x) {         hlp.push_back(v[i]);         i++;       }       if (i == v.size())         return 0;       else         i++;     }     while (i < v.size()) {       hlp.push_back(v[i]);       i++;     }     long long ans = 0;     long long j = hlp.size() - 1;     for (__typeof(((long long)a.size() - 1)) i = ((long long)a.size() - 1);          i >= (0); i--) {       long long x = a[i];       if (j < i) return 0;       if (hlp[j] >= x)         ans += (hlp[j] - x);       else         return 0;       j--;     }     while (j >= 0) {       ans += hlp[j];       j--;     }     return ans;   }   long long killExact(long long k) {     if (k > a.size()) return 0;     long long i = k - 1;     long long j = v.size() - 1;     long long ans = 0;     while (i >= 0 and j >= 0) {       if (v[j] >= a[i])         ans += (v[j] - a[i]);       else         return 0;       j--;       i--;     }     return ans;   }   long long killFew() {     long long ans = 0;     for (long long i = 1; i <= m; i++) ans = max(ans, killExact(i));     return ans;   }   long long solve() {     cin >> n >> m;     for (__typeof((n)) i = (1); i <= (n); i++) {       cin >> s >> x;       if (s ==  ATK )         a.push_back(x);       else         b.push_back(x);     }     for (__typeof((m)) i = (1); i <= (m); i++) {       cin >> x;       v.push_back(x);     }     sort((v).begin(), (v).end());     sort((a).begin(), (a).end());     sort((b).begin(), (b).end());     cout << max(killAll(), killFew()) <<   n ;     return 0;   }   signed main() {     long long t;     ios_base::sync_with_stdio(false);     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int a[n];       for (int i = 0; i < n; ++i) {         cin >> a[i];       }       for (int i = n - 1; i >= 0; --i) {         int temp = i % 2 != 0 ? -a[i] : a[i];         cout << temp <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool ckmin(T& a, const T& b) {     return b < a ? a = b, 1 : 0;   }   template <class T>   bool ckmax(T& a, const T& b) {     return a < b ? a = b, 1 : 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     stack<char> st;     string s;     cin >> s;     long long cnt = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  ( ) {         cnt++;       } else {         cnt--;       }     }     if (cnt != 0) {       cout <<  -1 ;       return 0;     }     long long ans = 0, len = 0, len1 = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  ( ) {         if (len == 0) {           st.push( ( );         } else {           len1++;         }       } else {         if (st.size() > 0) {           st.pop();         } else {           len++;         }       }       if (len == len1) {         ans += len + len1;         len = 0;         len1 = 0;       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = (int)1e5 + 100;   const int mod = (int)1e9 + 7;   int n, k, a[maxn], c[maxn];   bool was[maxn];   vector<int> g[maxn];   bool check(int pos) {     memset(was, 0, sizeof(was));     int used = 0, unused = pos;     for (int i = pos; i >= 1; i--) {       if (was[a[i]] || a[i] == 0) continue;       if (unused > c[a[i]]) {         was[a[i]] = 1;         unused -= 1 + c[a[i]];       }     }     for (int i = (1); i <= (k); ++i)       if (!was[i]) return 0;     return 1;   }   int main() {     scanf( %d%d , &n, &k);     vector<int> st;     for (int i = (1); i <= (n); ++i) {       scanf( %d , a + i);       if (a[i] > 0) {         g[a[i]].push_back(i);         st.push_back(i);       }     }     for (int i = (1); i <= (k); ++i) scanf( %d , c + i);     int l = 0, r = (int)st.size() - 1, ans = -1;     while (l <= r) {       int m = (l + r) >> 1;       if (check(st[m]))         ans = m, r = m - 1;       else         l = m + 1;     }     if (ans == -1)       puts( -1 );     else       printf( %d , st[ans]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     string s;     int first;     cin >> s >> first;     string w = string(s.length(),  w );     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  0 ) {         if (i - first >= 0) w[i - first] =  0 ;         if (i + first < s.length()) w[i + first] =  0 ;       }     }     for (int i = 0; i < s.length(); i++) {       if (w[i] ==  w ) w[i] =  1 ;     }     string newS =   ;     for (int i = 0; i < s.length(); i++) {       bool one = false;       if (i - first >= 0 && w[i - first] ==  1 ) one = true;       if (i + first < s.length() && w[i + first] ==  1 ) one = true;       if (one) {         newS +=  1 ;       } else         newS +=  0 ;     }     if (s == newS) {       cout << w <<   n ;     } else {       cout <<  -1 n ;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[10][10];   int t, i, j, o, x[2], y[2], ok;   int main() {     scanf( %d , &t);     while (t--) {       for (i = o = 0; i < 8; i++) {         scanf( %s , s + i);         for (j = 0; j < 8; j++)           if (s[i][j] ==  K ) x[o] = i, y[o++] = j;       }       if (abs(x[0] - x[1]) % 4 || abs(y[0] - y[1]) % 4)         puts( NO );       else         puts( YES );     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4 )   #pragma GCC optimize( unroll-loops )   using namespace std;   using i64 = int64_t;   using ui64 = uint64_t;   template <class A, class B>   bool smin(A &x, B &&y) {     if (y < x) {       x = y;       return true;     }     return false;   }   template <class A, class B>   bool smax(A &x, B &&y) {     if (x < y) {       x = y;       return true;     }     return false;   }   int const N = int(1e5 + 10);   int const INF = int(1.2e9);   struct node {     int min_pos = INF;     int min_neg = INF;   };   node a[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int q;     cin >> q;     while (q--) {       int t, l, r;       cin >> t >> l >> r;       --l, --r;       if (t == 1) {         int k;         cin >> k;         if (k > 0) {           for (int i = l; i < r; ++i) {             smin(a[i].min_pos, k);           }         } else {           k = -k;           for (int i = l; i < r; ++i) {             smin(a[i].min_neg, k);           }         }       } else {         i64 ans = 0;         for (int i = l; i < r; ++i) {           int const x = a[i].min_pos;           int const y = a[i].min_neg;           if (x != INF && y != INF) {             ans += x + y;           }         }         cout << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, ans = 1, bell[1005], c[1005][1005];   char s[55][1005];   map<long long, int> w;   long long get(int x) {     long long res = 0;     for (int i = 1; i <= n; i++) res = (res << 1) + s[i][x] - 48;     return res;   }   int main() {     scanf( %d%d , &m, &n);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf(  %c , &s[i][j]);     for (int i = 1; i <= m; i++) w[get(i)]++;     c[0][0] = 1;     bell[0] = 1;     for (int i = 1; i <= m; i++)       for (int j = 0; j <= i; j++) {         c[i][j] = (c[i - 1][j - 1] + (long long)j * c[i - 1][j]) % 1000000007;         bell[i] = (bell[i] + c[i][j]) % 1000000007;       }     for (int i = 1; i <= m; i++) {       long long num = get(i);       ans = (long long)ans * bell[w[num]] % 1000000007;       w[num] = 0;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   int N;   int Weight[300005];   long long SubWeight[300005];   std::vector<int> ADC[300005];   inline void AddEdge(int x, int y) {     ADC[x].push_back(y);     ADC[y].push_back(x);   }   long long Max;   int Count;   void DFS(bool Step, int Node = 1, int Parent = 0) {     SubWeight[Node] = Weight[Node];     for (auto Vecin : ADC[Node])       if (Vecin != Parent) {         DFS(Step, Vecin, Node);         SubWeight[Node] += std::max(SubWeight[Vecin], 0LL);       }     if (Step)       Max = std::max(Max, SubWeight[Node]);     else if (SubWeight[Node] == Max)       ++Count, SubWeight[Node] = 0;   }   void Citire() {     scanf( %d , &N);     for (int i = 1; i <= N; ++i) scanf( %d , &Weight[i]);     for (int i = 1, x, y; i < N; ++i) scanf( %d%d , &x, &y), AddEdge(x, y);   }   void Rezolvare() {     Max = -1000000005;     DFS(1);     DFS(0);     printf( %I64d %d , Count * Max, Count);   }   int main() {     Citire();     Rezolvare();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int id[n];     vector<int> ans(k, -1);     for (int i = 0; i < n; i++) {       cin >> id[i];       if (find(ans.begin(), ans.end(), id[i]) == ans.end()) {         ans.insert(ans.begin(), id[i]);         ans.resize(k);       }     }     int count = 0;     for (int i = 0; i < k; i++) {       if (ans[i] >= 0) {         count++;       }     }     cout << count << endl;     for (int i = 0; i < count; i++) {       cout << ans[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int tt;   string input;   int main() {     cin >> tt;     for (int qq = 1; qq <= tt; qq++) {       cin >> input;       int count[250] = {};       for (char c : input) count[c -  a ]++;       int diff = 0;       for (int i = 0; i < 250; i++) {         if (count[i] > 0) diff++;       }       if (diff == 1)         cout <<  -1  << endl;       else {         sort(input.begin(), input.end());         cout << input << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const int inf = 0x3f3f3f3f;   const long long inff = 0x3f3f3f3f3f3f3f3f;   int n;   int a[200010];   int dp[200010];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       a[i] += a[i - 1];     }     dp[n] = a[n];     int mx = dp[n];     for (int i = n - 1; i >= 2; i--) {       dp[i] = max(a[i] - mx, mx);       mx = max(a[i] - mx, mx);     }     cout << mx << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T abs(T t) {     return t < 0 ? -t : t;   }   const long long modn = 1000000007;   inline long long mod(long long x) { return x % modn; }   const int MAXN = 212345;   int n, m, k;   int s[MAXN];   int main() {     scanf( %d , &n);     for (int a = 0; a < n; a++) {       scanf( %d , s + a);     }     int mx = 0;     for (int i = 0; i <= n; i++) {       int cnt = 0;       for (int a = 0; a < n; a++) {         if (a < i)           cnt += (s[a] == 0);         else           cnt += (s[a] == 1);       }       mx = max(mx, cnt);     }     printf( %d n , mx);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2600;   int n, m;   char s[60][60];   int addedge[MAXN][MAXN];   int blocks[60][60];   int cnt;   int dis[MAXN];   bool inside(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }   vector<int> B;   vector<int> e[MAXN];   int dx[] = {-1, 0, 1, 0};   int dy[] = {0, -1, 0, 1};   int MAXLEN = 0;   int color[MAXN];   void bfs(int x, int y, char st) {     ++cnt;     if (st ==  W )       color[cnt] = 1;     else       color[cnt] = 0;     if (st ==  B ) B.push_back(cnt);     queue<pair<int, int> > q;     blocks[x][y] = cnt;     q.push(make_pair(x, y));     while (!q.empty()) {       int lx = q.front().first, ly = q.front().second;       q.pop();       for (int i = 0; i < 4; i++) {         int nx = lx + dx[i], ny = ly + dy[i];         if (inside(nx, ny) && s[nx][ny] == st && !blocks[nx][ny]) {           blocks[nx][ny] = cnt;           q.push(make_pair(nx, ny));         }       }     }   }   void spfa(int st) {     for (int i = 1; i <= cnt; i++) dis[i] = 0x3F3F3F3F;     dis[st] = 0;     queue<int> q;     q.push(st);     while (!q.empty()) {       int u = q.front();       q.pop();       for (int i = 0; i < e[u].size(); i++) {         int v = e[u][i];         if (dis[v] > dis[u] + 1) {           dis[v] = dis[u] + 1;           q.push(v);         }       }     }     int MX = 0;     for (int i = 0; i < B.size(); i++) {       if (dis[B[i]] > MX) MX = dis[B[i]];     }     MAXLEN = min(MAXLEN, MX + 1);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , s[i]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (!blocks[i][j]) {           bfs(i, j, s[i][j]);         }     for (int x = 0; x < n; x++)       for (int y = 0; y < m; y++) {         for (int i = 0; i < 4; i++) {           int nx = x + dx[i], ny = y + dy[i];           if (inside(nx, ny) && blocks[nx][ny] != blocks[x][y]) {             {               int u = blocks[x][y], v = blocks[nx][ny];               if (addedge[u][v]) continue;               e[u].push_back(v);               addedge[u][v] = true;             }           }         }       }     if (B.size() == 0)       puts( 0 );     else {       MAXLEN = 0x3F3F3F3F;       for (int i = 1; i <= cnt; i++) spfa(i);       printf( %d n , MAXLEN);     }     return 0;   }
#include <bits/stdc++.h>   int S(int x) { return x & 1 ? -(x + 1) / 2 : x / 2; }   int main() {     int q;     scanf( %d , &q);     while (q--) {       int l, r;       scanf( %d%d , &l, &r);       printf( %d n , S(r) - S(l - 1));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int m;     cin >> n >> m;     int a[6];     int b[6];     for (int i = 1; i < 6; i++) {       if (n % 5 >= i) {         a[i] = (n / 5) + 1;       } else {         a[i] = n / 5;       }     }     for (int i = 1; i < 6; i++) {       if (m % 5 >= i) {         b[i] = (m / 5) + 1;       } else {         b[i] = m / 5;       }     }     long long int y = 0;     y += a[5];     y *= b[5];     long long int t = 0;     t += a[4];     t *= b[1];     long long int s = 0;     s += a[1];     s *= b[4];     long long int c = 0;     c += a[2];     c *= b[3];     long long int f = 0;     f += a[3];     f *= b[2];     long long int k = y + t + s + c + f;     cout << k;     return 0;   }