malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long int fact[200005];   long long int n;   struct point {     long long int x, y;   };   bool cmp(struct point i1, struct point i2) {     if (i1.x != i2.x)       return i1.x < i2.x;     else {       return (i1.y < i2.y);     }   }   long long int fact_(long long int n) {     long long int ans = 1;     fact[0] = fact[1] = 1;     for (int i = 2; i <= n; i++) {       ans = (ans * i) % 1000000007;       fact[i] = ans % 1000000007;     }     return ans;   }   long long int mod_inv(long long int a, long long int b) {     long long int ans = 1;     while (b) {       if (b % 2 == 1) ans = (ans * a) % 1000000007;       a = (a * a) % 1000000007;       b = b >> 1;     }     return ans;   }   long long int ncr(long long int n, long long int r) {     if (n < r) return 0;     if (r == 0) return n;     if (r == 1) return n;     if (n == r) return 1;     return ((((fact[n] % 1000000007) *               mod_inv(fact[r] % 1000000007, 1000000007 - 2)) %              1000000007) *             mod_inv(fact[n - r] % 1000000007, 1000000007 - 2)) %            1000000007;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     vector<struct point> ar1(4), ar2(4);     for (int i = 0; i < 4; i++) {       long long int a, b;       cin >> a >> b;       ar1[i].x = a;       ar1[i].y = b;     }     for (int i = 0; i < 4; i++) {       long long int a, b;       cin >> a >> b;       ar2[i].x = a;       ar2[i].y = b;     }     sort(ar1.begin(), ar1.end(), cmp);     sort(ar2.begin(), ar2.end(), cmp);     bool f = 0;     for (int i = 0; i < 4; i++) {       if (ar2[i].x >= ar1[0].x && ar2[i].y >= ar1[0].y && ar2[i].x <= ar1[3].x &&           ar2[i].y <= ar1[3].y)         f = 1;     }     for (int i = 0; i < 4; i++) {       if ((ar1[i].x + ar1[i].y) >= (ar2[1].x + ar2[1].y) &&           (ar1[i].y - ar1[i].x) >= (ar2[1].y - ar2[1].x) &&           (ar1[i].x + ar1[i].y) <= (ar2[2].x + ar2[2].y) &&           (ar1[i].y - ar1[i].x) <= (ar2[2].y - ar2[2].x))         f = 1;     }     point c1, c2;     c1.x = (ar1[0].x + ar1[1].x) / 2;     c1.y = (ar1[0].y + ar1[3].y) / 2;     c2.x = (ar2[0].x + ar2[1].x) / 2;     c2.y = (ar2[0].y + ar2[3].y) / 2;     if (c2.x >= ar1[0].x && c2.y >= ar1[0].y && c2.x <= ar1[3].x &&         c2.y <= ar1[3].y)       f = 1;     if ((c1.x + c1.y) >= (ar2[1].x + ar2[1].y) &&         (c1.y - c1.x) >= (ar2[1].y - ar2[1].x) &&         (c1.x + c1.y) <= (ar2[2].x + ar2[2].y) &&         (c1.y - c1.x) <= (ar2[2].y - ar2[2].x))       f = 1;     if (!f)       cout <<  NO  << endl;     else {       cout <<  YES  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int N, M;     cin >> N >> M;     using Interval = pair<int, int>;     vector<Interval> intervals(N);     for (int i = 0; i < N; i++) {       cin >> intervals[i].first >> intervals[i].second;     }     int i = 0;     int current_time = 1;     for (int m = 0; m < M; m++) {       int moment;       cin >> moment;       while (i < N && moment > current_time +                                    intervals[i].first * intervals[i].second - 1) {         current_time += intervals[i].first * intervals[i].second;         i++;       }       assert(i < N);       cout << i + 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     long long p;     int d;   } store[200005];   bool cmp(node& a, node& b) { return a.d < b.d; }   bool check(int e, int full, int n) {     if (store[0].d > full) return 1;     for (int i = 0; i < (n - 1); ++i)       if (store[i + 1].d - store[i].d > full) return 1;     if (e - store[n - 1].d > full) return 1;     return 0;   }   int main(void) {     int e, full, n;     scanf( %d %d %d , &e, &full, &n);     for (int i = 0; i < (n); ++i) scanf( %d %lld , &store[i].d, &store[i].p);     sort(store, store + n, cmp);     if (check(e, full, n)) {       puts( -1 );       return 0;     }     long long ret = 0;     int cur = full - store[0].d;     for (int i = 0; i < (n); ++i) {       int d = store[i + 1].d - store[i].d;       int s = i + 1, minn = 1e7, indexx;       bool flag = 0;       while (d <= full && s < n) {         if (store[s].p <= store[i].p) {           if (d <= cur) {             cur -= d;           } else {             ret += (d - cur) * store[i].p;             cur = 0;           }           i = s - 1;           flag = 1;           break;         }         if (store[s].p <= minn) {           minn = store[i].p;           indexx = s;         }         s++;         d = store[s].d - store[i].d;       }       if (!flag) {         if (store[i].d + full >= e) {           ret += store[i].p * max(0, e - store[i].d - cur);           break;         }         ret += (full - cur) * store[i].p;         cur = full - (store[indexx].d - store[i].d);         i = indexx - 1;       }     }     printf( %lld , ret);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int getint() {     static char c;     while ((c = getchar()) <  0  || c >  9 )       ;     int res = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) res = res * 10 + c -  0 ;     return res;   }   const int MaxN = 200000;   int n;   int col[MaxN + 1];   struct state {     int x, l;     state() {}     state(const int &_x, const int &_l) : x(_x), l(_l) {}     friend inline bool operator<(const state &lhs, const state &rhs) {       if (lhs.x != rhs.x) return lhs.x < rhs.x;       return lhs.l < rhs.l;     }   };   state lower[MaxN + 1], upper[MaxN + 1];   int used[MaxN + 1];   int main() {     n = getint();     for (int i = 1; i <= n; ++i) col[i] = getint();     if (col[1] > 1) {       printf( -1 n );       return 0;     }     lower[1] = state(1, 1);     upper[1] = state(1, 1);     for (int i = 2; i <= n; ++i) {       lower[i] = lower[i - 1];       if (++lower[i].l > 5) ++lower[i].x, lower[i].l = 1;       upper[i] = upper[i - 1];       if (++upper[i].l > 2) ++upper[i].x, upper[i].l = 1;       if (col[i] > 0) {         state l(col[i], 1);         state r(col[i], 5);         lower[i] = max(lower[i], l);         upper[i] = min(upper[i], r);         if (lower[i].x > col[i] || upper[i].x < col[i]) {           printf( -1 n );           return 0;         }       }     }     state res = upper[n];     if (res.l == 1) res.l = 5, --res.x;     if (res < lower[n]) {       printf( -1 n );       return 0;     }     used[col[n] = res.x] = 1;     for (int i = n - 1; i >= 1; --i) {       col[i] = min(col[i + 1], upper[i].x);       col[i] -= used[col[i]] == 5;       ++used[col[i]];     }     printf( %d n , res.x);     for (int i = 1; i <= n; ++i) printf( %d  , col[i]);     return 0;   }
#include <bits/stdc++.h>   #define N 410   #define ll long long   #define ull unsigned long long   //#define mo (ll)((ll)1e9+7)   #define squ(x) ((x)*(x))   #define db double   #define all(x) x.begin(),x.end()   #define cmax(a,b) a=max(a,b)   #define cmin(a,b) a=min(a,b)   #define rep(i,l,r) for(register int i=l;i<=r;++i)   #define drep(i,r,l)for(register int i=r;i>=l;--i)   #define pb push_back   #define inline inline __attribute__((always_inline))   using namespace std;      inline ll read() {    ll x = 0, f = 1; char ch = getchar();    while (ch <  0  || ch >  9 ) {if (ch ==  - )f = -1; ch = getchar();}    while (ch >=  0  && ch <=  9 ) {x = x * 10 + ch -  0 ; ch = getchar();}    return x * f;   }   ll mo;   ll dp[N][N];      int fac[N], inv[N], bit[N];   ll Pow(ll a, ll b) {    ll res = 1;    a %= mo;    for (; b; b >>= 1, a = a * a % mo)     if (b & 1) res = res * a % mo;    return res;   }   void init_inv(int n) {    fac[0] = 1;    rep(i, 1, n)fac[i] = (ll)fac[i - 1] * i % mo;    inv[n] = Pow(fac[n], mo - 2);    drep(i, n, 1) inv[i - 1] = (ll)inv[i] * i % mo;   }   ll C(int n, int m) {    if (n < m)return 0;    return 1ll * fac[n] * inv[m] % mo * inv[n - m] % mo;   }   int main() {    int n = read(); mo = read();    init_inv(n);    bit[0] = 1; rep(i, 1, 400)bit[i] = bit[i - 1] * 1ll * 2 % mo;    dp[0][0] = 1;    rep(i, 0, n)rep(j, 0, i)if (dp[i][j] > 0) {     rep(k, 1, n - i)(dp[i + k + 1][j + k] += dp[i][j] * 1ll * C(j + k, k) % mo                      * bit[k - 1] % mo) %= mo;    }    ll ans = 0;    rep(i, 1, n)(ans += dp[n + 1][i]) %= mo;    printf( %lld n , ans);    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[20];   int main() {     int n, b[20];     cin >> n;     for (int i = 0; i < n; i++) cin >> b[i];     int kol = 1;     for (int i = 0; i < n; i++) kol *= 2;     for (int i = 0; i < kol; i++) {       int sum = 0;       a[n - 1]++;       for (int j = n - 1; j > 0; j--) {         a[j - 1] = a[j] / 2 + a[j - 1];         a[j] %= 2;       }       for (int j = 0; j < n; j++) {         if (a[j] == 1)           sum += b[j];         else           sum -= b[j];       }       sum = abs(sum);       sum %= 360;       if (sum == 0) {         cout <<  yes ;         return 0;       }     }     cout <<  no ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)500;   const int linf = (int)1e9 + 7;   const int mod = (int)1e9 + 7;   const int sN = (int)27000;   inline void ioi2020() {}   using ll = long long;   using ld = long double;   using ull = unsigned long long;   ll n, m, k;   ll a[N];   ll dp[(1 << 20)][20];   map<ll, ll> mp[N];   int main() {     ioi2020();     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 1; i <= k; i++) {       int a, b, c;       cin >> a >> b >> c;       mp[a - 1][b - 1] = c;     }     for (int mask = 0; mask < (1 << n); mask++) {       for (int bit = 0; bit < n; bit++) {         if ((mask >> bit) & 1) {           for (int sbit = 0; sbit < n; sbit++) {             if ((mask >> sbit) & 1) dp[mask][bit] += a[sbit];           }         }       }     }     for (int mask = 0; mask < (1 << n); mask++) {       for (int bit = 0; bit < n; bit++) {         if (!((mask >> bit) & 1)) {           for (int sbit = 0; sbit < n; sbit++) {             if ((mask >> sbit) & 1)               dp[(mask ^ (1 << bit))][bit] =                   max(dp[(mask ^ (1 << bit))][bit],                       dp[mask][sbit] + mp[sbit][bit] + a[bit]);           }         }       }     }     ll res = 0;     for (int mask = 0; mask < (1 << n); mask++) {       if (__builtin_popcount(mask) == m) {         for (int bit = 0; bit < n; bit++) {           res = max(res, dp[mask][bit]);         }       }     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXP = 1e5;   long long int n, s, p, q, x, sell[MAXP + 5] = {0}, buy[MAXP + 5] = {0};   char d;   vector<pair<long long int, long long int> > ansell;   int main() {     cin >> n >> s;     for (int i = 0; i < n; i++) {       cin >> d >> p >> q;       if (d ==  S )         sell[p] += q;       else         buy[p] += q;     }     x = 0;     for (int i = 0; i <= MAXP; i++) {       if (x == s) break;       if (sell[i]) {         ansell.push_back(make_pair(i, sell[i]));         x++;       }     }     for (int i = ((int(ansell.size()))) - 1; i >= 0; i--)       cout <<  S   << ansell[i].first <<     << ansell[i].second << endl;     x = 0;     for (int i = MAXP; i >= 0; i--) {       if (x == s) break;       if (buy[i]) {         cout <<  B   << i <<     << buy[i] << endl;         x++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int tm[100005];   int gcd(int a, int b) {     int r;     while (b > 0) {       r = a % b;       a = b;       b = r;     }     return a;   }   int main() {     int n, i, j, tt, m;     scanf( %d , &n);     scanf( %d , &tm[1]);     for (i = 2; i <= n; i++) {       scanf( %d , &tm[i]);     }     int flag = 0;     while (tm[1] % 2 == 0) tm[1] /= 2;     while (tm[1] % 3 == 0) tm[1] /= 3;     int gd = tm[1];     for (i = 1; i <= n; i++) {       while (tm[i] % 2 == 0) tm[i] /= 2;       while (tm[i] % 3 == 0) tm[i] /= 3;       if (tm[i] == tm[1])         continue;       else {         flag = 1;         break;       }     }     if (flag)       printf( NO n );     else       printf( YES n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     string ans =  no ;     cin >> n;     vector<int> lineas(n);     for (int i = 0; i < n; i++) {       int a;       cin >> a;       lineas[i] = a;     }     int minimo;     int maximo;     for (int i = 0; i < n - 1; i++) {       minimo = min(lineas[i], lineas[i + 1]);       maximo = max(lineas[i], lineas[i + 1]);       for (int j = 0; j < n - 1; j++) {         if (j != i) {           int anterior = min(lineas[j], lineas[j + 1]);           int siguiente = max(lineas[j], lineas[j + 1]);           if (siguiente < maximo and minimo < siguiente and anterior < minimo) {             ans =  yes ;           }           if (minimo < anterior and maximo < siguiente and anterior < maximo) {             ans =  yes ;           }         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long Pos[1 << (24)], dp[1 << (24)];   int a, b;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> Pos[1 << i];     }     int m;     cin >> m;     if (m) cin >> a, m--;     if (m) cin >> b, m--;     int upper = 1 << n;     dp[0] = 1;     for (int i = 1; i < upper; ++i) {       int GetLow = ((i) & (-(i))), tmp = i;       Pos[i] = Pos[GetLow] + Pos[GetLow ^ i];       if (Pos[i] == a || Pos[i] == b) continue;       while (tmp) {         int s = dp[i] + dp[GetLow ^ i];         dp[i] = s > (1000000007) ? s - (1000000007) : s;         tmp ^= ((tmp) & (-(tmp)));         GetLow = ((tmp) & (-(tmp)));       }     }     cout << dp[(1 << n) - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, k, n;     cin >> n;     k = n / 2;     for (i = 1; i <= n; i++) {       cout << (i - 1) * k + 1;       for (j = (i - 1) * k + 2; j <= i * k; j++) cout <<     << j;       for (j = n * n - (i - 1) * k; j > n * n - i * k; j--) cout <<     << j;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int ppr = 257;   const long long INF = 2e18;   const int inf = 2e9;   const int mod = 1e9 + 7;   const int N = 1e6 + 123;   const long double pi = 3.141592653589793238462643;   const int dx[] = {1, 0, -1, 0};   const int dy[] = {0, 1, 0, -1};   int n, dp[55][55][55][55], a[55][55], p[55][55];   bool u[55][55][55][55];   inline int get(int x1, int aza_ibagaliev, int x2, int y2) {     return p[x2][y2] - p[x2][aza_ibagaliev - 1] - p[x1 - 1][y2] +            p[x1 - 1][aza_ibagaliev - 1];   }   int calc(int x1, int aza_ibagaliev, int x2, int y2) {     if (u[x1][aza_ibagaliev][x2][y2]) return dp[x1][aza_ibagaliev][x2][y2];     u[x1][aza_ibagaliev][x2][y2] = 1;     dp[x1][aza_ibagaliev][x2][y2] = max((x2 - x1 + 1), (y2 - aza_ibagaliev + 1)) *                                     (get(x1, aza_ibagaliev, x2, y2) > 0);     for (int i = x1; i < x2; i++) {       dp[x1][aza_ibagaliev][x2][y2] = min(           dp[x1][aza_ibagaliev][x2][y2],           calc(x1, aza_ibagaliev, i, y2) + calc(i + 1, aza_ibagaliev, x2, y2));     }     for (int i = aza_ibagaliev; i < y2; i++) {       dp[x1][aza_ibagaliev][x2][y2] =           min(dp[x1][aza_ibagaliev][x2][y2],               calc(x1, aza_ibagaliev, x2, i) + calc(x1, i + 1, x2, y2));     }     return dp[x1][aza_ibagaliev][x2][y2];   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         char c;         cin >> c;         a[i][j] = (c ==  # );         p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + a[i][j];       }     cout << calc(1, 1, n, n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n;   int main() {     cin >> n;     long long int summ = n + (n - 1);     long long int wei = 0;     while (summ != 0) {       summ /= 10;       wei++;     }     long long int stdl = 9;     for (int i = 1; i < wei; i++) {       stdl = stdl * 10 + 9;     }     summ = n + (n - 1);     if (summ < stdl) wei--, stdl /= 10;     long long int ans, p = stdl / 2;     ans = min(p, n - p);     long long int qian = 1;     for (int i = 1; i <= wei; i++) qian *= 10;     while (stdl + qian <= summ) {       stdl += qian;       p = stdl / 2;       ans += min(p, n - p);     }     if (n < 5) {       if (n == 2) ans = 1;       if (n == 3) ans = 3;       if (n == 4) ans = 6;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int const N = 100 * 1000 + 16;   int const M = 1000 * 1000 * 1000 + 7;   int n, k;   int a[N];   int c[N];   ll e, v[N];   vector<int> idx[N];   struct wavelet {     int L, R;     vector<int> b;     wavelet* l = 0;     wavelet* r = 0;     wavelet(int* pl, int* pr, int L, int R) {       this->L = L;       this->R = R;       if (L == R || pl >= pr) return;       int M = L + R >> 1;       auto f = [M](int x) { return x <= M; };       b.reserve(pr - pl + 1);       b.emplace_back(0);       for (auto p = pl; p != pr; ++p) b.emplace_back(b.back() + f(*p));       auto pm = stable_partition(pl, pr, f);       l = new wavelet(pl, pm, L, M);       r = new wavelet(pm, pr, M + 1, R);     }     ~wavelet() {       delete l;       delete r;     }     int query(int l, int r, int k) {       if (k < L || l >= r) return 0;       if (R <= k) return r - l;       int lf = b.size() > l ? b[l] : 0;       int rg = b.size() > r ? b[r] : 0;       return (this->l ? this->l->query(lf, rg, k) : 0) +              (this->r ? this->r->query(l - lf, r - rg, k) : 0);     }   };   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     cin >> n >> k;     fill_n(a + 1, n, n + 1);     for (int i = 1; i <= n; ++i) {       int x;       cin >> x;       idx[x].emplace_back(i);       if (++c[x] > k) a[idx[x][c[x] - k - 1]] = i;     }     wavelet t(a + 1, a + 1 + n, 1, 1000 * 1000 * 1000);     int q;     cin >> q;     int last = 0;     while (q--) {       int xi, yi;       cin >> xi >> yi;       int l = (xi + last) % n + 1;       int r = (yi + last) % n + 1;       if (l > r) swap(l, r);       int z = t.query(l - 1, r, r);       last = r - l + 1 - z;       cout << last <<   n ;     }     cout << flush;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   const double eps = 1e-8;   bool order(double a, double b, double c) { return a < b && b < c; }   int main() {     double h, m, s, t1, t2;     cin >> h >> m >> s >> t1 >> t2;     s /= 60;     m = m / 60 + s / 60;     h = h / 12 + m / 12;     if (m >= 1 - eps) m -= 1;     if (h >= 1 - eps) h -= 1;     t1 /= 12;     t2 /= 12;     if (t1 >= 1 - eps) t1 -= 1;     if (t2 >= 1 - eps) t2 -= 1;     if (t1 > t2) swap(t1, t2);     bool should = order(t1, h, t2);     if (should == order(t1, m, t2) && should == order(t1, s, t2))       puts( YES );     else       puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 7;   const int MOD = 1e9 + 7;   vector<int> Gimp[MAXN];   vector<int> Gcrew[MAXN];   vector<int> G[MAXN];   int comp[MAXN];   int compSize[MAXN];   bool vis[MAXN];   bool col[MAXN];   bool ans;   int res;   int allSize;   void DFScomp(int v, int nr) {     comp[v] = nr;     ++compSize[nr];     for (auto u : Gcrew[v]) {       if (comp[u] > 0) continue;       DFScomp(u, nr);     }   }   void DFScolor(int v, bool c) {     vis[v] = true;     col[v] = c;     if (c) res += compSize[v];     allSize += compSize[v];     for (auto u : G[v]) {       if (vis[u]) {         if (col[u] == c) ans = false;         continue;       }       DFScolor(u, !c);     }   }   void solve() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= m; ++i) {       int u, v;       string c;       cin >> u >> v >> c;       if (c ==  imposter ) {         Gimp[v].push_back(u);         Gimp[u].push_back(v);       } else {         Gcrew[v].push_back(u);         Gcrew[u].push_back(v);       }     }     int c = 1;     for (int i = 1; i <= n; ++i) {       if (comp[i] == 0) {         DFScomp(i, c);         ++c;       }     }     for (int v = 1; v <= n; ++v) {       for (auto u : Gimp[v]) {         G[comp[u]].push_back(comp[v]);         G[comp[v]].push_back(comp[u]);       }     }     int best = 0;     ans = true;     for (int i = 1; i < c; ++i) {       if (!vis[i]) {         res = 0;         allSize = 0;         DFScolor(i, 0);         best += max(res, allSize - res);       }     }     if (!ans) best = -1;     cout << best <<   n ;     for (int i = 1; i <= n; ++i) {       Gimp[i].clear();       Gcrew[i].clear();       G[i].clear();       col[i] = 0;       comp[i] = 0;       compSize[i] = 0;       vis[i] = false;     }   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     int T;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k;     cin >> n;     cin >> k;     if (n % 2 == 0) {       if (k <= (n / 2))         cout << 2 * (k - 1) + 1;       else {         k = k - (n / 2);         cout << 2 * k;       }     } else {       if (k <= (n + 1) / 2)         cout << 2 * (k - 1) + 1;       else {         k = k - (n + 1) / 2;         cout << 2 * k;       }     }   }
#include <bits/stdc++.h>   using ll = long long;   using namespace std;   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     int n, r;     cin >> n >> r;     double R = -r / (sin(acos(-1) / n) - 1);     double ans = R - r;     cout << fixed << setprecision(10) << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long t, d, ct, q, ans, l, m, r, n, mx, mn, i, j, k, x, y, z, s;   char ch;   string ss =   , str =   ;   map<pair<long long, long long>, long long> mp;   set<long long> st;   long long a[300003], b[300003];   vector<pair<long long, long long>> v;   bool ask(long long k) {     long long i;     for (i = 0; i < v.size(); i++)       if (v[i].first != k && v[i].second != k) break;     if (i == v.size()) return 1;     long long x = v[i].first;     long long g = k;     if (x > k) swap(x, k);     if (a[x] + a[k] - mp[{x, k}] == m) return 1;     x = v[i].second;     if (x > g) swap(x, g);     if (a[x] + a[g] - mp[{x, g}] == m) return 1;     return 0;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr);     s = k = d = l = mx = m = mn = r = q = i = j = z = x = y = ct = ans = 0;     cin >> n >> m;     for (i = 0; i < m; i++) {       cin >> x >> y, a[x]++, a[y]++;       v.push_back({x, y});       if (x > y) swap(x, y);       mp[{x, y}]++;     }     x = v[0].first;     y = v[0].second;     bool ya = ask(x);     if (ya) {       cout <<  YES ;       return 0;     }     ya = ask(y);     if (ya) {       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(NULL);     string sub, inp =   ;     while (cin >> sub) {       inp += sub;     }     string s =   ;     for (int i = 0; i < (int)inp.size(); ++i) {       if (inp[i] ==  a ) {         inp[i - 2] ==  /  ? s +=  A  : s +=  a ;       } else if (inp[i] ==  r ) {         inp[i - 2] ==  /  ? s +=  R  : s +=  r ;       } else if (inp[i] ==  d ) {         inp[i - 2] ==  /  ? s +=  D  : s +=  d ;       }     }     vector<int> st, ans;     for (int i = 0; i < static_cast<int>((s).size()); ++i) {       if (s[i] ==  a ) {         st.push_back(0);       } else if (s[i] ==  A ) {         ans.push_back(st.back());         st.pop_back();       } else if (s[i] ==  d ) {         st[static_cast<int>((st).size()) - 1]++;       }     }     sort(ans.begin(), ans.end());     for (auto x : ans) cout << x <<    ;     cout <<   n ;     return 0;   }