malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline long long add(long long a, long long b, long long p = 1000000007) {     long long c = a + b;     if (c >= p) c -= p;     return c;   }   inline long long sub(long long a, long long b, long long p = 1000000007) {     long long c = a - b;     if (c < 0) c += p;     return c;   }   inline long long mul(long long a, long long b, long long p = 1000000007) {     return ((a % p) * (b % p)) % p;   }   long long power(long long x, long long y, long long p = 1000000007) {     long long res = 1;     x = x % p;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   vector<int> g[200005];   int t = 0;   int tim[500005];   void dfs(int u, int v = -1) {     tim[t++] = u;     for (auto x : g[u]) {       if (x == v) continue;       dfs(x, u);     }     tim[t++] = u;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     int a;     cin >> n;     int p[n + 1];     for (int i = 2; i <= n; i++) {       cin >> a;       g[i].push_back(a);       g[a].push_back(i);     }     dfs(1);     map<int, int> mp;     for (int i = 0; i <= 2 * n - 1; i++) {       mp[tim[i]]++;       if (tim[i] == n) break;     }     for (auto it = mp.begin(); it != mp.end(); it++) {       if (it->second == 1) {         cout << it->first <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long infll = powl(2, 63) - 1;   struct cup {     long long a, b, c;   };   bool comp(cup x, cup y) { return x.c < y.c; }   bool cmp1(cup x, cup y) {     if (x.a == y.a) return x.c < y.c;     return x.a > y.a;   }   int32_t main() {     long long n, tea;     cin >> n >> tea;     vector<cup> arr(n);     for (long long i = 0; i < (long long)(n); ++i) cin >> arr[i].a;     for (long long i = 0; i < (long long)(n); ++i) {       arr[i].b = ceil(arr[i].a / 2.0);       arr[i].c = i;       tea -= arr[i].b;       if (tea < 0) {         cout << -1 << endl;         return 0;       }     }     sort((arr).begin(), (arr).end(), cmp1);     for (long long i = 0; i < (long long)(n); ++i) {       long long temp = min(tea, arr[i].a - arr[i].b);       arr[i].b += temp;       tea -= temp;       if (tea == 0) break;     }     sort((arr).begin(), (arr).end(), comp);     for (long long i = 0; i < (long long)(n); ++i) cout << arr[i].b <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long x, y, m;     cin >> x >> y >> m;     long long sol = 0ll;     if (x >= m || y >= m) {       cout <<  0 n ;       return 0;     }     if (x <= 0ll && y <= 0ll) {       cout <<  -1 n ;       return 0;     }     if (x > y) {       swap(x, y);     }     if (x < 0ll) {       sol += ((-x) / y);       x = -((-x) % y);     }     while (x < m && y < m) {       if (x <= y) {         x += y;       } else {         y += x;       }       sol++;     }     cout << sol <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   using std::bitset;   const double Pi = acos(-1);   namespace fastIO {   template <class T>   inline void read(T &x) {     x = 0;     bool fu = 0;     char ch = 0;     while (ch >  9  || ch <  0 ) {       ch = getchar();       if (ch ==  - ) fu = 1;     }     while (ch <=  9  && ch >=  0 ) x = (x * 10 - 48 + ch), ch = getchar();     if (fu) x = -x;   }   inline int read() {     int x = 0;     bool fu = 0;     char ch = 0;     while (ch >  9  || ch <  0 ) {       ch = getchar();       if (ch ==  - ) fu = 1;     }     while (ch <=  9  && ch >=  0 ) x = (x * 10 - 48 + ch), ch = getchar();     return fu ? -x : x;   }   char _n_u_m_[40];   template <class T>   inline void write(T x) {     if (x == 0) {       putchar( 0 );       return;     }     T tmp = x > 0 ? x : -x;     if (x < 0) putchar( - );     register int cnt = 0;     while (tmp > 0) {       _n_u_m_[cnt++] = tmp % 10 +  0 ;       tmp /= 10;     }     while (cnt > 0) putchar(_n_u_m_[--cnt]);   }   template <class T>   inline void write(T x, char ch) {     write(x);     putchar(ch);   }   }  // namespace fastIO   using namespace fastIO;   const int MAXN = 1000005;   int len[MAXN], ch[MAXN][26], fail[MAXN], cnt, lst, up[MAXN], orz[MAXN];   long long qwq[MAXN], ans[MAXN];   char c[MAXN], ccf[MAXN];   int now, n;   inline void insert(int pos) {     while (c[pos] != c[pos - len[lst] - 1]) lst = fail[lst];     if (!ch[lst][c[pos] - 97]) {       len[++cnt] = len[lst] + 2;       register int i = fail[lst];       while (c[pos] != c[pos - len[i] - 1]) i = fail[i];       fail[cnt] = ch[i][c[pos] - 97];       ch[lst][c[pos] - 97] = cnt;       orz[cnt] = len[cnt] - len[fail[cnt]];       if (orz[cnt] == orz[fail[cnt]])         up[cnt] = up[fail[cnt]];       else         up[cnt] = fail[cnt];     }     lst = ch[lst][c[pos] - 97];   }   int main() {     len[1] = -1;     fail[0] = 1;     up[0] = 1;     ans[0] = 1;     cnt = 1;     scanf( %s , ccf + 1);     n = strlen(ccf + 1);     if (n % 2) {       cerr <<  Fuck CCF!!!  << endl;       cout << 0;       return 0;     }     for (register int i = 1, iend = n / 2; i <= iend; ++i) {       c[2 * i - 1] = ccf[i];       c[i << 1] = ccf[n - i + 1];     }     for (register int i = 1, iend = n; i <= iend; ++i) {       insert(i);       for (register int j = lst; j; j = up[j]) {         qwq[j] = ans[i - len[up[j]] - orz[j]];         if (up[j] != fail[j]) qwq[j] += qwq[fail[j]];         qwq[j] %= 1000000007ll;         if (!(i & 1)) ans[i] += qwq[j], ans[i] %= 1000000007ll;       }     }     cout << ans[n];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int T, n;   long long W;   pair<long long, int> w[N];   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     for (cin >> T; T--;) {       vector<int> id;       cin >> n >> W;       long long x = W;       for (int i = 1; i <= n; ++i) cin >> w[i].first, w[i].second = i;       sort(w + 1, w + n + 1, greater<pair<int, int> >());       for (int i = 1; i <= n; ++i)         if (w[i].first <= x) x -= w[i].first, id.push_back(w[i].second);       if (W - x < (W + 1) / 2)         cout <<  -1 n ;       else {         cout << id.size() <<   n ;         for (int i : id) cout << i <<    ;         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2004;   const int INF = 0x3f3f3f3f;   char s[MAXN][MAXN];   int u[MAXN][MAXN], d[MAXN][MAXN];   int l[MAXN][MAXN], r[MAXN][MAXN];   int dp[MAXN][MAXN];   int n, m;   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) scanf( %s , s[i]);     for (int i = 0; i < n; ++i) {       l[i][0] = 1;       r[i][m - 1] = 1;       dp[i][0] = dp[i][m - 1] = 1;       for (int j = 1; j < m; ++j) {         if (s[i][j - 1] == s[i][j])           l[i][j] = l[i][j - 1] + 1;         else           l[i][j] = 1;       }       for (int j = m - 2; j >= 0; --j) {         if (s[i][j + 1] == s[i][j])           r[i][j] = r[i][j + 1] + 1;         else           r[i][j] = 1;         dp[i][j] = min(l[i][j], r[i][j]);       }     }     for (int j = 0; j < m; ++j) {       u[0][j] = 1;       d[n - 1][j] = 1;       for (int i = 1; i < n; ++i) {         if (s[i - 1][j] == s[i][j])           u[i][j] = min(dp[i][j], u[i - 1][j] + 1);         else           u[i][j] = 1;       }       for (int i = n - 2; i >= 0; --i) {         if (s[i + 1][j] == s[i][j])           d[i][j] = min(dp[i][j], d[i + 1][j] + 1);         else           d[i][j] = 1;       }     }     int ans = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         ans += min(u[i][j], d[i][j]);       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 55;   int n, siz[N];   vector<int> e[N];   double f[N][N], sav[N], C[N][N], fac[N];   void dfs(int x, int fa) {     siz[x] = 0, f[x][0] = 1;     for (const int &v : e[x])       if (v != fa) {         dfs(v, x), ++siz[v];         double sum = 0, o;         for (int a = (0); a <= (siz[v]); a++)           o = f[v][a], f[v][a] = f[v][a] * (siz[v] - a) + sum / 2, sum += o;         for (int a = (0); a <= (siz[x]); a++)           for (int b = (0); b <= (siz[v]); b++)             sav[a + b] += C[a + b][a] *                           C[(siz[x] - a) + (siz[v] - b)][siz[x] - a] * f[x][a] *                           f[v][b];         siz[x] += siz[v];         for (int a = (0); a <= (siz[x]); a++) f[x][a] = sav[a], sav[a] = 0;       }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.precision(12), cout << fixed;     cin >> n;     fac[0] = C[0][0] = 1;     for (int i = (1); i <= (n); i++) fac[i] = fac[i - 1] * i, C[i][0] = 1;     for (int i = (1); i <= (n); i++)       for (int j = (1); j <= (i); j++) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];     for (int i = 1, u, v; i < n; i++)       cin >> u >> v, e[u].push_back(v), e[v].push_back(u);     for (int i = (1); i <= (n); i++)       memset(f, 0, sizeof(f)), dfs(i, -1),           cout << f[i][n - 1] / fac[n - 1] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long M = 1e9 + 7;   void solve() {     long long int n;     cin >> n;     vector<long long int> a(n);     long long int sum = 0;     long long int x = 0;     for (long long int i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];       x = x ^ a[i];     }     cout << 2 <<   n ;     cout << x <<     << sum + x <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 305000;   const int INF = 105000;   int main() {     long long n, k;     cin >> n >> k;     long long g = (n / 2) / (k + 1);     long long d = g * k;     long long ost = n - d - g;     cout << g <<     << d <<     << ost;   }
#include <bits/stdc++.h>   using namespace std;   map<string, vector<string> > graph;   unsigned long long int countSetBits(long long int n) {     unsigned long long int count = 0;     while (n) {       n &= (n - 1);       count++;     }     return count;   }   bool valid(set<string>& t) {     for (auto i = t.begin(); i != t.end(); i++) {       for (auto k : graph[*i]) {         if (t.find(k) != t.end()) {           return false;         }       }     }     return true;   }   void solve() {     long long int n, m;     cin >> n >> m;     vector<string> players(n);     for (long long int i = 0; i < n; i++) {       cin >> players[i];     }     for (long long int i = 0; i < m; i++) {       string a, b;       cin >> a >> b;       graph[a].push_back(b);       graph[b].push_back(a);     }     set<string> ans;     for (long long int i = 1; i < (1 << (n + 1)); i++) {       set<string> tmp;       for (long long int j = 0; j <= log2(i); j++) {         if (i & (1 << j)) {           tmp.insert(players[min(n - 1, j)]);         }       }       if (ans.size() < tmp.size() && valid(tmp)) {         ans = tmp;       }       tmp.clear();     }     cout << ans.size() <<   n ;     for (string s : ans) {       cout << s <<   n ;     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long int T = 1;     while (T--) {       solve();       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long LLINF = 1ll << 60;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << setprecision(25);     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       string s;       cin >> s;       int cnt = 1;       vector<int> v;       for (int i = 1; i < n; i++) {         if (s[i] == s[i - 1])           cnt++;         else {           v.push_back(cnt);           cnt = 1;         }       }       v.push_back(cnt);       int ans = 0;       int l = (int)v.size();       for (int i = 0; i < l; i++) ans = min(i + 1, ans + v[i] - 1);       cout << ans + (l - ans + 1) / 2 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 8;   bool vis[N][N];   int n, m, ans, a[8];   vector<pair<int, int> > edges;   vector<int> v;   int calc() {     memset(vis, 0, sizeof vis);     for (auto X : edges) {       int x = X.first;       int y = X.second;       vis[a[x]][a[y]] = vis[a[y]][a[x]] = 1;     }     int ret = 0;     for (int i = 1; i <= 6; i++)       for (int j = i; j <= 6; j++) ret += vis[i][j];     return ret;   }   void bt(int i) {     if (i == n + 1) {       for (int i = 1; i <= n; i++) a[i] = v[i];       ans = max(ans, calc());       return;     }     for (int j = 1; j <= 6; j++) {       v.push_back(j);       bt(i + 1);       v.pop_back();     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int a, b;       scanf( %d%d , &a, &b);       edges.push_back({a, b});     }     if (n <= 6) {       printf( %d n , m);       return 0;     }     v.push_back(69);     bt(1);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 3;   int a[MAXN], b[MAXN], p[MAXN];   int read() {     int x = 0, w = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) w = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x << 3) + (x << 1) + c - 48;       c = getchar();     }     return x * w;   }   int main() {     int n = read(), ans = 0;     for (int i = 1; i <= n; i++) a[i] = read(), p[a[i]] = 0;     for (int i = 1; i <= n; i++) b[i] = read(), p[b[i]] = i;     if (p[1]) {       int i, j;       for (i = 1; p[i] == p[1] + i - 1; i++)         ;       if (p[i - 1] == n) {         for (j = i; j <= n && p[j] <= j - i; j++)           ;         if (j > n) {           printf( %d n , n - i + 1);           return 0;         }       }     }     for (int i = 1; i <= n; i++) ans = max(ans, p[i] - (i - 1) + n);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 501000;   int n, a[N];   bool check(int p) {     for (int i = p - 1; i >= 0; i--) {       if (a[i] * 2 > a[n - p + i]) return false;     }     return true;   }   int work() {     int l = 0, r = n >> 1;     while (l <= r) {       int mid = l + r >> 1;       if (check(mid))         l = mid + 1;       else         r = mid - 1;     }     return n - (l - 1);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     printf( %d n , work());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::system_clock::now().time_since_epoch().count());   template <class T = int>   T __rand(T range = numeric_limits<T>::max()) {     return (T)(rng() % range);   }   int debug = 0;   int __db_level = 0;   struct debug_block {     string name;     debug_block(const string& name_) : name(name_) {       if (debug) cerr << string(__db_level * 2,    ) <<  {   << name << endl;       ++__db_level;     }     ~debug_block() {       --__db_level;       if (debug) cerr << string(__db_level * 2,    ) <<  }   << name << endl;     }   };   template <class U, class V>   ostream& operator<<(ostream& out, const pair<U, V>& p) {     return out <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <class A, class B>   ostream& operator<<(ostream& out, const tuple<A, B>& t) {     return out <<  (  << get<0>(t) <<  ,   << get<1>(t) <<  ) ;   }   template <class A, class B, class C>   ostream& operator<<(ostream& out, const tuple<A, B, C>& t) {     return out <<  (  << get<0>(t) <<  ,   << get<1>(t) <<  ,   << get<2>(t)                <<  ) ;   }   template <class T>   ostream& operator<<(ostream& out, const vector<T>& container) {     out <<  { ;     if (((int)container.size())) out << container[0];     for (int i = 0; i++ < ((int)container.size()) - 1;)       out <<  ,   << container[i];     return out <<  } ;   }   template <class x>   vector<typename x::value_type> $v(const x& a) {     return vector<typename x::value_type>(a.begin(), a.end());   }   template <class u>   vector<typename iterator_traits<u>::value_type> $v(u a, u b) {     return vector<typename iterator_traits<u>::value_type>(a, b);   }   int main(void) {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int ntest;     cin >> ntest;     for (int testcase = 0; testcase++ < ntest;) {       ;       int n, m, k;       cin >> n >> m >> k;       vector<int> a(n);       for (auto& i : a) cin >> i;       int ans = 0;       k = min(k, m - 1);       int left = m - 1 - k;       int width = n - k - left;       if (debug)         cerr << string(__db_level * 2,    ) <<  [               <<  width               <<  ] = [  << width <<  ]  << endl;       for (int i = -1; ++i < k + 1;) {         int cur_ans = INT_MAX;         for (int f = -1; ++f < left + 1;) {           int t = max(a[i + f], a[i + f + width - 1]);           if (debug)             cerr << string(__db_level * 2,    ) <<  [                   <<  i _ f _ t                   <<  ] = [  << i <<  ,   << f <<  ,   << t <<  ]  << endl;           cur_ans = min(cur_ans, t);         }         if (debug)           cerr << string(__db_level * 2,    ) <<  [                 <<  i _ cur_ans                 <<  ] = [  << i <<  ,   << cur_ans <<  ]  << endl;         ans = max(ans, cur_ans);       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char dat[1048576];   long long countSub(long long a, long long b, long long left, long long right,                      long long d) {     long long low = b * d - a;     if (low < 0) {       if (a % b != 0) {         low = b - a % b;       } else {         low = 0;       }     }     long long high = left + right;     if (low > high) return 0;     high -= (high - low) % b;     if (left > right) swap(left, right);     long long ans = 0;     long long firstcnt = 0, fb = low;     long long secondcnt = 0, sb = 0;     long long thirdcnt = 0, tb = 0;     if (fb <= left) {       if (high <= left) {         firstcnt = (high - fb) / b + 1;       } else {         firstcnt = (left - fb) / b + 1;       }     }     sb = fb + firstcnt * b;     if (high >= sb && sb <= right) {       if (high <= right) {         secondcnt = (high - sb) / b + 1;       } else if (high > right) {         secondcnt = (right - sb) / b + 1;       }     }     tb = sb + secondcnt * b;     if (high >= tb) {       thirdcnt = (high - tb) / b + 1;     }     if (firstcnt > 0)       ans += ((fb + 1) + (fb + (firstcnt - 1) * b + 1)) * firstcnt / 2;     if (secondcnt > 0) ans += ((left + 1) + (left + 1)) * secondcnt / 2;     if (thirdcnt > 0)       ans += ((left + right + 1 - (tb)) +               (left + right + 1 - (tb + (thirdcnt - 1) * b))) *              thirdcnt / 2;     return ans;   }   int main() {     scanf( %s , dat);     int n = (int)strlen(dat);     int n0 = 0, n1 = 0;     for (int i = 0; i < n; i++) {       if (dat[i] ==  0 ) {         n0++;       } else {         n1++;       }     }     long long ans = 0;     int maxratio = 0;     for (int ratio = 0; ratio <= 100 || 12 * ratio * ratio <= n; ratio++) {       maxratio = ratio;       long long depth = 0;       unordered_map<long long, int> cnt;       cnt.reserve(n + 10);       cnt[0] = 1;       for (int i = 0; i < n; i++) {         if (dat[i] ==  0 ) {           depth--;         } else {           depth += ratio;         }         ans += (cnt[depth]++);       }     }     vector<int> ones;     for (int i = 0; i < n; i++)       if (dat[i] ==  1 ) ones.emplace_back(i);     for (int i = 0; i < ones.size(); i++) {       for (int j = i; j < ones.size(); j++) {         int onecnt = j - i + 1;         if (onecnt * maxratio > n0) break;         int left = (i == 0 ? ones[0] : (ones[i] - ones[i - 1] - 1));         int right = (j + 1 == ones.size() ? (n - 1 - ones[j])                                           : (ones[j + 1] - ones[j] - 1));         int zerocnt = ones[j] - ones[i] + 1 - onecnt;         ans += countSub(zerocnt, onecnt, left, right, maxratio + 1);       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t, s[200005], d[200005], k;     while (cin >> n >> t) {       int maxx = 0x3f3f3f3f;       for (int i = 1; i <= n; i++) {         cin >> s[i] >> d[i];         int change = s[i];         while (change < t) {           change += d[i];         }         if (change - t < maxx) {           maxx = change - t;           k = i;         }       }       cout << k << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e4 + 5;   const double eps = 1e-10;   int n, m, cnt, v[N], tr[N << 1];   double a[N], b[N];   pair<double, int> e[N << 1];   inline int read() {     int x = 0, f = 1;     char ch = getchar();     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;   }   int lowbit(int x) { return x & (-x); }   void add(int x, int y) {     while (x <= cnt) tr[x] += y, x += lowbit(x);   }   int query(int x) {     int res = 0;     while (x) res += tr[x], x -= lowbit(x);     return res;   }   void work(double r) {     cnt = 0;     for (int i = 1; i <= n; i++) {       double a = ::a[i], b = ::b[i],              d = 4.0 * (a * a * b * b - (a * a + 1.0) * (b * b - r * r));       if (d < eps) continue;       d = sqrt(d);       double x = (-2.0 * a * b - d) / ((a * a + 1.0) * 2.0),              xx = (-2.0 * a * b + d) / ((a * a + 1.0) * 2.0);       double y = a * x + b, yy = a * xx + b;       e[++cnt] = make_pair(atan2(y, x), i);       e[++cnt] = make_pair(atan2(yy, xx), i);     }     sort(e + 1, e + cnt + 1);     for (int i = 1; i <= cnt; i++) v[e[i].second] = i;   }   int check(double r) {     work(r);     for (int i = 1; i <= cnt; i++) tr[i] = 0;     long long ans = 0;     for (int i = 1; i <= cnt; i++)       if (v[e[i].second] != i) {         ans += query(v[e[i].second]) - query(i - 1);         add(v[e[i].second], 1);       }     return ans >= m;   }   double calc(int i, int j) {     double x = (b[j] - b[i]) / (a[i] - a[j]), y = a[i] * x + b[i];     return sqrt(x * x + y * y);   }   double calc(double r) {     work(r);     set<pair<double, int> > s;     double ans = 0;     int tot = 0;     for (int i = 1; i <= cnt; i++)       if (v[e[i].second] != i) {         auto it = s.upper_bound(make_pair(i + 1, 0));         while (it != s.end() && it->first < v[e[i].second])           ans += calc(e[i].second, it->second), it++, tot++;         s.insert(make_pair(v[e[i].second], e[i].second));       }     return ans + (m - tot) * r;   }   int main() {     n = read();     double p = (double)read() / 1000.0, q = (double)read() / 1000.0;     m = read();     for (int i = 1; i <= n; i++) {       a[i] = (double)read() / 1000.0;       b[i] = (double)read() / 1000.0;       b[i] += a[i] * p - q;     }     double l = 0, r = 1e10;     for (int i = 1; i <= 100; i++) {       double mid = (l + r) / 2.0;       if (check(mid))         r = mid;       else         l = mid;     }     printf( %.10f n , max((double)0, calc(r)));     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char* argv[]) {     string s;     string t;     cin >> s >> t;     string result(s);     int carry = 1;     for (int ii = s.length() - 1; ii >= 0; --ii) {       result[ii] = (char)(s[ii] + carry);       if (result[ii] >  z ) {         result[ii] =  a ;         carry = 1;       } else {         carry = 0;       }     }     if (result == t) {       cout <<  No such string  << endl;     } else {       cout << result << endl;     }     return 0;   }