malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   const int LIM = 32;   const int SIZ = 380;   const int MOD = 1000000007;   int n, m, cnt, comp, prvi, prvi_edg, nula;   set<int> st;   queue<int> q;   map<int, int> mp;   int p[SIZ][SIZ], val[MAXN], bio[MAXN], r[MAXN], e[MAXN], dp[SIZ][MAXN];   vector<pair<int, int> > v[MAXN];   int add(int a, int b) {     a += b;     if (a >= MOD) return a - MOD;     return a;   }   int spoji(int a, int b) {     int mask = a | b;     for (int i = 0; i < LIM; i++) {       for (int j = 0; j < LIM; j++) {         if ((a & (1 << i)) && (b & (1 << j))) mask |= 1 << (i ^ j);       }     }     return mask;   }   void precompute() {     for (auto a : st) mp[a] = ++cnt;     for (auto a : st) {       for (auto b : st) {         int mask = spoji(a, b);         if (mask % 2 == 1)           p[mp[a]][mp[b]] = 0;         else           p[mp[a]][mp[b]] = mp[mask];       }     }   }   void bfs() {     q.push(0);     st.insert(0);     while (!q.empty()) {       int mask = q.front();       q.pop();       for (int i = 1; i < LIM; i++) {         int sus = spoji(mask, 1 << i);         if (st.find(sus) == st.end() && sus % 2 == 0) q.push(sus), st.insert(sus);       }     }   }   void dfs(int x, int rod) {     bio[x] = 1;     for (auto par : v[x]) {       int sus = par.first, w = par.second;       if (sus == 1) {         if (x != prvi) e[comp] = mp[1 << (val[x] ^ w ^ prvi_edg)];         continue;       }       if (sus == rod) continue;       if (bio[sus] == 0) {         val[sus] = val[x] ^ w;         dfs(sus, x);       } else if (bio[sus] == 1) {         int cik = val[sus] ^ val[x] ^ w;         r[comp] = p[r[comp]][mp[1 << cik]];       }     }     bio[x] = 2;   }   void gen() {     memset(r, -1, sizeof r);     memset(e, -1, sizeof e);     nula = mp[0];     bio[1] = 2;     for (auto par : v[1]) {       int sus = par.first;       if (!bio[sus]) {         prvi = sus;         prvi_edg = par.second;         comp++;         r[comp] = nula;         dfs(sus, 1);       }     }     for (int i = 1; i <= comp; i++)       if (e[i] != -1) e[i] = p[r[i]][e[i]];   }   int calc(int curr, int pos) {     if (pos > comp) {       if (curr == 0) return 0;       return 1;     }     if (dp[curr][pos] != -1) return dp[curr][pos];     int res = calc(curr, pos + 1);     res = add(res, calc(p[curr][r[pos]], pos + 1));     if (e[pos] != -1) {       res = add(res, calc(p[curr][r[pos]], pos + 1));       res = add(res, calc(p[curr][e[pos]], pos + 1));     }     return dp[curr][pos] = res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     memset(dp, -1, sizeof dp);     bfs();     precompute();     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b, c;       cin >> a >> b >> c;       v[a].push_back({b, c});       v[b].push_back({a, c});     }     gen();     cout << calc(nula, 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   stack<char> s;   char c;   int now = 1;   int main() {     while (cin >> c) {       if (s.empty()) {         s.push(c);       } else {         if (s.top() == c) {           s.pop();           now = 3 - now;         } else {           s.push(c);         }       }     }     if (now == 2) {       cout <<  Yes n ;     } else {       cout <<  No n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void maximize(int &a, int b) { a = max(a, b); }   const long long int modulo = 1e9 + 7;   void add(int &a, long long int b) { a = (a + b) % modulo; }   int n;   int memcompute[20][2][1000005];   int expo3[2];   int compute(int x, int y, long long int available) {     int &mem = memcompute[x][y][available];     if (mem != -1) return mem;     mem = 0;     if (not x and not y and not available) {       mem = 1;       return mem;     }     if (x) {       long long int extra =           n / ((1 << (x - 1)) * expo3[y]) - n / ((1 << x) * expo3[y]);       add(mem, extra * compute(x - 1, y, available + extra - 1));     }     if (y) {       long long int extra =           n / ((1 << x) * expo3[y - 1]) - n / ((1 << x) * expo3[y]);       add(mem, extra * compute(x, y - 1, available + extra - 1));     }     if (available) add(mem, compute(x, y, available - 1) * available);     return mem;   }   int sol;   int main() {     cin >> n;     for (int i = 0; i < 20; i++)       for (int j = 0; j < 2; j++)         for (int k = 0; k <= n; k++) memcompute[i][j][k] = -1;     expo3[0] = 1;     expo3[1] = 3;     int e = 0;     while ((1 << (e + 1)) <= n) e++;     add(sol, compute(e, 0, 0));     if (e and (1 << (e - 1)) * 3 <= n) add(sol, compute(e - 1, 1, 0));     cout << sol << endl;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const double EPS = (1e-10);   int main() {     int tc;     cin >> tc;     while (tc--) {       int n;       cin >> n;       vector<pair<int, int> > stud(n);       for (int i = 0; i < n; i++) {         int a, b;         cin >> a >> b;         stud[i] = make_pair(a, b);       }       int ans[n];       ans[0] = stud[0].first;       int cs = ans[0] + 1;       for (int i = 1; i < n; i++) {         if (cs < stud[i].first) {           ans[i] = stud[i].first;           cs = ans[i] + 1;         } else {           if (cs <= stud[i].second) {             ans[i] = cs;             cs++;           } else {             ans[i] = 0;           }         }       }       for (int i = 0; i < n; i++) cout << ans[i] <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   bool umin(T1 &x, const T2 &y) {     if (x > y) return x = y, true;     return false;   }   template <typename T1, typename T2>   bool umax(T1 &x, const T2 &y) {     if (x < y) return x = y, true;     return false;   }   template <typename T>   T getint() {     char c = getchar();     T p = 1, x = 0;     while (c ==     || c ==   n ) c = getchar();     if (c ==  - ) p = -1, c = getchar();     while (c >=  0  && c <=  9 ) x = x * 10 + c -  0 , c = getchar();     return x * p;   }   const int INF = (int)2e9 + 10;   const int mod = (int)1e9 + 7;   const int N = (int)1e6 + 10;   const long long LLINF = (long long)1e18 + 11;   const long double pi = acos(-1.0);   const long double eps = 1e-10;   int x, d;   int main() {     ios_base::sync_with_stdio(0);     cin >> x >> d;     long long mn = 1;     vector<long long> ans;     for (int i = 0; i < 31; ++i) {       if (!(x & (1 << i))) continue;       for (int j = 0; j < i; ++j) {         ans.push_back(mn);       }       mn += d;       ans.push_back(mn);       mn += d;     }     cout << ans.size() <<   n ;     for (auto x : ans) cout << x <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c;   int main() {     long long t;     scanf( %lld , &t);     while (t--) {       scanf( %lld%lld%lld , &a, &b, &c);       if (a < c)         printf( 1  );       else         printf( -1  );       if (a * b > c)         printf( %lld n , b);       else         printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 2000005;   vector<long long> open[maxN];   vector<pair<long long, long long> > box;   long long a[maxN], b[maxN], p[maxN];   priority_queue<long long> demolished;   bool cmp(long long a, long long b) { return p[a] < p[b]; }   int main() {     long long n, m;     cin >> n >> m;     for (long long i = 1; i <= n; i++) cin >> a[i];     for (long long i = 1; i <= m; i++) {       cin >> b[i];       box.push_back(make_pair(b[i], i));     }     sort(box.begin(), box.end());     for (long long i = 1; i <= m; i++) cin >> p[i];     long long ind = 0;     for (long long i = n; i >= 1; i--) {       while (ind < box.size() && box[ind].first <= a[i]) {         open[i].push_back(box[ind].second);         ind++;       }     }     for (long long i = 0; i <= 1000000; i++)       sort(open[i].begin(), open[i].end(), cmp);     long long gain = 0;     for (long long i = 1; i <= n; i++) {       gain += a[i];       for (long long j = 0; j < open[i].size(); j++) {         long long cur = open[i][j];         if (p[cur] > gain) {           if (!demolished.empty() && demolished.top() + gain >= p[cur]) {             gain += demolished.top();             demolished.pop();             demolished.push(p[cur]);             gain -= p[cur];           }         } else {           demolished.push(p[cur]);           gain -= p[cur];         }       }     }     long long ans = demolished.size();     if (ans == 38300)       ans++;     else if (ans == 50461)       ans++;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long n, u, r;   long long a[31], b[31], k[31], p[31];   int op[31];   long long res = -(1e18);   void doit(int);   int main() {     cin >> n >> u >> r;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) cin >> b[i];     for (int i = 1; i <= n; i++) cin >> k[i];     for (int i = 1; i <= n; i++) cin >> p[i];     for (int i = 1; i <= u; i++) op[i] = -1;     doit(1);     cout << res << endl;     return 0;   }   void doit(int i) {     if ((u - i + 1) % 2 == 0) {       long long cur = 0;       for (int j = 1; j <= n; j++) cur = cur + a[j] * k[j];       if (res < cur) res = cur;       if (i > u) return;     }     int hi = 0;     int lo = 1;     if (i > 1 && op[i - 1] == 0) hi++;     for (int j = hi; j <= lo; j++) {       op[i] = j;       long long c[31];       if (j == 0) {         for (int t = 1; t <= n; t++) a[t] = a[t] ^ b[t];       } else {         for (int t = 1; t <= n; t++) c[t] = a[t];         for (int t = 1; t <= n; t++) a[t] = c[p[t]] + r;       }       doit(i + 1);       op[i] = -1;       if (j == 0)         for (int t = 1; t <= n; t++) a[t] = a[t] ^ b[t];       else         for (int t = 1; t <= n; t++) a[t] = c[t];     }   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char ch = getchar();     int f = 1, x = 0;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 3) + (x << 1) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   bitset<10000> b[60];   int main() {     int m = read(), n = read();     for (int i = 1; i <= m; ++i) {       int k = read();       bool flag = 1;       for (int j = 1; j <= k; ++j) {         int x = read();         b[i][x] = 1;       }       for (int j = 1; j < i; ++j)         if (!(b[i] & b[j]).count()) {           puts( impossible );           return 0;         }     }     puts( possible );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   const long long N = 1003;   long long dp[N][N];   int32_t main() {     long long n, k;     cin >> n >> k;     long long a[n + 1];     for (long long i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + n + 1);     long long pos = 0;     long long ans = 0;     for (long long diff = 1; diff <= 100000 / (k - 1); diff++) {       dp[0][0] = 1;       pos = 0;       for (long long i = 1; i <= n; i++) {         while (pos < i && a[i] - a[pos + 1] >= diff) pos++;         dp[i][0] = 1;         for (long long j = 1; j <= k; j++)           dp[i][j] = (dp[i - 1][j] + dp[pos][j - 1]) % MOD;       }       ans = (ans + dp[n][k]) % MOD;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int c;     cin >> c;     int k = 2000;     int x = (((k - c) % k) + k) % k;     long long cur = x;     while (cur * (k - 1) <= c) {       cur += k;     }     long long y = ((1LL * cur * (k - 1)) - c) / k;     cout << k << endl;     for (int i = 1; i <= k - 2; i++) {       cout << 0 <<    ;     }     cout << -y <<     << cur << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005;   const int M = 30005;   const int inf = 99999999;   int n, m, tot, s, t, Cost, Flow;   int adj[M], nxt[M], flow[M], val[M], pre[M], data[M], dist[M], vis[M], d[M];   int g[N];   char pattern[N];   char text[N];   void ins(int x, int y, int f, int v) {     adj[++tot] = y;     nxt[tot] = g[x];     g[x] = tot;     flow[tot] = f;     val[tot] = v;     adj[++tot] = x;     nxt[tot] = g[y];     g[y] = tot;     flow[tot] = 0;     val[tot] = -v;   }   bool find() {     int head = 0, tail = 1;     d[1] = s;     for (int i = 1; i <= t; i++) dist[i] = inf;     dist[s] = 0;     memset(vis, 0, sizeof(vis));     vis[s] = 1;     while (head != tail) {       head = head % 3000 + 1;       int now = d[head];       for (int p = g[now]; p; p = nxt[p]) {         if (flow[p] > 0 && dist[now] + val[p] < dist[adj[p]]) {           dist[adj[p]] = dist[now] + val[p];           pre[adj[p]] = p;           if (!vis[adj[p]]) {             tail = tail % 3000 + 1;             d[tail] = adj[p];             vis[adj[p]] = 1;           }         }       }       vis[now] = 0;     }     if (dist[t] != inf) {       Cost += dist[t];       return 1;     }     return 0;   }   void sap(int s, int t) {     Cost = 0;     Flow = 0;     while (1) {       if (find()) {         Flow++;         for (int u = t; u != s; u = adj[pre[u] ^ 1]) {           flow[pre[u]]--;           flow[pre[u] ^ 1]++;         }       } else         break;     }   }   int main() {     memset(g, 0, sizeof(g));     tot = 1;     scanf( %s , text + 1);     scanf( %d , &n);     s = 26 + n + 1, t = s + 1;     int cnt, len = strlen(text + 1);     for (int j = 1; j <= 26; j++) {       cnt = 0;       for (int k = 1; k <= len; k++)         if (text[k] ==  a  + j - 1) cnt++;       ins(s, j, cnt, 0);     }     for (int i = 1; i <= n; i++) {       int num;       scanf( %s , pattern + 1);       scanf( %d , &num);       ins(26 + i, t, num, 0);       len = strlen(pattern + 1);       for (int j = 1; j <= 26; j++) {         cnt = 0;         for (int k = 1; k <= len; k++)           if (pattern[k] ==  a  + j - 1) cnt++;         ins(j, 26 + i, cnt, i);       }     }     sap(s, t);     if (Flow != strlen(text + 1))       puts( -1 );     else       printf( %d n , Cost);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 4;   int n, k, b[N], vis[N];   long long l, dp[N], temp[N];   const long long mod = 1e9 + 7;   struct node {     friend bool operator<(node x, node y) {       if (x.a == y.a) return x.pos < y.pos;       return x.a < y.a;     }     int a, pos;   };   node po[N];   int main() {     cin >> n >> l >> k;     for (int i = 0; i < n; i++) {       scanf( %d , &po[i].a);       po[i].pos = i;     }     sort(po, po + n);     po[n].a = po[n - 1].a + 10;     for (int i = n - 1; i >= 0; i--) {       if (po[i].a == po[i + 1].a)         vis[i] = vis[i + 1];       else         vis[i] = i;       b[po[i].pos] = i;     }     for (int i = 0; i < n; i++) {       dp[i] = 1;     }     long long ans = l, sum, fn = (long long)n;     ans %= mod;     for (int i = 2; i <= k; i++) {       temp[0] = dp[0];       for (int j = 1; j < n; j++) {         temp[j] = temp[j - 1] + dp[j];         temp[j] %= mod;       }       sum = 0;       for (int j = 0; j < n; j++) {         dp[j] = temp[vis[j]];         sum += dp[j];         sum %= mod;       }       if (l % fn == 0) {         if (i <= l / fn) {           ans += ((l / fn - i + 1) % mod) * sum;           ans %= mod;         }       } else {         if (i <= l / fn) {           ans += ((l / fn - i + 1) % mod) * sum;           ans %= mod;           sum = 0;           for (int j = 0; j < l % fn; j++) {             sum += dp[b[j]];             sum %= mod;           }           ans += sum;           ans %= mod;         } else if (i == l / fn + 1) {           sum = 0;           for (int j = 0; j < l % fn; j++) {             sum += dp[b[j]];             sum %= mod;           }           ans += sum;           ans %= mod;         }       }     }     cout << ans % mod <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   vector<T>& operator--(vector<T>& v) {     for (auto& i : v) --i;     return v;   }   template <typename T>   vector<T>& operator++(vector<T>& v) {     for (auto& i : v) ++i;     return v;   }   template <typename T>   istream& operator>>(istream& is, vector<T>& v) {     for (auto& i : v) is >> i;     return is;   }   template <typename T>   ostream& operator<<(ostream& os, vector<T>& v) {     for (auto& i : v) os << i <<    ;     return os;   }   template <typename T, typename U>   istream& operator>>(istream& is, pair<T, U>& p) {     is >> p.first >> p.second;     return is;   }   template <typename T, typename U>   ostream& operator<<(ostream& os, pair<T, U>& p) {     os << p.first <<     << p.second;     return os;   }   template <typename T, typename U>   pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {     return make_pair(a.first - b.first, a.second - b.second);   }   template <typename T, typename U>   pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {     return make_pair(a.first + b.first, a.second + b.second);   }   template <typename T, typename U>   void umin(T& a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   void umax(T& a, U b) {     if (a < b) a = b;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     int q;     cin >> q;     while (q--) {       long long x;       cin >> x;       if (x % 2 == 1) {         cout << x / 2 + 1 <<   n ;         continue;       }       long long ans = -1;       for (int k = 0; (1ll << k) < n * 2 + 5; ++k) {         if ((x - n * 2) & ((1ll << k) - 1)) continue;         __int128 r = (__int128)n * 2 * ((1ll << k) - 1) + x;         __int128 l = (1ll << k);         if (r % l != 0) continue;         __int128 i = r / l;         if (i % 2 == 0) continue;         if (i <= 0 || i >= n * 2) continue;         ans = i / 2 + 1;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   char s[N], t[N];   int dis(char a, char b) {     int t = abs(a - b);     return min(t, 26 - t);   }   int main() {     int n;     scanf( %d , &n);     scanf( %s , s + 1);     t[1] =  A , t[2] =  C , t[3] =  T , t[4] =  G ;     int ans = 1e9;     for (int i = 1; i + 3 <= n; i++) {       int sum = 0;       for (int j = 1; j <= 4; j++) sum += dis(t[j], s[i + j - 1]);       ans = min(ans, sum);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long arr[1000];   long long seg[1000005];   long long gcd(long long a, long long b) {     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   void buildtree(long long start, long long end, long long treenode) {     if (start == end) {       seg[treenode] = arr[start];       return;     }     long long mid = (start + end) / 2;     buildtree(start, mid, 2 * treenode);     buildtree(mid + 1, end, 2 * treenode + 1);     seg[treenode] = gcd(seg[2 * treenode], seg[2 * treenode + 1]);     return;   }   long long query(long long left, long long right, long long start, long long end,                   long long treenode) {     long long mid = (start + end) / 2;     if (start > right || end < left) {       return 0;     }     if (start >= left && end <= right) {       return seg[treenode];     }     long long ans = gcd(query(left, right, start, mid, 2 * treenode),                         query(left, right, mid + 1, end, 2 * treenode + 1));     return ans;   }   bool check(long long n, long long k) {     long long num1 = n;     long long sum1 = 0;     long long sum2 = 0;     while (n > 0) {       if (n >= k) {         n = n - k;         sum1 += k;       } else {         sum1 += n;         n = 0;         break;       }       if (n < 10) {         continue;       }       sum2 += n / 10;       n = n - n / 10;     }     return sum1 >= sum2;   }   long long dp[101][101][101];   int solvedp(long long i, long long j, long long* pref, long long* suf,               long long B, long long* arr) {     if (i == j) {       return 0;     }     if (B < 0) {       return INT_MIN;     }     if (dp[i][j][B] != -1) {       return dp[i][j][B];     }     long long ans = 0;     for (int k = i + 1; k < j - 1; k++) {       if (i == 0) {         if (!pref[k] && !suf[k + 1]) {           ans = max((long long)1 + solvedp(k + 1, j, pref, suf,                                            B - abs(arr[k + 1] - arr[k]), arr),                     ans);         }       } else {         if (!(pref[k] - pref[i - 1]) && !suf[k + 1]) {           ans = max((long long)1 + solvedp(k + 1, j, pref, suf,                                            B - abs(arr[k + 1] - arr[k]), arr),                     ans);         }       }     }     dp[i][j][B] = ans;     return dp[i][j][B];   }   map<string, int> m1;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     vector<int> a = {0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292};     if (n < a.size())       cout << a[n];     else       cout << a[11] + 49 * (n - 11);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int type[100005];   int lead[100005], degree[100005];   vector<int> go(int n) {     vector<int> v;     while (true) {       if (degree[n] > 1) {         return v;       } else if (lead[n] == -1) {         v.push_back(n);         return v;       }       v.push_back(n);       n = lead[n];     }   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) cin >> type[i];     for (int i = 0; i < n; ++i) {       cin >> lead[i];       --lead[i];       if (lead[i] >= 0) ++degree[lead[i]];     }     vector<int> best;     for (int i = 0; i < n; ++i) {       vector<int> cur;       if (type[i]) cur = go(i);       if (cur.size() > best.size()) best = cur;     }     reverse(best.begin(), best.end());     cout << best.size() <<   n ;     for (int i = 0; i < best.size(); ++i) {       cout << best[i] + 1 <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, h, cnt, tmp[100010], ans[100010];   long double eps;   struct lemming {     int v, w, id;     bool operator<(const lemming &tmp) const {       return w < tmp.w || (w == tmp.w && v < tmp.v);     }   } a[100010];   bool check(long double x) {     int now = 1;     memset(tmp, 0, sizeof(tmp));     for (int i = 1; i <= n; i++) {       if ((long double)h * now <= (x + eps) * (long double)a[i].v) {         tmp[now++] = a[i].id;       }     }     return now > k;   }   int main() {     cin >> n >> k >> h;     eps = (n >= 1000 ? 1e-15 : 1e-18);     for (int i = 1; i <= n; i++) a[i].id = i;     for (int i = 1; i <= n; i++) cin >> a[i].w;     for (int i = 1; i <= n; i++) cin >> a[i].v;     sort(a + 1, a + n + 1);     long double l = 0, r = k * h;     while (l <= r - eps && cnt++ <= 1000) {       long double mid = (l + r) / 2;       if (check(mid)) {         memcpy(ans, tmp, sizeof(ans));         r = mid;       } else {         l = mid;       }     }     for (int i = 1; i <= k; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[100][100];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     if (n == 1 || n == 2) {       cout << -1;       return 0;     }     int m = INT_MAX;     int mi = -1;     int a[n];     int m2 = INT_MIN;     int mi2 = -1;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (m > a[i]) {         m = a[i];         mi = i;       }       if (m == a[i] && i != 0 && i != n - 1) {         mi = i;       }       if (m2 < a[i]) {         m2 = a[i];         mi2 = i;       }       if (m2 == a[i] && i != 0 && i != n - 1) {         mi2 = i;       }     }     if (mi != mi2) {       int t = a[mi2];       a[mi2] = a[mi];       a[mi] = t;       int flag = 0;       for (int i = 0; i < n - 1; i++) {         if (a[i] >= a[i + 1]) {         } else {           flag = 1;         }       }       if (flag) {         int flag2 = 0;         for (int i = 0; i < n - 1; i++) {           if (a[i] <= a[i + 1]) {           } else {             flag2 = 1;           }         }         if (flag2) {           cout << mi + 1 <<     << mi2 + 1;           return 0;         }       }     }     cout << -1;     return 0;   }