malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, v[500005], lastLeft[500005], lastRight[500005], solLeft[500005],       solRight[500005], sol[500005];   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> v[i];     }     for (int i = 1; i <= n; ++i) {       lastLeft[i] = 0;     }     for (int i = n; i >= 1; --i) {       lastRight[i] = n + 1;     }     stack<pair<long long, long long> > st1;     st1.push({1, v[1]});     for (int i = 2; i <= n; ++i) {       while (!st1.empty() && v[i] <= st1.top().second) st1.pop();       if (!st1.empty()) lastLeft[i] = st1.top().first;       st1.push({i, v[i]});     }     stack<pair<long long, long long> > st2;     st2.push({n, v[n]});     for (int i = n - 1; i >= 1; --i) {       while (!st2.empty() && v[i] <= st2.top().second) st2.pop();       if (!st2.empty()) lastRight[i] = st2.top().first;       st2.push({i, v[i]});     }     long long big = 0;     for (int varf = 1; varf <= n; ++varf) {       solLeft[varf] =           solLeft[lastLeft[varf]] + abs(lastLeft[varf] - varf) * v[varf];     }     for (int varf = n; varf >= 1; --varf) {       solRight[varf] =           solRight[lastRight[varf]] + abs(lastRight[varf] - varf) * v[varf];     }     for (int varf = 1; varf <= n; ++varf) {       if (solLeft[varf] + solRight[varf] - v[varf] > big)         big = solLeft[varf] + solRight[varf] - v[varf];     }     for (int varf = 1; varf <= n; ++varf) {       if (solLeft[varf] + solRight[varf] - v[varf] == big) {         sol[varf] = v[varf];         for (int i = varf - 1; i >= 1; --i) {           sol[i] = min(sol[i + 1], v[i]);         }         for (int i = varf + 1; i <= n; ++i) {           sol[i] = min(sol[i - 1], v[i]);         }         for (int i = 1; i <= n; ++i) cout << sol[i] <<    ;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v1, v2, v3;   int n, flag;   int main() {     cin >> n;     int t = 0;     string s1, s2;     cin >> s1 >> s2;     for (int i = 0; i < n; i++) {       if (s1[i] ==  1  && s2[i] ==  0 ) v1.push_back(i + 1);       if (s1[i] ==  0  && s2[i] ==  1 ) v1.push_back(i + 1);       if (s1[i] ==  1  && s2[i] ==  1 ) v2.push_back(i + 1);       if (s1[i] ==  0  && s2[i] ==  0 ) v3.push_back(i + 1);       if (s2[i] ==  1 ) t++;     }     int a = v1.size(), b = v2.size(), c = v3.size();     for (int i = 0; i <= b; i++) {       int x = t - 2 * i;       if (x >= 0 && n / 2 - i - x >= 0 && x <= a && n / 2 - i - x <= c) {         a = x;         b = i;         c = n / 2 - i - x;         flag = 1;       }     }     if (flag) {       for (int i = 0; i < a; i++) cout << v1[i] <<    ;       for (int i = 0; i < b; i++) cout << v2[i] <<    ;       for (int i = 0; i < c; i++) cout << v3[i] <<    ;     } else       cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> ans;   int main() {     char c;     string ss =   ;     while ((c = getchar()) !=   n ) {       if ( a  <= c &&  z  >= c) {         ss += c;         continue;       } else if (c ==    ) {         if (!ss.empty()) {           ans.push_back(ss);           ss =   ;         }       } else {         if (!ss.empty()) {           ans.push_back(ss);           ss =   ;         }         ans[ans.size() - 1] += c;       }     }     if (!ss.empty()) ans.push_back(ss);     for (int i = 0; i < ans.size(); i++) {       cout << ans[i];       if (i == ans.size() - 1)         cout <<   n ;       else         cout <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   class SegTree {    private:     const ll NEUT = 4 * (ll)1e18;     vector<ll> seg, tag;     int h = 1;     void apply(int i, ll v) {       seg[i] += v;       if (i < h) tag[i] += v;     }     void push(int i) {       if (tag[i] == 0) return;       apply(2 * i, tag[i]);       apply(2 * i + 1, tag[i]);       tag[i] = 0;     }     ll combine(ll a, ll b) { return min(a, b); }     ll recGet(int a, int b, int i, int ia, int ib) {       if (ib <= a || b <= ia) return NEUT;       if (a <= ia && ib <= b) return seg[i];       push(i);       int im = (ia + ib) >> 1;       return combine(recGet(a, b, 2 * i, ia, im),                      recGet(a, b, 2 * i + 1, im, ib));     }     void recApply(int a, int b, ll v, int i, int ia, int ib) {       if (ib <= a || b <= ia) return;       if (a <= ia && ib <= b)         apply(i, v);       else {         push(i);         int im = (ia + ib) >> 1;         recApply(a, b, v, 2 * i, ia, im);         recApply(a, b, v, 2 * i + 1, im, ib);         seg[i] = combine(seg[2 * i], seg[2 * i + 1]);       }     }     int recFind(int a, int b, ll v, int i, int ia, int ib) {       if (seg[i] > v) return b;       if (b <= ia || ib <= a) return b;       if (ib == ia + 1) return ia;       push(i);       int im = (ia + ib) >> 1;       int off = recFind(a, b, v, 2 * i, ia, im);       if (off < b)         return off;       else         return recFind(a, b, v, 2 * i + 1, im, ib);     }       public:     SegTree(int n) {       while (h < n) h *= 2;       seg.resize(2 * h, 0);       tag.resize(h, 0);     }     ll rangeMin(int a, int b) { return recGet(a, b + 1, 1, 0, h); }     void rangeAdd(int a, int b, ll v) { recApply(a, b + 1, v, 1, 0, h); }     int findNext(int a, int b, ll v) { return recFind(a, b + 1, v, 1, 0, h); }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> inv(n);     for (int i = 0; i < n; ++i) {       int v;       cin >> v;       inv[v - 1] = i;     }     int res = n - 1;     SegTree seg(n);     seg.rangeAdd(0, inv[n - 1], -1);     for (int i = 0; i < n; ++i) {       while (seg.rangeMin(0, n - 1) >= 0) {         seg.rangeAdd(0, inv[res - 1], -1);         --res;       }       cout << res + 1 <<    ;       int q;       cin >> q;       seg.rangeAdd(0, q - 1, 1);     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t MAXN = 1000005;   const int64_t MAXINT = 2147483098;   const int64_t MAXLL = 9223372036854775258LL;   const int64_t MOD = 1e9 + 7;   void solve() {     int64_t n;     cin >> n;     vector<int64_t> a(n + 2);     for (int64_t i = 1; i < n + 1; ++i) cin >> a[i];     int64_t ans = a[1];     int64_t temp = 1;     for (int64_t i = 3; i < n + 1; ++i) {       if (a[i] == 1 && a[i] == a[i - 1])         temp++;       else {         ans += temp / 3;         temp = 1;       }     }     ans += temp / 3;     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int64_t t;     cin >> t;     while (t--) solve();     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   ostream& operator<<(ostream& o, const pair<T, U>& x) {     o <<  (  << x.first <<  ,   << x.second <<  ) ;     return o;   }   template <typename T>   ostream& operator<<(ostream& o, const vector<T>& x) {     o <<  [ ;     int b = 0;     for (auto& a : x) o << (b++ ?  ,   :   ) << a;     o <<  ] ;     return o;   }   template <typename T>   ostream& operator<<(ostream& o, const set<T>& x) {     o <<  { ;     int b = 0;     for (auto& a : x) o << (b++ ?  ,   :   ) << a;     o <<  } ;     return o;   }   template <typename T>   ostream& operator<<(ostream& o, const multiset<T>& x) {     o <<  { ;     int b = 0;     for (auto& a : x) o << (b++ ?  ,   :   ) << a;     o <<  } ;     return o;   }   template <typename T>   ostream& operator<<(ostream& o, const unordered_set<T>& x) {     o <<  { ;     int b = 0;     for (auto& a : x) o << (b++ ?  ,   :   ) << a;     o <<  } ;     return o;   }   template <typename T>   ostream& operator<<(ostream& o, const unordered_multiset<T>& x) {     o <<  { ;     int b = 0;     for (auto& a : x) o << (b++ ?  ,   :   ) << a;     o <<  } ;     return o;   }   template <typename T, typename U>   ostream& operator<<(ostream& o, const map<T, U>& x) {     o <<  { ;     int b = 0;     for (auto& a : x) o << (b++ ?  ,   :   ) << a;     o <<  } ;     return o;   }   template <typename T, typename U>   ostream& operator<<(ostream& o, const multimap<T, U>& x) {     o <<  { ;     int b = 0;     for (auto& a : x) o << (b++ ?  ,   :   ) << a;     o <<  } ;     return o;   }   template <typename T, typename U>   ostream& operator<<(ostream& o, const unordered_map<T, U>& x) {     o <<  { ;     int b = 0;     for (auto& a : x) o << (b++ ?  ,   :   ) << a;     o <<  } ;     return o;   }   template <typename T, typename U>   ostream& operator<<(ostream& o, const unordered_multimap<T, U>& x) {     o <<  { ;     int b = 0;     for (auto& a : x) o << (b++ ?  ,   :   ) << a;     o <<  } ;     return o;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n, k;       string s;       cin >> n >> k >> s;       vector<int> A(n);       for (int i = 0; i < n; i++) {         if (s[i] ==  R ) A[i] = 0;         if (s[i] ==  G ) A[i] = 1;         if (s[i] ==  B ) A[i] = 2;       }       int ans = k;       for (int o = 0; o < 3; o++) {         int x = 0;         for (int i = 0; i < k; i++) {           if (A[i] != (o + i) % 3) x++;         }         ans = min(ans, x);         for (int i = k; i < n; i++) {           if (A[i - k] != (o + i - k) % 3) x--;           if (A[i] != (o + i) % 3) x++;           ans = min(ans, x);         }       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   char line[100010];   vector<int> cua;   int main(int argc, char *argv[]) {     scanf( %d%d , &n, &k);     scanf( %c , &line[0]);     for (int i = 1; i <= n; i++) {       scanf( %c , &line[i]);       if (line[i] ==  7  && line[i - 1] ==  4 ) {         cua.push_back(i - 1);       }     }     int p;     int cont = 0;     while (!cua.empty() && cont < k) {       cont += 1;       p = cua[0];       if (p % 2) {         line[p + 1] =  4 ;         if (p + 2 <= n && line[p + 2] ==  7 ) {           cua[0] = p + 1;         } else {           cua.erase(cua.begin());         }       } else {         line[p] =  7 ;         if ((p - 1) >= 1 && line[p - 1] ==  4 ) {           cua[0] = p - 1;           if ((k - cont) % 2 == 1) {             line[p] =  4 ;           }           break;         } else {           cua.erase(cua.begin());         }       }     }     for (int i = 1; i <= n; i++) {       printf( %c , line[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int k, d;   char n[100005];   int a[100005];   int main() {     scanf( %d , &k);     d = 0;     scanf(  %s , &n);     for (int i = 0; i < strlen(n); i++) {       d += n[i] -  0 ;       a[i + 1] = n[i] -  0 ;     }     if (d >= k) {       cout << 0;       return 0;     }     int h = strlen(n);     sort(a + 1, a + h + 1);     for (int i = 1; i <= h; ++i) {       d = d + 9 - a[i];       if (d >= k) {         cout << i;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const long long mod = 1e9 + 7;   const long long N = 1e5 + 5, K = 105;   const int si = (1 << 20);   const long long add = 1e4;   const long long M = 100 + 5;   const double INFdb = 1e10;   int n;   vector<int> v[N];   bool check[N];   int legs[N];   void dfs(int u, int par) {     if (v[u].size() <= 2) {       check[u] = 1;       for (int x : v[u]) {         if (x != par) {           dfs(x, u);         }       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n - 1; ++i) {       int x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 1; i <= n; ++i) {       if ((int)v[i].size() == 1) dfs(i, 0);     }     for (int i = 1; i <= n; ++i) {       for (int x : v[i]) {         if (check[x]) {           legs[i] = min(legs[i] + 1, 2);         }       }     }     for (int i = 1; i <= n; ++i) {       if (!check[i]) {         int cnt = 0;         for (int x : v[i]) {           if (!check[x] && v[x].size() - legs[x] > 1) {             ++cnt;           }         }         if (cnt > 2) {           return cout <<  NO , 0;         }       }     }     cout <<  YES ;     cerr <<   nTime elapsed:   << 1000 * clock() / CLOCKS_PER_SEC <<  ms n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<short>> g;   vector<vector<short>> dp;   short rec(int l, int r) {     if (l > r) return 0;     if (dp[l][r] != -1) return dp[l][r];     short whole = binary_search(begin(g[l]), end(g[l]), r);     short ret = whole + rec(l + 1, r);     for (auto p : g[l]) {       if (p >= r) break;       int val = whole + rec(l, p) + rec(p + 1, r);       if (val > ret) {         ret = val;       }     }     return dp[l][r] = ret;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int tc;     cin >> tc;     while (tc--) {       int n;       cin >> n;       vector<pair<int, int>> arr(n);       vector<int> val;       for (auto& pp : arr) {         cin >> pp.first >> pp.second;         val.push_back(pp.first);         val.push_back(pp.second);       }       sort(begin(val), end(val));       val.erase(unique(begin(val), end(val)), end(val));       int m = int(val.size());       g = vector<vector<short>>(m);       vector<short> cnt(m + 1, 0);       for (auto& pp : arr) {         pp.first = lower_bound(begin(val), end(val), pp.first) - begin(val);         pp.second = lower_bound(begin(val), end(val), pp.second) - begin(val);         cnt[pp.first]++;       }       for (int i = 0; i < m; i++) {         g[i].resize(cnt[i]);       }       fill(begin(cnt), end(cnt), 0);       for (auto& pp : arr) {         g[pp.first][cnt[pp.first]++] = pp.second;       }       cnt.clear();       val.clear();       for (auto& row : g) {         sort(begin(row), end(row));         row.erase(unique(begin(row), end(row)), end(row));       }       dp = vector<vector<short>>(m, vector<short>(m, -1));       cout << rec(0, m - 1) <<   n ;     }     return (0);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   char str[MAXN];   class Value {    public:     char c1, c2, last_c1, last_c2;     int pos, l1, sz;     Value() {       c1 = 0;       c2 = 0;       pos = 0;       l1 = 0;       last_c1 = 0;       last_c2 = 0;     }     void push_front(char c) {       if (c == c1) {         l1++;       } else {         c2 = c1;         c1 = c;         l1 = 1;       }       if (last_c2 == 0) {         last_c2 = c;       } else if (last_c1 == 0) {         last_c1 = c;       }       sz++;     }     bool operator<(const Value &value) const {       if (c1 != value.c1) {         return c1 < value.c1;       }       char cl = c1, cr = c1;       if (l1 < value.l1) {         cl = c2;       } else if (value.l1 < l1) {         cr = value.c2;       }       return cl < cr;     }   } f[MAXN];   void print(int idx, int cnt) {     for (int i = 0; i < cnt; i++) {       putchar(f[idx].c1);       idx = f[idx].pos + 1;     }   }   int main() {     scanf( %s , str);     int len = strlen(str);     f[len].pos = len;     for (int i = len - 1; i >= 0; i--) {       f[i] = f[i + 1];       f[i].push_front(str[i]);       f[i].pos = i;       if (i + 1 < len && str[i] == str[i + 1]) {         f[i] = min(f[i], f[i + 2]);       }     }     for (int i = 0; i < len; i++) {       printf( %d  , f[i].sz);       if (f[i].sz <= 10) {         print(i, f[i].sz);         putchar(  n );       } else {         print(i, 5);         printf( ...%c%c n , f[i].last_c1, f[i].last_c2);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long int mypow(long long int a, int b) {     if (b < 0) return 0;     long long int ans = 1;     for (; b; b >>= 1, a = a * a % mod) {       if (b & 1) ans = ans * a % mod;     }     return ans;   }   void add(long long int &a, long long int b) {     a += b;     if (a >= mod) a -= mod;   }   int main() {     int n, k;     cin >> n >> k;     long long int dp[k + 1][k + 1];     for (int i = (0); i < (k + 1); i++) {       for (int j = (0); j < (k + 1); j++) {         if (i) {           dp[i][j] = 0;           add(dp[i][j], j * dp[i - 1][j] % mod);           if (n > j) add(dp[i][j], (n - j) * dp[i - 1][j + 1] % mod);         } else {           dp[i][j] = mypow(2, n - j);         }       }     }     cout << dp[k][0] << endl;   }
#include <bits/stdc++.h>   using namespace std;   double pi = acos(-1);   int n;   bool initial[2000][2000];   bool blur[2000][2000];   pair<int, int> direction[8] = {       make_pair(1, 0),  make_pair(1, 1),   make_pair(0, 1),  make_pair(-1, 1),       make_pair(-1, 0), make_pair(-1, -1), make_pair(0, -1), make_pair(1, -1)};   pair<int, int> operator+(pair<int, int> l, pair<int, int> r) {     return make_pair(l.first + r.first, l.second + r.second);   }   bool valid(pair<int, int> pos) {     return pos.first >= 0 && pos.first < n && pos.second >= 0 && pos.second < n;   }   int circle(int x, int y) {     vector<pair<int, int> > front(1, make_pair(x, y));     blur[x][y] = 0;     for (size_t i = 0; i < front.size(); i++)       for (auto m : direction) {         auto next = front[i] + m;         if (valid(next) && blur[next.first][next.second]) {           front.push_back(next);           blur[next.first][next.second] = 0;         }       }     pair<double, double> centre = make_pair(0, 0);     for (auto c : front)       centre = make_pair(centre.first + 1.0 * c.first / front.size(),                          centre.second + 1.0 * c.second / front.size());     double radius = 0;     for (auto c : front)       radius = max(radius, sqrt(pow(c.first - centre.first, 2.0) +                                 pow(c.second - centre.second, 2.0)));     radius += 0.5;     if (radius < 6) return 0;     return 1 + (front.size() > (pow(radius, 2) * 2 + pow(radius, 2) * pi) / 2);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) cin >> initial[i][j];     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) {         int cnt = 0;         for (int di = -2; di <= 2; di++)           for (int dj = -2; dj <= 2; dj++)             if (i + di >= 0 && i + di < n && j + dj >= 0 && j + dj < n &&                 initial[i + di][j + dj])               cnt++;         blur[i][j] = (cnt > 5 * 5 / 2);       }     int squares = 0, circles = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++)         if (blur[i][j]) {           int ret = circle(i, j);           if (ret == 1) squares++;           if (ret == 2) circles++;         }     cout << circles <<     << squares <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const char NL =   n ;   long long int n;   vector<long long int> a, dp;   long long int s(long long int i, long long int j) {     if (a[i] > a[j]) return dp[j] + 1;     return 1;   }   void solve() {     for (long long int i = 2; i < n + 1; i++) {       long long int m = 1;       for (long long int j = 1; (j * j <= i && j <= n); j++) {         if (i % j == 0) {           m = max({m, s(i, j), s(i, i / j)});         }       }       dp[i] = m;     }     cout << *max_element(dp.begin(), dp.end()) << NL;     return;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t;     cin >> t;     while (t--) {       cin >> n;       a.assign(n + 1, 0);       dp.assign(n + 1, 0);       dp[1] = 1;       for (long long int i = 1; i < n + 1; i++) {         cin >> a[i];       }       solve();     }     fflush(stdin);     fflush(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int &x, int y, int mod = 1000000007) {     x += y;     if (x >= mod) x -= mod;   }   void et() {     puts( -1 );     exit(0);   }   struct ant {     long long pos;     char d;     void rd() {       cin >> pos >> d;       pos--;     }     bool operator<(const ant &o) const { return pos < o.pos; }   } a[300105];   long long t;   int ans[300105];   vector<pair<int, int> > pre;   void fmain() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> t;     for (int(i) = 0; (i) < (int)(n); (i)++) a[i].rd();     for (int(i) = 0; (i) < (int)(n); (i)++) pre.push_back({a[i].pos, i});     sort(pre.begin(), pre.end());     long long offset = 0;     for (int(i) = 0; (i) < (int)(n); (i)++) {       if (a[i].d ==  R ) {         (offset += (a[i].pos + t) / m) %= n;         a[i].pos = (t + a[i].pos) % m;       } else {         if (t >= 1 + a[i].pos) {           offset += n - 1;           offset += n - (t - (a[i].pos + 1)) / m % n;           offset %= n;         }         a[i].pos = ((long long)a[i].pos - t) % m + m;         a[i].pos %= m;       }     }     sort(a, a + n);     for (int(i) = 0; (i) < (int)(n); (i)++)       ans[pre[i].second] = a[(i + offset) % n].pos + 1;     for (int(i) = 0; (i) < (int)(n); (i)++) cout << ans[i] <<    ;   }   int main() {     fmain();     return 0;   }
#include <bits/stdc++.h>   int main() {     int N;     std::cin >> N;     std::vector<int> array(N);     for (int i = 0; i < N; ++i) std::cin >> array[i];     std::sort(array.begin(), array.end());     if (1 == array.back())       array[N - 1] = 2;     else       array[N - 1] = 1;     std::sort(array.begin(), array.end());     for (int i = 0; i < N; ++i) std::cout << array[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long tree[4 * 1000005];   void update(int v, int l, int r, int ind) {     if (l > r || l > ind || ind > r) return;     if (l == r) {       tree[v] = 1;       return;     }     int mid = (l + r) / 2;     update(2 * v, l, mid, ind);     update(2 * v + 1, mid + 1, r, ind);     tree[v] = tree[2 * v] + tree[2 * v + 1];   }   long long query(int v, int l, int r, int lt, int rt) {     if (l > r || l > rt || lt > r || lt > rt) return 0;     if (lt <= l && r <= rt) return tree[v];     int mid = (l + r) / 2;     return query(2 * v, l, mid, lt, rt) + query(2 * v + 1, mid + 1, r, lt, rt);   }   int n;   int a;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     long long inv = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a;       inv += query(1, 1, n, a + 1, n);       update(1, 1, n, a);     }     if (inv % 2 == n % 2)       cout <<  Petr n ;     else       cout <<  Um_nik n ;     return 0;   }