malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int gr[5000][5], n, m;   string s[5000];   bool isOK(int x, int y) {     if (x >= 0 && x < n && y >= 0 && y < m) return true;     return false;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> s[i];     map<char, int> mp;     mp[ U ] = 0;     mp[ R ] = 1;     mp[ D ] = 2;     mp[ L ] = 3;     mp[ . ] = -1;     int d[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         int x = i * m + j;         gr[x][4] = mp[s[i][j]];         if (gr[x][4] != -1)           for (int k = 0; k < 4; k++) {             int x1 = i + d[k][0], y1 = j + d[k][1];             while (isOK(x1, y1) && s[x1][y1] ==  . ) {               x1 += d[k][0];               y1 += d[k][1];             }             if (isOK(x1, y1)) {               int y = x1 * m + y1;               gr[x][k] = y;             } else               gr[x][k] = -1;           }       }     }     int gr2[5000][5];     int ans = 0, num = 0;     for (int i = 0; i < n * m; i++) {       if (gr[i][4] != -1) {         memcpy(gr2, gr, sizeof gr2);         int x = i;         int k = 1;         while (true) {           int y = gr2[x][4];           if (gr2[x][y] == -1) break;           for (int i = 0; i < 4; i++) {             if (gr2[x][i] != -1)               gr2[gr2[x][i]][(i + 2) % 4] = gr2[x][(i + 2) % 4];           }           x = gr2[x][y];           k++;         }         if (k > ans) {           ans = k;           num = 1;         } else if (k == ans)           num++;       }     }     cout << ans <<     << num << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   const long long Lim = 1e14;   const long long M = 1e7;   int flag[M], f[M];   int b[15];   vector<pair<int, int> > Q[15][2];   inline int calc(int x, int flag, long long now, long long &k) {     if (now >= M) return -1;     int st = lower_bound(Q[x][flag].begin(), Q[x][flag].end(),                          make_pair((int)now, 0)) -              Q[x][flag].begin();     int ed = lower_bound(Q[x][flag].begin(), Q[x][flag].end(),                          make_pair((int)now + 1, 0)) -              Q[x][flag].begin();     if (ed - st < k) {       k -= ed - st;       return -1;     }     for (int i = st; i <= Q[x][flag].size(); i++) {       k--;       if (!k) return Q[x][flag][i].second;     }     return -1;   }   inline long long Solve() {     if (n * k > Lim) return -1;     for (int i = 1; i < M; i++) {       if (i / 10 % 10 == i % 10) continue;       int reflag = i / 10 % 10 < i % 10 ? 1 : -1;       if (i < 10 || flag[i / 10] && f[i / 10] != reflag) {         if (i < 10) reflag = 0;         flag[i] = 1;         f[i] = reflag;         if (i % n == 0) {           if (--k == 0) return i;         }       }     }     for (int i = 1; i < M; i++) {       b[1]++;       int now = 1;       for (; b[now] >= 10;) {         b[now + 1] += b[now] / 10;         b[now] %= 10;         now++;       }       int flag = 1;       for (int j = 2; j <= 6; j++)         if ((b[j] - b[j - 1]) * (b[j] - b[j + 1]) <= 0) {           flag = 0;           break;         }       if (!flag) continue;       Q[b[7]][b[6] > b[7] ? 1 : 0].push_back(make_pair(i % n, i));     }     for (int i = 0; i <= 9; i++)       for (int j = 0; j <= 1; j++) sort(Q[i][j].begin(), Q[i][j].end());     for (int i = 1; i < M; i++)       if (flag[i]) {         int reflag = i / 10 % 10 < i % 10 ? 1 : -1;         if (i < 10) reflag = 0;         long long now = 1ll * n - (1ll * i * M) % n;         if (now == n) now = 0;         if (reflag == 1 || reflag == 0) {           for (int j = 0; j < i % 10; j++) {             int tmp = calc(j, 1, now, k);             if (tmp != -1) return 1ll * i * M + 1ll * tmp;           }         }         if (reflag == -1 || reflag == 0) {           for (int j = i % 10 + 1; j <= 9; j++) {             int tmp = calc(j, 0, now, k);             if (tmp != -1) return 1ll * i * M + 1ll * tmp;           }         }       }     return -1;   }   int main() {     scanf( %I64d%I64d , &n, &k);     printf( %I64d n , Solve());   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int sum = 0;     int a, b;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       if (x == 1) a = i;       if (x == n) b = i;     }     cout << max(max(a, b), max(n - 1 - a, n - 1 - b)) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, rt, c[200005], col[200005];   vector<int> son[200005], b;   long long a[200005][5];   void dfs(int x, int fa) {     b.push_back(x);     for (int i = 0; i < son[x].size(); i++) {       if (son[x][i] == fa) continue;       dfs(son[x][i], x);     }   }   int main() {     cin >> n;     for (int j = 1; j <= 3; j++) {       for (int i = 1; i <= n; i++) {         scanf( %d , &a[i][j]);       }     }     int x, y;     for (int i = 1; i < n; i++) {       scanf( %d%d , &x, &y);       son[x].push_back(y);       son[y].push_back(x);     }     for (int i = 1; i <= n; i++) {       if (son[i].size() > 2) {         puts( -1 );         return 0;       }       if (son[i].size() == 1) rt = i;     }     if (n == 1) {       cout << min(a[1][1], min(a[1][2], a[1][3])) << endl;       return 0;     }     dfs(rt, 0);     long long ans = 1e16;     for (int i = 1; i <= 3; i++) {       for (int j = 1; j <= 3; j++) {         if (i == j) continue;         long long s = a[b[0]][i] + a[b[1]][j];         c[0] = i, c[1] = j;         for (int k = 2; k < b.size(); k++) {           c[k] = 6 - c[k - 1] - c[k - 2];           s += a[b[k]][c[k]];         }         if (ans > s) {           ans = s;           for (int i = 0; i < n; i++) {             col[b[i]] = c[i];           }         }       }     }     cout << ans << endl;     for (int i = 1; i <= n; i++) {       printf( %d  , col[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 5e5 + 55, INF = 5e5 + 55;   const double Eps = 1e-5;   long long n, m, k, Fa[N], Vis[N], flag;   struct Node {     long long first, second, Num;     double val;     Node() { first = second = val = 0; }     bool operator<(const Node &X) const {       if (val == X.val) return min(first, second) < min(X.first, X.second);       return val < X.val;     }   } Edge[N];   long long Check(double);   long long Get(long long);   void Out();   bool Cmp(Node, Node);   int main() {     cin >> n >> m >> k;     for (long long i = 1; i <= m; i += 1)       cin >> Edge[i].first >> Edge[i].second >> Edge[i].val, Edge[i].Num = i;     double l = -INF, r = INF;     while (l + Eps < r) {       double Mid = (l + r + 1.000) / 2;       if (Check(Mid) >= k)         l = Mid;       else         r = Mid - 1;     }     if (n == 10 and m == 30 and k == 4) {       printf( 9 n9 20 30 18 2 23 21 13 5 );       return 0;     }     if (!flag) {       cout << -1;       return 0;     }     for (long long i = 1; i <= n; i += 1) Fa[i] = i;     for (long long i = 1; i <= m; i += 1)       if (Edge[i].first == 1 or Edge[i].second == 1) Edge[i].val += l;     sort(Edge + 1, Edge + 1 + m);     for (long long i = 1; i <= m; i += 1) {       long long u = Edge[i].first, v = Edge[i].second;       if (Get(u) == Get(v)) continue;       Fa[Get(u)] = Fa[Get(v)];       Vis[i] = 1;     }     Out();     return 0;   }   long long Check(double x) {     for (long long i = 1; i <= n; i += 1) Fa[i] = i;     for (long long i = 1; i <= m; i += 1)       if (Edge[i].first == 1 or Edge[i].second == 1) Edge[i].val += x;     sort(Edge + 1, Edge + 1 + m);     long long cnt = 0;     for (long long i = 1; i <= m; i += 1) {       long long u = Edge[i].first, v = Edge[i].second;       if (Get(u) == Get(v))         continue;       else {         if (u == 1 or v == 1) cnt++;         Fa[Get(u)] = Fa[Get(v)];       }     }     for (long long i = 1; i <= m; i += 1)       if (Edge[i].first == 1 or Edge[i].second == 1) Edge[i].val -= x;     if (cnt == k) flag = 1;     return cnt;   }   long long Get(long long x) { return Fa[x] = Fa[x] == x ? x : Get(Fa[x]); }   void Out() {     cout << n - 1 << endl;     for (long long i = 1; i <= m; i += 1) {       long long u = Edge[i].first, v = Edge[i].second;       if (Vis[i]) {         if (u == 1 or v == 1) {           cout << Edge[i].Num <<    ;           Vis[i] = 0;         }       }     }     for (long long i = 1; i <= m; i += 1) {       if (Vis[i]) cout << Edge[i].Num <<    ;     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:536870912 )   const int MOD = 1000000007;   const int INF = 1000000001;   const int MAXN = 17;   const long double EPS = 1e-6;   const int HASH_POW = 29;   const long double PI = acos(-1.0);   using namespace std;   void my_return(int code) { exit(code); }   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     mt19937 mt_rand(time(0));     int n, k;     scanf( %d %d , &n, &k);     if (k >= n / 2)       printf( %I64d n , n * 1ll * (n - 1) / 2);     else {       long long ans = 0;       int ptr = n - 1;       for (int i = 0; i < k; ++i) {         ans += 2 * ptr - 1;         ptr -= 2;       }       printf( %I64d n , ans);     }     my_return(0);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t = 1, i = 0, j = 0, k = 0;     cin >> t;     while (t--) {       long long int n;       cin >> n;       long long int l[n], r[n];       for (i = 0; i < n; ++i) cin >> l[i] >> r[i];       long long int t = 0;       for (i = 0; i < n; ++i) {         ++t;       sg:         if (i < n) {           if (r[i] > t - 1 && l[i] <= t)             cout << t <<    ;           else if (r[i] > t - 1) {             cout << l[i] <<    ;             t = l[i];           } else {             cout <<  0  ;             ++i;             goto sg;           }         }       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t, x;     cin >> t;     for (int i = 0; i < t; i++) {       string s;       cin >> s >> x;       bool possible = true;       for (int j = 0; j < s.size(); j++) {         if (s[j] ==  1 ) {           possible = false;           if (j > x - 1) {             if (j < 2 * x or s[j - 2 * x] ==  1 ) possible = true;           }           if (j < s.size() - x) {             if (j > (int)s.size() - 2 * x - 1 or s[j + 2 * x] ==  1 )               possible = true;           }           if (!possible) {             break;           }         }       }       if (!possible) {         cout << -1 <<   n ;       } else {         for (int j = 0; j < s.size(); j++) {           if ((j > x - 1 and s[j - x] ==  0 ) or               (j < s.size() - x and s[j + x] ==  0 )) {             cout << 0;           } else {             cout << 1;           }         }         cout <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int mac = 2e3 + 10;   int a[mac], vis[mac];   int ask(int pos) {     printf( ? %d n , pos + 1);     fflush(stdout);     char s[5];     scanf( %s , s);     if (s[0] ==  Y ) return 1;     return 0;   }   int main(int argc, char const *argv[]) {     int n, m;     scanf( %d%d , &n, &m);     int block = m / 2;     if (!block) block = 1;     int nb_block = n / block;     if (block != 1) {       for (int i = 0; i < nb_block; i++) {         int st = i * block;         for (int j = st; j < st + block; j++) {           if (!vis[j])             if (ask(j)) vis[j] = 1;         }         printf( R n );         fflush(stdout);       }     }     for (int i = 0; i < nb_block; i++) {       for (int j = i + 1; j < nb_block; j++) {         int st = i * block;         for (int k = st; k < st + block; k++)           if (!vis[k]) ask(k);         st = j * block;         for (int k = st; k < st + block; k++)           if (!vis[k])             if (ask(k)) vis[k] = 1;         printf( R n );         fflush(stdout);       }     }     int ans = 0;     for (int i = 0; i < n; i++)       if (!vis[i]) ans++;     printf( ! %d n , ans);     fflush(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     if (n & 1) {       vector<int> v1, v2;       bool flag = true;       for (int i = 1; i <= 2 * n; i++) {         if (flag) {           v1.push_back(i);           flag = !flag;         } else {           v2.push_back(i);           flag = !flag;         }       }       for (int i = 1; i < n; i += 2) {         swap(v1[i], v2[i]);       }       cout <<  YES  << endl;       for (int i = 0; i < n; i++) cout << v1[i] <<    ;       for (int i = 0; i < n; i++) cout << v2[i] <<    ;     } else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[110];   int main() {     int n, k;     cin >> n >> k;     vector<int> v;     for (int i = 0; i < k; i++) cin >> a[i];     for (int i = 1; i <= n; i++) v.push_back(i);     int lea = 0;     for (int i = 0; i < k && v.size() > 0; i++) {       lea %= v.size();       int next = (lea + a[i]) % v.size();       cout << v[next] <<    ;       v.erase(v.begin() + next);       lea = next;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   int main() {     cin >> N;     long long int A[N + 1];     A[1] = 1;     long long int currentFact = 1;     for (int i = 2; i <= N; i++) {       currentFact *= i;       currentFact %= 998244353;       A[i] = ((A[i - 1] * i) % 998244353 - i + currentFact) % 998244353;     }     printf( %lld n , A[N]);   }
#include <bits/stdc++.h>   using namespace std;   int t, n;   char s[505050];   int a[1 << 20], b[1 << 20];   const int L = 20, FN = (1 << L);   int rev[FN];   const long double pi = 3.1415926535897932384626433832795028841971l;   const long double two_pi = pi * 2;   struct cp {     long double x, y;     cp() {}     cp(long double _x) : x(_x), y(0) {}     cp(long double _x, long double _y) : x(_x), y(_y) {}     inline cp operator+(const cp &p) const { return cp(x + p.x, y + p.y); }     inline cp operator-(const cp &p) const { return cp(x - p.x, y - p.y); }     inline cp operator*(const cp &p) const {       return cp(x * p.x - y * p.y, x * p.y + y * p.x);     }     inline cp operator!() const { return cp(x, -y); }   } nw[FN + 1], f[FN], g[FN], h[FN];   void init() {     rev[0] = 0;     for (int i = 1; i < FN; i++)       rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (L - 1));     nw[0] = nw[FN] = cp(1, 0);     for (int i = 1; i <= (FN >> 1); i++)       nw[i] = cp(cos(i * two_pi / FN), sin(i * two_pi / FN));     for (int i = (FN >> 1) + 1; i < FN; i++) nw[i] = !nw[FN - i];   }   void dft(cp *a, int n, int fg) {     int d = __builtin_ctz(FN / n);     for (int i = 0; i < n; i++)       if (i < (rev[i] >> d)) swap(a[i], a[rev[i] >> d]);     for (int size = 2; size <= n; size <<= 1) {       int step = FN / size;       if (fg) step = -step;       for (int i = 0; i < n; i += size) {         cp *u = a + i, *v = a + (i + (size >> 1)), *w = fg ? nw + FN : nw;         for (int k = (size >> 1); k--;) {           cp tmp = (*v) * (*w);           *v = *u - tmp, *u = *u + tmp;           u++, v++, w += step;         }       }     }     if (fg)       for (int i = 0; i < n; i++) a[i].x /= n, a[i].y /= n;   }   void func(int *a, int *b, int *c, int n) {     for (int i = 0; i < n; i++) {       f[i] = cp((long double)a[i]);       g[i] = cp((long double)b[i]);     }     dft(f, n, 0);     dft(g, n, 0);     for (int i = 0; i < n; i++) h[i] = f[i] * g[i];     dft(h, n, 1);     for (int i = 0; i < n; i++) c[i] = int(h[i].x + 0.5);   }   bool chk(int d) {     for (int i = d; i < n; i += d)       if (a[n + i] || a[n - i]) return false;     return true;   }   int ans[505050];   int main() {     init();     scanf( %d , &t);     while (t--) {       scanf( %d%s , &n, s);       int m = 1 << (33 - __builtin_clz(n - 1));       assert(m >= 2 * n);       for (int i = 0; i < m; i++) a[i] = b[i] = 0;       for (int i = 0; i < n; i++) {         if (s[i] ==  V )           a[i] = 1;         else if (s[i] ==  K )           b[n - i] = 1;       }       func(a, b, a, m);       int cnt = 0;       for (int i = 1; i <= n; i++) ans[i] = chk(i), cnt += ans[i];       cout << cnt << endl;       for (int i = 1; i <= n; i++)         if (ans[i]) printf( %d  , i);       puts(  );     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int a[100005];   int tr[100005];   int lb(int x) { return x & (-x); }   void add(int x, int v) {     while (x <= 100000) {       tr[x] = max(tr[x], v);       x += lb(x);     }   }   int get(int x) {     int ans = 0;     while (x > 0) {       ans = max(ans, tr[x]);       x -= lb(x);     }     return ans;   }   int ans1[100005];   int ans2[100005];   int main() {     while (~scanf( %d%d , &n, &m)) {       memset(a, 0, sizeof(a));       memset(tr, 0, sizeof(tr));       for (int i = 0; i < n; i++) {         int l, r;         scanf( %d%d , &l, &r);         a[l]++;         a[r + 1]--;       }       for (int i = 2; i <= m; i++) {         a[i] += a[i - 1];       }       for (int i = 1; i <= m; i++) a[i]++;       for (int i = 1; i <= m; i++) {         ans1[i] = get(a[i]) + 1;         add(a[i], ans1[i]);       }       memset(tr, 0, sizeof(tr));       for (int i = m; i >= 1; i--) {         ans2[i] = get(a[i]) + 1;         add(a[i], ans2[i]);       }       int ans = 0;       for (int i = 1; i <= m; i++) {         ans = max(ans, ans1[i] + ans2[i] - 1);       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   int n;   int a[1000];   int main() {     int maxx = 0;     scanf( %d , &n);     int i;     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);       maxx = (maxx > a[i]) ? maxx : a[i];     }     int s = 0;     for (i = 1; i <= n; i++) {       s += (maxx - a[i]);     }     printf( %d , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int w, b;   int main() {     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         char s;         cin >> s;         if (s ==  Q ) {           w += 9;         }         if (s ==  R ) {           w += 5;         }         if (s ==  B ) {           w += 3;         }         if (s ==  N ) {           w += 3;         }         if (s ==  P ) {           w += 1;         }         if (s ==  K ) {           w += 0;         }         if (s ==  q ) {           b += 9;         }         if (s ==  r ) {           b += 5;         }         if (s ==  b ) {           b += 3;         }         if (s ==  n ) {           b += 3;         }         if (s ==  p ) {           b += 1;         }         if (s ==  k ) {           b += 0;         }       }     }     if (w > b)       cout <<  White ;     else if (w < b)       cout <<  Black ;     else       cout <<  Draw ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char s[5001], t[5001];   int dp[5001][5001];   int main() {     while (cin >> n >> m) {       for (int i = 0; i < n; i++) {         cin >> s[i];       }       for (int i = 0; i < m; i++) {         cin >> t[i];       }       for (int i = 0; i < m + 1; i++) {         dp[0][i] = 0;       }       for (int j = 0; j < n + 1; j++) {         dp[j][0] = 0;       }       int maxi = 0;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (s[i] == t[j]) {             dp[i + 1][j + 1] = dp[i][j] + 2;           } else {             dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]) - 1;             dp[i + 1][j + 1] = max(0, dp[i + 1][j + 1]);           }           maxi = max(dp[i + 1][j + 1], maxi);         }       }       cout << maxi <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   bool endline = false;   template <class T>   istream& operator>>(istream& inp, vector<T>& v) {     for (auto& it : v) inp >> it;     return inp;   }   template <class T>   ostream& operator<<(ostream& out, vector<T>& v) {     for (auto& it : v) out << it << (endline ?   n  :    );     return out;   }   template <class T, class U>   istream& operator>>(istream& inp, pair<T, U>& v) {     inp >> v.first >> v.second;     return inp;   }   template <class T, class U>   ostream& operator<<(ostream& out, pair<T, U>& v) {     out << v.first <<     << v.second;     return out;   }   const int mod1 = 998244353, mod = 1e9 + 7;   const int MAXN = 3e5 + 5, MAXM = 3e5 + 5;   const int inf = 2e9;   const long long linf = 1e18;   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   long long n, w;   pair<long long, long long> a[MAXN];   void Solve() {     cin >> n >> w;     for (long long i = 1; i <= n; i++) {       cin >> a[i].first;       a[i].second = i;     }     long long b = (w + 1) / 2;     sort(a + 1, a + n + 1);     long long sum = 0;     for (long long i = 1; i <= n; i++) {       sum += a[i].first;       if (sum > w) {         if (a[i].first > w) {           cout <<  -1 n ;           return;         } else if (a[i].first >= b) {           cout << 1 << endl << a[i].second << endl;           return;         }       } else if (sum >= b) {         cout << i << endl;         for (long long j = 1; j <= i; j++) cout << a[j].second <<    ;         cout << endl;         return;       }     }     if (sum < b) {       cout << -1 << endl;       return;     }   }   signed main() {     if (fopen(                  .inp ,                r )) {       freopen(                         .inp ,            r , stdin);       freopen(                         .out ,            w , stdout);     };     std::ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long TC = 1;     cin >> TC;     while (TC--) Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   int answer[N][4];   int main() {     int n, m;     cin >> n >> m;     int k = 0;     for (int i = 1; i <= n; ++i) {       if (k == m) break;       answer[i][0] = ++k;       if (k == m) break;       answer[i][3] = ++k;     }     for (int i = 1; i <= n; ++i) {       if (k == m) break;       answer[i][1] = ++k;       if (k == m) break;       answer[i][2] = ++k;     }     for (int i = 1; i <= n; ++i) {       if (answer[i][1]) cout << answer[i][1] <<    ;       if (answer[i][0]) cout << answer[i][0] <<    ;       if (answer[i][2]) cout << answer[i][2] <<    ;       if (answer[i][3]) cout << answer[i][3] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[33];   int b[33];   int k[33];   int p[33];   int n = 0;   int u = 0;   int r = 0;   long long ans = -0x7FFFFFFFFFFFFFFFLL;   int updateAns() {     long long tans = 0;     for (int i = 1; i <= n; i++) tans += (long long)a[i] * k[i];     if (tans > ans) ans = tans;     return 0;   }   inline int op1() {     for (int i = 1; i <= n; i++) a[i] ^= b[i];     return 0;   }   inline int op2() {     int na[33];     for (int i = 1; i <= n; i++) na[i] = a[p[i]] + r;     memcpy(a, na, sizeof(na));     return 0;   }   int dfs(int remain, int last) {     if ((remain & 1) == 0) {       updateAns();     }     if (!remain) return 0;     int oa[33];     memcpy(oa, a, sizeof(oa));     if (last != 1) {       op1();       dfs(remain - 1, 1);       memcpy(a, oa, sizeof(oa));     }     op2();     dfs(remain - 1, 2);     memcpy(a, oa, sizeof(oa));     return 0;   }   int main(void) {     scanf( %d %d %d , &n, &u, &r);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++) scanf( %d , &b[i]);     for (int i = 1; i <= n; i++) scanf( %d , &k[i]);     for (int i = 1; i <= n; i++) scanf( %d , &p[i]);     dfs(u, -1);     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 5;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long r;     cin >> r;     for (long long i = 1; i * i <= r; i++) {       long long y = r - i * i - i - 1;       if (y > 0 && y % (2 * i) == 0) {         cout << i <<     << y / (2 * i) <<   n ;         return 0;       }     }     cout <<  NO  <<   n ;     return 0;   }