malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   namespace IO {   const int sz = 1 << 15;   char inbuf[sz], outbuf[sz];   char *pinbuf = inbuf + sz;   char *poutbuf = outbuf;   inline char _getchar() {     if (pinbuf == inbuf + sz) fread(inbuf, 1, sz, stdin), pinbuf = inbuf;     return *(pinbuf++);   }   inline void _putchar(char x) {     if (poutbuf == outbuf + sz) fwrite(outbuf, 1, sz, stdout), poutbuf = outbuf;     *(poutbuf++) = x;   }   inline void flush() {     if (poutbuf != outbuf)       fwrite(outbuf, 1, poutbuf - outbuf, stdout), poutbuf = outbuf;   }   }  // namespace IO   inline int read() {     int x = 0, p = 1;     char c = IO::_getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) p = -1;       c = IO::_getchar();     }     while (c >=  0  && c <=  9 ) x = x * 10 + c - 48, c = IO::_getchar();     return x * p;   }   namespace Mymath {   long long qp(long long x, long long p, long long mod) {     long long ans = 1;     while (p) {       if (p & 1) ans = ans * x % mod;       x = x * x % mod;       p >>= 1;     }     return ans;   }   long long inv(long long x, long long mod) { return qp(x, mod - 2, mod); }   long long C(long long N, long long K, long long fact[], long long mod) {     return fact[N] * inv(fact[K], mod) % mod * inv(fact[N - K], mod) % mod;   }   template <typename Tp>   Tp gcd(Tp A, Tp B) {     if (B == 0) return A;     return gcd(B, A % B);   }   template <typename Tp>   Tp lcm(Tp A, Tp B) {     return A * B / gcd(A, B);   }   };  // namespace Mymath   const int Maxn = 705;   const long long mod = 1e9 + 7;   int dp[Maxn][3][Maxn][11];   int tot[11][Maxn];   char c[Maxn];   int n;   void Add(int &x, int y) {     x += y;     if (x >= mod) x -= mod;   }   int main() {     scanf( %s , c);     n = strlen(c);     for (int i = 0; i <= 9; i++) dp[0][1][0][i] = 1;     for (int i = 0; i < n; i++) {       int curv = c[i] -  0 ;       for (int j = 0; j <= i; j++) {         for (int k = 0; k <= 9; k++) {           if (i)             for (int l = 0; l < 3; l++) Add(tot[k][j], dp[i][l][j][k]);           Add(dp[i + 1][1][j + (curv >= k)][k], dp[i][1][j][k]);           for (int l = 0; l <= 9; l++) {             if (!i && !l) continue;             if (l == curv) continue;             Add(dp[i + 1][(l < curv) ? 0 : 2][j + (l >= k)][k], dp[i][1][j][k]);           }           for (int l = 0; l <= 9; l++) {             if (!i && !l) continue;             Add(dp[i + 1][0][j + (l >= k)][k], dp[i][0][j][k]);             Add(dp[i + 1][2][j + (l >= k)][k], dp[i][2][j][k]);           }         }       }     }     for (int j = 0; j <= n; j++) {       for (int k = 0; k <= 9; k++) {         for (int l = 0; l < 2; l++) Add(tot[k][j], dp[n][l][j][k]);       }     }     for (int i = 0; i <= 9; i++) {       for (int j = n; j >= 0; j--) {         Add(tot[i][j], tot[i][j + 1]);       }     }     long long ans = 0;     int w = 1;     for (int i = 0; i < n; i++) {       for (int j = 1; j <= 9; j++) {         int cnt = tot[j][i + 1] - tot[j + 1][i + 1];         if (cnt < 0) cnt += mod;         ans += 1ll * cnt * w % mod * j;         ans %= mod;       }       w = 1ll * w * 10 % mod;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   std::ostream &operator<<(std::ostream &out, vector<T> &v) {     for (typename vector<T>::size_type i = 0; i < v.size(); ++i)       out << v[i] <<    ;     out <<   n ;     return out;   }   template <typename T>   std::ostream &operator<<(std::ostream &out, vector<vector<T> > &v) {     for (size_t i = 0; i < v.size(); ++i) {       for (size_t j = 0; j < v[i].size(); ++j) {         out << v[i][j] <<    ;       }       out <<   n ;     }     return out;   }   int main() {     std::ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, k;     cin >> n >> k;     vector<long long> divisors;     for (long long i = 1; i * i <= n; ++i) {       if (n % i == 0) {         divisors.push_back(i);         if (n / i != i) {           divisors.push_back(n / i);         }       }     }     if (k > divisors.size()) {       cout <<  -1 n ;       return 0;     }     sort(divisors.begin(), divisors.end());     cout << divisors[k - 1] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000;   struct node {     int n;     int i;     node(int n, int i) : n(n), i(i) {}     node() {}     bool operator<(const node& n1) const { return n < n1.n; }     bool is_happy() const {       int a = n;       while (a) {         if (a % 10 != 7 && a % 10 != 4) return false;         a /= 10;       }       return true;     }   };   node nodes[maxn];   int rev[maxn];   inline void sw(int i, int j, vector<pair<int, int> >& ans) {     ans.push_back(pair<int, int>(nodes[i].i, nodes[j].i));     swap(nodes[i].i, nodes[j].i);     rev[nodes[i].i] = i;     rev[nodes[j].i] = j;   }   int main() {     int n;     scanf( %d , &n);     bool sorted = true;     int x = -1, prev;     for (int i = 0; i < n; i++) {       prev = x;       scanf( %d , &x);       if (prev > x) sorted = false;       nodes[i] = node(x, i);     }     if (sorted) {       printf( 0 n );       return 0;     }     sort(nodes, nodes + n);     for (int i = 0; i < n; i++) {       rev[nodes[i].i] = i;     }     int happy = -1;     for (int i = 0; i < n; i++) {       if (nodes[i].is_happy()) {         happy = i;         break;       }     }     if (happy == -1) {       printf( -1 n );       return 0;     }     vector<pair<int, int> > ans;     for (int i = 0; i < n; i++)       if (i != happy && nodes[i].i != i) {         if (rev[i] != happy) sw(rev[i], happy, ans);         sw(happy, i, ans);       }     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); i++) {       printf( %d %d n , ans[i].first + 1, ans[i].second + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Mod = 1e9 + 7;   int qpow(long long a, long long b) {     long long c = 1;     while (b) {       if (b & 1) c = c * a % Mod;       if (b >>= 1) a = a * a % Mod;     }     return c;   }   int n;   long long a;   int p, q;   int main() {     scanf( %d , &n);     bool minus = 1;     q = 2;     for (int i = 1; i <= n; i++) {       scanf( %I64d , &a);       if (!(a & 1)) minus = 0;       q = qpow(q, a);     }     q = q * 500000004ll % Mod;     if (minus) {       p = q - 1;       if (p < 0) p += Mod;     } else       p = q + 1;     p = p * 333333336ll % Mod;     printf( %d/%d n , p, q);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int dx[4] = {-1, 0, 0, +1};   long long int dy[4] = {0, -1, +1, 0};   const long long int LINF = 1e18;   const long long int INF = 1e9;   const long long int mod = 1e9 + 7;   long long int power(long long int a, long long int b, long long int m) {     if (b == 0) return 1;     if (b == 1) return a % m;     long long int t = power(a, b / 2, m);     t = (t * t) % m;     if (b & 1) t = (t * a) % m;     return t;   }   long long int modInverse(long long int a, long long int m) {     return power(a, m - 2, m);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     cin >> t;     while (t--) {       long long int n, ans = 0, i, j;       string ip;       cin >> ip;       long long int sz = ip.size();       if (ip[0] ==  ? ) {         if (sz >= 2 && ip[1] ==  a )           ip[0] =  b ;         else           ip[0] =  a ;       }       for (long long int i = 1; i <= -1 + ip.size(); i++) {         if (ip[i] ==  ? ) {           if (ip[i - 1] ==  a ) {             if ((i + 1) < sz && ip[i + 1] ==  b )               ip[i] =  c ;             else               ip[i] =  b ;           } else if (ip[i - 1] ==  b ) {             if ((i + 1) < sz && ip[i + 1] ==  a )               ip[i] =  c ;             else               ip[i] =  a ;           } else if (ip[i - 1] ==  c ) {             if ((i + 1) < sz && ip[i + 1] ==  a )               ip[i] =  b ;             else               ip[i] =  a ;           } else             ip[i] =  a ;         }       }       bool poss = true;       for (long long int i = 1; i <= sz - 1; i++) {         if (ip[i] == ip[i - 1]) {           cout << -1 << endl;           poss = false;           break;         }       }       if (poss) cout << ip << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[105], b[105], c[105], tot, ans;   char s[105];   int main() {     scanf( %d , &n);     scanf( %s , s + 1);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &a[i], &b[i]);       c[i] = s[i] -  0 ;       if (c[i] == 1) tot++;     }     ans = tot;     for (int i = 1; i <= 125; i++) {       for (int j = 1; j <= n; j++) {         if (i < b[j]) continue;         int k = i - b[j];         if (k % a[j] != 0) continue;         tot -= c[j];         c[j] ^= 1;         tot += c[j];       }       ans = max(ans, tot);     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x7fffffff;   const int oo = 0x3f3f3f3f;   template <typename T>   inline void rd(T &x) {     x = 0;     int f = 1;     char CH = getchar();     while (!isdigit(CH)) {       if (CH ==  - ) f = 0;       CH = getchar();     }     while (isdigit(CH)) {       x = ((x + (x << 2)) << 1) + (CH - 48);       CH = getchar();     }     x = (f == 1) ? x : -x;     return;   }   const int MXN = 2e6;   int a[MXN], n;   inline void solve() {     long long fuck;     rd(fuck);     if (fuck > 36) {       cout << -1;       return;     }     if (fuck == 1)       cout << 6;     else if (fuck == 2)       cout << 8;     else if (fuck > 2) {       while (fuck > 2) fuck -= 2, cout << 8;       if (fuck == 1) cout << 0;       if (fuck == 2) cout << 8;     }   }   int main() { solve(); }
#include <bits/stdc++.h>   const int MAXN = 100;   char s[MAXN + 5];   int main() {     int n, p, q;     scanf( %d%d%d , &n, &p, &q);     scanf( %s , s);     for (int i = 0; p * i <= n; i++) {       if ((n - p * i) % q == 0) {         int j = (n - p * i) / q;         printf( %d n , i + j);         int pos = 0;         for (int k = 1; k <= i; k++) {           for (int l = 1; l <= p; l++) {             printf( %c , s[pos]);             pos++;           }           puts(  );         }         for (int k = 1; k <= j; k++) {           for (int l = 1; l <= q; l++) {             printf( %c , s[pos]);             pos++;           }           puts(  );         }         return 0;       }     }     puts( -1 );   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &x) {     x = 0;     bool f = 0;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = 1;     for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);     if (f) x = -x;   }   long long T, n, m, k;   int main() {     read(T);     while (T--) {       read(n), read(k);       k = k * k;       if ((n & 1) != (k & 1) || k > n)         puts( NO );       else         puts( YES );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mxn(3e5 + 10), mxm(4e5 + 10);   const long long modl(998244353);   int nm, n, m, p, t, k;   int ans;   int a[mxn], b[mxn], c[mxn];   int main() {     ios_base::sync_with_stdio(false);     cin >> nm;     while (cin >> n >> m) {       ans = max(0, n + m - 3) / m + 1;       cout << ans;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 27;   vector<vector<int>> g;   int t, tin[N], tout[N], up[N][20], sz[N], d[N];   void dfs(int v, int p = 0, int dp = 0) {     tin[v] = t++;     d[v] = dp;     sz[v] = 1;     up[v][0] = p;     for (int i = 1; i < 20; i++) up[v][i] = up[up[v][i - 1]][i - 1];     for (int u : g[v]) {       if (u != p) {         dfs(u, v, dp + 1);         sz[v] += sz[u];       }     }     tout[v] = t++;   }   bool is(int a, int b) { return tin[a] <= tin[b] && tout[b] <= tout[a]; }   int get_up(int a, int b) {     for (int i = 18; i >= 0; i--) {       if (!is(up[a][i], b)) a = up[a][i];     }     return a;   }   int lca(int a, int b) {     if (is(a, b)) return a;     if (is(b, a)) return b;     return up[get_up(a, b)][0];   }   int main() {     int n;     cin >> n;     g.resize(n + 1);     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     tin[0] = -1;     tout[0] = 3 * N;     dfs(1);     int q;     cin >> q;     for (int o = 0; o < q; o++) {       int a, b;       cin >> a >> b;       int l = lca(a, b);       if (a == b)         cout << n <<   n ;       else if (d[b] - d[l] == d[a] - d[l]) {         a = get_up(a, l);         b = get_up(b, l);         cout << n - sz[a] - sz[b] <<   n ;       } else {         if (d[a] < d[b]) swap(a, b);         int dist = d[a] + d[b] - 2 * d[l];         if (dist % 2) {           puts( 0 );           continue;         }         dist /= 2;         int u = a;         for (int i = 18; i >= 0; i--) {           if (d[a] - d[up[u][i]] < dist) u = up[u][i];         }         int m = up[u][0];         cout << sz[m] - sz[u] <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int l, t, c, a;   bool vis[26];   bool ok = false;   int main() {     cin >> s;     l = s.size();     if (l < 26) {       cout << -1 << endl;       return 0;     }     for (int i = 0; i < l; ++i) {       memset(vis, 0, sizeof vis);       t = c = 0;       for (int j = i; j < i + 26 && j < l; ++j) {         if (vis[s[j] -  A ]) break;         if (s[j] ==  ? ) {           c++;           continue;         }         vis[s[j] -  A ]++;         t++;       }       if (c + t == 26) {         a = i;         ok = true;         break;       }     }     if (!ok) {       cout << -1 << endl;       return 0;     }     queue<char> q;     for (int j = 0; j < 26; ++j) {       if (!vis[j]) q.push((char)j +  A );     }     for (int i = 0; i < a; ++i)       if (s[i] !=  ? )         cout << s[i];       else         cout <<  A ;     for (int i = a; i < 26 + a; ++i)       if (s[i] !=  ? )         cout << s[i];       else {         cout << q.front();         q.pop();       }     for (int i = 26 + a; i < l; ++i)       if (s[i] !=  ? )         cout << s[i];       else         cout <<  A ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     ios::sync_with_stdio(false);     cin.tie(NULL);     long long k;     cin >> k;     long long second = 2000 + k;     long long ar[2000];     ar[0] = -1;     for (long long int i = 1; i < 2000; i++) {       if (second <= 1000000) {         ar[i] = second;         second = 0;       } else {         ar[i] = 1000000;         second -= 1000000;       }     }     cout << 2000 <<   n ;     for (long long int i = 0; i < 2000; i++)       cout << ar[i] << ((i == (2000 - 1)) ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> blame(1002, 0);   vector<bool> visited(1002, false);   long long dfs(long long u) {     if (visited[u]) return u;     visited[u] = true;     return dfs(blame[u]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> blame[i];     }     for (long long i = 1; i <= n; i++) {       cout << dfs(i) <<    ;       fill(visited.begin(), visited.end(), false);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long g;   void ex_gcd(long long a, long long b, long long& x, long long& y) {     if (!b) {       g = a;       x = 1, y = 0;     } else {       ex_gcd(b, a % b, y, x);       y = y - a / b * x;     }   }   int main() {     long long a, b, c;     scanf( %lld%lld%lld , &a, &b, &c);     long long x, y;     ex_gcd(a, b, x, y);     if (c % g != 0) return 0 * printf( -1 n );     return 0 * printf( %lld %lld n , x * (-c / g), y * (-c / g));   }
#include <bits/stdc++.h>   using namespace std;   int n, m, x[300300], y[300300];   vector<int> graph[300300];   int counter, dfs_num[300300], dfs_low[300300], dfs_parent[300300];   vector<pair<int, int> > bs;   void bridges(int u) {     dfs_low[u] = dfs_num[u] = counter++;     for (int v : graph[u]) {       if (!dfs_num[v]) {         dfs_parent[v] = u;         bridges(v);         if (dfs_low[v] > dfs_num[u]) bs.push_back(pair<int, int>(u, v));         dfs_low[u] = min(dfs_low[u], dfs_low[v]);       } else if (v != dfs_parent[u]) {         dfs_low[u] = min(dfs_low[u], dfs_num[v]);       }     }   }   vector<pair<int, int> > ng[300300];   struct subset {     int parent, _rank;   } subsets[300300];   int Find(int i) {     if (subsets[i].parent != i) subsets[i].parent = Find(subsets[i].parent);     return subsets[i].parent;   }   void Union(int x, int y) {     int xroot = Find(x), yroot = Find(y);     if (subsets[xroot]._rank < subsets[yroot]._rank)       subsets[xroot].parent = yroot;     else if (subsets[xroot]._rank > subsets[yroot]._rank)       subsets[yroot].parent = xroot;     else {       subsets[yroot].parent = xroot;       subsets[xroot]._rank++;     }   }   int maxi = 1, dist[300300];   void dfs(int u, int p, int d) {     if (d > dist[maxi]) maxi = u;     dist[u] = d;     for (pair<int, int> v : ng[u]) {       if (v.first != p) {         dfs(v.first, u, d + v.second);       }     }   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       scanf( %d %d , &x[i], &y[i]);       graph[x[i]].push_back(y[i]);       graph[y[i]].push_back(x[i]);     }     counter = 1;     for (int i = 1; i <= n; i++)       if (!dfs_num[i]) bridges(i);     for (int i = 1; i <= n; i++) {       subsets[i].parent = i;       subsets[i]._rank = 1;     }     for (int i = 0; i < bs.size(); i++) {       Union(bs[i].first, bs[i].second);       ng[bs[i].first].push_back(pair<int, int>(bs[i].second, 1));       ng[bs[i].second].push_back(pair<int, int>(bs[i].first, 1));     }     for (int i = 0; i < m; i++) {       if (Find(x[i]) == Find(y[i])) continue;       Union(x[i], y[i]);       ng[x[i]].push_back(pair<int, int>(y[i], 0));       ng[y[i]].push_back(pair<int, int>(x[i], 0));     }     dfs(1, 0, 0);     memset(dist, 0, sizeof dist);     dfs(maxi, 0, 0);     printf( %d n , dist[maxi]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int A[100005], D[100005], n, m, w, L[100005];   bool go(int h) {     fill(L, L + n, 0);     for (int i = 0; i < n; ++i) D[i] = max(h - A[i], 0);     int pow = 0, cap = m, d;     for (int i = 0; i < n; ++i) {       pow -= L[i];       d = max(D[i] - pow, 0);       if (d > cap) return false;       pow += d;       cap -= d;       if (i + w < n) L[i + w] += d;     }     return true;   }   int main() {     std::ios::sync_with_stdio(false);     int mini = 2e9;     cin >> n >> m >> w;     for (int i = 0; i < n; ++i) {       cin >> A[i];       mini = min(mini, A[i]);     }     int lo = mini, hi = mini + m + 1, mid;     while (hi - lo > 1) {       mid = (hi + lo) >> 1;       if (go(mid))         lo = mid;       else         hi = mid;     }     cout << lo << endl;   }
#include <bits/stdc++.h>   int main(void) {     int t, n, d;     scanf( %d , &t);     while (t--) {       scanf( %d %d , &n, &d);       int i = 0;       int flag = 1;       while (i < n) {         int te = d / (i + 1);         te = te * (i + 1) == d ? te : te + 1;         if (i + te <= n) {           printf( YES n );           flag = 0;           break;         }         i++;       }       if (flag) printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m1 = 0, m2 = 0;     cin >> n;     vector<vector<long long> > m(n, vector<long long>(n));     vector<int> a(n);     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) cin >> m[i][j];     for (int i = 1; i < n - 1; i++)       a[i] = sqrt(m[i][i + 1] * m[i - 1][i] / m[i - 1][i + 1]);     a[0] = m[0][1] / a[1];     a[n - 1] = m[0][n - 1] / a[0];     for (int i = 0; i < n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   const long long maxm = 1e5 + 100;   long long n, m;   struct node {     long long col[maxm * 4], tag[maxm * 4], sum[maxm * 4], siz[maxm * 4];     inline void pushup(long long o) {       sum[o] = sum[(o << 1)] + sum[(o << 1) | 1];       col[o] = col[(o << 1)] == col[(o << 1) | 1] ? col[(o << 1)] : 0;     }     inline void pushdown(long long o) {       if (tag[o]) {         tag[(o << 1)] += tag[o];         tag[(o << 1) | 1] += tag[o];         sum[(o << 1)] += siz[(o << 1)] * tag[o];         sum[(o << 1) | 1] += siz[(o << 1) | 1] * tag[o];         col[(o << 1)] = col[(o << 1) | 1] = col[o];         tag[o] = 0;       }     }     void build(long long o, long long l, long long r) {       siz[o] = (r - l + 1);       if (l >= r) {         col[o] = l;         return;       }       long long mid = (l + r) >> 1;       build((o << 1), l, mid), build((o << 1) | 1, mid + 1, r);       pushup(o);     }     void cover(long long o, long long l, long long r, long long ql, long long qr,                long long c) {       if (ql > r || qr < l) return;       if ((ql <= l) && (r <= qr) && col[o]) {         tag[o] += abs(col[o] - c);         sum[o] += abs(col[o] - c) * siz[o];         col[o] = c;         return;       }       pushdown(o);       long long mid = (l + r) >> 1;       cover((o << 1), l, mid, ql, qr, c),           cover((o << 1) | 1, mid + 1, r, ql, qr, c);       pushup(o);     }     long long ask(long long o, long long l, long long r, long long ql,                   long long qr) {       if (ql > r || qr < l) return 0;       if ((ql <= l) && (r <= qr)) return sum[o];       pushdown(o);       long long mid = (l + r) >> 1;       return ask((o << 1), l, mid, ql, qr) +              ask((o << 1) | 1, mid + 1, r, ql, qr);     }   } st;   signed main() {     scanf( %I64d%I64d , &n, &m);     st.build(1, 1, n);     for (long long i = 1; i <= m; i++) {       long long opt, l, r, x;       scanf( %I64d%I64d%I64d , &opt, &l, &r);       if (opt == 1)         scanf( %I64d , &x), st.cover(1, 1, n, l, r, x);       else         printf( %I64d n , st.ask(1, 1, n, l, r));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 4;   int n, m, a, b, ay[N], by[N], l[N], linkY[N << 1];   void read() {     cin >> n >> m >> a >> b;     for (int i = 1; i <= n; ++i) {       cin >> ay[i];     }     for (int i = 1; i <= m; ++i) {       cin >> by[i];     }     for (int i = 1; i <= m; ++i) {       cin >> l[i];     }   }   long double dist = 1e18;   int ida, idb, idTmp;   long double sqr(long double x) { return x * x; }   long double euc(long double xa, long double ya, long double xb,                   long double yb) {     return sqrt(sqr(xa - xb) + sqr(ya - yb));   }   long double f(int ni, int mi) {     return euc(0, 0, a, ay[ni]) + euc(a, ay[ni], b, by[mi]);   }   long double ternarySearch(int num) {     int l = 1, r = n;     while (l + 2 < r) {       int dm = (r - l) / 3;       int m1 = l + dm;       int m2 = r - dm;       long double d1 = f(m1, num);       long double d2 = f(m2, num);       if (fabs(d1 - d2) < 1e-9) {         l = m1;         r = m2;       } else if (d1 < d2) {         r = m2;       } else {         l = m1;       }     }     idTmp = l;     for (int i = l + 1; i <= r; ++i) {       if (f(i, num) < f(idTmp, num)) {         idTmp = i;       }     }     return f(idTmp, num);   }   void calc() {     for (int i = 1; i <= m; ++i) {       long double distTmp = ternarySearch(i) + l[i];       if (distTmp < dist) {         dist = distTmp;         ida = idTmp;         idb = i;       }     }   }   void sovle() {     read();     calc();     cout << ida <<     << idb;   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     sovle();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long double n;     cin >> n;     long long m = sqrt(n);     if (m * m == n) {       cout << 2 * m;     } else if ((long long)m * (long long)(m + 1) >= n) {       cout << (long long)m + (long long)(m + 1);     } else       cout << (long long)2 * (long long)(m + 1);   }