malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n;     cin >> n;     for (long long int ij = 0; ij < n; ++ij) {       long long int a, b;       cin >> a >> b;       long long int p = llabs(a - b), s = 0, i = 0, d = 0;       while (s < p || d == 0) {         ++i;         s += i;         if (s >= p) {           if (s % 2 == p % 2) {             ++d;           }         }       }       if (a == b)         cout << 0 << endl;       else         cout << i << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int n, k, q, l, r;   int b[N], sum[N];   int main() {     scanf( %d%d%d , &n, &k, &q);     for (int i = 1; i <= n; ++i) {       scanf( %d%d , &l, &r);       b[l]++;       b[r + 1]--;     }     int tot = 0;     for (int i = 1; i <= 200000; ++i) {       tot += b[i];       sum[i] = sum[i - 1];       if (tot >= k) sum[i]++;     }     for (int i = 1; i <= q; ++i) {       scanf( %d%d , &l, &r);       printf( %d n , sum[r] - sum[l - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, a, b;     cin >> n >> m >> a >> b;     long long cost = 0;     if (m > n) m = n;     if (m * a <= b)       cost = n * a;     else {       cost = (n / m) * b;       n = n % m;       if (n > 0) {         if ((n)*a <= b)           cost += n * a;         else           cost += b;       }     }     cout << cost;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long inf = 1e9 + 7;   long long mod = 1e9 + 7;   using namespace std;   bool comp(pair<pair<long long, long long>, long long> a,             pair<pair<long long, long long>, long long> b) {     if (a.first.first != b.first.first) return a.first.first < b.first.first;     return a.first.second < b.first.second;   }   bool isOverlap(pair<long long, long long> a, pair<long long, long long> b) {     if (a.second < b.first or a.first > b.second) return false;     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long T, N, i, j, k, L, l, r, m, n;     long long K, P;     long long M;     cin >> T;     while (T--) {       deque<pair<pair<long long, long long>, long long> > v;       cin >> N;       vector<long long> ret(N, 0);       for (i = 0; i < N; i++) {         cin >> l >> r;         v.push_back(make_pair(make_pair(l, r), i));       }       sort(v.begin(), v.end(), comp);       vector<long long> ans;       while (!v.empty()) {         pair<long long, long long> inv = v.front().first;         ans.push_back(v.front().second);         v.pop_front();         while (!v.empty() and isOverlap(inv, v.front().first)) {           ans.push_back(v.front().second);           inv.first =               (((inv.first) < (v.front().first.first)) ? (inv.first)                                                        : (v.front().first.first));           inv.second = (((inv.second) > (v.front().first.second))                             ? (inv.second)                             : (v.front().first.second));           v.pop_front();         }         break;       }       if (v.empty())         cout << -1 << endl;       else {         for (i = 0; i < ans.size(); i++) ret[ans[i]] = 1;         while (!v.empty()) {           ret[v.front().second] = 2;           v.pop_front();         }         for (i = 0; i < N; i++) cout << ret[i] <<    ;         cout << endl;       }       ret.clear();     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool ckmax(T& x, T y) {     return x < y ? x = y, 1 : 0;   }   template <class T>   bool ckmin(T& x, T y) {     return x > y ? x = y, 1 : 0;   }   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = 0;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f ? x : -x;   }   const long long N = 200005;   long long n, a[N], b[N], now, tot;   bool isrt(long long x) {     if (x > 1e13) return 0;     long long l = max(1ll, (long long)(sqrt(x) - 3)), r = sqrt(x) + 3;     for (long long i = l, iend = r; i <= iend; ++i)       if (x % i == 0) return 1;     return 0;   }   signed main() {     n = read() / 2;     for (long long i = 1, iend = n; i <= iend; ++i) a[i] = read();     for (long long i = 1; i <= n; ++i) {       bool flg = 0;       long long res;       for (long long j = sqrt(a[i]); j >= 1; --j) {         if (a[i] % j) continue;         long long X = a[i] / j, Y = j;         if ((X - Y) % 2) continue;         res = (X - Y) / 2, res *= res;         if (res <= now) continue;         flg = 1;         break;       }       if (now >= res || !flg) return puts( No ), 0;       b[++tot] = res - now, b[++tot] = a[i];       now = a[i] + res;     }     now = 0;     for (long long i = 1, iend = n << 1; i <= iend; ++i) {       now += b[i];       if (!isrt(now)) return puts( No ), 0;     }     puts( Yes );     for (long long i = 1, iend = n << 1; i <= iend; ++i) printf( %lld  , b[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 20;   long long a[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, sum = 0, mx = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       mx = max(mx, a[i]);       sum += a[i];     }     cout << max((long long)((sum + n - 2) / (n - 1)), mx) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long 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 << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   const int N = 100008;   int n;   int x, y;   int nume, head[N];   struct edge {     int to, nxt;   } e[N << 1];   inline void add_edge(int x, int y) {     e[++nume] = (edge){y, head[x]};     head[x] = nume;   }   int ans[N];   int tmp;   int dp[N];   inline void dfs(int x, int fa, int goal) {     int mx1, mx2;     mx1 = mx2 = 0;     for (int i = head[x]; i; i = e[i].nxt) {       int to = e[i].to;       if (to != fa) {         dfs(to, x, goal);         if (dp[to] > mx1) {           mx2 = mx1;           mx1 = dp[to];         } else if (dp[to] > mx2) {           mx2 = dp[to];         }       }     }     if (mx1 + mx2 + 1 >= goal) {       dp[x] = 0;       ++tmp;     } else {       dp[x] = mx1 + 1;     }   }   inline void solve(int l, int r, int ansl, int ansr) {     if (l > r) return;     if (ansl == ansr) {       for (int i = l; i <= r; ++i) {         ans[i] = ansl;       }       return;     }     int mid = (l + r) >> 1;     tmp = 0;     dfs(1, 0, mid);     ans[mid] = tmp;     solve(l, mid - 1, ansl, ans[mid]);     solve(mid + 1, r, ans[mid], ansr);   }   int main() {     n = read();     for (int i = 1; i < n; ++i) {       x = read();       y = read();       add_edge(x, y);       add_edge(y, x);     }     solve(1, n, n, 0);     for (int i = 1; i <= n; ++i) {       printf( %d  , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const maxn = 1e5 + 5;   int ans[maxn], used[maxn];   inline int oks(vector<int> a) {     for (int i = 0; i < (int)a.size(); ++i)       if (a[i] == i + 1 || (a[i] & (i + 1)) == 0) return 0;     return 1;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, cnt = 1, N;     cin >> n;     N = n;     if (n % 2 == 1) {       cout <<  NO  <<   n ;     } else {       cout <<  YES  <<   n ;       while (n > 0) {         int x = 1;         while (x * 2 <= n) x *= 2;         for (int w = x; w <= n; ++w) {           ans[w] = x - (w - x) - 1;           ans[x - (w - x) - 1] = w;         }         n -= 2 * (n - x + 1);       }       for (int i = 1; i <= N; ++i) cout << ans[i] <<    ;       cout <<   n ;     }     n = N;     if (n <= 5) {       cout <<  NO  <<   n ;       exit(0);     }     while (n > 0) {       int x = 1;       while (x * 2 <= n) x *= 2;       if (x == n) {         cout <<  NO  <<   n ;         exit(0);       }       if (n == 6) {         ans[1] = 3, ans[2] = 6, ans[3] = 2, ans[4] = 5, ans[5] = 1, ans[6] = 4;         n = 0;         break;       }       if ((n - x + 1) % 2 == 1) {         int R = n, cur = (n - x) / 2 + 1;         for (int i = x; cur > 0; ++i, cur--) {           if (i == x + 1) continue;           ans[i] = R;           ans[R] = i;           R--;         }         ans[x + 1] = x - 1;         ans[x - 1] = x + 1;         n = x - 2;       } else {         while (n > 7) {           ans[n] = n - 1;           ans[n - 1] = n;           n -= 2;         }         ans[1] = 3, ans[2] = 6, ans[3] = 1, ans[4] = 5, ans[5] = 4, ans[6] = 7,         ans[7] = 2;         n = 0;       }     }     cout <<  YES  <<   n ;     for (int i = 1; i <= N; ++i) cout << ans[i] <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     float sum = 0;     cin >> n;     int k[n], count = 0;     float a[n];     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) sum += a[i];     for (int i = 1; i <= n; i++) {       if ((sum - a[i]) / (n - 1) == a[i]) {         count++;         k[count] = i;       }     }     if (count > 0) {       cout << count << endl;       for (long long int i = 1; i <= count; i++) cout << k[i] <<    ;     } else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long psum[505][505];   int pw[1000000];   int dp[505][505];   int main() {     int n, k;     scanf( %d%d , &n, &k);     if (!k) {       printf( 1 n );       return 0;     }     pw[0] = 1;     for (int i = 1; i < 1000000; ++i) pw[i] = (pw[i - 1] * 2) % 1000000007;     for (int i = 0; i < 505; ++i)       for (int j = 1; j < i; ++j) {         int s = 0;         for (int k = 1; k <= i - j; ++k) {           s = (s + pw[(i - j) * j + (k - 1)]) % 1000000007;         }         psum[i][j] = s;       }     for (int p = 0; p < n; ++p) {       dp[p][1] = (pw[p + 1] + 1000000007 - 1) % 1000000007;     }     for (int p = 1; p < n; ++p)       for (int i = 2; i <= k; ++i) {         int s = 0;         for (int j = p - 1; j >= 0; --j) {           s = (s + dp[j][i - 1] * psum[p + 1][j + 1]) % 1000000007;         }         dp[p][i] = s;       }     long long ans = 0;     for (int p = 0; p < n; ++p) {       long long tmp = dp[p][k];       ans = (ans + tmp * pw[(n - p - 1) * (p + 1)]) % 1000000007;     }     printf( %I64d n , ans);     return 0;   }
#include<cstdio>   #include<cstring>   #include<algorithm>   #include<queue>   #include<vector>   #include<cassert>   using namespace std;   int n,m,k,vx[100],vy[100];long long sum[100];bool mp[100][100],used[100],tmp[100],clsa[100],clsb[100];int match[100];vector<pair<int,int> >ansseq,curseq;   bool dfs(int v){for(int i=1;i<=n;++i)if(mp[v][i]&&!used[i]){used[i]=1;if(!match[i]||dfs(match[i])){match[i]=v; return 1;}}return 0;}   int maxmatch(){int cnt=0; for(int i=1;i<=n;++i){memset(used+1,0,n);cnt+=dfs(i);}memset(match+1,0,n<<2);return cnt;}   int main(){scanf( %d %d %d ,&n,&m,&k);for(int i=1,x,y;i<=m;++i){scanf( %d %d ,&x,&y);mp[x][y]=1;}for(int i=1;i<=k;++i)scanf( %d %d ,&vx[i],&vy[i]),sum[i]=sum[i-1]+vx[i];    int cnt=maxmatch();int mi=0x3f3f3f3f,mip=0;long long ans=-1,cur=0;for(int i=1;i<=k;++i){if(vy[i]<mi)mi=vy[i],mip=i;if(cur+sum[k]-sum[i]>ans)     {ans=cur+sum[k]-sum[i];ansseq=curseq;for(int j=1;j<=n;++j)if(!clsa[j])ansseq.emplace_back(make_pair(i,j));      for(int j=1;j<=n;++j)if(!clsb[j])ansseq.emplace_back(make_pair(i,-j));} cur+=vx[i];     if(i+cnt==n){cur-=mi;bool flag=0;for(int j=1;j<=n;++j){ if(clsa[j])continue;for(int k=1;k<=n;++k)tmp[k]=mp[j][k],mp[j][k]=0;       if(maxmatch()<cnt){ curseq.emplace_back(make_pair(mip,j));flag=1;clsa[j]=1; break;}else for(int k=1;k<=n;++k)mp[j][k]=tmp[k];}      for(int j=1;j<=n&&!flag;++j){if(clsb[j])continue;for(int k=1;k<=n;++k)tmp[k]=mp[k][j],mp[k][j]=0;       if(maxmatch()<cnt){ curseq.emplace_back(make_pair(mip,-j)); flag=1;clsb[j]=1;break; }else for(int k=1;k<=n;++k)mp[k][j]=tmp[k];}      assert(flag);--cnt;}}if(cur>ans)ans=cur,ansseq=curseq;printf( %d n ,(int)ansseq.size()+k);int t=0;    for(int i=1;i<=k;++i){while(t<(int)ansseq.size()&&ansseq[t].first==i)printf( %d  ,ansseq[t].second),++t;printf( 0  );}return 0;}
#include <bits/stdc++.h>   using namespace std;   int main() {     int meow, k = 0;     string s[4];     for (int i = 0; i < 4; i++) cin >> s[i];     for (int i = 0; i < 4; i++) {       int n1 = 0, n2 = 0;       for (int j = 0; j < 4; j++) {         if (j == i) continue;         n1 += (((s[i].size() - 2) * 2) <= (s[j].size() - 2));         n2 += ((s[i].size() - 2) >= ((s[j].size() - 2) * 2));       }       if (n1 == 3 || n2 == 3) {         meow = i;         k++;       }     }     if (k == 1)       cout << s[meow][0] << endl;     else       cout <<  C  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n;     k = (20.0 + pow(1.0 + 3 * n, 0.5)) / 3.0;     while (k--) {       if (3 * k * k - 2 * k <= n) break;     }     n -= 3 * k * k - 2 * k;     if (n - k <= 0) {       cout << k - 2 * n <<     << 2 * k << endl;       return 0;     }     n -= k;     if (n - k <= 0) {       cout << -k - n <<     << 2 * k - 2 * n << endl;       return 0;     }     n -= k;     if (n - k <= 0) {       cout << -2 * k + n <<     << -2 * n << endl;       return 0;     }     n -= k;     if (n - k <= 0) {       cout << -k + 2 * n <<     << -2 * k << endl;       return 0;     }     n -= k;     if (n - k - 1 <= 0) {       cout << k + n <<     << -2 * k + 2 * n << endl;       return 0;     }     n -= k + 1;     cout << 2 * k + 1 - n <<     << 2 + 2 * n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long temp = 0;     string s;     cin >> s;     for (int i = 0; i < s.length(); i++) {       temp = temp * 16;       if (s[i] ==  > )         temp += 8;       else if (s[i] ==  < )         temp += 9;       else if (s[i] ==  + )         temp += 10;       else if (s[i] ==  - )         temp += 11;       else if (s[i] ==  . )         temp += 12;       else if (s[i] ==  , )         temp += 13;       else if (s[i] ==  [ )         temp += 14;       else if (s[i] ==  ] )         temp += 15;       temp = temp % 1000003;     }     cout << temp << endl;   }
#pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #include  bits/stdc++.h    using namespace std;   #define FAST    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);    #define all(n)  (n).begin(), (n).end()   #define SZ(n)       ((int)(n).size())   #define MOD      1000000007      const int N = 200050;   pair<int, int> p[N];   int n;   bool chk(int m){    long long sum = p[m].first;    for (int i = 0; i < n; i++){     if (i == m) continue;     if (sum < p[i].first){      return false;     }     sum += p[i].first;    }     return true;   }   int main(){   FAST      int T; cin >> T;      while(T--){        cin >> n;           for (int i = 0; i < n; i++){            cin >> p[i].first;            p[i].second = i;           }           sort(p, p + n);           int l = 0, r = n;        while (l < r){                int mid = l + (r - l) / 2;                if (chk(mid)){                 r = mid;                }                else l = mid + 1;        }        vector<int> ans;           for (int i = r; i < n; i++){               ans.push_back(p[i].second + 1);           }           sort(all(ans));           cout << SZ(ans) <<   n ;           for (auto w : ans) cout << w <<    ;           cout <<   n ;            }        return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   constexpr string_view gtype() {     string_view s = __PRETTY_FUNCTION__;     return string_view(s.data() + 45, s.find( ; , 45) - 45);   }   const int MAXN = 10000;   int arr[MAXN];   int best[MAXN];   int cur[MAXN];   int n;   const long long MOD = 1000000009;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int n;     cin >> n;     vector<pair<int, int> > vv(n);     for (int i = 0; i < n; i++) {       int x;       cin >> x;       vv[i] = {x, i + 1};     }     vector<int> sim;     sim.push_back(-1);     sort(((vv).begin()), ((vv).end()));     for (int i = 0; i < int((vv).size()) - 1; i++)       if (vv[i].first == vv[i + 1].first) sim.push_back(i);     if (int((sim).size()) <= 2)       cout <<  NO n ;     else {       cout <<  YES n ;       for (int j = 0; j < 3; ++j) {         for (int i = 0; i < int((vv).size()); i++) {           if (i == sim[j]) {             cout << vv[i + 1].second <<     << vv[i].second <<    ;             i++;           } else             cout << vv[i].second <<    ;         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int less_than(vector<int>& a, vector<int>& b) {     for (int i = 0; i < 3; ++i)       if (a[i] >= b[i]) return false;     return true;   }   int main(int argc, char* argv[]) {     int n;     cin >> n;     vector<vector<int> > v(n, vector<int>(5));     for (int i = 0; i < n; ++i) {       cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3];       v[i][4] = i + 1;     }     sort(v.begin(), v.end());     for (int i = 0; i < n; ++i)       for (int j = i + 1; j < n; ++j)         if (less_than(v[i], v[j])) {           v[i][3] = 10000;           break;         }     int lowest = 0;     for (int i = 1; i < n; ++i)       if (v[i][3] < v[lowest][3]) lowest = i;     cout << v[lowest][4] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 213700;   vector<int> g[N];   int t[N];   int n;   vector<int> divisiors[N];   vector<int> genDivisiors(int a) {     vector<int> v;     for (int i = 1; i * i <= a; i++) {       if (a % i == 0) {         v.push_back(i);         if (i * i != (a)) v.push_back(a / i);       }     }     return v;   }   vector<int> himmler[N];   bool vis[N];   vector<int> wywal;   void dfs(int a, int sraka, int& size) {     vis[a] = true;     wywal.push_back(a);     size++;     for (int i = 0; i < g[a].size(); i++) {       int d = g[a][i];       if (!vis[d] and (t[d] % sraka == 0)) {         dfs(d, sraka, size);       }     }   }   long long dp1[N];   long long dp2[N];   vector<pair<int, long long>> sraka;   int main() {     scanf( %d , &n);     int maxa = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &t[i]);       maxa = max(maxa, t[i]);     }     for (int i = 0; i < n - 1; i++) {       int a, b;       scanf( %d%d , &a, &b);       g[a].push_back(b);       g[b].push_back(a);     }     for (int i = 1; i <= n; i++) {       if (divisiors[t[i]].empty()) divisiors[t[i]] = genDivisiors(t[i]);       for (int j = 0; j < divisiors[t[i]].size(); j++) {         himmler[divisiors[t[i]][j]].push_back(i);       }     }     for (int i = 1; i <= maxa; i++) {       for (int j = 0; j < himmler[i].size(); j++) {         int a = himmler[i][j];         if (!vis[a]) {           int s = 0;           dfs(a, i, s);           dp1[i] += ((long long)s * (long long)(s + 1)) / 2;         }       }       for (int i = 0; i < wywal.size(); i++) vis[wywal[i]] = false;       wywal.clear();     }     for (int i = maxa; i >= 1; i--) {       if (dp1[i] != 0) {         for (int j = 2 * i; j <= maxa; j += i) {           dp1[i] -= dp1[j];         }         if (dp1[i] != 0) sraka.emplace_back(i, dp1[i]);       }     }     sort(sraka.begin(), sraka.end());     for (auto it : sraka) {       printf( %d %lld n , it.first, it.second);     }   }
#include <bits/stdc++.h>   using namespace std;   int n, k, d, mod = 1000000007;   long long dp[105][2];   long long go(int nw, bool gotit) {     if (nw == 0 && gotit) return 1;     if (nw <= 0) return 0;     if (dp[nw][gotit] != -1) return dp[nw][gotit];     long long ret = 0;     for (int i = 1; i <= k; i++) {       if (nw - i >= 0) {         ret += go(nw - i, (gotit | i >= d));       } else         break;       ret %= mod;     }     return dp[nw][gotit] = ret;   }   int main() {     memset(dp, -1, sizeof(dp));     cin >> n >> k >> d;     cout << go(n, 0) << endl;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const int N = 100010;   char s[N];   int n, k;   int main() {     ios::sync_with_stdio(false);     cin.tie();     cout.tie(0);     int T = 1;     cin >> T;     while (T--) {       cin >> n >> k;       cin >> s + 1;       priority_queue<int, vector<int>, greater<int>> q1, q2, q3;       priority_queue<int> p1, p2;       int cnt = 0;       for (int i = 1; i <= n; i++) {         if (s[i] ==  L )           cnt++;         else {           if (!cnt) continue;           if (i > cnt + 1 && s[i - cnt - 1] ==  W  && i <= n && s[i] ==  W )             q1.push(cnt);           else if (i > cnt + 1 && s[i - cnt - 1] ==  W  || i <= n && s[i] ==  W )             q2.push(cnt);           else             q3.push(cnt);           cnt = 0;         }       }       if (cnt) {         if (n > cnt && s[n - cnt] ==  W )           q2.push(cnt);         else           q3.push(cnt);       }       int res = 0;       while (k && q1.size()) {         auto v = q1.top();         q1.pop();         if (k >= v)           res += 2 * v + 1, k -= v;         else           p1.push(v);       }       while (k && q2.size()) {         auto v = q2.top();         q2.pop();         if (k >= v)           res += 2 * v, k -= v;         else           p2.push(v);       }       while (k && (p1.size() || p2.size())) {         res += 2 * k;         k = 0;       }       if (k && q3.size()) {         auto v = q3.top();         res = 2 * min(k, v) - 1;       }       for (int i = 1; i <= n; i++) {         if (s[i] ==  W ) {           if (i > 1 && s[i - 1] ==  W )             res += 2;           else             res++;         }       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout.precision(30);     ;     int c = 0, z, n;     string a, b, s, t;     cin >> a >> b;     int x = a.size();     int y = b.size();     if (x > y) {       a.swap(b);       z = x;       x = y;       y = z;     }     for (int i = 1; i <= x; i++) {       if (x % i == 0 && y % i == 0) {         s = a.substr(0, i);         t =   ;         n = (y / i) - (x / i);         for (int j = 0; j < (x / i); j++) t += s;         if (a.compare(t) == 0) {           for (int j = 0; j < n; j++) t += s;           if (b.compare(t) == 0) c++;         }       }     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   long long c[1000001] = {0};   long long d[1000001] = {0};   long long f[1000001] = {0};   long long p;   int binpow(long long b, int n) {     long long ans = 1;     while (n) {       if (n & 1) ans = ans * 1ll * b % mod;       b = b * 1ll * b % mod;       n /= 2;     }     return int(ans);   }   int main() {     int n;     cin >> n;     n++;     long long a = 1;     for (int i = 1; i <= 2 * n - 1; i++) a = a * i % mod;     long long b = 1;     for (int i = 1; i <= n; i++) b = b * i % mod;     long long c = 1;     for (int i = 1; i <= n - 1; i++) c = c * i % mod;     long long d = binpow(b, mod - 2);     long long e = binpow(c, mod - 2);     cout << (2ll * a % mod * d % mod * e % mod - 1 + mod) % mod << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2e9 + 10;   const int MOD = 1e9 + 7;   const int N = 1e6 + 10;   int n, k, m;   string x, y, z;   int main() {     ios_base::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     cin >> x >> y;     n = x.length();     int ans = 1;     for (int i = 0; i < n; i++) {       if (y[i] > x[i]) {         cout << -1;         return 0;       }       z += min(x[i], y[i]);     }     cout << z;     return 0;   }