malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename X, typename Y>   static inline void xmin(X &x, Y y) {     if (y < x) x = y;   }   template <typename X, typename Y>   static inline void xmax(X &x, Y y) {     if (x < y) x = y;   }   long long pw(long long x, long long y, long long md) {     if (!y) return 1;     if (y & 1) return (x * pw(x, y - 1, md)) % md;     long long tmp = pw(x, y / 2, md);     return (tmp * tmp) % md;   }   int n, a[200001], sm[200001], seg[524288];   void ins(int x, int v, int s = 1, int e = n, int i = 1) {     seg[i] += v;     int md = (s + e) / 2;     if (s == e) return;     if (x > md)       ins(x, v, md + 1, e, 2 * i + 1);     else       ins(x, v, s, md, 2 * i);   }   int que(int x, int s = 1, int e = n, int i = 1) {     if (s > x) return 0;     if (e <= x) return seg[i];     int md = (s + e) / 2;     return que(x, s, md, 2 * i) + que(x, md + 1, e, 2 * i + 1);   }   int elt(int x, int s = 1, int e = n, int i = 1) {     if (s == e) return s;     int md = (s + e) / 2;     return seg[2 * i] >= x ? elt(x, s, md, 2 * i)                            : elt(x - seg[2 * i], md + 1, e, 2 * i + 1);   }   void solve() {     cin >> n;     for (int i = 1; i <= n; ++i) cin >> a[i], ins(a[i] + 1, 1);     for (int i = 1; i <= n; ++i) ins(a[i] + 1, -1), sm[i] = que(a[i] + 1);     for (int i = 1; i <= n; ++i) cin >> a[i], ins(a[i] + 1, 1);     for (int i = 1; i <= n; ++i) ins(a[i] + 1, -1), sm[i] += que(a[i] + 1);     for (int i = n; i >= 1; --i)       if (sm[i] > n - i) sm[i] -= n - i + 1, ++sm[i - 1];     for (int i = 1; i <= n; ++i) ins(i, 1);     for (int i = 1; i <= n; ++i) {       sm[i] = elt(sm[i] + 1);       ins(sm[i], -1);     }     for (int i = 1; i <= n; ++i) cout << sm[i] - 1 <<    ;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     int TESTS = 1;     while (TESTS--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool hell(vector<int>& v1, vector<int>& v2) { return v1.size() < v2.size(); }   int main() {     int n;     cin >> n;     vector<vector<int> > f(100);     int a[2 * n + 1];     for (int i = 1; i <= 2 * n; i++) {       cin >> a[i];       f[a[i]].push_back(i);     }     int b[2 * n + 1];     int u = 1;     sort(f.begin() + 10, f.end(), hell);     for (int i = 10; i < 100; i++) {       for (int j = 0; j < f[i].size(); j++) {         b[f[i][j]] = u;         if (u == 1)           u = 2;         else           u = 1;       }     }     int u1 = 0, u2 = 0;     for (int i = 10; i < 100; i++) {       if (f[i].size() == 0) {         continue;       }       if (f[i].size() >= 2) {         u1++;         u2++;       } else {         if (b[f[i][0]] == 1) {           u1++;         } else           u2++;       }     }     cout << (u1 * u2) << endl;     for (int i = 1; i <= 2 * n; i++) {       cout << b[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, v;   int main() {     cin >> n >> v;     int ans = 0;     int p = 1;     int cur = 0;     for (int i = n - 1; i >= 0; i--, p++) {       if (cur >= i) continue;       ans += p * (min(i, v - cur));       cur = cur + min(i, v - cur) - 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 810, maxn = 200010;   long long n, m, k, top, cnt, num;   struct wy {     long long x, y, z;   } t[maxn];   inline long long cmp(wy a, wy b) { return a.z < b.z; }   long long b[MAXN], c[MAXN], a[MAXN][MAXN], w[maxn];   inline void discrete() {     sort(b + 1, b + 1 + top);     for (long long i = 1; i <= top; ++i)       if (b[i] != b[i - 1]) c[++cnt] = b[i];   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m >> k;     for (long long i = 1; i <= m; ++i) {       long long x, y, z;       cin >> x >> y >> z;       t[i] = (wy){x, y, z};     }     sort(t + 1, t + 1 + m, cmp);     for (long long i = 1; i <= ((m) > (k) ? (k) : (m)); ++i) {       b[++top] = t[i].x;       b[++top] = t[i].y;     }     discrete();     for (long long i = 1; i <= cnt; ++i)       for (long long j = 1; j <= cnt; ++j) a[i][j] = 20000000000000000ll;     for (long long i = 1; i <= ((m) > (k) ? (k) : (m)); ++i) {       long long x = lower_bound(c + 1, c + 1 + cnt, t[i].x) - c;       long long y = lower_bound(c + 1, c + 1 + cnt, t[i].y) - c;       a[y][x] = a[x][y] = t[i].z;     }     for (long long p = 1; p <= cnt; ++p) {       for (long long i = 1; i <= cnt; ++i)         for (long long j = 1; j <= cnt; ++j) {           a[i][j] =               ((a[i][j]) > (a[i][p] + a[p][j]) ? (a[i][p] + a[p][j]) : (a[i][j]));         }     }     for (long long i = 1; i <= cnt; ++i)       for (long long j = i + 1; j <= cnt; ++j) c[++num] = a[i][j];     sort(c + 1, c + 1 + num);     printf( %lld , c[k]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string n;     int k = 0;     cin >> n;     if (n[0] <=  Z ) {       for (int i = 0; i < n.size(); i++) {         if (n[i] <=  Z ) k++;       }       if (k == n.size()) {         transform(n.begin(), n.end(), n.begin(), (int (*)(int))tolower);         cout << n;       } else         cout << n;     } else {       for (int i = 0; i < n.size(); i++) {         if (n[i] <=  Z ) k++;       }       if (k == n.size() - 1) {         transform(n.begin(), n.end(), n.begin(), (int (*)(int))tolower);         n.at(0) = toupper(n.at(0));         cout << n;       } else         cout << n;     }   }
#include <bits/stdc++.h>   int main() {     int tp, x, ans;     while (~scanf( %d , &x)) {       x = x < 0 ? -x : x, ans = ceil((-1 + sqrt(1 + 8.0 * x)) / 2),       tp = ans * (ans + 1) / 2 - x;       while (tp & 1) ans++, tp += ans;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     {       int t;       cin >> t;       long long int a[t];       for (int i = 0; i < t; i++) {         cin >> a[i];         if (a[i] % 2 == 0 && a[i] != 0)           cout << a[i] - 1 <<    ;         else           cout << a[i] <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T, a[260];   int main() {     scanf( %d , &T);     while (T--) {       int s = 0;       int ct = 0;       for (int i = 0; i < 250; i++) {         scanf( %d , &a[i]);         s += a[i];       }       double ave = s / 250.0;       for (int i = 0; i < 250; i++) {         if (fabs(a[i] - ave) <= ave / 2) ct++;       }       if (ct > 250 * 0.75)         printf( poisson n );       else         printf( uniform n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   int main() {     int a, b;     while (scanf( %d%d , &a, &b) != EOF) {       int g = gcd(a, b);       int x = -1, y = -1;       for (int dx = 1; dx <= 1000; ++dx)         for (int dy = 1; dy <= 1000; ++dy)           if (dx * dx + dy * dy == g * g) x = dx, y = dy;       if (x == -1 && y == -1)         printf( NO n );       else {         printf( YES n0 0 n );         if (a / g * y == b / g * x) swap(a, b);         printf( %d %d n , a / g * x, a / g * y);         printf( %d %d n , -b / g * y, b / g * x);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[200005];   int arr[200005];   int cum[200005];   int main() {     scanf( %s , &str);     int n = strlen(str);     int q, idx;     scanf( %d , &q);     while (q--) {       scanf( %d , &idx);       int l = idx, r = n - idx + 1;       arr[l]++;       arr[r + 1]--;     }     for (int i = 1; i <= n; i++) {       cum[i] = cum[i - 1] + arr[i];     }     for (int i = 0; i < n; i++) {       if (cum[i + 1] % 2 == 0) {         printf( %c , str[i]);       } else {         printf( %c , str[n - i - 1]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   int n, ans = 0;   int b[1000001];   int num;   void dfs(int u, int d) {     if (u == n) {       num = min(num, ans);       return;     }     if (abs(b[u] - b[u - 1] - d) > 1) return;     int d1 = b[u] - b[u - 1];     if (d1 < d) {       b[u]++;       ans++;       dfs(u + 1, d);       b[u]--;       ans--;     } else if (d1 > d) {       b[u]--;       ans++;       dfs(u + 1, d);       b[u]++;       ans--;     } else if (d1 == d)       dfs(u + 1, d);     return;   }   int main() {     scanf( %d , &n);     for (long long(i) = (0); (i) < (n); (i)++) scanf( %d , b + i);     num = 2e7;     dfs(1, b[1] - b[0]);     dfs(1, b[1] - b[0] + 1);     dfs(1, b[1] - b[0] - 1);     b[0]++;     ans = 1;     dfs(1, b[1] - b[0]);     dfs(1, b[1] - b[0] + 1);     dfs(1, b[1] - b[0] - 1);     b[0] -= 2;     ans = 1;     dfs(1, b[1] - b[0]);     dfs(1, b[1] - b[0] + 1);     dfs(1, b[1] - b[0] - 1);     if (num < 2e7)       printf( %d n , num);     else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void DBG() { cerr << endl; }   template <class Head, class... Tail>   void DBG(Head H, Tail... T) {     cerr <<     << H;     DBG(T...);   }   using ll = long long;   using ld = long double;   template <class T>   using vec = vector<T>;   template <class... Args>   inline void read(Args&... args) {     ((cin >> args), ...);   }   template <class... Args>   inline void show(Args... args) {     ((cout << args <<    ), ...);   }   template <class T1, class T2>   inline bool ckmin(T1& a, T2 b) {     return a > b ? a = b, 1 : 0;   }   template <class T1, class T2>   inline bool ckmax(T1& a, T2 b) {     return a < b ? a = b, 1 : 0;   }   template <class T>   inline void operator>>(istream& in, vector<T>& v) {     for (auto i = 0; i < int(v.size()); i++) in >> v[i];   }   template <class T>   inline void operator<<(ostream& out, const vector<T>& v) {     for (auto i = 0; i < int(v.size()); i++)       out << v[i] <<    n [i + 1 == int(v.size())];   }   const int MOD = 7340033;   ll dp[31][4][1001];   void solve() {     int n, k;     read(n, k);     function<ll(int, int, int)> F = [&](int part, int idx, int rem) {       if (part == 0 || idx == 4) return rem == 0 ? 1ll : 0ll;       if (idx == 0 && rem == 0) return 1ll;       if (~dp[part][idx][rem]) return dp[part][idx][rem];       ll cnt = 0;       int new_rem = idx == 0 ? rem - 1 : rem;       for (auto i = 0; i < new_rem + 1; i++) {         cnt += F(part, idx + 1, i) * F(part - 1, 0, new_rem - i);         cnt %= MOD;       }       return dp[part][idx][rem] = cnt;     };     int part = 0;     while (n > 1 && n % 2) n /= 2, part++;     cout << F(part, 0, k) <<   n ;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout << fixed << setprecision(12);     cerr << fixed << setprecision(12);     memset(dp, -1, sizeof(dp));     int _ = 1;     cin >> _;     for (auto i = 1; i < _ + 1; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = LONG_MAX;   const long long arr = 1000000;   bool comp(pair<string, long long> a, pair<string, long long> b) {     return a.second > b.second;   }   int main(void) {     long long n;     cin >> n;     vector<pair<long long, long long> > v;     for (int i = 0; i < n + 1; i++) {       long long x, y;       cin >> x >> y;       v.push_back({x, y});     }     long long ans = 0;     for (int i = 1; i < n; i++) {       long long x1 = v[i - 1].first, y1 = v[i - 1].second;       long long x2 = v[i].first, y2 = v[i].second;       long long x3 = v[i + 1].first, y3 = v[i + 1].second;       if (x1 == x2 && y2 > y1) {         if (x3 < x1 && y3 > y1) ans++;       }       if (y1 == y2 && x2 > x1) {         if (x3 > x1 && y3 > y1) ans++;       }       if (x1 == x2 && y2 < y1) {         if (x3 > x1 && y3 < y1) ans++;       }       if (y1 == y2 && x2 < x1) {         if (x3 < x1 && y3 < y1) ans++;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long Mod = 7 + 1e9;   const long long INF32 = 5 + 2e9;   const long long INF64 = 1 + 1e18;   const long long MAX = 5 + 3e5;   int N, M, ans = 4;   int main() {     cin >> N >> M;     for (int i = 1; i <= N; i++)       for (int j = 1; j <= M; j++) {         bool b;         cin >> b;         if (b && (i == 1 || j == 1 || i == N || j == M)) {           ans = 2;           break;         }       }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = (int)1e9 + 7;   long long int pow(long long int base, long long int exp, int m) {     if (exp == 0)       return 1;     else if (exp == 1)       return base;     long long int root = pow(base, exp >> 1, m);     if ((exp & 1) == 0)       return (root * root) % m;     else       return (((root * root) % m) * base) % m;   }   long long int fact[(int)1e6];   long long int ncr(int n, int r) {     return (((fact[n] * pow(fact[n - r], mod - 2, mod)) % mod) *             pow(fact[r], mod - 2, mod)) %            mod;   }   void solve(long long int *a, int n) {     if (n == 2) {       cout << (a[0] + a[1]) % mod;       return;     }     int last = 1, i, j;     for (i = n; i > 2; i--) {       if (i % 2 == 0) {         last *= -1;       }     }     j = n / 2;     long long int p1 = 0, p2 = 0;     for (i = 0; i < n; i += 2) {       long long int v = ncr(j - 1, i / 2);       v = v * a[i];       v %= mod;       p1 = (p1 + v) % mod;     }     for (i = 1; i < n; i += 2) {       long long int v = ncr(j - 1, i / 2);       v = (v * a[i]) % mod;       p2 = (p2 + v) % mod;     }     p2 *= last;     p1 += p2;     p1 %= mod;     if (p1 < 0) p1 += mod;     cout << p1;   }   int main() {     int t, n, m, i, j, k, l, p;     cin >> n;     fact[0] = 1;     for (i = 1; i < (int)3e5; i++) {       fact[i] = fact[i - 1] * i;       fact[i] %= mod;     }     long long int a[n];     for (int i = 0; i < n; ++i) {       scanf( %lld , a + i);     }     if (n == 1) {       cout << a[0];       return 0;     }     if (n % 2 == 0)       solve(a, n);     else {       long long int tmp[n - 1];       p = 1;       for (i = 0; i < n - 1; i++) {         tmp[i] = a[i] + (p * a[i + 1]);         tmp[i] %= mod;         if (tmp[i] < 0) tmp[i] += mod;         p *= -1;       }       solve(tmp, n - 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> v(n);       for (int i = 0; i < n; i++) cin >> v[i];       int mn = INT_MAX;       int cnt = 0;       for (int i = n - 1; i >= 0; i--) {         if (v[i] > mn) cnt++;         mn = min(mn, v[i]);       }       cout << cnt <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n, m;   int a[maxn];   int b[maxn];   int ans[maxn];   int main() {     cin >> n >> m;     int num = 0;     for (int i = 0; i < m; i++) {       scanf( %d , a + i);       if (b[a[i]] == 0) num++;       b[a[i]]++;       if (num == n) {         ans[i] = 1;         num = 0;         for (int j = 1; j <= n; j++) {           b[j]--;           if (b[j] > 0) num++;         }       } else {         ans[i] = 0;       }     }     for (int i = 0; i < m; i++) {       printf( %d , ans[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 myrand(time(0));   bool isprime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i += 6) {       if (n % i == 0 || n % (i + 2) == 0) return false;     }     return true;   }   long long modexp(long long a, long long b, long long m) {     long long r = 1;     a = a % m;     while (b > 0) {       if (b & 1) r = (r * a) % m;       b = b >> 1;       a = (a * a) % m;     }     return r % m;   }   long long builtin_popcount(long long x) {     long long cnt = 0;     for (long long i = 60; i >= 0; i--) {       if ((1LL << i) & x) cnt++;     }     return cnt;   }   long long addmod(long long a, long long b) {     a %= 1000000007;     b %= 1000000007;     return (a + b) % 1000000007;   }   long long mulmod(long long a, long long b) {     a %= 1000000007;     b %= 1000000007;     return (a * b) % 1000000007;   }   long long submod(long long a, long long b) {     a %= 1000000007;     b %= 1000000007;     a -= b;     if (a < 0) a += 1000000007;     return a % 1000000007;   }   struct CustomCompare {     bool operator()(pair<long long, long long> a, pair<long long, long long> b) {       return a.first < b.first;     }   };   long long n, m, d;   vector<vector<long long> > g;   vector<long long> arr;   void dfs(long long src, vector<long long> &dp, long long par = -1) {     dp[src] = (par != -1 ? dp[par] + 1LL : 0LL);     for (auto x : g[src]) {       if (x != par) dfs(x, dp, src);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> d;     g = vector<vector<long long> >(n);     arr = vector<long long>(m);     vector<long long> vis(n, 0);     for (int i = 0; i < m; i++) cin >> arr[i], arr[i]--, vis[arr[i]] = 1;     for (int i = 1; i < n; i++) {       long long u, v;       cin >> u >> v;       --u, --v;       g[u].push_back(v), g[v].push_back(u);     }     vector<long long> dp(n, 0);     dfs(0, dp);     long long a = -1, mx = -1000000007;     for (int i = 0; i < n; i++) {       if (mx < dp[i] && vis[i]) {         mx = dp[i];         a = i;       }       dp[i] = 0;     }     dfs(a, dp);     long long b = -1;     mx = -1000000007;     for (int i = 0; i < n; i++) {       if (mx < dp[i] && vis[i]) {         mx = dp[i];         b = i;       }     }     vector<long long> dp2(n);     dfs(b, dp2);     long long ans = 0;     for (int i = 0; i < n; i++)       if (dp[i] <= d && dp2[i] <= d) ans++;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   template <typename... T>   void rd(T&... args) {     ((cin >> args), ...);   }   template <typename... T>   void wr(T... args) {     ((cout << args <<    ), ...);     cout << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int tt;     cin >> tt;     while (tt--) {       int n;       cin >> n;       vector<int> a(n), l(n);       for (auto& i : a) cin >> i;       for (auto& i : l) cin >> i;       vector<int> tmp;       for (int i = 0; i < n; i++) {         if (!l[i]) {           tmp.push_back(a[i]);         }       }       sort(tmp.begin(), tmp.end());       for (int i = 0; i < n; i++) {         if (l[i])           cout << a[i] <<    ;         else {           cout << tmp.back() <<    ;           tmp.pop_back();         }       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string x;     cin >> x;     int sum = 0, s;     s = x.size();     for (int i = 0; i < x.size(); i++) {       if (x[i] == x[s - i - 1] &&           (x[i] ==  A  || x[i] ==  H  || x[i] ==  I  || x[i] ==  M  ||            x[i] ==  O  || x[i] ==  T  || x[i] ==  U  || x[i] ==  V  ||            x[i] ==  W  || x[i] ==  X  || x[i] ==  Y ))         sum++;     }     if (sum == s) {       cout <<  YES ;       return 0;     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     vector<long long> v;     long long last;     int q, a, b, lo, hi, one, two;     long double aa, bb;     cin >> q;     cout << fixed;     cout << setprecision(6);     while (q--) {       cin >> a;       if (a == 1) {         cin >> b;         if (v.size() == 0) {           v.push_back(b);         } else {           v.push_back(b);           v.back() += v[v.size() - 2];         }       } else {         lo = 0;         hi = v.size() - 2;         if (hi < 0) {           cout << (long double)0 <<   n ;           continue;         }         last = v.back() - v[v.size() - 2];         while (lo < hi) {           one = ((hi - lo) / 3) + lo;           two = hi - ((hi - lo) / 3);           aa = (long double)(v[one] + last) / (long double)(one + 2);           bb = (long double)(v[two] + last) / (long double)(two + 2);           if (aa < bb) {             hi = two - 1;           } else {             lo = one + 1;           }         }         aa = (long double)(v[lo] + last) / (long double)(lo + 2);         aa = (long double)last - aa;         cout << aa <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n;   int main() {     cin >> n;     long long int cnt = 0, c;     for (long long int i = 2; i <= sqrt(n); i++) {       if (n % i == 0) cnt++;     }     if (cnt == 0) {       cout << n;       goto skip;     }     for (long long int i = 2; i <= sqrt(n); i++)       if (n % i == 0) {         c = i;         break;       }     while (n % c == 0) {       n /= c;     }     if (n == 1) {       cout << c;     } else {       cout << 1;     }   skip:;     return 0;   }
#include <bits/stdc++.h>   template <typename T>   T gcd(T a, T b) {     if (!b) return a;     return gcd(b, a % b);   }   template <typename T>   T lcm(T a, T b) {     return a * b / gcd(a, b);   }   template <typename T>   void chmin(T& a, T b) {     a = (a > b) ? b : a;   }   template <typename T>   void chmax(T& a, T b) {     a = (a < b) ? b : a;   }   int in() {     int x;     scanf( %d , &x);     return x;   }   using namespace std;   const int MAXN = 502;   int N, M;   int P[MAXN][MAXN];   vector<int> G[MAXN], GA[MAXN];   vector<int> comp;   bool vis[MAXN];   int color[MAXN];   void dfs(int x) {     vis[x] = true;     for (int i = 0; i < (int)GA[x].size(); i++) {       int u = G[x][i];       if (!vis[u]) {         dfs(u);       }     }   }   bool dfs_color(int node, int c) {     if (color[node] != 0) {       if (color[node] == c) {         return true;       } else {         return false;       }     }     color[node] = c;     for (int i = 0; i < (int)GA[node].size(); i++) {       if (!dfs_color(GA[node][i], -c)) {         return false;       }     }     return true;   }   int main(void) {     cin >> N >> M;     string S(N,  b );     for (int i = 0; i < M; i++) {       int A, B;       cin >> A >> B;       A -= 1;       B -= 1;       P[A][B] = 1;       P[B][A] = 1;       G[A].push_back(B);       G[B].push_back(A);     }     bool valid = true;     for (int i = 0; i < N; i++) {       for (int j = i; j < N; j++) {         if (i != j && !P[i][j]) {           GA[i].push_back(j);           GA[j].push_back(i);         }       }     }     for (int i = 0; i < N; i++) {       if (!vis[i] && GA[i].size() > 0) {         comp.push_back(i);       }     }     for (int i = 0; i < (int)comp.size(); i++) {       if (color[comp[i]] == 0 && !dfs_color(comp[i], 1)) {         valid = false;       }     }     for (int i = 0; i < N; i++) {       if (color[i] == -1) {         S[i] =  a ;       }       if (color[i] == 1) {         S[i] =  c ;       }     }     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) {         if (i != j) {           if (P[i][j] && abs(S[i] - S[j]) > 1) {             valid = false;           }           if (!P[i][j] && abs(S[i] - S[j]) <= 1) {             valid = false;           }         }       }     }     if (valid) {       cout <<  Yes n  << S <<   n ;     } else {       cout <<  No n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long a, b;     cin >> a >> b;     if (b / 2 >= a)       cout << (b % (b / 2 + 1));     else       cout << b % a;     cout <<   n ;     return;   }   signed main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     srand(time(NULL));     long long t = 1;     cin >> t;     while (t--) solve();   }