malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100 * 1000 + 7, MAX_LOG = 20;   int n, m;   vector<int> adj[MAXN];   bool isPassed[MAXN];   int par[MAXN][MAX_LOG], cycleCnt[MAXN], h[MAXN];   void pre(int root) {     isPassed[root] = true;     for (auto nei : adj[root]) {       if (!isPassed[nei]) {         par[nei][0] = root;         h[nei] = h[root] + 1;         pre(nei);         cycleCnt[root] = cycleCnt[root] + cycleCnt[nei];       } else if (par[root][0] != nei and h[nei] < h[root]) {         cycleCnt[nei]--;         cycleCnt[root]++;       }     }     return;   }   int nanCyCnt[MAXN][MAX_LOG];   void dfs(int root, int lstRt) {     par[root][0] = lstRt;     if (lstRt != -1 and cycleCnt[root] == 0) nanCyCnt[root][0] = 1;     for (int i = 1; i < MAX_LOG and h[root] >= (1 << i) and                     par[par[root][i - 1]][i - 1] != -1;          ++i) {       par[root][i] = par[par[root][i - 1]][i - 1];       nanCyCnt[root][i] =           nanCyCnt[root][i - 1] + nanCyCnt[par[root][i - 1]][i - 1];     }     isPassed[root] = true;     for (auto nei : adj[root]) {       if (!isPassed[nei]) {         h[nei] = h[root] + 1;         dfs(nei, root);       }     }     return;   }   int lca(int v, int u) {     int nancy = 0;     if (h[v] > h[u]) swap(v, u);     for (int i = 0; h[v] ^ h[u]; ++i) {       if ((h[u] - h[v]) & (1 << i)) {         nancy += nanCyCnt[u][i];         u = par[u][i];       }     }     if (v == u) return nancy;     for (int i = MAX_LOG - 1; i >= 0; --i) {       if (par[v][i] != par[u][i]) {         nancy += (nanCyCnt[v][i] + nanCyCnt[u][i]);         v = par[v][i], u = par[u][i];       }     }     return nancy + nanCyCnt[v][0] + nanCyCnt[u][0];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     memset(par, -1, sizeof par);     cin >> n >> m;     for (int i = 0; i < m; ++i) {       int v, u;       cin >> v >> u, v--, u--;       adj[v].push_back(u);       adj[u].push_back(v);     }     memset(isPassed, 0, sizeof isPassed);     pre(0);     memset(isPassed, 0, sizeof isPassed);     memset(h, 0, sizeof h);     dfs(0, -1);     int mercsNum;     cin >> mercsNum;     while (mercsNum--) {       int sh, wa;       cin >> wa >> sh, wa--, sh--;       cout << lca(wa, sh) << endl;     }     return 0;   }
#include <bits/stdc++.h>   int n = 0, m = 0, a[100002], b[1000002], c[1000002];   int main() {     while (scanf( %d , &n) != EOF) {       memset(a, 0, sizeof(a));       memset(b, 0, sizeof(b));       if (n == 0) continue;       int max = 0;       int p = 0, q = 0, k = 0;       for (int i = 0; i < n; i++) {         scanf( %d , &a[i]);         b[a[i]]++;         if (b[a[i]] == 1) c[a[i]] = i;         if (b[a[i]] > max) {           max = b[a[i]];           k = a[i];           q = i;         }         if (b[a[i]] == max) {           if (i - c[a[i]] < q - c[a[q]]) {             q = i;             k = a[i];           }         }       }       for (int j = 0; j <= q; j++) {         if (a[j] == k) {           p = j;           break;         }       }       printf( %d %d n , p + 1, q + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long l, r, k;   void go(long long x) {     int i, j;     long long y, z;     for (i = 62; i >= 0; i--) {       if (x & (1LL << i)) break;     }     if ((1LL << i) == x) {       x++;     }     long long xx = x;     xx &= ((1LL << i) - 1);     y = (1LL << (i + 1)) | xx;     z = (1LL << (i + 1)) | (1LL << i);     if (y <= r && z <= r && k >= 3) {       cout << 0 << endl << 3 << endl << x <<     << y <<     << z << endl;       exit(0);     }   }   int main() {     cin >> l >> r >> k;     pair<long long, long long> p;     if (l == 1) {       if (k >= 3) {         cout << 0 << endl << 3 << endl;         cout << 1 <<     << 2 <<     << 3 << endl;         return 0;       } else {         cout << 1 << endl << 1 << endl << 1 << endl;         return 0;       }     }     go(l);     if (k >= 5) {       cout << 0 << endl << 4 << endl;       if (l % 2 == 0)         cout << l <<     << l + 1 <<     << l + 2 <<     << l + 3 << endl;       else         cout << l + 1 <<     << l + 2 <<     << l + 3 <<     << l + 4 << endl;     } else if (k == 4) {       if (l % 2 == 0) {         cout << 0 << endl << 4 << endl;         cout << l <<     << l + 1 <<     << l + 2 <<     << l + 3 << endl;       } else {         if (r - l + 1 >= 5) {           cout << 0 << endl << 4 << endl;           cout << l + 1 <<     << l + 2 <<     << l + 3 <<     << l + 4 << endl;         } else {           cout << 1 << endl << 2 << endl;           if (l % 2 == 0)             cout << l <<     << l + 1 << endl;           else             cout << l + 1 <<     << l + 2 << endl;         }       }     } else if (k == 3) {       cout << 1 << endl << 2 << endl;       if (l % 2 == 0)         cout << l <<     << l + 1 << endl;       else         cout << l + 1 <<     << l + 2 << endl;     } else if (k == 2) {       if (r - l + 1 > 2) {         cout << 1 << endl << 2 << endl;         if (l % 2 == 0)           cout << l <<     << l + 1 << endl;         else           cout << l + 1 <<     << l + 2 << endl;       } else {         if ((l ^ (l + 1)) < l) {           cout << (l ^ (l + 1)) << endl << 2 << endl;           cout << l <<     << l + 1 << endl;         } else           cout << l << endl << 1 << endl << l << endl;       }     } else {       cout << l << endl << 1 << endl << l << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m;     int count[200005][2];     cin >> m;     while (m--) {       int n, a, b;       long long T;       cin >> n >> T >> a >> b;       vector<pair<int, int> > problems(n + 1);       for (int i = 1; i <= n; i++) {         cin >> problems[i].second;       }       for (int i = 1; i <= n; i++) {         cin >> problems[i].first;       }       sort(problems.begin(), problems.end());       count[0][0] = 0;       count[0][1] = 0;       for (int i = 1; i <= n; i++) {         count[i][problems[i].second] = count[i - 1][problems[i].second] + 1;         count[i][problems[i].second ^ 1] = count[i - 1][problems[i].second ^ 1];       }       long long curr = 0;       int res = 0;       for (int i = 1; i <= n; i++) {         long long spare = problems[i].first - 1 - curr;         curr += problems[i].second ? b : a;         if (spare < 0) continue;         int res1 = i - 1;         if (spare)           for (int type = 0; type <= 1; type++) {             long long currCount = count[n][type] - count[i - 1][type];             int solvable = min(spare / (type ? b : a), currCount);             res1 += solvable;             spare -= solvable * (type ? b : a);           }         res = max(res, res1);       }       if (T >= curr)         cout << n << endl;       else         cout << res << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<long long int> v;     for (int i = 1; i <= n; i++) {       long long int a;       cin >> a;       v.push_back(a);     }     sort(v.begin(), v.end());     long long int total = 0;     int cnt = 0;     for (int i = 0; i < v.size(); i++) {       total += v[i];       if (total - v[i] <= v[i])         ++cnt;       else         total -= v[i];     }     cout << cnt << endl;   }
#include<bits/stdc++.h>      #define ll long long   #define MAX 1000006   #define gcd(a, b)           __gcd(a, b)   #define lcm(a, b)           ((a)*((b)/gcd(a,b)))   using namespace std;         //******************* my code starts here **********************************      int main()   {   int t;      cin>>t;   getchar();      while(t--)   {        //ll i,x1,n,k,m;                  vector<ll>v;            vector<int>v1;            vector<pair<int,int>>pir;               string s,s1;            ll a,b,coun=0,new_coun=0,ans=0;            cin>>a>>b;               if(a<b)            {                cout<< 1 <<endl;                continue;            }              ll sqr=sqrt(a),minn=INT_MAX;               for(int i=0;i<=sqr;i++)            {                if(i==0 and b==1)                {                    continue;                }                   int check=b+i;                 coun =i;                int temp=a;                   while(temp != 0)                {                    temp/=check;                    coun++;                }                   minn=min(minn,coun);            }               cout<<minn<<endl;                              }                     return 0;      }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 50;   inline int rd(register int x = 0, register char ch = getchar(),                 register int f = 0) {     for (; ch <  0  || ch >  9 ; ch = getchar()) f = ch ==  - ;     for (; ch >=  0  && ch <=  9 ; ch = getchar())       x = (x << 1) + (x << 3) + ch - 48;     return f ? -x : x;   }   int n, m, cnt;   int a[N], pre[N], A[N], fr[N];   long long val[N], bit[N];   set<int> Set[N];   struct node {     int t, x, y, val, op;   } q[N * 4], p[N * 4];   bool cmp(node a, node b) { return a.t < b.t; }   void add(int p, int v) {     p += 5;     for (; p <= n + 5; p += p & -p) bit[p] += v;   }   long long ask(int p, long long a = 0) {     p += 5;     if (p <= 0) return 0;     for (; p; p -= p & -p) a += bit[p];     return a;   }   void cdq(int l, int r) {     if (l >= r) return;     int mid = (l + r) >> 1, pl = l, pr = mid + 1, pp = l;     cdq(l, mid), cdq(mid + 1, r);     while (pl <= mid && pr <= r) {       if (q[pl].x <= q[pr].x)         p[pp] = q[pl++], fr[pp++] = 1;       else         p[pp++] = q[pr++];     }     while (pl <= mid) p[pp] = q[pl++], fr[pp++] = 1;     while (pr <= r) p[pp++] = q[pr++];     for (int pos = l; pos <= r; ++pos) {       if (fr[pos] && !p[pos].op)         add(p[pos].y, p[pos].val);       else if (!fr[pos] && p[pos].op)         val[p[pos].op] += ask(n) - ask(p[pos].y - 1);     }     for (int pos = l; pos <= r; ++pos) {       q[pos] = p[pos];       if (fr[pos] && !p[pos].op) add(p[pos].y, -p[pos].val);       fr[pos] = 0;     }   }   int main() {     n = rd(), m = rd();     for (int i = 1; i <= n; ++i) {       a[i] = rd();       if (Set[a[i]].size()) pre[i] = *--Set[a[i]].end();       Set[a[i]].insert(i);       q[++cnt] = (node){0, i, pre[i], i - pre[i], 0};     }     for (int r = 1; r <= m; ++r) {       A[r] = rd();       int b = rd(), c = rd();       if (A[r] == 1) {         q[++cnt] = (node){r, b, pre[b], pre[b] - b, 0};         if (next(Set[a[b]].find(b)) != Set[a[b]].end()) {           int pos = *next(Set[a[b]].find(b));           q[++cnt] = (node){r, pos, pre[pos], pre[pos] - pos, 0};           pre[pos] = pre[b];           q[++cnt] = (node){r, pos, pre[pos], pos - pre[pos], 0};         }         Set[a[b]].erase(b);         a[b] = c;         pre[b] = 0;         Set[a[b]].insert(b);         if (Set[a[b]].find(b) != Set[a[b]].begin())           pre[b] = *prev(Set[a[b]].find(b));         q[++cnt] = (node){r, b, pre[b], b - pre[b], 0};         if (next(Set[a[b]].find(b)) != Set[a[b]].end()) {           int pos = *next(Set[a[b]].find(b));           q[++cnt] = (node){r, pos, pre[pos], pre[pos] - pos, 0};           pre[pos] = b;           q[++cnt] = (node){r, pos, pre[pos], pos - pre[pos], 0};         }       } else         q[++cnt] = (node){r, c, b, 0, r};     }     cdq(1, cnt);     for (int i = 1; i <= m; ++i)       if (A[i] == 2) printf( %lld n , val[i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, k;     cin >> n >> k;     int answer = 1;     while (k % 2 == 0) {       k /= 2;       answer++;     }     cout << answer;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct STree {     vector<int> st;     int n;     STree(int n) : st(4 * n + 5, 0), n(n) {}     void upd(int k, int s, int e, int p, int v) {       if (s + 1 == e) {         st[k] = v;         return;       }       int m = (s + e) / 2;       if (p < m)         upd(2 * k, s, m, p, v);       else         upd(2 * k + 1, m, e, p, v);       st[k] = (st[2 * k] | st[2 * k + 1]);     }     int query(int k, int s, int e, int pos, int v) {       if (e - 1 < pos) return -1;       if (s >= pos) {         if (!(st[k] & v)) return -1;         if (s + 1 == e) return s;       }       int m = (s + e) / 2;       int ans = query(2 * k, s, m, pos, v);       if (ans == -1) ans = query(2 * k + 1, m, e, pos, v);       return ans;     }     void upd(int p, int v) { upd(1, 0, n, p, v); }     int query(int a, int b) { return query(1, 0, n, a, b); }   };   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       string s;       int n, k;       cin >> n >> k >> s;       vector<int> a(n);       int ne = n / 2 - k;       for (int i = 0, ThxDem = 2 * (k - 1); i < ThxDem; ++i) a[i] = i % 2;       for (int i = 2 * (k - 1), ThxDem = n; i < ThxDem; ++i)         a[i] = i - 2 * (k - 1) > ne;       STree st(n);       for (int i = 0, ThxDem = n; i < ThxDem; ++i) st.upd(i, 1 << (s[i] ==  ) ));       cout << n <<   n ;       for (int i = 0, ThxDem = n; i < ThxDem; ++i) {         int wh = st.query(i, 1 << a[i]);         swap(s[i], s[wh]);         st.upd(i, 1 << (s[i] ==  ) ));         st.upd(wh, 1 << (s[wh] ==  ) ));         cout << i + 1 <<     << wh + 1 <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v[3001];   long long visited[3001][3001];   long long poss[3001];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, m, k;     cin >> n >> m >> k;     pair<long long, long long> parent[n + 1][n + 1];     for (long long i = 0; i < m; i++) {       long long a, b;       cin >> a >> b;       v[a].push_back(b);       v[b].push_back(a);     }     set<tuple<long long, long long, long long>> s;     for (long long i = 0; i < k; i++) {       long long a, b, c;       cin >> a >> b >> c;       s.insert({a, b, c});     }     queue<pair<long long, long long>> q;     q.push({1, 1});     visited[1][1] = 1;     parent[1][1] = {-1, -1};     poss[1] = 1;     pair<long long, long long> last = {-1, -1};     while (!q.empty()) {       pair<long long, long long> node = q.front();       if (node.second == n) {         last = {node};         break;       }       q.pop();       for (auto c : v[node.second]) {         if (visited[node.second][c] == 0 &&             !s.count({node.first, node.second, c})) {           parent[node.second][c] = node;           visited[node.second][c] = visited[node.first][node.second] + 1;           poss[c] = 1;           q.push({node.second, c});         }       }     }     if (poss[n]) {       vector<long long> ans;       pair<long long, long long> start = last;       while ((parent[start.first][start.second]) != parent[1][1]) {         ans.push_back(start.second);         start = parent[start.first][start.second];       }       ans.push_back(start.second);       reverse(ans.begin(), ans.end());       cout << ans.size() - 1 <<   n ;       for (auto c : ans) cout << c <<    ;     } else       cout << -1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2e5 + 6;   const long long MOD = 1e9 + 7;   int a[56];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, cnt = 0, mn = 50;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       mn = min(mn, a[i]);     }     for (int i = 0; i < n; i++)       if (a[i] == mn) cnt++;     if (cnt <= n / 2)       cout <<  Alice ;     else       cout <<  Bob ;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   struct sch {     long long int s, e, t;   };   bool sortinrev(const struct sch &a, const struct sch &b) { return (a.s < b.s); }   vector<long long int> graph[200010];   vector<long long int> graphr[200010];   long long int vis[200010], visf[200010], visr[200010];   char ans[200010];   int flag;   void cycle(long long int cur) {     if (!flag) return;     vis[cur] = 1;     for (long long int i = 0; i < graph[cur].size(); i++) {       long long int u = graph[cur][i];       if (vis[u] == 1) {         flag = 0;         return;       } else if (vis[u] == 2) {         continue;       } else {         cycle(u);       }     }     vis[cur] = 2;     return;   }   void dfs_front(long long int cur, long long int s) {     visf[cur] = 1;     for (long long int i = 0; i < graph[cur].size(); i++) {       long long int u = graph[cur][i];       if (visf[u] == 1) {         continue;       }       if (ans[u] ==  z ) ans[u] =  E ;       dfs_front(u, s);     }   }   void dfs_back(long long int cur, long long int s) {     visr[cur] = 1;     for (long long int i = 0; i < graphr[cur].size(); i++) {       long long int u = graphr[cur][i];       if (visr[u] == 1) {         continue;       }       if (ans[u] ==  z ) ans[u] =  E ;       dfs_back(u, s);     }   }   int main() {     long long int n, m;     cin >> n >> m;     flag = 1;     for (long long int i = 0; i < n; i++) ans[i] =  z ;     for (long long int i = 0; i < m; i++) {       long long int u, v;       cin >> u >> v;       graph[u - 1].push_back(v - 1);       graphr[v - 1].push_back(u - 1);     }     for (long long int i = 0; i < n; i++) {       if (!vis[i]) cycle(i);     }     if (flag == 0) {       cout << -1 << endl;       return 0;     }     memset(visf, 0, sizeof(visf));     memset(visr, 0, sizeof(visr));     for (long long int i = 0; i < n; i++) {       if (ans[i] ==  z ) {         ans[i] =  A ;         dfs_front(i, i);         dfs_back(i, i);       } else if (ans[i] ==  E ) {         if (visf[i] == 0) dfs_front(i, i);         if (visr[i] == 0) dfs_back(i, i);       }     }     long long int cnt = 0;     for (long long int i = 0; i < n; i++) {       if (ans[i] ==  A ) cnt++;     }     cout << cnt << endl;     for (long long int i = 0; i < n; i++) {       cout << ans[i];     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <typename U, typename V>   inline void smax(U &a, const V &b) {     if (a < b) a = b;   }   const long long INF = 0x3f3f3f3f3f3f3f3fLL;   const double pi = acosl(-1.), eps = 1e-9;   const int NN = 1010;   int hd[NN];   int nx[NN << 1];   int to[NN << 1];   int E;   void add(int u, int v) {     nx[E] = hd[u];     to[E] = v;     hd[u] = E++;     nx[E] = hd[v];     to[E] = u;     hd[v] = E++;   }   int flag[NN];   int father[NN];   int id[NN];   int crr_dp, crr_id;   pair<int, int> p[NN];   void dfs(int u, int dp = 0, int key = 1) {     flag[u] = key;     if (crr_dp < dp) {       crr_id = u;       crr_dp = dp;     }     for (int e = hd[u]; ~e; e = nx[e]) {       int v = to[e];       if (flag[v] == key) continue;       father[v] = u;       dfs(v, dp + 1, key);     }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     memset(hd, -1, sizeof(hd));     for (int i = 0, u, v; i < m; i++) {       scanf( %d%d , &u, &v);       add(u, v);     }     m = 0;     for (int i = 1, u, v; i <= n; i++) {       if (!flag[i]) {         crr_dp = -1;         dfs(i);         crr_dp = -1;         dfs(u = crr_id, 0, 2);         v = crr_id;         for (int j = 0; j < crr_dp / 2; j++) {           v = father[v];         }         p[m++] = pair<int, int>(crr_dp, v);       }     }     sort(p, p + m,          [](pair<int, int> a, pair<int, int> b) { return a.first > b.first; });     int dia = p[0].first;     if (m > 1) smax(dia, (p[0].first + 1 >> 1) + 1 + (p[1].first + 1 >> 1));     if (m > 2) smax(dia, (p[1].first + 1 >> 1) + 2 + (p[2].first + 1 >> 1));     printf( %d n , dia);     for (int i = 1; i < m; i++) {       printf( %d %d n , p[0].second, p[i].second);     }     return 0;   }
#include <bits/stdc++.h>   int N, M, K, MOD;   int dp[200][200][200];   int C[200][200];   int fac[200];   __attribute__((optimize( -O3 ))) __attribute__((optimize( -O3 ))) __inline       __attribute__((__gnu_inline__, __always_inline__, __artificial__)) int       calc(int n, int m, int k) {     if (n == 0) {       if (k == 0) return dp[n][m][k] = 1 % MOD;       return dp[n][m][k] = 0;     }     if (n == 1) {       if (m == 1 && k == 1) return dp[n][m][k] = 1 % MOD;       if (m > 1 && k == 0) return dp[n][m][k] = 1 % MOD;       return dp[n][m][k] = 0;     }     if (m == 1) {       if (k == 1) {         return dp[n][m][k] = fac[n];       }       return dp[n][m][k] = 0;     }     if (m > n) {       if (k == 0) {         return dp[n][m][k] = fac[n];       }       return dp[n][m][k] = 0;     }     int ans = 0;     for (int ln = 0; ln + 1 <= n; ++ln) {       if (m - 1 > ln) {         int lk = 0;         int rn = n - ln - 1, rk = k - lk;         ans += 1ll * dp[ln][m - 1][lk] * dp[rn][m - 1][rk] % MOD * C[n - 1][ln] %                MOD;         if (ans >= MOD) ans -= MOD;         continue;       }       if (m - 1 > n - ln - 1 && k <= ln) {         int lk = k;         int rn = n - ln - 1, rk = k - lk;         ans += 1ll * dp[ln][m - 1][lk] * dp[rn][m - 1][rk] % MOD * C[n - 1][ln] %                MOD;         if (ans >= MOD) ans -= MOD;         continue;       }       for (int lk = std::max(0, k - (n - ln - 1)); lk <= std::min(ln, k); ++lk) {         int rn = n - ln - 1, rk = k - lk;         ans += 1ll * dp[ln][m - 1][lk] * dp[rn][m - 1][rk] % MOD * C[n - 1][ln] %                MOD;         if (ans >= MOD) ans -= MOD;       }     }     return dp[n][m][k] = ans;   }   __attribute__((optimize( -O3 ))) int main() {     scanf( %d%d%d%d , &N, &M, &K, &MOD);     for (int i = 1; i <= N; ++i) {       C[i][0] = C[i][i] = 1 % MOD;       for (int j = 1; j <= i - 1; ++j)         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;     }     fac[0] = 1;     for (int i = 1; i <= N; ++i) fac[i] = 1ll * fac[i - 1] * i % MOD;     for (int i = 0; i <= N; ++i)       for (int j = 0; j <= std::min(N, M); ++j)         for (int k = 0; k <= std::min(i, K); ++k) {           calc(i, j, k);         }     printf( %d n , dp[N][M][K]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, a, b;     cin >> n >> a >> b;     long long int m = 0;     for (long long int i = 1; i < n; i++) {       long long int q = i;       long long int w = n - i;       long long int ca = a / q, cb = b / w;       if (min(ca, cb) > m) m = min(ca, cb);     }     cout << m;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int L, v, l, r, d;       cin >> L >> v >> l >> r;       if (r == l && r % v == 0)         d = 1;       else         d = r / v - (l - 1) / v;       cout << L / v - d <<   n ;     }     return 0;   }