malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 200 * 1000 + 20;   int p[N], q[N], n, ans[N], cnt[N], seg[N << 2];   void build(int id = 1, int st = 0, int en = n) {     if (en - st == 1) {       seg[id] = 1;       return;     }     int mid = st + en >> 1;     build(id << 1, st, mid);     build(id << 1 | 1, mid, en);     seg[id] = seg[id << 1] + seg[id << 1 | 1];   }   void update(int idx, int id = 1, int st = 0, int en = n) {     if (en - st == 1) {       seg[id] = 0;       return;     }     int mid = st + en >> 1;     if (idx < mid)       update(idx, id << 1, st, mid);     else       update(idx, id << 1 | 1, mid, en);     seg[id] = seg[id << 1] + seg[id << 1 | 1];   }   int get(int l, int r, int id = 1, int st = 0, int en = n) {     if (l <= st && en <= r) return seg[id];     if (r <= st || en <= l) return 0;     int mid = st + en >> 1;     return get(l, r, id << 1, st, mid) + get(l, r, id << 1 | 1, mid, en);   }   int get2(int val, int id = 1, int st = 0, int en = n) {     if (en - st == 1) return st;     int mid = st + en >> 1;     if (val < seg[id << 1])       return get2(val, id << 1, st, mid);     else       return get2(val - seg[id << 1], id << 1 | 1, mid, en);   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> p[i];     for (int i = 0; i < n; i++) cin >> q[i];     build();     for (int i = 0; i < n; i++) {       cnt[n - i - 1] = get(0, p[i]);       update(p[i]);     }     build();     for (int i = 0; i < n; i++) {       cnt[n - i - 1] += get(0, q[i]);       update(q[i]);     }     for (int i = 0; i < n; i++) {       cnt[i + 1] += cnt[i] / (i + 1);       cnt[i] %= i + 1;     }     build();     for (int i = n - 1; ~i; i--) {       ans[n - i - 1] = get2(cnt[i]);       update(ans[n - i - 1]);     }     for (int i = 0; i < n; i++) cout << ans[i] <<    ;     return cout <<   n , 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long s = 0, w = 1;     register char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();     return s * w;   }   void print(long long x) {     if (x < 0) x = -x, putchar( - );     if (x > 9) print(x / 10);     putchar(x % 10 +  0 );   }   long long n, c, x, y, res = 1, now = 1;   signed main() {     n = read(), x = read(), y = read(), c = read();     if (c == 1) {       puts( 0 );       return 0;     }     for (; c > res; now++) {       long long L = min(now, y - 1);       if (L == now) res--;       res += max(0ll, L - max(now - x + 1, 1ll) + 1) +              max(0ll, L - max(x + now - n, 1ll) + 1);       long long R = min(now, n - y);       if (R == now) res--;       res += max(0ll, R - max(now - x + 1, 0ll) + 1) +              max(0ll, R - max(x + now - n, 0ll) + 1);     }     printf( %lld n , --now);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int rdi() {     int d;     scanf( %d , &d);     return d;   }   inline char rdc() {     scanf(   );     return getchar();   }   inline string rds() {     string s;     cin >> s;     return s;   }   inline double rddb() {     double d;     scanf( %lf , &d);     return d;   }   template <class T>   inline bool setmin(T& a, T b) {     return a > b ? a = b, true : false;   }   template <class T>   inline bool setmax(T& a, T b) {     return a < b ? a = b, true : false;   }   struct debugger {     template <typename T>     debugger& operator,(const T& x) {       cerr << x <<  , ;       return *this;     }   } dbgr;   const int N = 131072, M = 128;   char s[N];   int n, c[3], cnt[N][3];   int Abs(int x) { return x < 0 ? -x : +x; }   int main() {     scanf( %s , s + 1), n = strlen(s + 1);     for (int i = (1); i <= (n); ++i)       memcpy(cnt[i], cnt[i - 1], sizeof cnt[i]), ++cnt[i][s[i] -  x ];     for (int repp_b = (rdi()), repp = 0; repp < repp_b; ++repp) {       int l = rdi(), r = rdi();       for (int i = (0); i < (3); ++i) c[i] = cnt[r][i] - cnt[l - 1][i];       int mx = *max_element(c, c + 3);       int mn = *min_element(c, c + 3);       puts(r - l + 1 < 3 || mx - mn <= 1 ?  YES  :  NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[4];   int y[4];   int newx[4];   int newy[4];   int T;   int get() {     int answ = INT_MAX;     for (auto y1 : y)       for (auto y2 : y) {         int delta = abs(y1 - y2);         if (delta == 0) continue;         set<int> s;         for (auto x1 : x)           for (auto x2 : x)             for (auto d : {0, -delta, -2 * delta, 1, -delta + 1, -2 * delta + 1})               s.insert((x1 + x2 + d) / 2);         for (auto x1 : s) {           int p[4] = {3, 2, 1, 0};           for (int ori = 0; ori < 24; ori++) {             next_permutation(p, p + 4);             int xs[4] = {x1, x1, x1 + delta, x1 + delta};             int ys[4] = {y1, y2, y1, y2};             bool flag = false;             for (int i = 0; i < 4; i++)               if (xs[i] != x[p[i]] && ys[i] != y[p[i]]) {                 flag = true;               }             if (flag) continue;             int t = 0;             for (int i = 0; i < 4; i++)               t = max(t, abs(xs[i] - x[p[i]]) + abs(ys[i] - y[p[i]]));             if (answ > t) {               answ = t;               for (int i = 0; i < 4; i++) {                 newx[p[i]] = xs[i];                 newy[p[i]] = ys[i];               }             }           }         }       }     return answ;   }   int boom = 1e9;   int main() {     scanf( %d , &T);     while (T--) {       for (int i = 0; i < 4; i++) {         scanf( %d%d , &x[i], &y[i]);         x[i] = x[i] + boom;         y[i] = y[i] + boom;       }       int t1 = get();       swap(x, y);       swap(newx, newy);       int t2 = get();       swap(x, y);       swap(newx, newy);       if (t1 < t2) get();       if (min(t1, t2) == INT_MAX) {         puts( -1 );       } else {         printf( %d n , min(t1, t2));         for (int i = 0; i < 4; i++)           printf( %d %d n , newx[i] - boom, newy[i] - boom);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x;     int a;     scanf( %d%d , &n, &x);     int sum = 0;     while (n--) {       scanf( %d , &a);       sum += a;     }     int count = 0;     if (sum == 0) {     } else {       if (abs(sum) <= x) {         count = 1;       } else {         count = abs(sum) / abs(x);         if (abs(sum) % abs(x) != 0) count++;       }     }     cout << count << endl;   }
#include <bits/stdc++.h>   using namespace std;   int mp[27][27];   int dp[111][111][26];   bool flag[111][111][26];   char s[111];   inline void checkmax(int &a, int b) {     if (a < b) a = b;   }   int main() {     int i, j, k, n, m;     scanf( %s , s);     scanf( %d , &k);     scanf( %d , &n);     for (i = 1; i <= n; i++) {       getchar();       char ch1, ch2;       scanf( %c , &ch1);       getchar();       scanf( %c%d , &ch2, &m);       mp[ch1 -  a ][ch2 -  a ] = m;     }     memset(flag, 0, sizeof(flag));     for (i = 0; i < 26; i++) {       if (s[0] -  a  == i) {         dp[0][0][i] = 0;         flag[0][0][i] = true;       } else if (k > 0) {         dp[0][1][i] = 0;         flag[0][1][i] = true;       }     }     for (i = 0; i < strlen(s) - 1; i++) {       for (j = 0; j <= k; j++)         for (int x = 0; x < 26; x++) {           if (!flag[i][j][x]) continue;           for (int y = 0; y < 26; y++)             if (s[i + 1] -  a  == y) {               if (!flag[i + 1][j][y]) dp[i + 1][j][y] = dp[i][j][x] + mp[x][y];               flag[i + 1][j][y] = true;               checkmax(dp[i + 1][j][y], dp[i][j][x] + mp[x][y]);             } else if (j < k) {               if (!flag[i + 1][j + 1][y])                 dp[i + 1][j + 1][y] = dp[i][j][x] + mp[x][y];               flag[i + 1][j + 1][y] = true;               checkmax(dp[i + 1][j + 1][y], dp[i][j][x] + mp[x][y]);             }         }     }     m = -999999999;     for (i = 0; i <= k; i++) {       for (j = 0; j < 26; j++) {         if (flag[strlen(s) - 1][i][j]) checkmax(m, dp[strlen(s) - 1][i][j]);       }     }     cout << m << endl;   }
#include <bits/stdc++.h>   int main() {     static char xx[100 + 1], yy[100 + 1];     int n, i;     scanf( %s%s , xx, yy);     n = strlen(xx);     for (i = 0; i < n; i++)       if (xx[i] < yy[i]) {         printf( -1 n );         return 0;       }     printf( %s n , yy);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[100002];   int main() {     int i, n, ans = 0, mm = 0;     cin >> n;     n = n << 1;     for (i = 0; i < n; i++) {       int a;       scanf( %d , &a);       ans = ans - arr[a];       arr[a] = arr[a] ^ 1;       ans += arr[a];       mm = max(mm, ans);     }     cout << mm << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int s = 0, w = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) s = s * 10 + ch -  0 , ch = getchar();     return s * w;   }   int main() {     int T = read();     while (T--) {       int n = read(), a = read(), flag = 0, k;       for (int i = 2; i <= n; i++) {         int b = read();         if (abs(a - b) >= 2) {           k = i;           flag = 1;         }         a = b;       }       if (flag)         cout <<  YES n  << k - 1 <<     << k << endl;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool foiare[1024], cand[1024], foivert[1024];   int n, a[32];   int main() {     scanf( %d , &n);     memset(foiare, false, sizeof(foiare));     memset(foivert, false, sizeof(foivert));     for (int i = 0; i < n; i++) {       for (int j = 1; j <= 1000; j++)         if (!foivert[j]) {           bool podej = true;           memset(cand, false, sizeof(cand));           for (int k = 0; k < i; k++)             if (foiare[a[k] + j] or a[k] + j > 1000) {               podej = false;               break;             } else if (cand[a[k] + j]) {               podej = false;               break;             } else               cand[a[k] + j] = true;           if (podej) {             a[i] = j;             foivert[j] = true;             for (int k = 0; k < i; k++) foiare[a[k] + a[i]] = true;             break;           }         }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (j) printf(   );         if (i == j)           printf( 0 );         else           printf( %d , a[i] + a[j]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   int n, m;   long double p[3010][310], delta[310], f[310][3010], ans = 0, lastf[3010];   int num[310];   void solve(int cur) {     num[cur]++;     if (num[cur] >= n) {       delta[cur] = 0;       return;     }     memcpy(lastf, f[cur], sizeof(f[cur]));     f[cur][0] = 0;     for (int i = 1; i <= n; i++)       f[cur][i] = f[cur][i - 1] * (1 - p[i][cur]) + lastf[i - 1] * p[i][cur];     delta[cur] -= f[cur][n];   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         scanf( %Lf , &p[i][j]);         p[i][j] /= 1000;       }     }     for (int i = 1; i <= m; i++) {       f[i][0] = 1;       for (int j = 1; j <= n; j++) f[i][j] = f[i][j - 1] * (1 - p[j][i]);       delta[i] = 1 - f[i][n];     }     for (int i = 1; i <= n; i++) {       long double mx = 0;       int k = 0;       for (int j = 1; j <= m; j++) {         if (delta[j] > mx) mx = delta[j], k = j;       }       ans += mx;       if (!k) break;       solve(k);     }     printf( %.10Lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[10000], b[10000];   void mergesort(int *a, int *b, int n) {     int i0, i1, iRight, iEnd, width, i, j;     for (width = 1; width < n; width <<= 1)       for (i = 0; i < n; i += (width << 1)) {         i0 = i;         i1 = iRight = min(i + width, n);         iEnd = min(i + (width << 1), n);         for (j = i; j < iEnd; j++)           if (i0 < iRight && (a[i0] <= a[i1] || i1 == iEnd))             b[j] = a[i0++];           else             b[j] = a[i1++];         for (j = i; j < iEnd; j++) a[j] = b[j];       }   }   int main() {     int n, x, y;     cin >> n >> x >> y;     int i;     for (i = 0; i < n; i++) cin >> a[i];     mergesort(a, b, n);     int count = 0;     i = 0;     while (count < y) {       i++;       count++;     }     if (a[i] == a[i - 1])       cout <<  0 ;     else       cout << a[i] - a[i - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Test() {     long long n;     cin >> n;     string s[n];     for (long long i = 0; i < n; i++) {       cin >> s[i];     }     long long ans = 0;     for (char i =  a ; i <=  e ; i++) {       vector<pair<long long, long long> > v;       for (long long j = 0; j < n; j++) {         long long cnti = 0, len = s[j].size();         for (long long k = 0; k < len; k++) {           if (s[j][k] == i) {             ++cnti;           }         }         v.push_back(make_pair(2 * cnti - len, cnti));       }       sort(v.begin(), v.end());       long long curr = 0, oth = 0, temp = 0;       for (long long j = n - 1; j >= 0; j--) {         long long length = ((2 * v[j].second) - v[j].first);         long long x = v[j].second;         long long y = (length - v[j].second);         if ((curr + x) > (oth + y)) {           curr += x;           oth += y;           ++temp;         }       }       ans = max(ans, temp);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout << fixed << setprecision(10);     long long tests;     cin >> tests;     for (long long tc = 1; tc <= tests; tc++) Test();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 5;   const int MAXM = 4e5 + 5;   template <typename T>   void chkmax(T &x, T y) {     x = max(x, y);   }   template <typename T>   void chkmin(T &x, T y) {     x = min(x, y);   }   template <typename T>   void read(T &x) {     x = 0;     int f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -f;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     x *= f;   }   int n, m, q, res[MAXN];   int tot, point[MAXN][2];   int x[MAXN], y[MAXN];   int f[MAXM], s[MAXM];   int find(int x) {     if (f[x] == x)       return x;     else       return find(f[x]);   }   void work(int xl, int xr, int yl, int yr) {     if (xl > xr) return;     vector<pair<int, pair<int, int>>> rev;     auto merge = [&](int x, int y) {       x = find(x), y = find(y);       if (x == y) return;       if (s[x] < s[y]) swap(x, y);       rev.emplace_back(x, make_pair(f[x], s[x]));       rev.emplace_back(y, make_pair(f[y], s[y]));       s[x] += s[y], f[y] = x;       return;     };     auto addedge = [&](int x, int y) {       merge(point[x][0], point[y][1]);       merge(point[x][1], point[y][0]);       return;     };     auto check = [&](int x, int y) {       return find(point[x][0]) != find(point[y][0]);     };     auto clear = [&]() {       reverse(rev.begin(), rev.end());       for (auto x : rev) {         f[x.first] = x.second.first;         s[x.first] = x.second.second;       }       rev.clear();       return;     };     if (yl == yr) {       for (int i = xl; i <= xr; i++) res[i] = yl;       return;     }     bool fail = false;     int mid = (yl + yr + 1) / 2, divp = 0;     for (int i = max(yl, 1); i < mid && !fail; i++) {       fail |= !check(x[m - i + 1], y[m - i + 1]);       if (!fail) addedge(x[m - i + 1], y[m - i + 1]);     }     if (fail) {       clear();       work(xl, xr, yl, mid - 1);       return;     }     divp = xl;     for (int i = xl; i <= xr - 1; i++) {       if (check(x[i], y[i])) {         divp++;         addedge(x[i], y[i]);       } else         break;     }     clear();     for (int i = max(yl, 1); i < mid; i++) addedge(x[m - i + 1], y[m - i + 1]);     work(xl, divp, mid, yr);     clear();     fail = false;     for (int i = xl; i <= divp; i++) {       if (!check(x[i], y[i])) {         fail = true;         break;       }       addedge(x[i], y[i]);     }     if (!fail) work(divp + 1, xr, yl, mid - 1);     clear();   }   int main() {     read(n), read(m), read(q);     for (int i = 1; i <= m; i++) read(x[i]), read(y[i]);     for (int i = 1; i <= n; i++) {       point[i][0] = ++tot;       f[tot] = tot, s[tot] = 1;       point[i][1] = ++tot;       f[tot] = tot, s[tot] = 1;     }     work(1, m, 0, m);     for (int i = 1; i <= q; i++) {       int l, r;       read(l), read(r);       if (res[l] >= m - r + 1)         puts( NO );       else         puts( YES );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T, pw[10000005], N, K, X, c[10000005], d[10000005];   long long exp(long long a, long long b) {     if (b == 0) return 1;     if (b == 1) return a;     long long res = exp(a, b >> 1);     if (b & 1) {       return a * (res * res % 998244353) % 998244353;     }     return res * res % 998244353;   }   void solve() {     cin >> N >> K >> X;     if (!X) {       if (K == 0 || N > K) {         cout << 0 << endl;         return;       }       long long ans = 1;       for (int i = 0; i < N; ++i) {         ans = 1ll * ans * ((long long)998244353 + pw[K] - pw[i]) % 998244353;       }       cout << ans << endl;       return;     }     d[K] = 1;     for (int i = K - 1; i >= 0; --i) {       c[i] = 1ll * pw[i] * d[i + 1] % 998244353;       d[i] = 1ll * (pw[i] - 1) * d[i + 1] % 998244353;     }     long long ans = 0;     long long pwn = exp(2, N);     long long cur = 1;     for (int i = 0; i < K; ++i) {       ans += 1ll * ((K - i - 1) & 1 ? 998244353 - 1 : 1) *              (1ll * c[i] * cur % 998244353) % 998244353;       if (ans >= 998244353) ans -= 998244353;       cur = cur * pwn % 998244353;     }     cout << ans << endl;     return;   }   int main() {     pw[0] = 1;     for (int i = 1; i < 10000005; ++i) {       pw[i] = pw[i - 1] << 1;       if (pw[i] >= 998244353) pw[i] -= 998244353;     }     int T;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   int main() {     int p, q, l, r;     scanf( %d %d %d %d , &p, &q, &l, &r);     std::vector<std::pair<int, int> > fixed;     std::vector<std::pair<int, int> > changing;     for (int k = 0; k < p; k++) {       int a, b;       scanf( %d %d , &a, &b);       fixed.push_back(std::pair<int, int>(a, b));     }     for (int k = 0; k < q; k++) {       int a, b;       scanf( %d %d , &a, &b);       changing.push_back(std::pair<int, int>(a, b));     }     bool done;     int output(0);     for (int k = l; k <= r; k++) {       done = 0;       for (int x = 0; x < fixed.size(); x++) {         if (done) {           continue;         }         for (int y = 0; y < changing.size(); y++) {           if ((fixed[x].second < k + changing[y].first) ||               (k + changing[y].second < fixed[x].first)) {             continue;           } else {             done = 1;             ++output;             break;           }         }       }     }     printf( %d n , output);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const int mod = 1000000007;   const int inf = 0x3f3f3f3f;   const int maxn = 200005;   void task() {     int n;     cin >> n;     vector<int> row(n, 0), coulmn(n, 0);     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) {         int a;         cin >> a;         row[i] += a;         coulmn[j] += a;       }     int ans = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++)         if (coulmn[j] > row[i]) ans++;     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T = 1;     while (T--) {       task();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k;     cin >> k;     int a[k + 1];     for (int i = 0; i < k; i++) cin >> a[i];     long long int comb[1005][1005];     comb[0][0] = 1;     for (int i = 1; i < 1005; i++) {       comb[i][0] = 1;       for (int j = 1; j <= i; j++) {         comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % 1000000007;       }     }     long long sum = 0, ans = 1;     for (int i = 0; i < k; i++) {       ans = (ans * comb[sum + a[i] - 1][a[i] - 1]) % 1000000007;       sum += a[i];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 50005, M = 50005;   int mo;   struct matrix {     int a[2][2];     int *operator[](const int i) { return a[i]; }     const int *operator[](const int i) const { return a[i]; }     friend matrix operator*(const matrix &a, const matrix &b) {       matrix c;       for (int i = 0; i < 2; i++)         for (int j = 0; j < 2; j++) {           long long s = 0;           for (int k = 0; k < 2; k++) s += (long long)a[i][k] * b[k][j];           c[i][j] = s % mo;         }       return c;     }   };   int n, m;   long long k;   int s[N];   pair<long long, int> a[M];   inline int gs(long long i) {     pair<long long, int> *it = lower_bound(a, a + m, pair<long long, int>(i, 0));     if (it < a + m && it->first == i) return it->second;     return s[i % n];   }   matrix t[N * 4];   void build(int cur, int beg, int end) {     if (end - beg == 1) {       t[cur][1][0] = 1 % mo;       t[cur][0][1] = s[beg];       t[cur][1][1] = s[(beg + 1) % n];       return;     }     int mid = beg + end >> 1;     build(cur << 1, beg, mid);     build(cur << 1 | 1, mid, end);     t[cur] = t[cur << 1] * t[cur << 1 | 1];   }   matrix ans;   void query(int cur, int beg, int end, int L, int R) {     if (end <= L || beg >= R) return;     if (beg >= L && end <= R) {       ans = ans * t[cur];       return;     }     int mid = beg + end >> 1;     query(cur << 1, beg, mid, L, R);     query(cur << 1 | 1, mid, end, L, R);   }   long long p[M * 2], *top = p;   long long q[M * 2], *toq = q;   void power(long long s) {     matrix a = t[1];     for (; s; s >>= 1, a = a * a)       if (s & 1) ans = ans * a;   }   int main() {     scanf( %I64d%d , &k, &mo);     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &s[i]), s[i] %= mo;     scanf( %d , &m);     for (int i = 0; i < m; i++)       scanf( %I64d%d , &a[i].first, &a[i].second), a[i].second %= mo;     sort(a, a + m);     for (int i = 0; i < m; i++)       p[i << 1] = a[i].first - 1, p[i << 1 | 1] = a[i].first;     p[m * 2] = k;     sort(p, p + m * 2 + 1);     top = unique(p, p + m * 2 + 1);     for (int i = 0; i < top - p; i++) q[i] = p[i] / n;     toq = unique(q, q + (top - p));     build(1, 0, n);     ans[0][0] = ans[1][1] = 1 % mo;     ans[0][1] = ans[1][0] = 0;     long long block = 0;     for (int i = 0, j = 0; i < toq - q; i++) {       power(q[i] - block);       block = q[i];       long long id = block * n;       for (; j < top - p && p[j] / n == block; j++) {         query(1, 0, n, id % n, p[j] % n);         id = p[j];         if (id == k) {           printf( %d n , ans[1][0]);           return 0;         }         matrix tmp;         tmp[0][0] = 0;         tmp[1][0] = 1 % mo;         tmp[0][1] = gs(id);         tmp[1][1] = gs(id + 1);         ans = ans * tmp;         id++;       }       query(1, 0, n, id - block * n, n);       id = (++block) * n;     }   }
#include <bits/stdc++.h>   using namespace std;   string s[1010];   int main() {     int n;     cin >> n;     bool f = 1;     for (int i = 0; i < n; ++i) {       cin >> s[i];       if (f && s[i].substr(0, 2) ==  OO ) {         f = 0;         s[i][0] =  + ;         s[i][1] =  + ;       }       if (f && s[i].substr(3, 2) ==  OO ) {         f = 0;         s[i][3] =  + ;         s[i][4] =  + ;       }     }     if (f) {       cout <<  NO ;     } else {       cout <<  YES  << endl;       for (int i = 0; i < n; ++i) cout << s[i] << endl;     }     return 0;   }