malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T1, class T2>   int upmin(T1 &x, T2 v) {     if (x <= v) {       return 0;     }     x = v;     return 1;   }   template <class T1, class T2>   int upmax(T1 &x, T2 v) {     if (x >= v) {       return 0;     }     x = v;     return 1;   }   const int INF = 0x3f3f3f3f;   void init() {     int N;     cin >> N;     map<string, string> mp, rvmp;     for (int i = 0; i < N; ++i) {       string a, b;       cin >> a >> b;       if (not rvmp.count(a)) {         mp[a] = b;         rvmp[b] = a;       } else {         mp[rvmp[a]] = b;         rvmp[b] = rvmp[a];         rvmp.erase(a);       }     }     cout << mp.size() << endl;     for (auto it = mp.begin(); it != mp.end(); ++it) {       cout << it->first <<     << it->second << endl;     }   }   void preprocess() {}   void solve() {}   signed main() {     ios::sync_with_stdio(0);     init();     preprocess();     solve();     return 0;   }
#include <bits/stdc++.h>   int abs(int x) { return x > 0 ? x : -x; }   int max(int x, int y) { return x > y ? x : y; }   int min(int x, int y) { return x < y ? x : y; }   long long read() {     long long ans = 0;     char ch = getchar(), t = ch;     while (ch <  0  || ch >  9 ) {       t = ch;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       ans = ans * 10 + ch -  0 ;       ch = getchar();     }     if (t ==  - ) ans = -ans;     return ans;   }   using namespace std;   int main() {     long long n = read();     while (n--) {       long long l = read(), r = read();       long long bit = 0;       if (l == 0 && r == 0) {         printf( 0 n );         continue;       }       while ((1ll * 1 << bit) <= r) {         if ((l | (1ll * 1 << bit)) > r) {           printf( %I64d n , l);           break;         }         if ((l | (1ll * 1 << bit)) == r) {           printf( %I64d n , l | (1ll * 1 << bit));           break;         }         l = l | (1ll * 1 << bit);         bit++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, long long> C;   long long B[1100000], pre[1100000], suf[1100000], A[1100000], tot, i, n,       c[1100000], ans;   void add(long long x) {     for (; x <= n; x += (x & (-x))) c[x]++;   }   long long getsum(long long x) {     long long sum = 0;     for (; x >= 1; x -= (x & (-x))) sum += c[x];     return sum;   }   int main() {     scanf( %I64d , &n);     for (i = 1; i <= n; i++) cin >> A[i];     for (i = 1; i <= n; i++) C[A[i]]++, pre[i] = C[A[i]];     C.clear();     for (i = n; i >= 1; i--) C[A[i]]++, suf[i] = C[A[i]];     for (i = n; i >= 1; i--) {       ans += getsum(pre[i] - 1);       add(suf[i]);     }     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   char st[100000];   int n, t, a[26], minn, maxx;   int main() {     scanf( %d%d , &n, &t);     scanf( %s , st);     minn = 25;     maxx = 0;     for (int i = 0; i < n; i++) {       if (st[i] - 97 < minn) minn = st[i] - 97;       if (st[i] - 97 > maxx) maxx = st[i] - 97;       a[st[i] - 97] = 1;     }     if (t > n) {       printf( %s , st);       for (int i = n + 1; i <= t; i++) printf( %c , minn + 97);     } else {       int wei = t - 1;       while (st[wei] - 97 == maxx) {         st[wei] = minn + 97;         wei--;       }       st[wei]++;       while (a[st[wei] - 97] == 0) st[wei]++;       for (int i = 0; i < t; i++) printf( %c , st[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 100;   void breakGame(int a, int b) {     int n, j, k, dk;     if (a > b) swap(a, b);     dk = 2 * a;     k = a + 1;     n = b - a;     if (n & 1) k *= 2;     cout << k <<   n ;     if (n % 2 == 0) {       for (j = 0; j <= dk; j += 2) cout << n / 2 + j <<    ;     } else       for (j = 0; j <= dk; j += 2)         cout << n / 2 + j <<     << n / 2 + j + 1 <<    ;     cout <<   n ;   }   int main() {     int t, a, b;     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> t;     while (t--) {       cin >> a >> b;       breakGame(a, b);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 113;   const long long maxn = 5000 + 113;   bool used[maxn];   int main() {     srand(time(NULL));     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     vector<pair<pair<int, int>, int>> we;     for (int i = 0; i < n; i++) {       cout <<  ? 0   << i << endl;       cout.flush();       int s;       cin >> s;       we.push_back({{0, i}, s});     }     for (int i = 1; i < n; i++) {       cout <<  ?   << i <<   0  << endl;       cout.flush();       int s;       cin >> s;       we.push_back({{i, 0}, s});     }     int k = 1;     vector<int> p, b;     vector<int> ansp;     ansp.resize(n);     long long ans = 0;     p.resize(n), b.resize(n);     for (int x = 0; x < n; x++) {       for (int i = 0; i < n; i++) p[i] = 0, b[i] = 0;       p[0] = x;       for (int j = 0; j < we.size(); j++) {         if (we[j].first.first == 0)           b[we[j].first.second] = p[0] ^ we[j].second;         else           p[we[j].first.first] = b[0] ^ we[j].second;       }       bool tr = true;       for (int i = 0; i < n; i++) {         if (used[p[i]] == k || p[i] >= n) {           tr = false;           break;         }         used[p[i]] = k;       }       k++;       if (!tr) continue;       for (int i = 0; i < n; i++) {         if (used[b[i]] == k || b[i] >= n) {           tr = false;           break;         }         used[b[i]] = k;       }       k++;       if (!tr) continue;       for (int i = 0; i < n; i++) {         if (p[b[i]] != i) {           tr = false;           break;         }       }       if (!tr) continue;       if (!ans)         for (int i = 0; i < n; i++) ansp[i] = p[i];       ans++;     }     cout <<  !  << endl;     cout << ans << endl;     for (int i = 0; i < n; i++) cout << ansp[i] <<    ;     cout << endl;     cout.flush();   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   void add(int &a, int b) {     a += b;     if (a >= M) a -= M;   }   int mypow(int x, int t) {     int ans = 1, res = x;     while (t) {       if (t & 1) ans = (long long)ans * res % M;       res = (long long)res * res % M, t >>= 1;     }     return ans;   }   int n;   int fac[103], inv[103], p2[53], d[53], s1[53], s2[53], coef[53];   int f[53][53], g[53][103];   void init() {     fac[0] = 1;     for (int i = 1; i <= 100; i++) fac[i] = (long long)fac[i - 1] * i % M;     inv[100] = mypow(fac[100], M - 2);     for (int i = 99; ~i; i--) inv[i] = (long long)inv[i + 1] * (i + 1) % M;     p2[0] = 1;     for (int i = 1; i <= n; i++) p2[i] = (long long)p2[i - 1] * inv[2] % M;   }   int main() {     scanf( %d , &n);     init();     for (int i = 1; i <= n; i++) {       scanf( %d , &d[i]);       if (i > 1) {         d[i]--;         s1[i] = s1[i - 1], s2[i] = s2[i - 1];         if (d[i] == 1)           s1[i]++;         else           s2[i]++;       }     }     for (int s = 0; s <= n; s++)       for (int p = 0; p * 2 <= s; p++) {         int q = s - 2 * p, t = (long long)inv[p] * inv[q] % M;         if ((p + q) & 1)           add(coef[s], M - t);         else           add(coef[s], t);       }     f[1][d[1]] = 1;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= 2 * n; j++)         if (g[i][j])           for (int d = 0; d * 2 <= j; d++)             add(f[i][j - d * 2], (long long)g[i][j] * inv[d] % M * p2[d] % M);       for (int j = 1; i + j <= n; j++)         if (f[i][j]) {           int x = s1[i + j] - s1[i], y = s2[i + j] - s2[i];           int res = (long long)f[i][j] * fac[y] % M;           for (int s = 0; s <= y; s++)             add(g[i + j][x + 2 * y - 2 * s], (long long)res * coef[s] % M *                                                  fac[x + 2 * y - 2 * s] % M *                                                  inv[y - s] % M);         }     }     int ans = f[n][0];     for (int i = 2; i <= n; i++) ans = (long long)ans * inv[d[i]] % M;     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 251, N2 = N * N, M = 1e9 + 7;   long long kc[N2], k1c[N2], ans, n, k, n2, C[N][N];   int main() {     cin >> n >> k;     kc[0] = k1c[0] = 1;     for (int i = 1; i < N2; i++) {       kc[i] = kc[i - 1] * k % M;       k1c[i] = k1c[i - 1] * (k - 1) % M;     }     C[0][0] = 1;     for (int i = 1; i < N; i++) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; j++) {         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % M;       }     }     n2 = n * n;     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= n; j++) {         long long t = C[n][j] * C[n][i] % M * kc[n2 - n * (i + j) + i * j] % M *                       k1c[n * (i + j) - i * j] % M;         if ((i + j) & 1)           ans = (ans + M - t) % M;         else           ans = (ans + t) % M;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, rt, ra, ca, b;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int t;       scanf( %d , &t);       if (t != rt) {         rt = t;         ra = ca;         ca = 0;       }       ca++;       b = max(b, min(ra, ca) * 2);     }     printf( %d , b);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mabs(int a) {     if (a < 0)       return -a;     else       return a;   }   bool vis[4010];   int main() {     int x, k;     int t, n1, n2;     cin >> x >> k;     for (int i = 0; i < k; ++i) {       cin >> t;       if (t == 2) {         cin >> n2;         vis[n2] = true;       } else {         cin >> n2 >> n1;         vis[n2] = vis[n1] = true;       }     }     vector<int> v;     for (int i = 1; i < x; ++i)       if (!vis[i]) v.push_back(i);     int ret = 0;     for (int i = 1; i < v.size(); ++i) {       if (v[i] - v[i - 1] == 1) ++ret, ++i;     }     cout << ret + v.size() - ret * 2 <<     << v.size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200], b[200], res[200];   int main() {     int n, count, i, j, m, k, ans;     cin >> n >> m >> k;     for (i = 0; i < m; i++) cin >> a[i];     for (i = 0; i < k; i++) cin >> b[i];     for (i = 0; i < m; i++) {       for (j = 0; j < k; j++) {         if (b[j] % a[i] == 0) res[i]++;       }     }     ans = res[0];     for (i = 0; i < m; i++) ans = min(res[i], ans);     count = 0;     for (i = 0; i < m; i++)       if (res[i] == ans) count++;     cout << count <<   n ;     for (i = 0; i < m; i++)       if (ans == res[i]) cout << i + 1 <<    ;     return 0;   }
#include <bits/stdc++.h>   template <class T>   inline void read(T &res) {     char ch;     while (ch = getchar(), !isdigit(ch))       ;     res = ch ^ 48;     while (ch = getchar(), isdigit(ch)) res = res * 10 + ch - 48;   }   template <class T>   inline void put(T x) {     if (x > 9) put(x / 10);     putchar(x % 10 + 48);   }   const int N = 1e6 + 5;   int a[N], vis[N], nxt[N], pre[N], suf[N];   int n, m, now = 1;   inline void Fail() {     puts( no );     exit(0);   }   inline int Get() {     while (vis[now]) ++now;     if (now > n) Fail();     vis[now] = 1;     return now;   }   inline void Delete(int l, int r) {     int tl = pre[l], tr = suf[r];     suf[tl] = tr, pre[tr] = tl;   }   inline void Merge(int l, int r, int &x) {     while (x > l && suf[suf[x]] && suf[suf[x]] <= r && !a[x] && a[suf[x]] &&            a[suf[suf[x]]]) {       a[x] = a[suf[suf[x]]];       Delete(suf[x], suf[suf[x]]);       x = pre[x] > l ? pre[pre[x]] : pre[x];     }     while (x > l && suf[suf[x]] && suf[suf[x]] <= r && a[x] && a[suf[x]] &&            !a[suf[suf[x]]]) {       a[suf[suf[x]]] = a[x];       Delete(suf[x], suf[suf[x]]);       x = pre[x] > l ? pre[pre[x]] : pre[x];     }   }   inline void solve(int l, int r) {     if (r - l & 1) Fail();     for (int i = l; i <= r; i = suf[i])       while (nxt[i]) {         if (nxt[i] > r) Fail();         solve(suf[i], pre[nxt[i]]);         Delete(suf[i], nxt[i]);         nxt[i] = nxt[nxt[i]];       }     int num1 = 0, num2 = 0, rt = a[pre[l]];     for (int i = l; i <= r; i = suf[i]) num1 += a[i] > 0, ++num2;     num2 = (num2 >> 1) + 1;     if (num1 > num2) Fail();     num2 -= num1;     for (int i = l; num2 && i <= r; i = suf[i])       if (!a[i]) a[i] = Get(), --num2;     if (!a[l]) {       for (int i = suf[l]; i <= r; i = suf[i]) Merge(l, r, i);       Merge(l - 1, r, l);     } else {       for (int i = l; i <= r; i = suf[i]) Merge(l - 1, r, i);     }     for (int i = l; i <= r; i = suf[i])       if (!a[i]) a[i] = rt;   }   int main() {     read(n);     if (n == 1) return puts( yes n1 ), 0;     m = (n << 1) - 1;     for (int i = 1; i <= m; ++i) read(a[i]);     for (int i = 2; i <= m; ++i)       if (a[i] && a[i - 1] && a[i] == a[i - 1]) Fail();     if (a[1] && a[m] && a[1] != a[m]) Fail();     a[1] = a[m] = a[1] | a[m];     for (int i = 0; i <= m + 1; ++i) pre[i] = i - 1, suf[i] = i + 1;     pre[0] = 0;     for (int i = m; i >= 1; --i)       if (a[i]) {         nxt[i] = vis[a[i]];         vis[a[i]] = i;       }     solve(1, m);     puts( yes );     for (int i = 1; i <= m; ++i) put(a[i]), putchar(   );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   char a[1 << 9][1 << 9];   void solve(int n) {     if (n == 0) {       a[0][0] =  + ;       return;     }     solve(n - 1);     int mid = 1 << (n - 1);     for (int i = (mid), _b = ((1 << n) - 1); i <= _b; ++i)       for (int j = 0, _a = (mid); j < _a; ++j) a[i][j] = a[i - mid][j];     for (int i = 0, _a = (mid); i < _a; ++i)       for (int j = (mid), _b = ((1 << n) - 1); j <= _b; ++j)         a[i][j] = a[i][j - mid];     for (int i = (mid), _b = ((1 << n) - 1); i <= _b; ++i)       for (int j = (mid), _b = ((1 << n) - 1); j <= _b; ++j)         a[i][j] =  +  +  *  - a[i - mid][j - mid];   }   int main() {     ios ::sync_with_stdio(0);     cin.tie(0);     while (cin >> n) {       solve(n);       for (int i = 0, _a = (1 << n); i < _a; ++i) {         for (int j = 0, _a = (1 << n); j < _a; ++j) putchar(a[i][j]);         puts(  );       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long fact[200010], cnt, cnt1[200010], cnt2[200010];   void precalc() {     fact[0] = 1;     for (int i = 1; i < 200010; i++) {       fact[i] = (i * fact[i - 1]) % 1000000007;     }   }   long long power(long long a, long long b, long long p) {     if (b == 0) return 1;     long long ret = power(a, b / 2, p);     ret = (ret * ret) % p;     if ((b % 2) == 1) ret = (ret * a) % p;     return ret % p;   }   long long ncr(long long n, long long r) {     if (n < r) {       return 0;     }     long long ans = fact[n];     long long den = (fact[n - r] * fact[r]) % 1000000007;     ans = (ans * power(den, 1000000007 - 2, 1000000007)) % 1000000007;     return ans;   }   int main() {     precalc();     string str;     cin >> str;     long long n = str.length();     cnt = 0;     long long ans = 0;     for (int i = 0; i < n; i++) {       if (str[i] ==  ( ) {         cnt++;       }       cnt1[i] = cnt;     }     cnt = 0;     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  ) ) {         cnt++;       }       cnt2[i] = cnt;     }     for (int i = 0; i < n; i++) {       if (str[i] ==  ( ) {         long long x = cnt1[i];         long long y = cnt2[i];         ans = (ans + ncr(x + y - 1, x)) % 1000000007;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[101];   int d[101];   int main() {     int N;     cin >> N;     for (int i = 0; i < N; ++i) cin >> arr[i];     for (int i = 1; i < N; ++i) d[i] = arr[i] - arr[i - 1];     int ans = 1001;     for (int i = 1; i < N - 1; ++i) {       int temp1 = 0;       for (int j = 1; j < N; ++j) {         int temp2;         if (i == j) {           temp2 = d[j] + d[j + 1];           j++;         } else           temp2 = d[j];         temp1 = max(temp1, temp2);       }       ans = min(ans, temp1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     scanf( %I64d %I64d , &n, &m);     long long a = min(n, m);     long long b = max(n, m);     long long ans;     if (a == 1) {       ans = b / 6 * 6;       if (b % 6 == 4)         ans += 2;       else if (b % 6 == 5)         ans += 4;     } else if (a == 2) {       if (b == 2)         ans = 0;       else if (b == 3)         ans = 4;       else if (b == 7)         ans = 12;       else         ans = a * b;     } else {       ans = a * b / 2 * 2;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     vector<int> prime(n + 2, 1);     prime[0] = 0;     prime[1] = 0;     long long ans = 1;     for (long long i = 2; i <= n + 1; i++) {       if (prime[i] == 1 && i * i <= n + 1) {         for (long long j = i * i; j <= n + 1; j += i) {           prime[j] = 2;         }         ans = 2;       }     }     cout << ans << endl;     for (long long i = 2; i <= n + 1; i++) cout << prime[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<int> arr(n);     for (auto &x : arr) cin >> x;     int height = 1;     for (int i = 0; i < n; i++) {       if (i > 0 and !arr[i - 1] and !arr[i]) {         cout << -1 <<   n ;         return;       }       height += arr[i] + (i > 0 and arr[i] and arr[i - 1] ? 4 : 0);     }     cout << height << endl;   }   int main(int argc, char const *argv[]) {     int tc;     cin >> tc;     while (tc--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e9 + 55;   const int inf = 1e9 + 77;   const int MOD = 1e9 + 7;   const double PI = acos(-1.0);   const double eps = 1e-7;   vector<int> primes;   bitset<int(1e7) + 2> isprime;   void seive() {     isprime[0] = isprime[1] = 1;     for (int i = 2; i < int(1e6); ++i) {       if (!isprime.test(i)) {         primes.push_back(i);         for (int j = i * 2; j < int(1e6) + 2; j += i) {           isprime.set(j);         }       }     }   }   const int n = 1e6 + 55;   int p[2][n];   bool check(int n) {     if (n < int(1e6)) return !isprime.test(n);     for (auto i : primes)       if (n % i == 0) return false;     return true;   }   void factor(int a, int f) {     long long id = 0, pf = primes[0];     while (pf * pf <= a) {       while (a % pf == 0) {         a /= pf;         p[f][pf]++;       }       pf = primes[++id];     }     if (a != 1) p[f][a]++;   }   int main() {     seive();     int a, b;     scanf( %d , &a);     scanf( %d , &b);     bool t1 = true;     if (!check(a)) {       factor(a, 0);       t1 = false;     }     bool t2 = true;     if (!check(b)) {       factor(b, 1);       t2 = false;     }     if (t1 && t2) {       printf( -1 );       return 0;     }     if (t1 || t2) {       if (t1) {         if (t1 > int(1e6)) {           printf( -1 );           return 0;         }       } else {         if (t2 > int(1e6)) {           printf( -1 );           return 0;         }       }     }     if (t1) factor(a, 0);     if (t2) factor(b, 1);     int res1 = 0;     for (int i = 7; i < n; ++i) {       if (abs(p[1][i] - p[0][i]) > 0) {         res1 = -1;         break;       }     }     if (res1 == -1) {       printf( -1 );       return 0;     }     for (int i = 2; i <= 5; ++i) {       res1 += abs(p[0][i] - p[1][i]);     }     printf( %d , res1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long L, R;     int n;     cin >> n;     while (n--) {       cin >> L >> R;       for (long long k = 0; k <= 60; ++k) {         if ((1LL << k) & (L)) {           continue;         } else {           if ((1LL << k) + L <= R) {             L += (1LL << k);           } else {             break;           }         }       }       cout << L <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 3.14159265358979;   const double PI2 = 6.28318530717958;   const double PId2 = 1.570796326794895;   inline long long pw(long long n, int p) {     long long ans = 1;     for (int i = 0; i < p; i++) ans *= n;     return ans;   }   inline vector<int> ReadVI(int count) {     vector<int> arrayname(count);     for (int i = 0; i < int(count); i++) cin >> arrayname[i];     return arrayname;   };   inline vector<long long> ReadVlong(int count) {     vector<long long> arrayname(count);     for (int i = 0; i < int(count); i++) cin >> arrayname[i];     return arrayname;   };   inline vector<pair<int, int> > ReadVII(int count) {     vector<pair<int, int> > arrayname(count);     for (int i = 0; i < int(count); i++) {       cin >> arrayname[i].first;       arrayname[i].second = i;     }     return arrayname;   };   const int MOD = 1000000007;   const int MAXVALUE = 101;   int main() {     int f[5];     cin >> f[0] >> f[1] >> f[2] >> f[3] >> f[4];     int n;     cin >> n;     string a[5] = { S ,  M ,  L ,  XL ,  XXL };     int d[9] = {0, 1, -1, 2, -2, 3, -3, 4, -4};     string ts;     int t;     for (int i = 0; i < n; i++) {       cin >> ts;       t = 0;       for (; t < 5; t++)         if (a[t] == ts) break;       for (int j = 0; j < 9; j++) {         int k = t;         k += d[j];         if (k < 0 || k > 4) continue;         if (f[k]) {           f[k]--;           cout << a[k] << endl;           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void debug_out() { cerr <<   n ; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << H;     debug_out(T...);   }   const long long MAXN = 1e2 + 10, INF = 1e9;   long long n, m, k, a, b, u, v, floyd[MAXN][MAXN], second[MAXN], t[MAXN],       dp[2][MAXN];   bool bo[MAXN][MAXN];   vector<long long> h[MAXN];   void update(long long id) {     if (floyd[second[id]][t[id]] == INF) return;     for (long long i = 0; i <= floyd[second[id]][t[id]]; i++) h[i].clear();     for (long long i = 1; i <= n; i++) dp[1][i] = INF;     for (long long i = 1; i <= n; i++)       if (floyd[second[id]][i] + floyd[i][t[id]] == floyd[second[id]][t[id]])         h[floyd[second[id]][i]].push_back(i);     dp[1][t[id]] = dp[0][t[id]];     for (long long i = floyd[second[id]][t[id]] - 1; i >= 0; i--) {       for (auto u : h[i]) {         dp[1][u] = -1;         for (auto v : h[i + 1])           if (bo[u][v]) dp[1][u] = max(dp[1][u], dp[1][v]);         if (dp[1][u] == -1)           dp[1][u] = dp[0][u];         else           dp[1][u] = min(dp[1][u], dp[0][u]);       }       if ((long long)h[i].size() == 1)         dp[0][h[i][0]] = min(dp[0][h[i][0]], dp[1][h[i][0]] + 1);     }     return;   }   void pre_Floyd() {     for (long long i = 1; i <= n; i++)       for (long long j = 1; j <= n; j++) floyd[i][j] = INF, floyd[j][j] = 0;     return;   }   void Floyd_update() {     for (long long k = 1; k <= n; k++)       for (long long i = 1; i <= n; i++)         for (long long j = 1; j <= n; j++)           floyd[i][j] = min(floyd[i][j], floyd[i][k] + floyd[k][j]);     return;   }   int32_t main() {     cin >> n >> m >> a >> b, pre_Floyd();     for (long long i = 1; i <= n; i++) dp[0][i] = INF;     for (long long i = 1; i <= m; i++)       cin >> u >> v, floyd[u][v] = 1, bo[u][v] = true;     cin >> k;     for (long long i = 1; i <= k; i++) cin >> second[i] >> t[i];     Floyd_update(), dp[0][b] = 0;     for (long long i = 1; i <= n; i++)       for (long long j = 1; j <= k; j++) update(j);     if (dp[0][a] == INF) return cout << -1 <<   n , 0;     return cout << dp[0][a] <<   n , 0;   }
#include <bits/stdc++.h>   using namespace std;   set<string> st;   int main() {     string s;     cin >> s;     string a = s + s;     for (int i = 0; i < a.size() - s.size(); i++) {       string k =   ;       for (int j = i; j < i + s.size(); j++) k += a[j];       st.insert(k);     }     cout << st.size();   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long k, n, w;     cin >> k >> n >> w;     long long req = ((w * (w + 1)) / 2) * k;     req = req - n;     if (req > 0)       cout << req;     else       cout <<  0 ;   }