malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   long long mpow(long long x, long long y) {     if (y == 0) return 1;     if (y % 2) return x * mpow(x, y - 1) % MOD;     long long h = mpow(x, y / 2);     return h * h % MOD;   }   long long arr[111111];   int main() {     int k;     scanf( %d , &k);     for (int i = 0; i < k; i++) scanf( %lld , arr + i);     long long p = 2;     for (int i = 0; i < k; i++) p = mpow(p, arr[i]);     p = p * mpow(2, MOD - 2) % MOD;     long long q = p;     if (all_of(arr, arr + k, [&](long long i) { return i % 2; }))       p = (p - 1 + MOD) % MOD;     else       p = (p + 1) % MOD;     p = p * mpow(3, MOD - 2) % MOD;     printf( %lld/%lld , p, q);   }
#include <bits/stdc++.h>   using namespace std;   long long solve() {     long long m, n, i, j;     string a, b;     cin >> m >> n >> a >> b;     long long t[m + 1][n + 1];     memset(t, 0, sizeof(t));     long long sol = 0;     for (i = 1; i <= m; i++)       for (j = 1; j <= n; j++) {         if (a[i - 1] == b[j - 1])           t[i][j] = 2 + t[i - 1][j - 1];         else           t[i][j] = max(t[i - 1][j], t[i][j - 1]) - 1;         t[i][j] = max((long long)0, t[i][j]);         sol = max(sol, t[i][j]);       }     return sol;   }   int32_t main() {     long long t = 1;     while (t--) cout << solve() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int nm = 0, f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) nm = nm * 10 + c -  0 ;     return nm * f;   }   long long cup[10001], flow[10001], to[10001], head[10001], nxt[10001],       deep[10001];   bool vis[10001];   int n, m, s, t, cnt = 1;   long long ans = 0;   void push(int vi, int vj, long long v) {     cnt++, to[cnt] = vj, nxt[cnt] = head[vi], head[vi] = cnt, cup[cnt] = v;     cnt++, to[cnt] = vi, nxt[cnt] = head[vj], head[vj] = cnt;   }   bool bfs(int be, int ed) {     memset(deep, 0, sizeof(deep));     deep[be] = 1;     queue<int> q;     q.push(be);     while (!q.empty()) {       int now = q.front();       q.pop();       for (int i = head[now]; i; i = nxt[i]) {         int vj = to[i];         if (flow[i] >= cup[i] || deep[vj]) continue;         deep[vj] = deep[now] + 1;         q.push(vj);         if (vj == ed) return true;       }     }     return false;   }   long long dfs(int now, int ed, long long f) {     if (f == 0 || now == ed) return f;     long long tot = 0, x;     for (int i = head[now]; i; i = nxt[i]) {       int vj = to[i];       if (deep[vj] != deep[now] + 1) continue;       if (x = dfs(vj, ed, min(f, cup[i] - flow[i]))) {         flow[i] += x;         flow[i ^ 1] -= x;         tot += x;         f -= x;       }       if (f == 0) break;     }     if (tot == 0) deep[now] = -1;     return tot;   }   void Dinic(int be, int ed) {     while (bfs(be, ed)) ans -= dfs(be, ed, 1ll << 50);   }   int main() {     n = read(), m = read();     s = n + m + 1, t = s + 1;     for (int i = 1; i <= n; i++) {       push(i, t, read());     }     for (int i = 1; i <= m; i++) {       int vi = read(), vj = read(), v = read();       ans += v;       push(s, n + i, v);       push(n + i, vi, 1ll << 50);       push(n + i, vj, 1ll << 50);     }     Dinic(s, t);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2036000;   const long long INF = 199999999999LL;   int n, m;   long long a[N], b[N];   long long first, second, mod;   long long w[N], t[N];   int nn;   void AddA(int &i) {     w[nn] = a[i++];     t[nn++] = 1;   }   void AddB(int &j) {     w[nn] = b[j++];     t[nn++] = 2;   }   int main() {     cin >> n;     cin >> n >> a[0] >> first >> second >> mod;     for (int i = (1); i < (int)(n); i++) a[i] = (a[i - 1] * first + second) % mod;     cin >> m >> b[0] >> first >> second >> mod;     for (int j = (1); j < (int)(m); j++) b[j] = (b[j - 1] * first + second) % mod;     int i = 0, j = 0;     nn = 0;     long long lt = -INF;     while (i < n || j < m) {       if (i == n) {         AddB(j);       } else if (j == m) {         AddA(i);       } else {         bool ga = a[i] >= lt;         bool gb = b[j] >= lt;         if (ga ^ gb) {           if (ga) {             AddA(i);           } else {             AddB(j);           }         } else {           if (a[i] < b[j]) {             AddA(i);           } else {             AddB(j);           }         }       }       lt = w[nn - 1];     }     int bad = 0;     for (int k = (1); k < (int)(nn); k++) bad += (w[k] < w[k - 1]);     cout << bad << endl;     if (n + m <= 200000) {       for (int k = (0); k < (int)(nn); k++) cout << w[k] <<     << t[k] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 5;   const int inf = 1e9 + 1;   const long long OO = 1e18;   long long p1, p2, c1, c2, w1, w2;   long long solve() {     long long a2, b1, b3, ans = 0;     for (int i = 0; i <= min(p1 / w1, c1); i++) {       long long a2 = min((p1 - i * w1) / w2, c2);       long long b1 = min(p2 / w1, c1 - i);       long long b2 = min((p2 - b1 * w1) / w2, c2 - a2);       ans = max(ans, i + a2 + b1 + b2);     }     return ans;   }   int main() {     int t;     cin >> t;     while (t--) {       cin >> p1 >> p2 >> c1 >> c2 >> w1 >> w2;       if (w1 > w2) {         swap(w1, w2);         swap(c1, c2);       }       cout << solve() <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, lam, mx = 0, c = 0;     cin >> n;     vector<int> cand(n);     for (int i = 0; i < n; i++) {       cin >> cand[i];       if (mx < cand[i]) mx = cand[i];     }     for (int i = 0; i < n; i++)       if (mx == cand[i]) c++;     int x = lam = cand[0];     if (lam == mx && c > 1) return cout <<  1 , 0;     if (lam == mx && c == 1) return cout <<  0 , 0;     sort(cand.begin(), cand.end());     while (lam <= cand[n - 1]) {       lam += 1;       cand[n - 1] -= 1;       sort(cand.begin(), cand.end());     }     cout << lam - x;   }
#include <bits/stdc++.h>   using namespace std;   int64_t *arry[3];   int main(void) {     int64_t n, p, q, r;     cin >> n >> p >> q >> r;     for (int i = 0; i < 3; i++) {       arry[i] = (int64_t *)malloc(sizeof(int64_t) * n);     }     for (int i = 0; i < n; i++) {       int buf;       cin >> buf;       arry[0][i] = buf * p;       arry[1][i] = buf * q;       arry[2][i] = buf * r;     }     {       int64_t *pt = (int64_t *)malloc(sizeof(int64_t) * n);       pt[n - 1] = arry[2][n - 1];       for (int i = n - 1; i > 0; i--) {         pt[i - 1] = max(pt[i], arry[2][i - 1]);       }       free(arry[2]);       arry[2] = pt;     }     {       int64_t *pt = (int64_t *)malloc(sizeof(int64_t) * n);       for (int i = 0; i < n; i++) {         pt[i] = arry[1][i] + arry[2][i];       }       free(arry[1]);       arry[1] = pt;     }     {       int64_t *pt = (int64_t *)malloc(sizeof(int64_t) * n);       pt[0] = *arry[0];       for (int i = 1; i < n; i++) {         pt[i] = max(pt[i - 1], arry[0][i]);       }       free(arry[0]);       arry[0] = pt;     }     int64_t max = arry[0][0] + arry[1][0];     for (int i = 1; i < n; i++) {       int64_t buf = arry[0][i] + arry[1][i];       if (buf > max) max = buf;     }     cout << max << endl;     for (int i = 0; i < 3; i++) {       free(arry[i]);     }   }
#include <bits/stdc++.h>   int main() {     int n, w = 0, k = 1, i = 0, t = 0;     scanf( %d , &n);     int a[n];     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       if (a[i] > t) t = a[i];     }     for (i = 0; i < n; i++) {       if ((a[i] == t) && (a[i + 1] == t))         k++;       else if ((a[i] == t) && (a[i + 1] != t)) {         if (k > w) w = k;         k = 1;       }     }     printf( %d , w);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int func(long long int n) {     long long int res = 0;     while (n != 0) {       n /= 10;       res++;     }     return res;   }   int main() {     long long int w, m, k;     cin >> w >> m >> k;     long long int n = func(m), tr = w / k, res = 0;     while (tr > 0) {       long long int dum = pow(10, n) - m;       res += fmin(tr / n, dum);       tr -= dum * n;       m += dum;       n++;     }     cout << res;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimization( O3 )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( avx,avx2,fma )   using namespace std;   int main() {     long double r, x1, y1, x2, y2;     cin >> r >> x1 >> y1 >> x2 >> y2;     long double x = sqrt((y1 - y2) * (y1 - y2) + (x1 - x2) * (x1 - x2));     if (x - r >= 0)       cout << fixed << setprecision(10) << x1 <<     << y1 <<     << r;     else {       if (x == 0) {         cout << x1 - r / 2 <<     << y1 <<     << r / 2;         return 0;       }       x1 = x1 + ((x - r) / 2) * (x2 - x1) / x;       y1 = y1 + ((x - r) / 2) * (y2 - y1) / x;       cout << fixed << setprecision(10) << x1 <<     << y1 <<                << r - (r - x) / 2;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Rd(int &x) {     static char c;     x = 0;     while ((c = getchar()) < 48)       ;     do x = (x << 3) + (x << 1) + (c ^ 48);     while ((c = getchar()) > 47);   }   int n;   int Next[200004 << 1], V[200004 << 1], W[200004], Head[200004], tot;   void Add_Edge(int u, int v) { Next[++tot] = Head[u], V[Head[u] = tot] = v; }   int Sz[200004], G, Mn, Nowsz;   bool Mark[200004];   long long Ans, Dis[200004];   void GetG(int x, int f) {     int y, mx = 0;     Sz[x] = 1;     for (int i = Head[x]; i; i = Next[i])       if (!Mark[y = V[i]] && y != f) {         GetG(y, x);         Sz[x] += Sz[y];         mx = max(mx, Sz[y]);       }     mx = max(mx, Nowsz - Sz[x]);     if (mx < Mn) Mn = mx, G = x;   }   int m;   struct Node {     int l;     long long d;   } D[200004];   long long Calc(int x) {     long long Tmp[2] = {0, 0}, Cnt[2] = {0, 0}, Res = 0;     for (int i = (0), i_end_ = (m); i < i_end_; ++i)       (Tmp[D[i].l & 1] += D[i].d) %= 1000000007, Cnt[D[i].l & 1]++;     Res -= 2 * Cnt[1] * Tmp[1] + Cnt[1] * Cnt[1] % 1000000007 * W[x];     Res += 2 * Cnt[0] * Tmp[0] + Cnt[0] * Cnt[0] % 1000000007 * W[x];     return Res % 1000000007;   }   void Gets(int x, int f, int d) {     D[m++] = (Node){d, Dis[x]};     int y;     Sz[x] = 1;     for (int i = Head[x]; i; i = Next[i])       if (!Mark[y = V[i]] && y != f) {         Dis[y] = Dis[x] + ((d & 1) ? W[y] : -W[y]);         Gets(y, x, d + 1);         Sz[x] += Sz[y];       }   }   void Work(int x, int sz) {     Mn = 200004, Nowsz = sz;     GetG(x, 0);     Mark[x = G] = 1;     m = Dis[x] = 0;     Gets(x, 0, 0);     Ans += Calc(x);     if (sz == 1) return;     int y;     for (int i = Head[x]; i; i = Next[i])       if (!Mark[y = V[i]]) {         m = 0;         Gets(y, x, 1);         Ans -= Calc(x);         Work(y, Sz[y]);       }   }   int main() {     Rd(n);     for (int i = (1), i_end_ = (n + 1); i < i_end_; ++i) scanf( %d , &W[i]);     for (int i = (1), i_end_ = (n); i < i_end_; ++i) {       int u, v, w;       Rd(u), Rd(v);       Add_Edge(u, v);       Add_Edge(v, u);     }     Work(1, n);     printf( %I64d n , (Ans % 1000000007 + 1000000007) % 1000000007);     return 0;   }
#include<bits/stdc++.h>   using namespace std;   typedef long long ll;   const ll MOD =  998244353;   #define rep(i,a,b) for(ll i=a;i<b;++i)    #define pii pair<int,int>      int main()   {       ios_base::sync_with_stdio(0);       cin.tie(0);       int tt=1;       cin>>tt;       while(tt--)       {           int n;           cin>>n;           int a[n];           rep(i,0,n)           cin>>a[i];           vector<int> v;           rep(i,0,n)           {               v.push_back(a[i]);               int p = i+1;               rep(j,i+1,n)               {                   p = j;                   if(a[j]>a[i]) break;                   v.push_back(a[j]);               }               reverse(v.begin()+i,v.end());               i = p-1;               if(p==n-1 && v.size()==n) i=n;           }           for(int i=v.size()-1;i>=0;--i)           cout<<v[i]<<   ;           cout<<  n ;       }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a[120], i, j, res;     while (scanf( %d %d , &n, &m) == 2) {       for (i = 1; i <= n; i++) {         scanf( %d , &a[i]);       }       bool flag = true;       int k = 0;       while (flag) {         for (i = 1; i <= n; i++) {           if (a[i]) {             if (a[i] <= m) {               a[i] = 0;               k++;               if (k == n) {                 flag = false;                 res = i;               }             } else if (a[i] > m) {               a[i] -= m;             }           }         }       }       printf( %d n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     double r, v, si, fi;     cin >> n >> r >> v;     for (int i = 0; i < n; i++) {       cin >> si >> fi;       double dist = fi - si;       double cir = 2 * 3.14159265358979323846 * r;       double rev = dist / cir;       rev = floor(rev);       double time = rev * (cir / v);       dist -= time * v;       double left = 0;       double right = cir / v;       double x;       while (right - left > 1e-12) {         double mid = (left + right) / 2;         double temp =             2 * r * sin((mid * 3.14159265358979323846) / (cir / v)) + mid * v;         if (temp >= dist) {           right = mid;         } else           left = mid;       }       time += left;       printf( %.12f n , time);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 5;   int n, Q, x;   int fa[N], fv[N];   vector<int> c[N];   struct nod {     int i, l, r;   } b;   vector<nod> a[N];   int pl, pr;   long long px;   long long t[N * 4], lz[N * 4];   void down(int i) {     if (lz[i]) {       t[i + i] += lz[i];       lz[i + i] += lz[i];       t[i + i + 1] += lz[i];       lz[i + i + 1] += lz[i];       lz[i] = 0;     }   }   void add(int i, int x, int y) {     if (y < pl || x > pr) return;     if (x >= pl && y <= pr) {       t[i] += px;       lz[i] += px;       return;     }     int m = x + y >> 1;     down(i);     add(i + i, x, m);     add(i + i + 1, m + 1, y);     t[i] = min(t[i + i], t[i + i + 1]);   }   void ft(int i, int x, int y) {     if (y < pl || x > pr) return;     if (x >= pl && y <= pr) {       px = min(px, t[i]);       return;     }     int m = x + y >> 1;     down(i);     ft(i + i, x, m);     ft(i + i + 1, m + 1, y);   }   int p[N], q[N], tp;   long long s[N];   const long long M = 1e18;   void dg(int x) {     p[x] = ++tp;     for (int j = 0, B = c[x].size() - 1; j <= B; j++) {       int y = c[x][j];       s[y] = s[x] + fv[y], dg(y);     }     q[x] = tp;     if (p[x] == q[x]) {       pl = pr = p[x];       px = s[x] - M;       add(1, 1, n);     }   }   long long ans[N];   void dfs(int x) {     for (int j = 0, B = a[x].size() - 1; j <= B; j++) {       pl = a[x][j].l, pr = a[x][j].r;       px = 1e18;       ft(1, 1, n);       ans[a[x][j].i] = px;     }     for (int j = 0, B = c[x].size() - 1; j <= B; j++) {       int y = c[x][j];       px = -fv[y];       pl = p[y];       pr = q[y];       add(1, 1, n);       px = fv[y];       pl = 1;       pr = p[y] - 1;       add(1, 1, n);       pl = q[y] + 1;       pr = n;       add(1, 1, n);       dfs(y);       px = -fv[y];       pl = q[y] + 1;       pr = n;       add(1, 1, n);       pl = 1;       pr = p[y] - 1;       add(1, 1, n);       px = fv[y];       pl = p[y];       pr = q[y];       add(1, 1, n);     }   }   int main() {     scanf( %d %d , &n, &Q);     for (int i = 1, B = n * 4; i <= B; i++) t[i] = 1e18;     for (int i = 2, B = n; i <= B; i++) {       scanf( %d %d , &fa[i], &fv[i]);       c[fa[i]].push_back(i);     }     for (int i = 1, B = Q; i <= B; i++) {       scanf( %d , &x);       scanf( %d %d , &b.l, &b.r);       b.i = i;       a[x].push_back(b);     }     dg(1);     dfs(1);     for (int i = 1, B = Q; i <= B; i++) printf( %I64d n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int NWarm, NChip;     cin >> NWarm >> NChip;     int temp = NWarm * (NWarm + 1) / 2;     int ans = NChip % temp;     int i;     for (i = 1; i <= temp; i++) {       ans = ans - i;       if (ans < 0) break;     }     int ans1 = ans + i;     cout << ans1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<int> start(m);     vector<int> ending(m);     vector<int> time(m);     vector<int> prize(m);     int money = 0;     for (int i = 0; i < m; i++) {       cin >> start[i] >> ending[i] >> time[i] >> prize[i];     }     int mn = 9000;     int currprize;     for (int j = 1; j <= n; j++) {       mn = 9000;       currprize = 0;       for (int i = 0; i < m; i++) {         if (start[i] <= j && ending[i] >= j && time[i] < mn) {           mn = time[i];           currprize = prize[i];         }       }       money += currprize;     }     cout << money << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 200005;   const int Maxd = 10;   int bits[1 << Maxd];   int t;   char str[Maxn];   int slen;   int main() {     for (int i = 1; i < 1 << Maxd; i++) bits[i] = 1 + bits[i - (i & -i)];     scanf( %d , &t);     while (t--) {       scanf( %s , str);       slen = strlen(str);       int cur = 0;       for (int i = 0; i < slen; i++) cur ^= 1 << int(str[i] -  0 );       bool solved = false;       for (int i = slen - 1; i >= 0 && !solved; i--) {         int my = str[i] -  0 ;         cur ^= 1 << my;         for (int j = my - 1; j >= 0 && !solved; j--) {           cur ^= 1 << j;           if (i + 1 + bits[cur] <= slen) {             solved = true;             str[i] = j +  0 ;             int pnt = i + 1;             int lft = slen - (i + 1 + bits[cur]);             while (lft--) str[pnt++] =  9 ;             for (int l = Maxd - 1; l >= 0; l--)               if (cur & 1 << l) str[pnt++] =  0  + l;           }           cur ^= 1 << j;         }       }       int pnt = 0;       while (str[pnt] ==  0 ) pnt++;       for (int i = pnt; i < slen - pnt; i++) printf( %c , str[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   int n;   vector<int> v, lm, rm;   class SegmentTreeMax {    public:     int n;     vector<long long> vect;     SegmentTreeMax(int _n) : n(_n) {       vect.resize(2 * n);       fill(vect.begin(), vect.end(), 0);     }     void modify(int p, long long value) {       for (vect[p += n] = value; p > 1; p >>= 1) {         int val = rm[vect[p]] > rm[vect[p ^ 1]] ? vect[p] : vect[p ^ 1];         vect[p >> 1] = val;       }     }     long long query(int l, int r) {       long long res = 0;       for (l += n, r += n; l < r; l >>= 1, r >>= 1) {         if (l & 1) {           if (rm[res] < rm[vect[l]]) res = vect[l];           l++;         }         if (r & 1) {           if (rm[res] < rm[vect[r - 1]]) res = vect[r - 1];           r--;         }       }       return res;     }   };   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     v.resize(n + 1);     lm.resize(n + 1);     rm.resize(n + 1);     vector<int> v2;     for (int i = 1; i <= n; i++) {       cin >> v[i];       v2.push_back(v[i]);     }     v2.push_back(0);     sort(v2.begin(), v2.end());     auto it = unique(v2.begin(), v2.end());     v2.resize(it - v2.begin());     int l = 1, r = 1;     vector<int> ans;     SegmentTreeMax stm(n + 1);     vector<int> visited, ct(n + 1);     vector<vector<int>> updates(n + 1);     while (r <= n) {       int id = lower_bound(v2.begin(), v2.end(), v[r]) - v2.begin();       if (!lm[id]) lm[id] = r;       int val = stm.query(l, lm[id]);       updates[id].push_back(r);       rm[id] = r;       ct[id]++;       visited.push_back(id);       if (rm[val] > lm[id] || ct[id] == 4) {         if (ct[id] == 4) {           for (int i = 0; i < 4; i++) ans.push_back(v[r]);         } else {           ans.push_back(v2[val]);           ans.push_back(v[r]);           ans.push_back(v2[val]);           ans.push_back(v[r]);         }         for (int i : visited) {           lm[i] = 0;           rm[i] = 0;           ct[i] = 0;           updates[i].clear();         }         visited.clear();         l = r + 1;         r = l;       } else {         for (int i : updates[id]) {           stm.modify(i, id);         }         r++;       }     }     cout << ans.size() <<   n ;     for (int i : ans) {       cout << i <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   bool get_int(T &x) {     char t = getchar();     bool neg = false;     x = 0;     for (; (t >  9  || t <  0 ) && t !=  -  && t != EOF; t = getchar())       ;     if (t ==  - ) neg = true, t = getchar();     if (t == EOF) return false;     for (; t <=  9  && t >=  0 ; t = getchar()) x = x * 10 + t -  0 ;     if (neg) x = -x;     return true;   }   template <typename T>   void print_int(T x) {     if (x < 0) putchar( - ), x = -x;     short a[20] = {}, sz = 0;     while (x > 0) a[sz++] = x % 10, x /= 10;     if (sz == 0) putchar( 0 );     for (int i = sz - 1; i >= 0; i--) putchar( 0  + a[i]);   }   const int inf = 0x3f3f3f3f;   const long long Linf = 1ll << 61;   const double pi = acos(-1.0);   const int mod = 1e9 + 7;   const int maxn = 100111;   int qpow(int x, int y) {     int ret = 1;     while (y) {       if (y & 1) ret = (long long)ret * x % mod;       x = (long long)x * x % mod;       y >>= 1;     }     return ret;   }   int n, k, p[maxn];   long long cnt[maxn];   vector<int> divs[maxn * 2];   int main() {     (get_int(n) && get_int(k));     k = qpow(k, mod - 2);     p[0] = 1;     for (int i = 1; i <= n; i++) p[i] = (long long)p[i - 1] * k % mod;     for (int i = 1; i < n; i++)       for (int j = i; j < n * 2; j += i) divs[j].push_back(i);     for (int s = 1; s < n + n; s++) {       reverse(divs[s].begin(), divs[s].end());       vector<int> ansv;       for (auto g : divs[s]) {         int lb = g, rb = (n - 1) / g * g;         lb = max(lb, s - rb);         rb = min(rb, s - lb);         if (lb > rb)           ansv.push_back(0);         else           ansv.push_back((rb - lb) / g + 1);       }       for (int i = 0; i < (int)divs[s].size(); i++) {         for (int j = 0; j < i; j++)           if (divs[s][j] % divs[s][i] == 0) ansv[i] -= ansv[j];         int g = divs[s][i];         if (s - g <= n)           cnt[n - g] += ansv[i];         else           cnt[n + n - s] += ansv[i];       }     }     int ans = 0;     for (int i = 1; i <= n; i++) ans = (ans + cnt[i] % mod * p[i]) % mod;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   int A[104][104], B[104][104];   int main() {     scanf( %d %d , &N, &M);     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= M; ++j) {         char c;         scanf(  %c , &c);         if (c ==  * ) A[i][j] = 1;       }     int cnt = 0;     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= M; ++j)         if (A[i][j]) {           int x;           for (x = 0;; ++x) {             if (!A[i - x][j] || !A[i + x][j] || !A[i][j - x] || !A[i][j + x])               break;           }           --x;           if (x) {             ++cnt;             for (int k = 0; k <= x; ++k) {               B[i - k][j] = B[i + k][j] = B[i][j - k] = B[i][j + k] = 1;             }           }         }     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= M; ++j)         if (A[i][j] != B[i][j]) {           puts( -1 );           return 0;         }     printf( %d n , cnt);     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= M; ++j)         if (A[i][j]) {           int x;           for (x = 0;; ++x) {             if (!A[i - x][j] || !A[i + x][j] || !A[i][j - x] || !A[i][j + x])               break;           }           --x;           if (x) printf( %d %d %d n , i, j, x);         }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     scanf( %d%d , &a, &b);     if (b > a)       printf( -1 n );     else {       double ans, a1, a2;       a1 = (a + b) / (2.0 * ((a + b) / (2 * b)));       a2 = (a - b) / (2.0 * ((a - b) / (2 * b)));       printf( %.12lf n , min(a1, a2));     }   }