malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int a[505];   int sorted_a[505];   void rot(int i) {     i--;     int temp = a[i + 2];     a[i + 2] = a[i + 1];     a[i + 1] = a[i];     a[i] = temp;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int cases;     cin >> cases;     while (cases--) {       int n;       cin >> n;       for (int i = 0; i < n; i++) {         cin >> a[i];         sorted_a[i] = a[i];       }       sort(sorted_a, sorted_a + n);       vector<int> ans;       for (int i = n - 1; i > 1; i--) {         int j = i;         while (a[j] != sorted_a[i]) j--;         if (j == 0) {           ans.push_back(1);           rot(1);           j++;         }         for (; j < i; j++) {           ans.push_back(j);           rot(j);         }       }       if (a[0] != sorted_a[0]) {         if (a[0] == a[2]) {           ans.push_back(1);           ans.push_back(1);           rot(1);           rot(1);         } else {           for (int i = 2; i < n - 1; i++) {             if (a[i] == a[i + 1]) {               for (int j = i; j >= 1; j--) {                 ans.push_back(j);                 rot(j);               }               break;             }           }         }       }       if (a[0] == sorted_a[0]) {         cout << ans.size() <<   n ;         for (int i : ans) cout << i <<    ;         cout <<   n ;       } else         cout <<  -1 n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int maxim = 0, sum = 0, a[n];       for (int i = 0; i < n; i++) {         cin >> a[i];         maxim = max(maxim, a[i]);         sum += a[i];       }       if (maxim > sum / 2) {         cout <<  T n ;         continue;       }       if (sum % 2 == 0)         cout <<  HL n ;       else         cout <<  T n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isPrime(int n) {     if (n <= 1) return false;     for (int i = 2; i < n; i++)       if (n % i == 0) return false;     return true;   }   int odd(int arr[], int n) {     for (int i = 0; i < n; i++) {       if (arr[i] % 2 != 0) {         return i;       }     }   }   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       for (int i = 0; i < n; i++) {         cin >> arr[i];       }       int sum = 0;       for (int i = 0; i < n; i++) {         sum += arr[i];       }       int fodd = odd(arr, n);       if (isPrime(sum)) {         cout << n - 1 << endl;         for (int i = 0; i < n; i++) {           if (i == fodd) {             continue;           }           cout << (i + 1) <<    ;         }         cout << endl;       }       if (!(isPrime(sum))) {         cout << n << endl;         for (int i = 0; i < n; i++) {           cout << (i + 1) <<    ;         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     string s1 =   ;     if (n % 2 == 0) {       for (int i = 0; i < n; i++) {         cout << s[i] << s[i + 1];         i++;         if (i < n - 2) {           cout <<  - ;         }       }     } else {       if (n == 3)         cout << s << endl;       else {         for (int i = 0; i < n; i++) {           if (i == 0) {             cout << s[i] << s[i + 1] << s[i + 2] <<  - ;             i += 2;             continue;           } else {             cout << s[i] << s[i + 1];           }           if (i < n - 2) {             cout <<  - ;           }           i++;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   long long int fastPow(long long int x, long long int y) {     long long int p = mod;     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long int arr[200005];   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cin.tie(0), cout.tie(0),         cout.precision(15);     long long int n, m, A, res = 1;     cin >> n >> m >> A;     for (long long int i = 1; i <= m; i++) {       cin >> arr[i];     }     res = fastPow(A, n - 2 * arr[m]);     for (long long int i = m - 1; i >= 0; i--) {       long long int tmp = fastPow(A, arr[i + 1] - arr[i]) % mod;       long long int tmp2 = (tmp * ((tmp - 1 + mod) % mod) / 2) % mod;       long long int tmp3 = (tmp + tmp2) % mod;       res = (res * tmp3) % mod;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long p[10005];   long long s[10005];   long long dp[2][10005];   int n;   long long m;   int main() {     scanf( %d%I64d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %I64d , &p[i]);     for (int i = 1; i <= n; i++) scanf( %I64d , &s[i]);     int now = 0, next = 1;     for (int i = 1; i <= n; i++) {       memset(dp[next], 0, sizeof(dp[next]));       for (int j = 0; j <= i; j++) {         if (j == 0) {           dp[next][j] = dp[now][j] + p[i];         } else if (j == i) {           dp[next][j] = dp[now][j - 1] + s[i];         } else {           dp[next][j] = min(dp[now][j] + p[i] + j * m, dp[now][j - 1] + s[i]);         }       }       swap(now, next);     }     long long ans = dp[now][0];     for (int i = 1; i <= n; i++) ans = min(ans, dp[now][i]);     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a1, a2, b1, b2, c1, c2;   int main() {     scanf( %d%d%d , &a1, &b1, &c1);     scanf( %d%d%d , &a2, &b2, &c2);     if (a1 == 0 && b1 == 0) {       if (c1 != 0) {         puts( 0 );         return 0;       }       if (a2 == 0 && b2 == 0 && c2 != 0)         puts( 0 );       else         puts( -1 );       return 0;     }     if (a2 == 0 && b2 == 0) {       if (c2 != 0) {         puts( 0 );         return 0;       }       if (a1 == 0 && b1 == 0 && c1 != 0)         puts( 0 );       else         puts( -1 );       return 0;     }     if (a1 * b2 == a2 * b1) {       if (c1 * b2 == c2 * b1 && c1 * a2 == c2 * a1)         puts( -1 );       else         puts( 0 );     } else       puts( 1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a, b, p;       cin >> a >> b >> p;       string s;       cin >> s;       int len = s.size();       int pos = 0;       char ss =  C ;       for (int i = len - 2; i >= 0; i--) {         if (ss != s[i]) {           p -= (s[i] ==  A  ? a : b);           ss = s[i];           if (p < 0) {             pos = i + 1;             break;           }         }       }       cout << pos + 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int col[n + 2], k[m + 2];     for (int i = 1; i <= n; i++) cin >> col[i];     for (int i = 1; i <= m; i++) cin >> k[i];     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         vector<int> v[105];         int cnt = 0;         for (int kk = i; kk <= j; kk++) v[col[kk]].push_back(1);         for (int kk = 1; kk <= m; kk++) {           if (v[kk].size() != k[kk]) goto damn;         }         cout <<  YES n ;         return 0;       damn:;       }     }     cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();     return x * f;   }   int n, m;   vector<int> G[20], G2[20];   int low[20], dfn[20];   int cur;   bool tarjan(int u, int fa) {     bool flg = 0;     low[u] = dfn[u] = ++cur;     bool flg2 = 1;     for (auto v : G2[u]) {       if (!dfn[v]) {         if (!tarjan(v, u)) flg2 = 0;         low[u] = min(low[u], low[v]);         if (dfn[v] == low[v]) flg2 = 0;       } else if (v != fa || flg)         low[u] = min(low[u], dfn[v]);       else         flg = 1;     }     return flg2;   }   vector<pair<int, int> > del;   int curcnt;   int ans = 0x3f3f3f3f;   vector<int> Gans[20];   void delete_edge(int x) {     if (!x) return;     if (G2[x].empty()) return;     int rrrnd = (rand() % G2[x].size() + G2[x].size()) % G2[x].size();     int y = G2[x][rrrnd];     del.emplace_back(x, y);     G2[x].erase(find(G2[x].begin(), G2[x].end(), y));     G2[y].erase(find(G2[y].begin(), G2[y].end(), x));     memset(low, 0, sizeof low);     memset(dfn, 0, sizeof dfn);     cur = 0;     if (!tarjan(1, -1)) {     Ret:       G2[x].push_back(y);       G2[y].push_back(x);       del.pop_back();       return;     }     for (int i = 1; i <= n; i++)       if (!dfn[i]) goto Ret;     curcnt--;     if (curcnt < ans) {       ans = curcnt;       for (int i = 1; i <= n; i++) Gans[i] = G2[i];     }   }   void add_edge(int x) {     if (del.empty()) return;     G2[del[x].first].push_back(del[x].second);     G2[del[x].second].push_back(del[x].first);     del.erase(del.begin() + x);     curcnt++;   }   int main() {     srand(19260817);     int stt = clock();     n = read(), m = read();     for (int i = 1, x, y; i <= m; i++) {       x = read(), y = read();       G[x].push_back(y);       G[y].push_back(x);     }     curcnt = ans = m;     for (int i = 1; i <= n; i++) Gans[i] = G[i];     const int max_time = 1950;     for (int _ = 1; _ <= 1000; _++) {       for (int i = 1; i <= n; i++) G2[i] = G[i];       curcnt = m;       for (int __ = 1; __ <= 1000; __++) {         if (rand() % 4)           delete_edge((rand() % n + n) % n + 1);         else if (!del.empty()) {           add_edge(rand() % del.size());         }       }       if (clock() - stt > max_time) break;     }     printf( %d n , ans);     for (int i = 1; i <= n; i++)       for (int j = 0; j < Gans[i].size(); j++)         if (Gans[i][j] > i) printf( %d %d n , i, Gans[i][j]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void chkmin(T &x, T y) {     x = min(x, y);   }   template <typename T>   inline void chkmax(T &x, T y) {     x = max(x, y);   }   template <typename T>   inline void read(T &x) {     T f = 1;     x = 0;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -f;     for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c -  0 ;     x *= f;   }   int main() {     int q;     read(q);     while (q--) {       long long l, r;       read(l);       read(r);       long long ans = (l + r) * (r - l + 1) / 2;       if (!(r & 1)) --r;       if (!(l & 1)) ++l;       if (l > r)         cout << ans <<   n ;       else         cout << ans - (l + r) * ((r - l) / 2 + 1) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   template <class T>   inline void gmax(T &a, T b) {     if (b > a) a = b;   }   template <class T>   inline void gmin(T &a, T b) {     if (b < a) a = b;   }   using namespace std;   const int N = 1e5 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647,             ms1 = 16843009, ms31 = 522133279, ms63 = 1061109567,             ms127 = 2139062143;   const double PI = acos(-1.0), eps = 1e-8;   void fre() {     freopen( /Users/luras/Desktop/in.txt ,  r , stdin);     freopen( /Users/luras/Desktop/out.txt ,  w , stdout);   }   const int INF = 1e9;   int casenum, casei;   const int top = 1e5, top2 = top + top;   int g, n, m, b[N], c[N];   struct A {     int typ, p, t, o, v;     bool operator<(const A &b) const { return p < b.p; }   } a[N];   pair<int, int> ans[N];   vector<int> sot1[N + top], sot2[N + top];   int main() {     while (~scanf( %d%d%d , &g, &n, &m)) {       for (int i = 1; i <= g; i++) {         scanf( %d%d%d , &a[i].typ, &a[i].p, &a[i].t);         a[i].o = i;       }       sort(a + 1, a + g + 1);       for (int i = 1; i <= g; i++) {         a[i].v = a[i].t - a[i].p;         if (a[i].typ == 1)           ans[a[i].o] = {a[i].p, m};         else           ans[a[i].o] = {n, a[i].p};         if (a[i].typ == 2)           sot2[a[i].v + top].push_back(a[i].o);         else           sot1[a[i].v + top].push_back(a[i].o);       }       for (int i = 1; i <= top2; i++) {         int t1 = sot1[i].size(), t2 = sot2[i].size(), t3 = min(t1, t2);         for (int j = t1 - 1, k = 0; j >= t1 - t3; j--, k++) {           b[sot1[i][j]] = sot2[i][k];         }         for (int j = t2 - 1, k = 0; j >= t2 - t3; j--, k++) {           b[sot2[i][j]] = sot1[i][k];         }         if (t1 > t2) {           for (int j = 0, k = t3; j < t1 - t3; j++, k++) {             b[sot1[i][j]] = sot1[i][k];           }         } else if (t2 > t1) {           for (int j = 0, k = t3; j < t2 - t3; j++, k++) {             b[sot2[i][j]] = sot2[i][k];           }         }       }       for (int i = 1; i <= g; i++) {         printf( %d %d n , ans[b[i]].first, ans[b[i]].second);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int c = 3002;   int w, n, m, dif[c], rf[c];   long long sok = 1e15;   pair<long long, long long> op[c][c], cl[c][c];   vector<int> sz[c];   bool v[c];   pair<long long, long long> add(pair<long long, long long> a,                                  pair<long long, long long> b) {     return {a.first + b.first, a.second + b.second};   }   void dfs(int a) {     v[a] = true;     rf[a] = 1;     for (int i = 0; i <= n; i++) {       op[a][i] = {-sok, -sok};     }     op[a][1] = {0, dif[a]};     for (int x : sz[a]) {       if (!v[x]) {         dfs(x);         rf[a] += rf[x];         for (int db = rf[a]; db >= 1; db--) {           op[a][db] = max(add(op[a][db], op[x][1]), add(op[a][db - 1], cl[x][1]));           for (int i = max(2, db - rf[a] + rf[x]); i <= min(rf[x], db); i++) {             op[a][db] = max({op[a][db], add(op[a][db - i], cl[x][i]),                              add(op[a][db - i + 1], op[x][i])});           }         }       }     }     for (int i = 1; i <= rf[a]; i++) {       cl[a][i] = {op[a][i].first + (op[a][i].second > 0), 0};     }   }   int main() {     ios_base::sync_with_stdio(false);     cin >> w;     while (w--) {       cin >> n >> m;       for (int i = 1; i <= n; i++) {         int x;         cin >> x;         dif[i] = -x;       }       for (int i = 1; i <= n; i++) {         int x;         cin >> x;         dif[i] += x;       }       for (int i = 1; i < n; i++) {         int a, b;         cin >> a >> b;         sz[a].push_back(b), sz[b].push_back(a);       }       dfs(1);       cout << cl[1][m].first <<   n ;       for (int i = 1; i <= n; i++) {         v[i] = 0;         sz[i].clear();       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, c;   vector<vector<long long> > a;   long long dp[200000 + 5][2][2];   long long fun(long long idx, bool state, bool prev) {     if (idx == 0) return 0;     if (dp[idx][state][prev]) return dp[idx][state][prev];     if (prev || !state)       return dp[idx][state][prev] = a[idx][state] + min(fun(idx - 1, 0, state),                                                         fun(idx - 1, 1, state));     return dp[idx][state][prev] =                c + a[idx][state] +                min(fun(idx - 1, 0, state), fun(idx - 1, 1, state));   }   void solve() {     cin >> n >> c;     a.resize(n + 1, vector<long long>(2));     for (long long i = 1; i <= n - 1; i++) cin >> a[i][0];     for (long long i = 1; i <= n - 1; i++) cin >> a[i][1];     dp[n][0][0] = dp[n][1][0] = min(fun(n - 1, 0, 0), fun(n - 1, 1, 0));     for (long long i = 0; i <= n - 1; i++)       cout << min(dp[i][0][0], dp[i][1][0]) <<    ;     cout <<   n ;   }   int main() {     ios::sync_with_stdio(false);     solve();   }
#include <bits/stdc++.h>   using namespace std;   const int M = 6;   const int MSK = 1 << M;   const int N = 45;   int D[45][MSK][MSK];   int col(int x) {     int ans = 0;     while (x) ans += x % 2, x /= 2;     return ans;   }   int n, m;   bool BIT(int x, int i) {     if (i < 0) return 0;     return (x >> i) & 1;   }   bool bad(int a, int b, int c) {     for (int i = 0; i < m; i++)       if (!(BIT(a, i) || BIT(c, i) || BIT(b, i - 1) || BIT(b, i) ||             BIT(b, i + 1)))         return true;     return false;   }   int main() {     cin >> n >> m;     if (n < m) swap(n, m);     for (int i = 0; i < N; i++)       for (int j = 0; j < MSK; j++)         for (int k = 0; k < MSK; k++) D[i][j][k] = 1e9;     for (int i = 0; i < MSK; i++) {       D[0][0][i] = col(i);     }     for (int i = 1; i <= n; i++) {       for (int pmsk = 0; pmsk < MSK; pmsk++)         for (int msk = 0; msk < MSK; msk++) {           for (int tmsk = 0; tmsk < MSK; tmsk++) {             if (bad(tmsk, pmsk, msk)) continue;             D[i][pmsk][msk] =                 min(D[i][pmsk][msk], D[i - 1][tmsk][pmsk] + col(msk));           }         }     }     int ans = 1e9;     for (int msk = 0; msk < MSK; msk++) {       ans = min(ans, (D[n][msk][0]));     }     cout << n * m - ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     set<int> keyboards;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int a;       scanf( %d , &a);       keyboards.insert(a);     }     int prev = 0;     int result = 0;     for (auto keyboard : keyboards) {       if (prev != 0) result += (keyboard - prev - 1);       prev = keyboard;     }     printf( %d n , result);   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[300010], f[300010], p;   vector<int> x[300010], w;   int main() {     srand(time(0));     int i, j, k, l;     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) {       a[i] = i + 1;       for (j = i + i; j <= n; j += i) x[j].push_back(i);     }     p = n - 1;     for (i = 1; i <= p; i++) {       for (j = 2; j * j <= a[i]; j++)         if (a[i] % j == 0) break;       if (j * j > a[i] && a[i] * 2 > n) {         swap(a[i], a[p]);         p--;         i--;       }     }     for (int t = 1; t <= 12; t++) {       for (i = 1; i <= n; i++) f[i] = 0;       for (i = 1; i <= p; i++) swap(a[i], a[((rand() << 15) + rand()) % i + 1]);       for (i = 1, k = 0; i <= p && k < m; i++) {         for (j = a[i], l = 0; j <= n; j += a[i])           if (f[j]) l++;         for (auto j : x[a[i]])           if (f[j]) l++;         if (k + l <= m) {           k += l;           f[a[i]] = 1;           w.push_back(a[i]);         }         if (k + w.size() >= m - (n - 1 - p)) {           k += w.size();           w.push_back(1);           for (j = p + 1; k < m; j++, k++) w.push_back(a[j]);           break;         }       }       if (k < m && k + w.size() >= m - (n - 1 - p)) {         k += w.size();         w.push_back(1);         for (j = p + 1; k < m; j++, k++) w.push_back(a[j]);       }       if (k == m) {         printf( Yes n%d n , w.size());         for (auto i : w) printf( %d  , i);         return 0;       }       w.clear();     }     printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int L = 1000000 + 10;   int main() {     int n;     scanf( %d , &n);     char s[n + 10];     scanf( %s , s);     int next[n + 10];     next[0] = -1;     int j = 0, k = -1;     int maxn = 1;     while (j < n) {       if (k == -1 || s[j] == s[k]) {         next[++j] = ++k;         int xun = j - next[j];         maxn = max(maxn, j / xun / 2 * xun);       } else         k = next[k];     }     printf( %d n , n - maxn + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string char_to_str(char c) {     string tem(1, c);     return tem;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   template <class T>   T rand() {     return uniform_int_distribution<T>()(rng);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long n, k;     cin >> n >> k;     vector<long long> v;     vector<long long> v2;     for (long long i = 1; i * i <= n; ++i) {       if (n % i == 0) {         v.push_back(i);         v2.push_back(n / i);       }     }     reverse(v2.begin(), v2.end());     for (auto r : v2) v.push_back(r);     long long f = 0;     for (long long i = v.size() - 1; i >= 0; --i) {       long long t = n / v[i];       if (k > 100000000 || (k * (k + 1)) / 2 > t) {         continue;       }       for (long long j = 1; j < k; ++j) {         t -= j;         cout << j * v[i] <<    ;       }       cout << t * v[i];       return 0;     }     cout <<  -1 ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     int n;     while (t--) {       scanf( %d , &n);       int k = sqrt(n);       if (n == 1)         cout << 0 << endl;       else if (k * k == n) {         cout << 2 * k - 2 << endl;       } else         cout << k - 1 + (n + k - 1) / k - 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5;   int n, fa[N], p[N], cnt, mk, la[N], size[N];   int getfa(int x) {     if (fa[x] == x) return x;     return fa[x] = getfa(fa[x]);   }   void merge(int x, int y) {     int fx = getfa(x), fy = getfa(y);     if (fx == fy) return;     fa[fx] = fy;     size[fy] += size[fx];   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> p[i];     for (int i = 1; i <= n; i++) {       fa[i] = i;       size[i] = 1;       if (p[i] == i) {         if (!mk)           mk = i;         else           p[i] = mk, cnt++;       }     }     if (!mk) {       for (int i = 1; i <= n; i++) merge(i, p[i]);       int now = 0;       for (int i = 1; i <= n; i++) {         if (size[i] > now) {           now = size[i];           mk = i;         }       }       for (int i = 1; i <= n; i++) fa[i] = i;       p[mk] = mk;       cnt++;     }     for (int i = 1; i <= n; i++) {       if (p[i] == i) continue;       if (getfa(i) == getfa(p[i])) p[i] = mk, cnt++;       merge(i, p[i]);     }     cout << cnt << endl;     for (int i = 1; i <= n; i++) cout << p[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, m, mod, a[N], b[N], ans[N];   int main() {     cin >> n >> m >> mod;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= m; i++) {       cin >> b[i];     }     for (int i = 1; i <= m; i++) {       ans[i] += b[i];       ans[i + n - m + 1] -= b[i];     }     for (int i = 1; i <= n; i++) {       ans[i] += ans[i - 1];     }     for (int i = 1; i <= n; i++) {       ans[i] += a[i];       cout << ans[i] % mod <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double epsilon = 1e-9;   int main() {     long long n, m, v;     cin >> n >> m >> v;     long long p = ((n - 1) * (n - 2)) / 2LL + 1;     if (m > p || m < n - 1) {       cout << -1 << endl;       return 0;     }     int other = 1;     if (v == 1) other = 2;     for (int i = 1; i <= n; i++) {       if (i == v)         continue;       else         cout << v <<     << i << endl;     }     m -= n - 1;     for (int i = 1; i <= n && m > 0; i++) {       if (i == v || i == other) continue;       for (int j = i + 1; j <= n && m > 0; j++) {         if (j == v || j == other || j == i) continue;         printf( %d %d n , i, j);         m--;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-7;   const double PI = acos(-1.0);   const double ZERO = 0;   const double DOUBLE_MAX = 1 / ZERO;   int main() {     long double t, s, q;     cin >> t >> s >> q;     long double speed = (q - 1) / q;     long double x = 0, d;     int res = 0;     while (t - s > 1e-9) {       x += s * speed;       while (t - s > 1e-9 && x > 1e-10) {         s += (x) + 1e-9;         x *= speed;       }       res++;     }     cout << res;   }