malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 1e5 + 10;   const long long INF = 1e18;   int n, m, h[MAXN], a[MAXN], c[MAXN];   double x, ans[MAXN];   vector<pair<int, int>> g[MAXN];   vector<int> going;   bool visited[MAXN], b, res, f;   void dfs(int v, int hi, int p) {     visited[v] = true;     going.push_back(v);     h[v] = hi;     for (auto u : g[v]) {       if (!visited[u.first]) {         a[u.first] = u.second - a[v];         dfs(u.first, hi + 1, v);       } else if (u.first != p) {         if ((h[v] & 1) == (h[u.first] & 1)) {           double z = double(a[v] - (u.second - a[u.first])) / 2;           if (!(h[v] & 1)) {             z *= -1;           }           if (!b) {             b = true;             x = z;           } else if (z != x) {             res = false;           }         } else {           if (u.second - a[u.first] != a[v]) {             res = false;           }         }       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v, c;       cin >> u >> v >> c;       g[u].push_back({v, c});       g[v].push_back({u, c});     }     res = true;     for (int i = 1; i <= n; i++) {       if (!visited[i]) {         b = false;         going.clear();         dfs(i, 0, 0);         if (res) {           if (!b) {             for (int j = 0; j < going.size(); j++) {               if (h[going[j]] & 1) {                 c[j] = a[going[j]];               } else {                 c[j] = -a[going[j]];               }             }             sort(c, c + going.size());             x = c[going.size() / 2];           }           for (auto j : going) {             if (h[j] & 1) {               ans[j] = double(a[j]) - x;             } else {               ans[j] = double(a[j]) + x;             }           }         } else {           cout <<  NO ;           return 0;         }       }     }     cout <<  YES  <<   n ;     for (int i = 1; i <= n; i++) {       if (ceil(ans[i]) != ans[i]) {         cout << fixed << setprecision(1);       }       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   void solve() {     int n, m, k;     cin >> n >> m >> k;     vector<int> A(n);     for (int i = 0; i < n; ++i) {       cin >> A[i];     }     int x = min(k, m - 1);     int y = m - 1 - x;     vector<int> b;     for (int i = 0; i + n - m < n; ++i) {       b.push_back(max({A[i], A[i + n - m]}));     }     deque<int> dq;     for (int i = 0; i <= y; ++i) {       while (!dq.empty() && b[dq.back()] >= b[i]) {         dq.pop_back();       }       dq.push_back(i);     }     int ans = b[dq.front()];     for (int i = y + 1; i <= m - 1; ++i) {       while (!dq.empty() && b[dq.back()] >= b[i]) {         dq.pop_back();       }       while (!dq.empty() && dq.front() <= i - (y + 1)) {         dq.pop_front();       }       dq.push_back(i);       ans = max(ans, b[dq.front()]);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e3 + 10, INF = 1e9 + 7;   int r[N][N], n, a[N], o[N], t[N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       o[i] = o[i - 1];       if (a[i] == 1) o[i]++;     }     for (int i = n; i >= 0; i--) {       t[i] = t[i + 1];       if (a[i] == 2) t[i]++;     }     for (int i = 1; i <= n; i++) {       r[i][i] = 1;       for (int j = i + 1; j <= n; j++) {         r[i][j] = r[i][j - 1];         if (a[j] == 1)           r[i][j]++;         else if (t[i - 1] - t[j + 1] > r[i][j])           r[i][j] = t[i - 1] - t[j + 1];       }     }     int MAX = 0;     for (int i = 1; i <= n; i++) {       for (int j = i; j <= n; j++) {         MAX = max(o[i - 1] + r[i][j] + t[j + 1], MAX);       }     }     cout << MAX <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     int qq = 1;     cin >> qq;     for (int qqq = 0; qqq < qq; qqq++) {       int n, first, v;       cin >> n >> first;       int maxx = 0;       int maxxd = 0;       for (int i = 0; i < n; i++) {         cin >> v;         maxx = max(maxx, v);         if (v <= first) {           maxxd = max(maxxd, v);         }       }       if (maxxd == 0)         cout << 2 <<   n ;       else if (maxx == maxxd) {         cout << first / maxx + (first % maxx > 0) <<   n ;       } else if (maxxd == first) {         cout << 1 <<   n ;       } else         cout << 2 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     ;     long long ans = 0;     int arr[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     sort(arr, arr + n);     for (int i = 0; i < n; i++) {       ans += abs(i + 1 - arr[i]);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int fa[100010];   int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }   bool merge(int x, int y) {     int f1 = find(x), f2 = find(y);     if (f1 == f2) return false;     fa[f2] = f1;     return true;   }   int main() {     int n, k;     scanf( %d %d , &n, &k);     int ans = 0;     for (int i = 1; i <= n; i++) fa[i] = i;     for (int i = 1; i <= k; i++) {       int u, v;       scanf( %d %d , &u, &v);       ans += merge(u, v);     }     printf( %d n , k - ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void open(const char *s) {}   inline int rd() {     static int x, f;     x = 0;     f = 1;     char ch = getchar();     for (; ch <  0  || ch >  9 ; ch = getchar())       if (ch ==  - ) f = -1;     for (; ch >=  0  && ch <=  9 ; ch = getchar()) x = x * 10 + ch -  0 ;     return f > 0 ? x : -x;   }   const int N = 5010;   int n;   bool f[N][N];   char s[N], ans[N];   int main() {     open( hh );     scanf( %s , s + 1);     n = strlen(s + 1);     int m = -1;     while ((1 << (m + 1)) <= n) ++m;     int Max = (1 << m) - 1, nn = n - Max;     memset(f[0], 1, sizeof f[0]);     for (int i = 1; i <= nn; i++) {       char mn =  z  + 1;       for (int j = 0; j <= Max; j++) f[i][j] = f[i - 1][j];       for (int j = 0; j <= Max; j++)         if (f[i][j]) mn = min(mn, s[i + j]);       for (int j = 0; j <= Max; j++)         if (mn != s[i + j]) f[i][j] = 0;       for (int j = 0; j <= Max; j++)         for (int k = 0; k <= m; k++)           if (j >> k & 1) f[i][j] |= f[i][j ^ (1 << k)];       ans[i] = mn;     }     printf( %s , ans + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct edge {     int to, cost;     edge(int to = 0, int cost = 0) : to(to), cost(cost) {}   };   vector<edge> vec[100005];   long long int F[100005], G[100005];   int nd[100005];   int n;   long long int mpow(long long int m, long long int t) {     if (t == 0) return 1LL;     long long int ret = mpow(m * m % 1000000007, t / 2);     if (t % 2 == 1) ret = ret * m % 1000000007;     return ret;   }   long long int inv(long long int m) { return mpow(m, 1000000007 - 2); }   void dfs(int v = 0, int p = -1) {     if (vec[v].size() == 1) {       F[v] = G[v] = 0;       return;     }     long long int sumG = 0, sumF = vec[v].size();     for (int i = 0; i < vec[v].size(); i++) {       edge e = vec[v][i];       sumG += e.cost;       if (sumG >= 1000000007) sumG -= 1000000007;       if (e.to != p) {         dfs(e.to, v);         sumG += G[e.to];         if (sumG >= 1000000007) sumG -= 1000000007;         sumF -= F[e.to];         if (sumF < 0) sumF += 1000000007;       }     }     long long int g = inv(sumF);     F[v] = g;     G[v] = g * sumG % 1000000007;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       int a, b, c;       scanf( %d %d %d , &a, &b, &c);       vec[a].push_back(edge(b, c));       vec[b].push_back(edge(a, c));     }     dfs();     printf( %lld n , G[0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int xa, xb, xc, da, db, dc, ta, tb, tc, ans;   bool f[42 + 5][42 + 5][42 + 5][8][8][8];   void calc(int a, int b, int c, int aa, int bb, int cc) {     if (a < 0 || b < 0 || c < 0) return;     if (a == b || a == c || b == c || f[a][b][c][aa][bb][cc]) return;     int x = max(a > 42 ? 0 : a, max(b > 42 ? 0 : b, c > 42 ? 0 : c)),         y = min(a, min(b, c));     ans = max(ans, x), f[a][b][c][aa][bb][cc] = 1;     if (a <= 42) {       if (aa == 1 || aa == 7)         for (int i = a + da; i >= a - da && i >= y - 1; i--)           calc(i, b, c, aa ^ 1, bb, cc);       if (aa & 2) {         if (b == a - 1 || b == a + 1) calc(a, 42 + 1, c, aa ^ 2, bb, cc);         if (c == a - 1 || c == a + 1) calc(a, b, 42 + 1, aa ^ 2, bb, cc);       }       if ((aa & 4) && !(aa & 2))         for (int i = a + ta; i >= a - ta && i >= y - 1; i--) {           if (b == 42 + 1) calc(a, i, c, aa ^ 4, bb, cc);           if (c == 42 + 1) calc(a, b, i, aa ^ 4, bb, cc);         }     }     if (b <= 42) {       if (bb == 1 || bb == 7)         for (int i = b + db; i >= b - db && i >= y - 1; i--)           calc(a, i, c, aa, bb ^ 1, cc);       if (bb & 2) {         if (a == b - 1 || a == b + 1) calc(42 + 2, b, c, aa, bb ^ 2, cc);         if (c == b - 1 || c == b + 1) calc(a, b, 42 + 2, aa, bb ^ 2, cc);       }       if ((bb & 4) && !(bb & 2))         for (int i = b + tb; i >= b - tb && i >= y - 1; i--) {           if (a == 42 + 2) calc(i, b, c, aa, bb ^ 4, cc);           if (c == 42 + 2) calc(a, b, i, aa, bb ^ 4, cc);         }     }     if (c <= 42) {       if (cc == 1 || cc == 7)         for (int i = c + dc; i >= c - dc && i >= y - 1; i--)           calc(a, b, i, aa, bb, cc ^ 1);       if (cc & 2) {         if (a == c - 1 || a == c + 1) calc(42 + 3, b, c, aa, bb, cc ^ 2);         if (b == c - 1 || b == c + 1) calc(a, 42 + 3, c, aa, bb, cc ^ 2);       }       if ((cc & 4) && !(cc & 2))         for (int i = c + tc; i >= c - tc && i >= y - 1; i--) {           if (a == 42 + 3) calc(i, b, c, aa, bb, cc ^ 4);           if (b == 42 + 3) calc(a, i, c, aa, bb, cc ^ 4);         }     }   }   void doit() {     scanf( %d%d%d%d%d%d%d%d%d , &xa, &da, &ta, &xb, &db, &tb, &xc, &dc, &tc);     ans = 0, memset(f, 0, sizeof(f)), calc(xa, xb, xc, 7, 7, 7);     printf( %d n , ans);   }   int main() {     doit();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = LLONG_MAX - 1e10;   const long long maxn = 1e6 + 5;   const long long mo_num = 1e9 + 7;   long long n, m, a[maxn], b[maxn], ans;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     for (long long i = 1; i <= 4; i++) cin >> a[i];     long long key = 0;     if (a[1] == a[4]) {       if (!a[3])         key = 1;       else if (a[1] > 0)         key = 1;     }     cout << key ? 1 : 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     scanf( %d , &t);     while (t--) {       int x;       scanf( %d , &x);       bool found = 0;       for (int n = 1; n <= 200000; n++) {         int lo = 1, hi = n;         bool done = 0;         while (lo <= hi) {           int m = lo + hi >> 1;           long long val = 1ll * n * n - 1ll * (n / m) * (n / m);           if (val == x) {             done = 1;             printf( %d %d n , n, m);             break;           }           if (val < x) lo = m + 1;           if (val > x) hi = m - 1;         }         if (done) {           found = 1;           break;         }       }       if (!found) puts( -1 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 100;   int n, h, l, r, dp[2222][2222], a[2222];   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> h >> l >> r;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < h; i++)       for (int j = 0; j <= n; j++) dp[j][i] = -1e9;     dp[0][0] = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < h; j++) {         int x = j + a[i];         if (x >= h) x -= h;         dp[i + 1][x] = max(dp[i + 1][x], dp[i][j] + (l <= x && x <= r));         int y = j + a[i] - 1;         if (y >= h) y -= h;         dp[i + 1][y] = max(dp[i + 1][y], dp[i][j] + (l <= y && y <= r));       }     }     cout << *max_element(dp[n], dp[n] + h);     cerr <<   nTime elapsed:   << 1.0 * clock() / CLOCKS_PER_SEC <<   s. n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 1e3 + 5;   const int max_p = 1e3 + 5;   const int max_k = 50 + 5;   bool a[max_n], b[max_n];   int dp[2][max_p][max_k][max_k];   inline void check_max(int &x, int y) { x = max(x, y); }   int main() {     int n, p, k;     scanf( %d%d%d , &n, &p, &k);     int r;     scanf( %d , &r);     for (int i = 1; i <= r; ++i) {       int x;       scanf( %d , &x);       a[x] = true;     }     int s;     scanf( %d , &s);     for (int i = 1; i <= s; ++i) {       int x;       scanf( %d , &x);       b[x] = true;     }     if (p >= 2 * ((n + k - 1) / k)) {       int ans = 0;       for (int i = 1; i <= n; ++i) ans += a[i] | b[i];       printf( %d n , ans);       return 0;     }     for (int j = 0; j <= p; ++j)       for (int l = 0; l < k; ++l)         for (int r = 0; r < k; ++r) dp[0][j][l][r] = -1e9;     dp[0][p][0][0] = 0;     for (int i = 1; i <= n; ++i) {       int y = i & 1, x = y ^ 1;       for (int j = 0; j <= p; ++j)         for (int l = 0; l < k; ++l)           for (int r = 0; r < k; ++r) dp[y][j][l][r] = -1e9;       for (int j = 0; j <= p; ++j)         for (int l = 0; l < k; ++l)           for (int r = 0; r < k; ++r) {             if (dp[x][j][l][r] >= 0) {               check_max(dp[y][j][max(l - 1, 0)][max(r - 1, 0)],                         dp[x][j][l][r] + ((l > 0 && a[i]) || (r > 0 && b[i])));               if (j > 0) {                 if (a[i])                   check_max(dp[y][j - 1][k - 1][max(r - 1, 0)],                             dp[x][j][l][r] + 1);                 if (b[i])                   check_max(dp[y][j - 1][max(l - 1, 0)][k - 1],                             dp[x][j][l][r] + 1);               }             }           }     }     int x = n & 1, ans = 0;     for (int j = 0; j <= p; ++j)       for (int l = 0; l < k; ++l)         for (int r = 0; r < k; ++r) ans = max(ans, dp[x][j][l][r]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long calc(long long n, long long k) {     long long a = 1, b = 1, c;     for (long long i = 1; i <= k; i++) a = a * (n - i + 1), b = b * i;     if (k == 4)       c = 9;     else if (k == 3)       c = 2;     else if (k == 2)       c = 1;     else       c = 0;     return c * a / b;   }   int main() {     long long n, k;     cin >> n >> k;     long long res = 0;     while (k) res += calc(n, k--);     cout << res + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0;     char zf = 1;     char ch = getchar();     while (ch !=  -  && !isdigit(ch)) ch = getchar();     if (ch ==  - ) zf = -1, ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * zf;   }   void write(long long y) {     if (y < 0) putchar( - ), y = -y;     if (y > 9) write(y / 10);     putchar(y % 10 + 48);   }   void writeln(const long long y) {     write(y);     putchar(  n );   }   int i, j, k, m, n, cnt;   const double PI = acos(-1.0);   struct node {     int x, y;   } a[3030];   double b[5030];   int main() {     n = read();     for (register int i = 1; i <= n; i++) a[i].x = read(), a[i].y = read();     unsigned long long ans = 0;     for (register int i = 1; i <= n; i++) {       cnt = 0;       for (register int j = 1; j <= n; j++)         if (i != j) b[++cnt] = atan2(a[j].x - a[i].x, a[j].y - a[i].y);       sort(b + 1, b + cnt + 1);       for (register int i = cnt + 1; i <= 2 * cnt; i++)         b[i] = b[i - cnt] + PI * 2;       for (register int j = k = 1; j <= cnt; j++) {         if (k < j) k = j;         while (k < cnt * 2 && b[k + 1] - b[j] < PI) k++;         int sum = k - j, sum2 = cnt - sum - 1;         ans += (unsigned long long)sum * (sum - 1) * sum2 * (sum2 - 1) / 4;       }     }     cout << ans / 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   ostream &operator<<(ostream &str, vector<T> &a) {     for (auto &i : a) {       str << i <<    ;     }     return str;   }   template <class T>   istream &operator>>(istream &str, vector<T> &a) {     for (auto &i : a) {       str >> i;     }     return str;   }   template <class T>   ostream &operator<<(ostream &str, pair<T, T> &a) {     str << a.first <<     << a.second;     return str;   }   template <class T>   istream &operator>>(istream &str, pair<T, T> &a) {     str >> a.first >> a.second;     return str;   }   void solve();   signed main() {     srand(time(0));     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout.setf(ios::fixed);     cout.precision(6);     solve();     return 0;   }   const long long MOD = 998244353, MAXN = 5e5 + 10, INF = 1e18 + 10, BASE = 37;   long long bin_pow(long long a, long long n) {     if (n == 0) {       return 1;     }     if (n & 1) {       return a * bin_pow(a, n - 1) % MOD;     } else {       long long tmp = bin_pow(a, n / 2);       return tmp * tmp % MOD;     }   }   void solve() {     long long n;     cin >> n;     vector<long long> c(n);     cin >> c;     sort((c).rbegin(), (c).rend());     long long ans = 0;     for (long long i = 0; i < n; ++i) {       ans = (ans + i * c[i] % MOD) % MOD;     }     cout << ans * bin_pow(n, MOD - 2) % MOD <<    ;     vector<long long> ps(n);     ps[0] = c[0];     for (long long i = 1; i < n; ++i) {       ps[i] = (ps[i - 1] + c[i]) % MOD;     }     for (long long k = 2; k <= n; ++k) {       ans = 0;       for (long long i = k - 1; i <= n - 1; i += k) {         ans = (ans +                ((i / k) * (ps[i] - (i - k == -1 ? 0 : ps[i - k]) + MOD)) % MOD) %               MOD;       }       if (n % k != 0) {         ans = (ans + ((n - 1) / k) *                          (ps[n - 1] -                           (n - 1 - n % k == -1 ? 0 : ps[n - 1 - n % k]) + MOD) %                          MOD) %               MOD;       }       cout << ans * bin_pow(n, MOD - 2) % MOD <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( -ffloat-store )   #pragma GCC optimize( -fno-defer-pop )   long long int power(long long int a, long long int b, long long int m) {     if (b == 0) return 1;     if (b == 1) return a % m;     long long int t = power(a, b / 2, m) % m;     t = (t * t) % m;     if (b & 1) t = ((t % m) * (a % m)) % m;     return t;   }   long long int modInverse(long long int a, long long int m) {     return power(a, m - 2, m);   }   long long int solve(long long int n) {     long long int a, b, mid, an = -1, k, l;     a = 1;     b = 1e9;     while (b >= a) {       mid = (a + b) / 2;       k = mid;       l = 0;       while (k > 0) {         l += (k / 5);         k = k / 5;       }       if (l == n) {         an = mid;         b = mid - 1;       } else if (l > n) {         b = mid - 1;       } else {         a = mid + 1;       }     }     return an;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int i, j, k, l, n;     cin >> n;     k = solve(n);     if (k == -1) {       cout <<  0             <<   n ;     } else {       cout <<  5 n ;       for (i = k; i < k + 5; i++) {         cout << i <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int nn = 115;   const double PI = 2 * acos(0);   int main() {     int n;     double r;     double ans;     cin >> n >> r;     double x = (PI * (180 - (360.0 / n)) / 2.0) / 180.0;     double L = 0, R = 1e5;     while (L <= R) {       double mid = (L + R) / 2.0;       if (fabs(cos(x) * (mid + r) - mid) < 1e-9) {         ans = mid;         break;       } else if (cos(x) * (mid + r) > (mid)) {         L = mid;       } else {         R = mid;       }     }     printf( %.6f n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, i, o = 0;     cin >> n;     long long int a[n];     for (i = 0; i < n; ++i) {       cin >> a[i];       if (a[i] & 1) o++;     }     cout << min(o, n - o);   }
#include <bits/stdc++.h>   using namespace std;   int count(string &s) {     int p = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  1 ) p++;     }     return p;   }   int main() {     string a, b;     cin >> a >> b;     int x, y;     x = count(a);     y = count(b);     if (x >= y || (x + 1 == y && x % 2 == 1))       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int n = s.length();     bool sign = false;     for (int i = 0; i < n; i++) {       if (s[i] ==  a  && !sign) continue;       if (s[i] ==  a  && sign) break;       s[i]--;       sign = true;     }     if (!sign) s[n - 1] =  z ;     cout << s <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int q, n, a[200000 + 5], cnt[200000 + 5];   int main() {     scanf( %d , &q);     for (; q--;) {       memset(cnt, 0, sizeof(cnt));       int sum1 = 0, sum2 = 0, tot = 0, m = 0;       scanf( %d , &n);       for (int i = 1; i <= n; i++) {         scanf( %d , &a[i]);         cnt[a[i]]++;         m = max(a[i], m);       }       if (m % 30 == 0 && cnt[m / 2] && cnt[m / 3] && cnt[m / 5])         sum1 = m / 30 * 31;       for (int i = 200000; i >= 1; i--)         if (cnt[i]) {           for (int j = i - 1; j >= 1; j--)             if (i % j == 0) cnt[j] = 0;           tot++;           sum2 += i;           if (tot == 3) break;         }       printf( %d n , max(sum1, sum2));     }     return 0;   }
#include <bits/stdc++.h>   const int N = 1e2 + 9;   using namespace std;   int n, m;   int mp[N][N];   int main() {     scanf( %d%d , &n, &m);     puts( YES );     memset(mp, 0, sizeof mp);     if (m <= n - 2) {       int mid = (n + 1) / 2;       if (m & 1) {         mp[2][mid] = 1;       }       for (int i = 1; i <= m / 2; i++) {         mp[2][mid - i] = mp[2][mid + i] = 1;       }     } else {       for (int i = 2; i < n; i++) {         mp[2][i] = 1;       }       m -= n - 2;       int mid = (n + 1) / 2;       if (m & 1) {         mp[3][mid] = 1;       }       for (int i = 1; i <= m / 2; i++) {         mp[3][mid - i] = mp[3][mid + i] = 1;       }     }     for (int i = 1; i <= 4; i++) {       for (int j = 1; j <= n; j++) {         if (mp[i][j] == 1)           printf( # );         else           printf( . );       }       puts(  );     }   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9;   const long long MOD = 1e9 + 7;   const long long maxn = 2e5 + 7;   const long long maxm = 2e5 + 7;   int n;   bool isPrime(int a) {     for (int i = 2; i <= sqrt(a); i++) {       if (a % i == 0) {         return 0;       }     }     return 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     cin >> n;     for (int m = 1;; m++) {       if (!isPrime(n * m + 1)) {         cout << m << endl;         return 0;       }     }     return 0;   }