malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int N, K, ans;   vector<int> ady[1000005];   set<int> dfs(int x, int p) {     set<int> s;     if (ady[x].size() == 1) {       s.insert(0);       return s;     }     for (auto v : ady[x]) {       if (v == p) continue;       set<int> tmp = dfs(v, x);       for (auto aux : tmp) {         aux++;         if (aux > K)           ans++;         else if (s.find(aux) != s.end() && aux + aux > K)           ans++;         else           s.insert(aux);       }     }     auto it = s.begin();     while (s.begin() != s.end()) {       auto it2 = it;       it2++;       if (it2 == s.end()) break;       if (*it + *it2 <= K) s.erase(it);       it = it2;     }     return s;   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     cin >> N >> K;     for (int i = 1; i < N; i++) {       int u, v;       cin >> u >> v;       ady[u].push_back(v);       ady[v].push_back(u);     }     int root = 1;     while (ady[root].size() == 1) root++;     ans += dfs(root, 0).size();     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-10;   struct rec {     double x, y;   } a[110], s, e, f[2];   int g[2], n, m, i;   double ans;   double XJ(rec a, rec b, rec c) {     return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);   }   double dist(rec a, rec b) {     return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));   }   void cross(rec a, rec b, rec c, rec d) {     double t1 = XJ(a, c, b), t2 = XJ(a, b, d), t3 = XJ(c, a, d), t4 = XJ(c, d, b);     if (fabs(t1) < eps && fabs(t2) < eps) return;     if (fabs(dist(a, c) + dist(b, c) - dist(a, b)) < eps) {       f[m] = c;       g[m++] = i;       return;     }     if (t1 * t2 > eps && t3 * t4 > eps) {       f[m].x = (t1 * d.x + t2 * c.x) / (t1 + t2);       f[m].y = (t1 * d.y + t2 * c.y) / (t1 + t2);       g[m++] = i;       return;     }   }   double calc(int st, int ed, int s, int e) {     if (ed == 1)       ed = n;     else       ed--;     double ans = dist(f[s], a[st]);     for (int i = st; i != ed; i == n ? i = 1 : i++)       ans += dist(a[i], a[i == n ? 1 : i + 1]);     return ans + dist(a[ed], f[e]);   }   int main() {     scanf( %lf%lf%lf%lf%d , &s.x, &s.y, &e.x, &e.y, &n);     for (i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;     a[0] = a[n];     for (i = 1; i <= n; i++) cross(s, e, a[i - 1], a[i]);     if (m > 1) {       if (dist(s, f[0]) > dist(s, f[1])) swap(f[0], f[1]), swap(g[0], g[1]);       ans = min(calc(g[0], g[1], 0, 1), calc(g[1], g[0], 1, 0));       ans = min(ans, 2 * dist(f[0], f[1]));       ans += dist(s, f[0]) + dist(f[1], e);     } else       ans = dist(s, e);     printf( %.10lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[2500000];   int main() {     int all;     scanf( %d , &all);     for (int i = 1; i <= all; i++) {       scanf( %I64d , &a[i]);     }     sort(a + 1, a + all + 1);     reverse(a + 1, a + all + 1);     long long sum = 0;     for (int fro = 1; fro <= all; fro = fro << 2) {       for (int p = 1; p <= fro; p++) {         sum += a[p];       }     }     long long temp = 0, area = 1;     printf( %I64d , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     vector<int> a(n + 1);     vector<vector<int> > inc(n + 1);     vector<vector<int> > dec(n + 2);     for (int i = 0; i < n; i++) {       cin >> a[i + 1];     }     for (int i = 0; i <= n; i++) {       if (i == 0)         ;       else {         inc[i] = inc[i - 1];         inc[i].push_back(a[i]);         sort(inc[i].begin(), inc[i].end());       }     }     for (int i = n; i >= 1; i--) {       if (i == n)         dec[i].push_back(a[i]);       else {         dec[i] = dec[i + 1];         dec[i].push_back(a[i]);         sort(dec[i].begin(), dec[i].end());       }     }     int fsum = accumulate(a.begin(), a.end(), 0);     for (int i = 1; i <= n; i++) {       for (int j = i; j <= n; j++) {         vector<int> tmp(j - i + 1);         copy(a.begin() + i, a.begin() + j + 1, tmp.begin());         sort(tmp.begin(), tmp.end(), greater<int>());         vector<int> incb = inc[i - 1];         vector<int> deca = dec[j + 1];         int swaps = 0, tmpsum = 0;         while (swaps < k && tmp.size()) {           int src = 0;           int v1 = INT_MIN, v2 = INT_MIN, finval = INT_MIN;           if (incb.size()) v1 = incb.back();           if (deca.size()) v2 = deca.back();           if (v1 == INT_MIN && v2 == INT_MIN) break;           if (v1 >= v2) {             src = 1;             finval = v1;           } else if (v1 < v2) {             src = 2;             finval = v2;           }           swaps++;           if (finval > tmp.back()) {             tmpsum += finval;             if (src == 1)               incb.pop_back();             else if (src == 2)               deca.pop_back();             tmp.pop_back();           } else             break;         }         fsum = max(fsum, tmpsum + accumulate(tmp.begin(), tmp.end(), 0));       }     }     cout << fsum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int zsern = 1e6 + 1000;   const long long mod = 1e9 + 7;   const double pi = acos(-1.0);   long long n, k;   long long a[zsern];   std::vector<long long> num;   void gst(int id, int zser) {     if (id - 1 >= 0 && id - 1 != zser)       gst(id - 1, zser);     else if (id - 2 >= 0 && id - 2 != zser)       gst(id - 2, zser);     num.push_back(1 << id);     if (id - 1 >= 0 && id - 1 != zser)       gst(id - 1, zser);     else if (id - 2 >= 0 && id - 2 != zser)       gst(id - 2, zser);   }   void AC() {     long long x;     while (~scanf( %lld%lld , &n, &x)) {       long long zser = 0;       for (int i = 0; i <= 18; i++) {         if ((1ll << i) <= x) zser = i;       }       for (int i = n - 1; i >= 0; i--) {         if (i != zser) {           gst(i, zser);           break;         }       }       cout << num.size() << endl;       for (int i = 0; i < num.size(); i++) printf( %lld  , num[i]);     }   }   int main() {     AC();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int n = s.size(), c = 0, c1 = 0, k = 0, k1 = 0;     if (n % 2 != 0)       cout << -1;     else {       for (int i = 0; i < n; i++) {         if (s[i] ==  R )           c++;         else if (s[i] ==  L )           c1++;         else if (s[i] ==  U )           k++;         else if (s[i] ==  D )           k1++;       }       n = abs(c - c1) + abs(k - k1);       n = n / 2;       cout << n;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int32_t mod = 1e9 + 7;   const long long inf = 1e18;   set<long long> S;   void doq() {     for (long long i = 0; i < 40; i++) {       for (long long j = 0; j < 40; j++) {         long long a = 3 * i + 7 * j;         if (a <= 100) S.insert(a);       }     }   }   void solve() {     long long n;     cin >> n;     if (S.find(n) != S.end())       cout <<  YES n ;     else       cout <<  NO n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     doq();     long long tcs = 1;     cin >> tcs;     while (tcs--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long int n, x, d = 0;     cin >> n >> x;     while (n--) {       long long int t;       char s;       cin >> s;       cin >> t;       if (s ==  + ) {         x += t;       } else {         if (x - t >= 0)           x -= t;         else           d++;       }     }     cout << x <<     << d;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void setIO(string s =   ) {     ios_base::sync_with_stdio(0);     cin.tie(0);     if ((int)s.size()) {       freopen((s +  .in ).c_str(),  r , stdin);       freopen((s +  .out ).c_str(),  w , stdout);     }   }   int main() {     setIO();     int n;     string s;     cin >> n >> s;     string result;     result += s[0];     for (int i = 1; i < n; i++) {       if (i % 2) {         result = s[i] + result;       } else {         result += s[i];       }     }     if (n % 2) {       cout << result << endl;     } else {       reverse((result).begin(), (result).end());       cout << result << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1000;   bool fg[55][55];   long long n, m, dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};   bool flag;   char s[55][55];   void dfs(long long x, long long y, long long st, long long ed) {     fg[x][y] = true;     for (long long i = 0; i < 4; i++) {       long long a = x + dx[i], b = y + dy[i];       if (a >= 1 && a <= n && b >= 1 && b <= m && s[a][b] == s[x][y] &&           (st != a || ed != b)) {         if (fg[a][b]) {           flag = true;           break;         }         dfs(a, b, x, y);       }     }   }   signed main() {     memset(fg, false, sizeof fg);     cin >> n >> m;     flag = false;     for (long long i = 1; i <= n; i++) scanf( %s , s[i] + 1);     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= m; j++) {         if (!fg[i][j]) {           fg[i][j] = true;           dfs(i, j, i, j);           if (flag) break;         }       }       if (flag) break;     }     if (flag)       cout <<  Yes ;     else       cout <<  No ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   #define pb push_back   #define endl   n    #define F first   #define S second   #define pp pop_back   ll mod = 1e9+7;   ll dp[200200][2];   ll st[200200];   ll n;      ll rec(ll level,int curr){       if(st[level]==1||st[level]==0){           if(curr!=st[level])return 0;       }       if(level==n-1){           return 1;       }       if(dp[level][curr]!=-1)return dp[level][curr];       return dp[level][curr] = 1+rec(level+1,1-curr);   }         int main()   {       ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);       ll t;cin>>t;       while(t--){           memset(dp,-1,sizeof(dp));memset(st,-1,sizeof(st));           string s;cin>>s;           n = (ll)s.size();           for(ll i=0;i<n;i++){               if(s[i]== 1  ||s[i]== 0 ){st[i]=s[i]- 0 ;}               else{                   st[i]=3;               }           }           ll ans = 0;           for(int i=0;i<n;i++){               ans+=max(rec(i,1),rec(i,0));           }           cout<<ans<<endl;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     long long a[n][m];     vector<long long> b(n);     for (int i = 0; i < n; i++) {       long long k = 0;       for (int j = 0; j < m; j++) {         cin >> a[i][j];         k += a[i][j];       }       b[i] = k;     }     if (n <= 4 || m <= 4) {       long long res = 0;       for (int i = 0; i < n; i++) res += b[i];       cout << res;       return 0;     }     vector<long long> c(m);     for (int j = 0; j < m; j++) {       long long k = 0;       for (int i = 0; i < n; i++) {         k += a[i][j];       }       c[j] = k;     }     long long res = 0;     vector<long long> d = b;     vector<long long> e = c;     sort(d.begin(), d.end());     sort(e.begin(), e.end());     res = max(d[n - 1] + d[n - 2] + d[n - 3] + d[n - 4],               e[m - 1] + e[m - 2] + e[m - 3] + e[m - 4]);     for (int i = 0; i < n; i++) {       vector<long long> f;       for (int j = 0; j < m; j++) {         f.push_back(c[j] - a[i][j]);       }       sort(f.begin(), f.end());       res = max(res, b[i] + f[m - 1] + f[m - 2] + f[m - 3]);     }     for (int j = 0; j < m; j++) {       vector<long long> f;       for (int i = 0; i < n; i++) {         f.push_back(b[i] - a[i][j]);       }       sort(f.begin(), f.end());       res = max(res, c[j] + f[n - 1] + f[n - 2] + f[n - 3]);     }     if (n <= m) {       for (int i = 0; i < n; i++) {         for (int l = i + 1; i < n; i++) {           vector<long long> f;           for (int j = 0; j < m; j++) {             f.push_back(c[j] - a[i][j] - a[l][j]);           }           sort(f.begin(), f.end());           res = max(res, b[i] + b[l] + f[m - 1] + f[m - 2]);         }       }     } else {       for (int j = 0; j < m; j++) {         for (int l = j + 1; j < m; j++) {           vector<long long> f;           for (int i = 0; i < n; i++) {             f.push_back(b[i] - a[i][j] - a[i][l]);           }           sort(f.begin(), f.end());           res = max(res, c[j] + c[l] + f[n - 1] + f[n - 2]);         }       }     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   int a[100010];   int b[100010];   int ans[100010];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       b[a[i]] = i;     }     ans[b[n]] = 0;     for (int i = n - 1; i >= 1; i--) {       int idx = b[i];       int flag = 0;       for (int j = idx + i; j <= n; j += i) {         if (a[j] > i && ans[j] == 0) {           flag = 1;           break;         }       }       for (int j = idx - i; j >= 1; j -= i) {         if (a[j] > i && ans[j] == 0) {           flag = 1;           break;         }       }       if (flag == 1) {         ans[idx] = 1;       } else {         ans[idx] = 0;       }     }     for (int i = 1; i <= n; i++) {       if (ans[i]) {         cout <<  A ;       } else {         cout <<  B ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e7;   vector<long long> primes;   vector<long long> p(N, 1);   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, p, w, d;     cin >> n >> p >> w >> d;     long long l = 0, r = n;     while (r - l > 10000000) {       long long wins = (l + r) / 2;       if (w * wins > p) {         r = wins - 1;         continue;       }       long long draws = (p - (wins * w)) / d;       if (draws < 0) {         l = wins + 1;         continue;       }       long long points = w * wins + d * draws;       cerr << wins <<     << draws <<     << points <<   n ;       if (points == p) {         if (wins + draws <= n) {           cout << wins <<     << draws <<     << n - wins - draws <<   n ;           return 0;         } else {           l = wins + 1;         }       } else {         if (points < p) {           l = wins + 1;         } else {           r = wins - 1;         }       }     }     for (long long wins = l; wins <= r; wins++) {       if (w * wins > p) {         continue;       }       long long draws = (p - (wins * w)) / d;       if (draws < 0) {         continue;       }       long long points = w * wins + d * draws;       if (points == p) {         if (wins + draws <= n) {           cout << wins <<     << draws <<     << n - wins - draws <<   n ;           return 0;         }       }     }     cout << -1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct chip {     int l;     int r;     int u;     int d;   };   vector<char> a[5005];   vector<chip> link1[5005], link2[5005];   int n, m, kq, res;   void nhap() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     char x;     for (int i = 1; i <= n; ++i) a[i].push_back(   );     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) {         cin >> x;         a[i].push_back(x);       }     for (int i = 1; i <= n; ++i) a[i].push_back(   );     for (int i = 0; i <= m + 1; ++i) {       a[0].push_back(   );       a[n + 1].push_back(   );     }     for (int i = 0; i <= n + 1; ++i)       for (int j = 0; j <= m + 1; ++j) {         chip x;         x.l = 0;         x.r = 0;         x.u = 0;         x.d = 0;         link1[i].push_back(x);         link2[i].push_back(x);       }   }   void prep() {     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (a[i][j] !=  . ) {           int l = j - 1, r = j + 1, u = i - 1, d = i + 1;           while (a[i][l] ==  .  && l > 0) --l;           while (a[i][r] ==  .  && r <= m) ++r;           while (a[u][j] ==  .  && u > 0) --u;           while (a[d][j] ==  .  && d <= n) ++d;           link1[i][j].l = l;           link1[i][j].r = r;           link1[i][j].u = u;           link1[i][j].d = d;         }   }   void xl(int x, int y) {     int dem = 0;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) link2[i][j] = link1[i][j];     while (a[x][y] !=  .  && x > 0 && x <= n && y > 0 && y <= m) {       ++dem;       int l = link2[x][y].l, r = link2[x][y].r, u = link2[x][y].u,           d = link2[x][y].d;       link2[x][l].r = r;       link2[x][r].l = l;       link2[u][y].d = d;       link2[d][y].u = u;       if (a[x][y] ==  L )         y = l;       else if (a[x][y] ==  R )         y = r;       else if (a[x][y] ==  U )         x = u;       else if (a[x][y] ==  D )         x = d;     }     kq = max(kq, dem);   }   void xl1(int x, int y) {     int dem = 0;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) link2[i][j] = link1[i][j];     while (a[x][y] !=  .  && x > 0 && x <= n && y > 0 && y <= m) {       ++dem;       int l = link2[x][y].l, r = link2[x][y].r, u = link2[x][y].u,           d = link2[x][y].d;       link2[x][l].r = r;       link2[x][r].l = l;       link2[u][y].d = d;       link2[d][y].u = u;       if (a[x][y] ==  L )         y = l;       else if (a[x][y] ==  R )         y = r;       else if (a[x][y] ==  U )         x = u;       else if (a[x][y] ==  D )         x = d;     }     if (dem == kq) ++res;   }   int main() {     nhap();     prep();     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (a[i][j] !=  . ) xl(i, j);     cout << kq <<    ;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (a[i][j] !=  . ) xl1(i, j);     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long INFF = 0x3f3f3f3f3f3f3f3fll;   const long long M = 1e9 + 7;   const long long maxn = 2e6 + 7;   const double eps = 0.00000001;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   template <typename T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   template <typename T>   inline T powMM(T a, T b) {     T ret = 1;     for (; b; b >>= 1ll, a = a * a % M) ret = 1ll * ret * a % M;     return ret;   }   set<int> SET;   set<int>::iterator it;   int n, m, t;   int i;   int len;   int mx;   char a[maxn], s[maxn];   int main() {     scanf( %d , &n);     for (i = 0; i <= 2e6; i++) SET.insert(i);     while (n--) {       scanf( %s , s);       len = strlen(s);       scanf( %d , &m);       while (m--) {         scanf( %d , &t);         t--;         for (it = SET.lower_bound(t); it != SET.end() && *it < t + len;              it = SET.lower_bound(t)) {           a[*it] = s[*it - t];           if (mx < *it) mx = *it;           SET.erase(it);         }       }     }     for (i = 0; i < mx + 1; i++) {       if (a[i])         putchar(a[i]);       else         putchar( a );     }   }
#include <bits/stdc++.h>   const int N = 1e6 + 5;   const int mod = 1e9 + 7;   const int MOD = mod - 1;   const double eps = 1e-18;   const double PI = acos(-1.0);   using namespace std;   char s[200];   int main() {     int n, m;     scanf( %d , &n), scanf( %d , &m);     scanf( %s , s + 1);     int l = strlen(s + 1);     while (m--) {       int l, r;       char a, b;       scanf( %d %d %c %c , &l, &r, &a, &b);       getchar();       for (int i = l; i <= r; i++)         if (s[i] == a) s[i] = b;     }     puts(s + 1);   }
#include <bits/stdc++.h>   using namespace std;   long long M = 1000000007;   int sum(int n) {     int ans = 0;     while (n) {       ans += n % 10;       n = n / 10;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int k;     cin >> k;     int ans = 18;     while (k) {       ans++;       if (sum(ans) == 10) k--;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   template <typename X>   inline X abs(const X& a) {     return a < 0 ? -a : a;   }   template <typename X>   inline X sqr(const X& a) {     return a * a;   }   long long combine(long long n, int k) {     long long ans = 1;     for (int i = 0; i < k; i++) ans = (ans * (n - i)) / (i + 1);     return ans;   }   long long pw(long long a, long long p) {     long long ans = 1;     for (int i = 0; i < p; i++) ans *= a;     return ans;   }   int toint(string s) {     int n = 0, k = 1;     for (int i = (int)s.size() - 1; i >= 0; i--) {       n += (s[i] -  0 ) * k;       k *= 10;     }     return n;   }   int main() {     int k, m, n, p;     int a = 0, b;     cin >> n >> k >> p, b = n * p;     while (n > 1) {       m = 1;       while (2 * m <= n) m <<= 1;       a += m * k + m / 2;       n = n - m + m / 2;     }     cout << a <<     << b << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> a[210000], b[2100000];   vector<pair<int, int> > ans;   int main() {     int N, M, i, j, k;     scanf( %d%d , &N, &M);     if (N <= M) {       puts( -1 );       return 0;     }     for (i = 0; i < N; i++) scanf( %d%d , &a[i].first, &a[i].second);     sort(a, a + N);     for (i = 0; i <= M; i++)       for (j = 0; i + j <= M; j++) {         int l = i, r = N - 1 - j;         int first = a[l].first + a[r].first, second = a[l].second + a[r].second;         bool flag = 1;         for (k = l; k <= r; k++)           b[k] = make_pair(first - a[k].first, second - a[k].second);         reverse(b + l, b + r + 1);         int p = l, q = l, cnt = 0;         while (p <= r && q <= r) {           if (a[p] < b[q])             ++p;           else if (a[p] > b[q])             ++q;           else {             ++cnt;             ++p;             ++q;           }         }         if (r - l + 1 - cnt + i + j <= M) ans.push_back(make_pair(first, second));       }     sort(ans.begin(), ans.end());     ans.resize(unique(ans.begin(), ans.end()) - ans.begin());     cout << ans.size() << endl;     for (i = 0; i < ans.size(); i++)       printf( %.12f %.12f n , ans[i].first / 2.0, ans[i].second / 2.0);   }
#include <bits/stdc++.h>   using namespace std;   long long N, L, W;   vector<long long> neg, pos;   long long INF32 = 0x7fffffff;   inline long long div_floor(long long a, long long b) {     return (long long)floor(1.0 * a / b);   }   int main() {     cin >> N >> L >> W;     for (int i = 0; i < N; ++i) {       long long x, d;       cin >> x >> d;       (d == 1 ? pos : neg).push_back(d == 1 ? x : x + L);     }     sort(pos.begin(), pos.end());     sort(neg.begin(), neg.end());     long long ans = 0;     for (auto x : pos) {       long long lval = max(-x - 1, x);       if (W == 1) {         if (x < 0) {         } else {           lval = INF32;         }       } else {         lval = max(lval, div_floor(((W + 1) * x), (W - 1)));       }       auto l = upper_bound(neg.begin(), neg.end(), lval);       ans += int(neg.end() - l);       lval = max(x, div_floor((W - 1) * x, (W + 1)));       long long rval = -x;       l = upper_bound(neg.begin(), neg.end(), lval);       auto r = lower_bound(neg.begin(), neg.end(), rval);       ans += max(0, int(r - l));     }     cout << ans << endl;     return 0;   }