malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long a[200020];   long long va[200020];   long long b[200020];   long long c[200020];   char ans[200020];   char ansstring[200020];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     long long n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];       va[a[i]] = i;     }     for (int i = 1; i <= n; i++) {       cin >> b[i];       c[i] = va[b[i]];     }     char ch =  a ;     for (int i = 1; i <= n; i++) {       long long reach = c[i];       if (ch >  z ) {         ch--;       }       for (int j = i; j <= reach; j++) {         reach = max(reach, c[j]);         ans[j] = ch;       }       i = reach;       ch++;     }     if (ch -  a  < k) {       cout <<  NO ;       return 0;     }     for (int i = 1; i <= n; i++) {       ansstring[b[i]] = ans[i];     }     cout <<  YES n ;     for (int i = 1; i <= n; i++) {       cout << ansstring[i];     }   }
#include <bits/stdc++.h>   using namespace std;   bool isPrime(int n) {     if (n <= 1) return false;     for (int i = 2; i < n; i++)       if (n % i == 0) return false;     return true;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     int n;     cin >> n;     vector<int> v;     if (n == 1) {       cout <<  0 ;       return 0;     }     int temp;     for (long long int i = (2); i <= (n); i++) {       temp = i;       if (isPrime(i)) {         while (temp <= n) {           v.push_back(temp);           temp *= i;         }       }     }     cout << v.size() << endl;     for (auto i = v.begin(); i != v.end(); i++) cout << *i <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 120;   int a[N][N], n, k;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> k;     if (k > n * n) {       cout <<  -1 n ;     } else {       for (int i = 0; i < n && k > 0; i++) {         a[i][i] = 1, k--;         for (int j = i + 1; j < n && k > 1; j++) {           a[i][j] = 1, a[j][i] = 1, k -= 2;         }       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           cout << a[i][j] << (j + 1 == n ?   n  :    );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   const int MAXN = 200010;   const double EPS = 1e-7;   inline int read() {     char c = getchar();     int x = 0, f = 1;     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + (c -  0 );       c = getchar();     }     return x * f;   }   char s[55], t[55];   int cnt[30], vis[55];   vector<int> pos[30];   vector<int> ans;   int main() {     int n = read();     scanf( %s , s + 1);     scanf( %s , t + 1);     for (int i = 1; i <= n; i++) cnt[s[i] -  a ]++;     for (int i = 1; i <= n; i++) pos[t[i] -  a ].push_back(i);     int flag = 1;     for (int i = 0; i < 26; i++)       if (cnt[i] != (int)((pos[i]).size())) flag = 0;     if (flag) {       for (int i = 1; i <= n; i++) {         for (int j = i; j <= n; j++) {           if (s[j] == t[i]) {             for (int k = j - 1; k >= i; k--) {               swap(s[k], s[k + 1]);               ans.push_back(k);             }             break;           }         }       }       cout << (int)((ans).size()) << endl;       for (int i = 0; i < (int)((ans).size()); i++) cout << ans[i] <<    ;     } else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gen(int order) {     long long sum = 0;     while (order != 0) {       sum = (sum * 10) + 9;       order--;     }     return sum;   }   int main() {     long long l, r;     cin >> l >> r;     long long p = l, k = r;     int order = 0, sorder = 0;     while (k != 0) {       k = k / 10;       order++;     }     while (p != 0) {       p = p / 10;       sorder++;     }     if (sorder == order) {       long long max = gen(order);       if ((max - 1) / 2 <= r && l <= (max - 1) / 2) {         long long ans = ((max + 1) / 2) * ((max - 1) / 2);         cout << ans;       } else {         long long max = gen(order);         if (r < (max - 1) / 2) {           long long ans = r * (max - r);           cout << ans;         } else {           long long ans = l * (max - l);           cout << ans;         }       }     } else {       long long max = gen(order);       long long smax = gen(order - 1);       if (r >= (max - 1) / 2) {         long long ans = ((max + 1) / 2) * ((max - 1) / 2);         cout << ans;       } else {         if (l <= (smax + 1) / 2) {           if ((smax + 1) * (smax - 1) / 4 > r * (max - r)) {             cout << (smax + 1) * (smax - 1) / 4;           } else {             cout << r * (max - r);           }         } else {           if (l * (smax - l) > r * (max - r)) {             cout << l * (smax - l);           } else {             cout << r * (max - r);           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T a, T b) {     return a ? gcd(b % a, a) : b;   }   template <typename T>   T lcm(T a, T b) {     return (a / gcd(a, b)) * b;   }   string int_to_str_easy(long long n) {     return n ?    : int_to_str_easy(n / 10) + (char)( 0  + n % 10);   }   template <typename T>   T sum(vector<T> v) {     T ans = 0;     for (T i : v) ans += i;     return ans;   }   bool is_down(char x) { return ( a  <= x && x <=  z ); }   bool is_upper(char x) { return ( A  <= x && x <=  Z ); }   bool is_digit(char x) { return ( 0  <= x && x <=  9 ); }   string follow(string s) {     for (int i = 0; i < s.length(); i++)       if (is_upper(s[i])) s[i] +=  a  -  A ;     return s;   }   const long double pi = 3.141592653589793238462643383279;   const long double log23 = 1.58496250072115618145373894394781;   const long double eps = 1e-8;   const long double zero = 0;   const long long INF = 1e18;   const int COUT = 30;   const int prost = 239;   const long long prost64 = 239;   const int two = 2;   const long long MOD = 1000000007;   const int BIG = 1e9;   const int alf = 26;   const int MAX_M = 2001;   const int MAX_N = 2 * 1e5 + 1;   const int km = (1 << 18) - 1;   const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};   const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};   const int dx[4] = {-1, 0, 1, 0};   const int dy[4] = {0, 1, 0, -1};   const int bit_max = 32;   void solve() { return; }   int n;   string s;   int main() {     cin.sync_with_stdio(0);     cin >> n >> s;     string e =   ;     int ans = 0;     for (int i = 0; i < n; i++) {       if (i % 2 == 0)         e +=  r ;       else         e +=  b ;     }     int now = 0;     string w = s;     int no1 = 0;     int no2 = 0;     for (int i = 0; i < n; i++) {       if (w[i] != e[i] && (i + 1) % 2 == 0)         no1++;       else if (w[i] != e[i])         no2++;     }     now = min(no1, no2) + abs(no1 - no2);     ans = now;     now = 0;     e =   ;     for (int i = 0; i < n; i++) {       if (i % 2 == 0)         e +=  b ;       else         e +=  r ;     }     w = s;     no1 = 0;     no2 = 0;     for (int i = 0; i < n; i++) {       if (w[i] != e[i] && (i + 1) % 2 == 0)         no1++;       else if (w[i] != e[i])         no2++;     }     now = min(no1, no2) + abs(no1 - no2);     ans = min(ans, now);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   const int MAXN = 1e6 + 10;   const long long MOD = 1e9 + 7;   const long long MOD2 = 998244353;   const long long INF = 8e18;   const int LOG = 22;   long long pw(long long a, long long b, long long mod) {     return (!b ? 1                : (b & 1 ? (a * pw(a * a % mod, b / 2, mod)) % mod                         : pw(a * a % mod, b / 2, mod)));   }   long long dp[2][MAXN];   int x[MAXN];   vector<int> G[MAXN];   void DFS(int v, int par) {     dp[0][v] = 1;     dp[1][v] = 0;     for (auto u : G[v]) {       if (u == par) {         continue;       }       DFS(u, v);       dp[1][v] = (dp[1][v] * dp[0][u]) % MOD;       dp[1][v] = (dp[1][v] + dp[1][u] * dp[0][v]) % MOD;       dp[0][v] = (dp[0][v] * dp[0][u]) % MOD;     }     if (x[v]) {       dp[1][v] = dp[0][v];     } else {       dp[0][v] = (dp[0][v] + dp[1][v]) % MOD;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     for (int i = 1; i < n; i++) {       int a;       cin >> a;       G[a].push_back(i);       G[i].push_back(a);     }     for (int i = 0; i < n; i++) {       cin >> x[i];     }     DFS(0, -1);     cout << dp[1][0] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   const int MAXN = 1e5 + 10;   const long long mod = (1ll << 32);   const long long inf = 1e16;   const int N = 1e7 + 1;   struct Query {     int l, r, id;   };   Query q[MAXN];   long long a[MAXN], p[MAXN], cntl[N], cntr[N], res[MAXN], K = 1000, k, n, Q;   long long ans = 0;   bool cmp(Query a, Query b) {     if (a.l / K != b.l / K) return a.l < b.l;     return a.r < b.r;   }   void addL(int id) {     cntr[p[id]]++;     cntl[p[id - 1]]++;     ans += cntr[k ^ p[id - 1]];   }   void addR(int id) {     cntr[p[id]]++;     cntl[p[id - 1]]++;     ans += cntl[k ^ p[id]];   }   void delL(int id) {     ans -= cntr[k ^ p[id - 1]];     cntr[p[id]]--;     cntl[p[id - 1]]--;   }   void delR(int id) {     ans -= cntl[k ^ p[id]];     cntr[p[id]]--;     cntl[p[id - 1]]--;   }   void solve() {     cin >> n >> Q >> k;     for (int i = 1; i < n + 1; ++i) {       cin >> a[i];       p[i] = p[i - 1] ^ a[i];     }     for (int i = 0; i < Q; ++i) {       int l, r;       cin >> l >> r;       q[i] = {l, r, i};     }     sort(q, q + Q, cmp);     int L = 1, R = 0;     for (int i = 0; i < Q; ++i) {       int l = q[i].l, r = q[i].r, id = q[i].id;       while (L > l) addL(--L);       while (R < r) addR(++R);       while (L < l) delL(L++);       while (R > r) delR(R--);       res[id] = ans;     }     for (int i = 0; i < Q; ++i) cout << res[i] <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     cin.tie(0);     ios_base::sync_with_stdio(false);     int a, ta, b, tb;     string t;     cin >> a >> ta >> b >> tb >> t;     int p =         600 * (t[0] -  0 ) + 60 * (t[1] -  0 ) + 10 * (t[3] -  0 ) + t[4] -  0 ;     int q = p + ta;     int ans = 0, i;     for (i = 300; i < 1440; i += b) {       if (p * (ta + tb) < ta * tb + p * tb + i * ta &&           ta * tb + p * tb + i * ta < q * (ta + tb))         ans++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   long long ara[205];   long long dp[205][205][205];   int n, k, x;   long long rec(int pos, int last, int left) {     if (last > k) return -1e17;     if (pos == n + 1) {       if (!left) return 0;       return (-1e17);     }     if (left < 0) return -1e17;     long long& ret = dp[pos][last][left];     if (~ret) return ret;     ret = -1e17;     if (rec(pos + 1, 1, left - 1) >= 0)       ret = max(ret, rec(pos + 1, 1, left - 1) + ara[pos]);     if (rec(pos + 1, last + 1, left) >= 0)       ret = max(ret, rec(pos + 1, last + 1, left));     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     scanf( %d %d %d , &n, &k, &x);     for (int i = 1; i <= n; i++) scanf( %lld , &ara[i]);     memset(dp, -1, sizeof dp);     printf( %lld n , (rec(1, 1, x) <= 0 ? -1 : rec(1, 1, x)));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long num[300010];   long long sum[300010];   int n;   bool cmp(int a, int b) { return a > b; }   int main() {     while (~scanf( %d , &n)) {       for (int i = 0; i < n; i++) cin >> num[i];       sort(num, num + n, cmp);       sum[0] = num[0];       for (int i = 1; i < n; i++) {         sum[i] = sum[i - 1] + num[i];       }       long long ans = sum[n - 1];       for (int i = n - 2; i >= 0; i--) ans += sum[i] + num[n - 1 - i];       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double n, m, k, a, b, c;   string s;   vector<double> v;   int main() {     scanf( %lf %lf %lf , &a, &b, &c);     if (a == 0 && b == 0 && c == 0) {       printf( -1 n );       return 0;     }     if (a == 0 && b == 0 && c != 0) {       printf( 0 n );       return 0;     }     if (b * b - 4 * a * c < 0) {       printf( 0 n );       return 0;     }     if (a == 0) {       printf( 1 n );       double cev = -c / b;       printf( %lf , cev);       return 0;     }     if (b * b - 4 * a * c == 0) {       printf( 1 n );       double cev = -b / (2 * a);       printf( %lf , cev);       return 0;     }     printf( 2 n );     double cev = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);     double cevap = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);     v.push_back(cev);     v.push_back(cevap);     sort(v.begin(), v.end());     printf( %lf n , v[0]);     printf( %lf n , v[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1E-15;   const int inf = int(1e9) + 7;   const int maxN = 1000 + 5;   int in[maxN], to[maxN], cs[maxN];   int n, m;   int main() {     scanf( %d%d , &n, &m);     int a, b, c;     for (int(i) = 0; (i) < (m); ++(i)) {       scanf( %d%d%d , &a, &b, &c);       to[a] = b;       in[b] = 1;       cs[a] = c;     }     int tot = 0;     for (int(i) = (1); (i) < (n + 1); ++(i))       if (in[i] == 0 && to[i] != 0) tot++;     printf( %d n , tot);     for (int(i) = (1); (i) < (n + 1); ++(i))       if (in[i] == 0 && to[i] != 0) {         int x = i, ans = inf;         while (to[x]) {           ans = min(ans, cs[x]);           x = to[x];         }         printf( %d %d %d n , i, x, ans);       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 6001;   int n, m, k, a, b, x[N], y[N], z[N];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &x[i]);     scanf( %d , &m);     for (int i = 1; i <= m; i++) scanf( %d , &y[i]);     scanf( %d , &k);     for (int i = 1; i <= k; i++) scanf( %d , &z[i]);     scanf( %d%d , &a, &b);     sort(x + 1, x + 1 + n);     sort(y + 1, y + 1 + m);     sort(z + 1, z + 1 + k);     double p2 = z[1];     double r1 = x[n];     double res = 0;     for (int i = 1; i <= m; i++) {       double p1 = y[i];       double cur = (p1 * b * r1 * r1) / (p1 * b + p2 * a);       cur = sqrt(cur);       if (cur - res > 1e-6) res = cur;     }     printf( %.7f n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[52][52], d[52], dd[52], c[52], b[52][52];   bool check(int pos) {     int t[n + 2];     for (int i = 1; i <= n; i++) t[i] = d[i];     for (int i = 1; i <= n; i++)       if (t[i] == n && i != pos) t[i] = n - 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         if (i == j)           b[i][j] = 0;         else {           b[i][j] = min(t[i], t[j]);         }       }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (a[i][j] != b[i][j]) return 0;     return 1;   }   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++) cin >> a[i][j];     for (int i = 1; i <= n; i++) {       for (int j = 0; j < n + 1; j++) dd[j] = 0;       for (int j = 1; j <= n; j++) dd[a[i][j]] = 1;       if (dd[n - 1] == 1) {         c[n] = 1;         d[i] = n;       }       if (d[i]) continue;       for (int j = 0; j < n + 1; j++) {         if (dd[j] == 0 && c[j - 1] == 0) {           c[j - 1] = 1;           d[i] = j - 1;           break;         }       }     }     int pos = -1;     for (int i = 1; i <= n; i++) {       if (d[i] == n) {         if (check(i)) {           pos = i;           break;         }       }     }     for (int i = 1; i <= n; i++)       if (d[i] == n && i != pos) d[i] = n - 1;     for (int i = 1; i <= n; i++) cout << d[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int const MAX_N = 1e5 + 10;   int n, p, l[MAX_N], r[MAX_N];   int get_count(int l, int r) {     int ans = 0;     if (l % p == 0) ++ans;     l -= l % p;     r -= r % p;     ans += (r - l) / p;     return ans;   }   double get_prob(int a, int b) {     long long count = 0;     count +=         1LL * get_count(l[a], r[a]) * (r[b] - l[b] + 1 - get_count(l[b], r[b]));     count +=         1LL * get_count(l[b], r[b]) * (r[a] - l[a] + 1 - get_count(l[a], r[a]));     count += 1LL * get_count(l[a], r[a]) * get_count(l[b], r[b]);     return count * 1.0 / (1LL * (r[a] - l[a] + 1) * (r[b] - l[b] + 1));   }   int main() {     ios_base::sync_with_stdio(false);     cout << fixed << setprecision(12);     cin >> n >> p;     for (int i = 0; i < n; ++i) cin >> l[i] >> r[i];     double ret = 0;     for (int i = 0; i < n; ++i) {       int j = (i + 1) % n;       ret += 2000.0 * get_prob(i, j);     }     cout << ret << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( Ofast )   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     long double u;     cin >> n >> u;     vector<long double> e(n);     for (int i = 0; i < n; i++) cin >> e[i];     long double ans = 0;     bool fl = 0;     for (int i = 2; i < n; i++) {       if (e[i] - e[i - 2] <= u) fl = 1;     }     if (!fl) {       cout <<  -1  << endl;       return 0;     }     for (int i = 0; i < n; i++) {       int tmp = upper_bound(e.begin(), e.end(), e[i] + u) - e.begin() - 1;       if (tmp - i < 2) continue;       ans = max(ans, (e[tmp] - e[i + 1]) / (e[tmp] - e[i]));     }     cout << fixed << setprecision(13) << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, e[10][10] = {}, a, b;     scanf( %d , &m);     while (m--) {       scanf( %d%d , &a, &b);       e[a][b] = e[b][a] = 1;     }     for (int i = 1; i <= 5; i++)       for (int j = i + 1; j <= 5; j++)         for (int k = j + 1; k <= 5; k++)           if (e[i][j] == e[j][k] && e[j][k] == e[k][i]) {             puts( WIN );             return 0;           }     puts( FAIL );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   struct node {     long long x, y;   } po[100000];   inline long long dis(node a, node b) {     return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);   }   bool cmp(const node &a, const node &b) {     return (a.y == b.y ? a.x < b.x : a.y < b.y);   }   long long solve(long long ll, long long rr) {     if (ll == rr) return (long long)2e18;     if (ll + 1 == rr) return dis(po[ll], po[rr]);     if (ll + 2 == rr)       return min(dis(po[ll], po[rr]),                  min(dis(po[ll], po[ll + 1]), dis(po[ll + 1], po[rr])));     long long mid = (ll + rr) >> 1;     long long res = min(solve(ll, mid), solve(mid + 1, rr));     sort(po + ll, po + rr + 1, cmp);     for (long long i = ll; i <= rr; ++i) {       for (long long j = i + 1; j <= rr && j <= i + 8; ++j)         res = min(res, dis(po[i], po[j]));     }     return res;   }   int main() {     scanf( %I64d , &n);     for (long long i = 1; i <= n; ++i)       scanf( %I64d , &po[i].y), po[i].y += po[i - 1].y, po[i].x = i;     printf( %I64d n , solve(1, n));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char c[200010];   int main() {     int n;     while (scanf( %d , &n) != EOF) {       memset(c, 0, sizeof c);       scanf( %s , c);       int ans = 0;       for (int i = 0; i < n; i++) {         if (c[i] ==  < )           ans++;         else           break;       }       for (int i = n - 1; i >= 0; i--) {         if (c[i] ==  > )           ans++;         else           break;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505;   int a[N];   int z[2][N][N];   int main() {     int n, bl, bugs, md;     scanf( %d %d %d %d , &n, &bl, &bugs, &md);     for (int i = 0; i < int(n); i++) scanf( %d , &a[i]);     z[0][0][0] = 1;     for (int it = 1; it <= n; it++) {       int i = it & 1;       for (int j = 0; j <= bl; j++) {         for (int k = 0; k <= bugs; k++) {           z[i][j][k] = z[i ^ 1][j][k];           if (j > 0 && k >= a[it - 1]) z[i][j][k] += z[i][j - 1][k - a[it - 1]];           z[i][j][k] %= md;         }       }     }     int ans = 0;     for (int i = 0; i <= bugs; i++) {       ans += z[n & 1][bl][i];       ans %= md;     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( inline )   #pragma GCC optimize( omit-frame-pointer )   #pragma GCC optimize( unroll-loops )   using namespace std;   template <class T>   void debug(vector<T> vec) {     for (int i = 0; i < vec.size(); i++) cerr << vec[i] <<    ;     cerr <<   n ;   }   template <class T>   void debug(vector<vector<T> > vec) {     for (int i = 0; i < vec.size(); i++) {       for (int ii = 0; ii < vec[i].size(); ii++) cerr << vec[i][ii] <<    ;       cerr <<   n ;     }   }   void solve() {     int T;     int i;     cin >> T;     for (int i = 0; i < T; i++) {       int n;       string s;       cin >> n;       cin >> s;       if (s.size() == 1) {         cout <<  YES               <<   n ;         continue;       } else if (s.size() == 2) {         if (abs(s[0] - s[1]) > 2 || abs(s[0] - s[1]) == 1)           cout <<  NO                 <<   n ;         else           cout <<  YES                 <<   n ;         continue;       }       int x;       bool possible = true;       for (int x = 0; x < n / 2; x++) {         if (abs(s[x] - s[n - x - 1]) > 2 || abs(s[x] - s[n - x - 1]) == 1) {           possible = false;           cout <<  NO                 <<   n ;           break;         }       }       if (possible == true)         cout <<  YES               <<   n ;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ;     cin.tie(NULL);     int testcases = 1;     while (testcases-- != 0) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1E-9;   int cnt;   double a, b, m, vx, vy, vz, t, f;   double ansx, ansz;   int main() {     scanf( %lf%lf%lf , &a, &b, &m);     scanf( %lf%lf%lf , &vx, &vy, &vz);     t = -m / vy;     ansx = a / 2 + t * vx;     ansz = t * vz;     while (ansx < 0) ansx += a;     while (ansz < 0) ansz += b;     while (ansx + eps > a) ansx -= a;     while (ansz + eps > b) ansz -= b;     cnt = (int)(fabs(t / (b / vz)) + eps);     if (cnt % 2) ansz = b - ansz;     cnt = 0;     if (t + eps > fabs((a / 2) / vx)) {       cnt = 1;       t -= fabs(a / 2 / vx);     }     cnt += (int)(fabs(t / (a / vx)) + eps);     if (cnt % 2) ansx = a - ansx;     printf( %.10lf %.10lf n , ansx, ansz);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class _T>   inline _T sqr(const _T& first) {     return first * first;   }   template <class _T>   inline string tostr(const _T& a) {     ostringstream os(  );     os << a;     return os.str();   }   const long double PI = 3.1415926535897932384626433832795L;   const long double EPS = 5e-12;   char TEMPORARY_CHAR;   const int INF = 1e9;   inline void input(int& a) {     a = 0;     while (((TEMPORARY_CHAR = getchar()) >  9  || TEMPORARY_CHAR <  0 ) &&            (TEMPORARY_CHAR !=  - )) {     }     char neg = 0;     if (TEMPORARY_CHAR ==  - ) {       neg = 1;       TEMPORARY_CHAR = getchar();     }     while (TEMPORARY_CHAR <=  9  && TEMPORARY_CHAR >=  0 ) {       a = 10 * a + TEMPORARY_CHAR -  0 ;       TEMPORARY_CHAR = getchar();     }     if (neg) a = -a;   }   inline void out(int a) {     if (!a) putchar( 0 );     if (a < 0) {       putchar( - );       a = -a;     }     char s[10];     int i;     for (i = 0; a; ++i) {       s[i] =  0  + a % 10;       a /= 10;     }     for (int j = (i)-1; j >= 0; j--) putchar(s[j]);   }   inline int nxt() {     int(ret);     input((ret));     ;     return ret;   }   char can[8][8];   bool check(const vector<int>& a) {     for (int i : a)       for (int j : a)         if (!can[i][j]) return false;     return true;   }   int main() {     long long n;     cin >> n;     long long tri = 1;     while (n % tri == 0) tri *= 3;     cout << (n + tri - 1) / tri << endl;     return 0;   }